From b93c4978eff355cf912ef84d036231996754e053 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 13 Jun 2019 15:58:26 +0300 Subject: [PATCH] upd --- firmware/GyverLamp_v1.0/GyverLamp_v1.0.ino | 6 ++++-- firmware/GyverLamp_v1.0/button.ino | 7 ++++--- firmware/GyverLamp_v1.0/effectTicker.ino | 4 ++-- firmware/GyverLamp_v1.0/parsing.ino | 1 + 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/firmware/GyverLamp_v1.0/GyverLamp_v1.0.ino b/firmware/GyverLamp_v1.0/GyverLamp_v1.0.ino index 684b9cb..6dcd863 100644 --- a/firmware/GyverLamp_v1.0/GyverLamp_v1.0.ino +++ b/firmware/GyverLamp_v1.0/GyverLamp_v1.0.ino @@ -127,6 +127,9 @@ void setup() { FastLED.clear(); FastLED.show(); randomSeed(analogRead(0)); // пинаем генератор случайных чисел + touch.setStepTimeout(100); + touch.setClickTimeout(500); + Serial.begin(115200); // WI-FI @@ -189,8 +192,7 @@ void setup() { Udp.write(reply); Udp.endPacket(); - timeClient.begin(); - touch.setStepTimeout(100); + timeClient.begin(); } void loop() { diff --git a/firmware/GyverLamp_v1.0/button.ino b/firmware/GyverLamp_v1.0/button.ino index 9b9ef05..05f2027 100644 --- a/firmware/GyverLamp_v1.0/button.ino +++ b/firmware/GyverLamp_v1.0/button.ino @@ -17,17 +17,18 @@ void buttonTick() { } } - if (touch.isDouble()) { + if (ONflag && touch.isDouble()) { if (++currentMode >= MODE_AMOUNT) currentMode = 0; + FastLED.setBrightness(modes[currentMode].brightness); loadingFlag = true; settChanged = true; eepromTimer = millis(); } - if (touch.isHolded()) { + if (ONflag && touch.isHolded()) { brightDirection = !brightDirection; } - if (touch.isStep()) { + if (ONflag && touch.isStep()) { if (brightDirection) { if (modes[currentMode].brightness < 250) modes[currentMode].brightness += 5; else modes[currentMode].brightness = 255; diff --git a/firmware/GyverLamp_v1.0/effectTicker.ino b/firmware/GyverLamp_v1.0/effectTicker.ino index 896a53c..3fa08e0 100644 --- a/firmware/GyverLamp_v1.0/effectTicker.ino +++ b/firmware/GyverLamp_v1.0/effectTicker.ino @@ -45,7 +45,7 @@ void effectsTick() { void changePower() { if (ONflag) { effectsTick(); - for (int i = 0; i < modes[currentMode].brightness; i += 5) { + for (int i = 0; i < modes[currentMode].brightness; i += 8) { FastLED.setBrightness(i); delay(1); FastLED.show(); @@ -54,7 +54,7 @@ void changePower() { FastLED.show(); } else { effectsTick(); - for (int i = modes[currentMode].brightness; i > 8; i -= 5) { + for (int i = modes[currentMode].brightness; i > 8; i -= 8) { FastLED.setBrightness(i); delay(1); FastLED.show(); diff --git a/firmware/GyverLamp_v1.0/parsing.ino b/firmware/GyverLamp_v1.0/parsing.ino index 3852291..ebabaea 100644 --- a/firmware/GyverLamp_v1.0/parsing.ino +++ b/firmware/GyverLamp_v1.0/parsing.ino @@ -14,6 +14,7 @@ void parseUDP() { currentMode = (byte)inputBuffer.substring(3).toInt(); loadingFlag = true; sendCurrent(); + FastLED.setBrightness(modes[currentMode].brightness); } else if (inputBuffer.startsWith("BRI")) { modes[currentMode].brightness = inputBuffer.substring(3).toInt(); FastLED.setBrightness(modes[currentMode].brightness);