mirror of
https://github.com/AlexGyver/GyverLamp.git
synced 2025-08-08 17:01:00 +03:00
add
This commit is contained in:
66
firmware/old/GyverLamp_v1.5/button.ino
Normal file
66
firmware/old/GyverLamp_v1.5/button.ino
Normal file
@@ -0,0 +1,66 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
if (ONflag && touch.isTriple()) {
|
||||
if (--currentMode < 0) currentMode = MODE_AMOUNT;
|
||||
FastLED.setBrightness(modes[currentMode].brightness);
|
||||
loadingFlag = true;
|
||||
settChanged = true;
|
||||
eepromTimer = millis();
|
||||
FastLED.clear();
|
||||
delay(1);
|
||||
}
|
||||
|
||||
// вывод IP на лампу
|
||||
if (ONflag && touch.hasClicks()) {
|
||||
if (touch.getClicks() == 5) {
|
||||
while(!fillString(lampIP)) delay(1);
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user