mirror of
https://github.com/AlexGyver/GyverLamp.git
synced 2025-08-07 08:30:32 +03:00
76 lines
2.1 KiB
C++
76 lines
2.1 KiB
C++
boolean brightDirection;
|
|
|
|
void buttonTick() {
|
|
touch.tick();
|
|
if (touch.isSingle()) {
|
|
if (dawnFlag) {
|
|
manualOff = true;
|
|
dawnFlag = false;
|
|
loadingFlag = true;
|
|
FastLED.setBrightness(modes[currentMode].brightness);
|
|
changePower();
|
|
} else {
|
|
if (ONflag) {
|
|
ONflag = false;
|
|
changePower();
|
|
} else {
|
|
ONflag = true;
|
|
changePower();
|
|
}
|
|
sendSettings_flag = true;
|
|
}
|
|
}
|
|
|
|
if (ONflag && touch.isDouble()) {
|
|
if (++currentMode >= MODE_AMOUNT) currentMode = 0;
|
|
FastLED.setBrightness(modes[currentMode].brightness);
|
|
loadingFlag = true;
|
|
settChanged = true;
|
|
eepromTimer = millis();
|
|
FastLED.clear();
|
|
delay(1);
|
|
sendSettings_flag = true;
|
|
}
|
|
if (ONflag && touch.isTriple()) {
|
|
if (--currentMode < 0) currentMode = MODE_AMOUNT - 1;
|
|
FastLED.setBrightness(modes[currentMode].brightness);
|
|
loadingFlag = true;
|
|
settChanged = true;
|
|
eepromTimer = millis();
|
|
FastLED.clear();
|
|
delay(1);
|
|
sendSettings_flag = true;
|
|
}
|
|
|
|
// вывод IP на лампу
|
|
if (ONflag && touch.hasClicks()) {
|
|
if (touch.getClicks() == 5) {
|
|
resetString();
|
|
while (!fillString(lampIP, CRGB::Green, true)) {
|
|
delay(1);
|
|
ESP.wdtFeed(); // пнуть собаку
|
|
yield(); // ещё раз пнуть собаку
|
|
}
|
|
}
|
|
}
|
|
|
|
if (ONflag && touch.isHolded()) {
|
|
brightDirection = !brightDirection;
|
|
}
|
|
if (ONflag && touch.isStep()) {
|
|
if (brightDirection) {
|
|
if (modes[currentMode].brightness < 10) modes[currentMode].brightness += 1;
|
|
else if (modes[currentMode].brightness < 250) modes[currentMode].brightness += 5;
|
|
else modes[currentMode].brightness = 255;
|
|
} else {
|
|
if (modes[currentMode].brightness > 15) modes[currentMode].brightness -= 5;
|
|
else if (modes[currentMode].brightness > 1) modes[currentMode].brightness -= 1;
|
|
else modes[currentMode].brightness = 1;
|
|
}
|
|
FastLED.setBrightness(modes[currentMode].brightness);
|
|
settChanged = true;
|
|
eepromTimer = millis();
|
|
sendSettings_flag = true;
|
|
}
|
|
}
|