From 2f9f6bffeb122711f83fcf62e69cdbc00c7c07df Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 14 Jun 2019 10:29:09 +0300 Subject: [PATCH] add --- firmware/GyverLamp_v1.1/GyverLamp_v1.1.ino | 11 +++++++---- firmware/GyverLamp_v1.1/button.ino | 7 +++++++ firmware/GyverLamp_v1.1/effects.ino | 10 ++++------ 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/firmware/GyverLamp_v1.1/GyverLamp_v1.1.ino b/firmware/GyverLamp_v1.1/GyverLamp_v1.1.ino index a96f421..c4d0fb7 100644 --- a/firmware/GyverLamp_v1.1/GyverLamp_v1.1.ino +++ b/firmware/GyverLamp_v1.1/GyverLamp_v1.1.ino @@ -107,7 +107,7 @@ boolean dawnFlag = false; long thisTime; boolean manualOff = false; -byte currentMode = 0; +int8_t currentMode = 0; boolean loadingFlag = true; boolean ONflag = true; uint32_t eepromTimer; @@ -116,6 +116,8 @@ boolean settChanged = false; // Безумие 3D, Облака 3D, Лава 3D, Плазма 3D, Радуга 3D, // Павлин 3D, Зебра 3D, Лес 3D, Океан 3D, +unsigned char matrixValue[8][16]; + void setup() { ESP.wdtDisable(); //ESP.wdtEnable(WDTO_8S); @@ -129,7 +131,7 @@ void setup() { randomSeed(analogRead(0)); // пинаем генератор случайных чисел touch.setStepTimeout(100); touch.setClickTimeout(500); - + Serial.begin(115200); // WI-FI @@ -182,7 +184,7 @@ void setup() { alarm[i].time = eeGetInt(5 * i + 50 + 1); } dawnMode = EEPROM.read(100); - currentMode = EEPROM.read(101); + currentMode = (int8_t)EEPROM.read(101); // отправляем настройки sendCurrent(); @@ -192,7 +194,8 @@ void setup() { Udp.write(reply); Udp.endPacket(); - timeClient.begin(); + timeClient.begin(); + memset(matrixValue, 0, sizeof(matrixValue)); } void loop() { diff --git a/firmware/GyverLamp_v1.1/button.ino b/firmware/GyverLamp_v1.1/button.ino index 7920de4..25ab366 100644 --- a/firmware/GyverLamp_v1.1/button.ino +++ b/firmware/GyverLamp_v1.1/button.ino @@ -27,6 +27,13 @@ void buttonTick() { settChanged = true; eepromTimer = millis(); } + if (ONflag && touch.isTriple()) { + if (--currentMode < 0) currentMode = 0; + FastLED.setBrightness(modes[currentMode].brightness); + loadingFlag = true; + settChanged = true; + eepromTimer = millis(); + } if (ONflag && touch.isHolded()) { brightDirection = !brightDirection; diff --git a/firmware/GyverLamp_v1.1/effects.ino b/firmware/GyverLamp_v1.1/effects.ino index 4812a23..0073630 100644 --- a/firmware/GyverLamp_v1.1/effects.ino +++ b/firmware/GyverLamp_v1.1/effects.ino @@ -35,7 +35,6 @@ void fadePixel(byte i, byte j, byte step) { // новый фейдер // -------------------------------------- огонь --------------------------------------------- // эффект "огонь" #define SPARKLES 1 // вылетающие угольки вкл выкл -unsigned char matrixValue[8][16]; unsigned char line[WIDTH]; int pcnt = 0; @@ -67,9 +66,8 @@ const unsigned char hueMask[8][16] PROGMEM = { void fireRoutine() { if (loadingFlag) { loadingFlag = false; - FastLED.clear(); - generateLine(); - memset(matrixValue, 0, sizeof(matrixValue)); + //FastLED.clear(); + generateLine(); } if (pcnt >= 100) { shiftUp(); @@ -123,7 +121,7 @@ void drawFrame(int pcnt) { - pgm_read_byte(&(valueMask[y][newX])); CRGB color = CHSV( - modes[1].scale + pgm_read_byte(&(hueMask[y][newX])), // H + modes[1].scale * 2.5 + pgm_read_byte(&(hueMask[y][newX])), // H 255, // S (uint8_t)max(0, nextv) // V ); @@ -148,7 +146,7 @@ void drawFrame(int pcnt) { uint8_t newX = x; if (x > 15) newX = x - 15; CRGB color = CHSV( - modes[1].scale + pgm_read_byte(&(hueMask[0][newX])), // H + modes[1].scale * 2.5 + pgm_read_byte(&(hueMask[0][newX])), // H 255, // S (uint8_t)(((100.0 - pcnt) * matrixValue[0][newX] + pcnt * line[newX]) / 100.0) // V );