From 12f2caa8d6a2c58c113d8367607377274315858c Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Mon, 20 Dec 2021 20:44:06 +0100 Subject: [PATCH] Alt Rotary Encoder & Alt 4LD enhancements. --- .../usermod_v2_four_line_display_ALT.h | 190 +++++++----- .../usermod_v2_rotary_encoder_ui_ALT.h | 280 +++++++++--------- wled00/wled.h | 2 +- 3 files changed, 253 insertions(+), 219 deletions(-) diff --git a/usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.h b/usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.h index d4f762a8..bf11a73f 100644 --- a/usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.h +++ b/usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.h @@ -254,7 +254,6 @@ class FourLineDisplayUsermod : public Usermod { private: bool initDone = false; - unsigned long lastTime = 0; // HW interface & configuration U8X8 *u8x8 = nullptr; // pointer to U8X8 display object @@ -296,7 +295,7 @@ class FourLineDisplayUsermod : public Usermod { bool powerON = true; bool displayTurnedOff = false; - unsigned long lastUpdate = 0; + unsigned long nextUpdate = 0; unsigned long lastRedraw = 0; unsigned long overlayUntil = 0; Line4Type lineType = FLD_LINE_BRIGHTNESS; @@ -401,15 +400,20 @@ class FourLineDisplayUsermod : public Usermod { // gets called every time WiFi is (re-)connected. Initialize own network // interfaces here - void connected() {} + void connected() { + knownSsid = apActive ? apSSID : WiFi.SSID(); //apActive ? WiFi.softAPSSID() : + knownIp = apActive ? IPAddress(4, 3, 2, 1) : Network.localIP(); + networkOverlay(PSTR("NETWORK INFO"),7000); + } /** * Da loop. */ void loop() { - if (!enabled || millis() - lastUpdate < (clockMode?1000:refreshRate) || strip.isUpdating()) return; - lastUpdate = millis(); - + if (!enabled || strip.isUpdating()) return; + unsigned long now = millis(); + if (now < nextUpdate) return; + nextUpdate = now + (clockMode?1000:refreshRate); redraw(false); } @@ -461,9 +465,9 @@ class FourLineDisplayUsermod : public Usermod { } //function to update lastredraw - void updateRedrawTime(){ - lastRedraw = millis(); - } + void updateRedrawTime() { + lastRedraw = millis(); + } /** * Redraw the screen (but only if things have changed @@ -473,19 +477,18 @@ class FourLineDisplayUsermod : public Usermod { unsigned long now = millis(); if (type == NONE || !enabled) return; - if (overlayUntil > 0) { - if (now >= overlayUntil) { - // Time to display the overlay has elapsed. - overlayUntil = 0; - forceRedraw = true; - } else { - // We are still displaying the overlay - // Don't redraw. - return; - } + if (overlayUntil > 0) { + if (now >= overlayUntil) { + // Time to display the overlay has elapsed. + overlayUntil = 0; + forceRedraw = true; + } else { + // We are still displaying the overlay + // Don't redraw. + return; } + } - // Check if values which are shown on display changed from the last time. if (forceRedraw) { needRedraw = true; @@ -493,40 +496,42 @@ class FourLineDisplayUsermod : public Usermod { powerON = !powerON; drawStatusIcons(); lastRedraw = millis(); + return; } else if (knownnightlight != nightlightActive) { //trigger moon icon knownnightlight = nightlightActive; drawStatusIcons(); - if (knownnightlight) overlay(" Timer On", 1000, 6); + if (knownnightlight) overlay(PSTR(" Timer On"), 3000, 6); lastRedraw = millis(); - }else if (wificonnected != interfacesInited){ //trigger wifi icon + return; + } else if (wificonnected != interfacesInited) { //trigger wifi icon wificonnected = interfacesInited; drawStatusIcons(); lastRedraw = millis(); + return; } else if (knownMode != effectCurrent) { knownMode = effectCurrent; - if(displayTurnedOff)needRedraw = true; + if (displayTurnedOff) needRedraw = true; else showCurrentEffectOrPalette(knownMode, JSON_mode_names, 3); } else if (knownPalette != effectPalette) { knownPalette = effectPalette; - if(displayTurnedOff)needRedraw = true; + if (displayTurnedOff) needRedraw = true; else showCurrentEffectOrPalette(knownPalette, JSON_palette_names, 2); } else if (knownBrightness != bri) { - if(displayTurnedOff && nightlightActive){needRedraw = false; knownBrightness = bri;} - else if(displayTurnedOff)needRedraw = true; + if (displayTurnedOff && nightlightActive){needRedraw = false; knownBrightness = bri;} + else if(displayTurnedOff) needRedraw = true; else updateBrightness(); } else if (knownEffectSpeed != effectSpeed) { - if(displayTurnedOff)needRedraw = true; + if (displayTurnedOff) needRedraw = true; else updateSpeed(); } else if (knownEffectIntensity != effectIntensity) { - if(displayTurnedOff)needRedraw = true; + if (displayTurnedOff) needRedraw = true; else updateIntensity(); } - if (!needRedraw) { // Nothing to change. // Turn off display after 1 minutes with no change. - if(sleepMode && !displayTurnedOff && (now - lastRedraw > screenTimeout)) { + if (sleepMode && !displayTurnedOff && (now - lastRedraw > screenTimeout)) { // We will still check if there is a change in redraw() // and turn it back on if it changed. sleepOrClock(true); @@ -547,8 +552,6 @@ class FourLineDisplayUsermod : public Usermod { } // Update last known values. - knownSsid = apActive ? apSSID : WiFi.SSID(); //apActive ? WiFi.softAPSSID() : - knownIp = apActive ? IPAddress(4, 3, 2, 1) : Network.localIP(); knownBrightness = bri; knownMode = effectCurrent; knownPalette = effectPalette; @@ -575,37 +578,40 @@ class FourLineDisplayUsermod : public Usermod { showCurrentEffectOrPalette(knownMode, JSON_mode_names, 3); //Effect Mode info } - void updateBrightness(){ + void updateBrightness() { knownBrightness = bri; - if(overlayUntil == 0){ - brightness100 = (((float)(bri)/255)*100); - char lineBuffer[4]; - sprintf_P(lineBuffer, PSTR("%-3d"), brightness100); - drawString(1, lineHeight, lineBuffer); - lastRedraw = millis();} + if (overlayUntil == 0) { + brightness100 = ((uint16_t)bri*100)/255; + char lineBuffer[4]; + sprintf_P(lineBuffer, PSTR("%-3d"), brightness100); + drawString(1, lineHeight, lineBuffer); + lastRedraw = millis(); + } } - void updateSpeed(){ + void updateSpeed() { knownEffectSpeed = effectSpeed; - if(overlayUntil == 0){ - fxspeed100 = (((float)(effectSpeed)/255)*100); - char lineBuffer[4]; - sprintf_P(lineBuffer, PSTR("%-3d"), fxspeed100); - drawString(5, lineHeight, lineBuffer); - lastRedraw = millis();} + if (overlayUntil == 0) { + fxspeed100 = ((uint16_t)effectSpeed*100)/255; + char lineBuffer[4]; + sprintf_P(lineBuffer, PSTR("%-3d"), fxspeed100); + drawString(5, lineHeight, lineBuffer); + lastRedraw = millis(); + } } - void updateIntensity(){ + void updateIntensity() { knownEffectIntensity = effectIntensity; - if(overlayUntil == 0){ - fxintensity100 = (((float)(effectIntensity)/255)*100); - char lineBuffer[4]; - sprintf_P(lineBuffer, PSTR("%-3d"), fxintensity100); - drawString(9, lineHeight, lineBuffer); - lastRedraw = millis();} + if (overlayUntil == 0) { + fxintensity100 = ((uint16_t)effectIntensity*100)/255; + char lineBuffer[4]; + sprintf_P(lineBuffer, PSTR("%-3d"), fxintensity100); + drawString(9, lineHeight, lineBuffer); + lastRedraw = millis(); + } } - void draw2x2GlyphIcons(){ + void draw2x2GlyphIcons() { if (lineHeight == 2) { drawGlyph(1, 0, 1, u8x8_font_benji_custom_icons_2x2, true);//brightness icon drawGlyph(5, 0, 2, u8x8_font_benji_custom_icons_2x2, true);//speed icon @@ -621,7 +627,7 @@ class FourLineDisplayUsermod : public Usermod { } } - void drawStatusIcons(){ + void drawStatusIcons() { drawGlyph(14, 0, 80 + (wificonnected?0:1), u8x8_font_open_iconic_embedded_1x1, true); // wifi icon drawGlyph(15, 0, 78 + (bri > 0 ? 0 : 3), u8x8_font_open_iconic_embedded_1x1, true); // power icon drawGlyph(13, 0, 66 + (nightlightActive?0:4), u8x8_font_open_iconic_weather_1x1, true); // moon icon for nighlight mode @@ -638,8 +644,8 @@ class FourLineDisplayUsermod : public Usermod { } //Draw the arrow for the current setting beiong changed - void drawArrow(){ - if(markColNum != 255 && markLineNum !=255)drawGlyph(markColNum, markLineNum*lineHeight, 69, u8x8_font_open_iconic_play_1x1); + void drawArrow() { + if (markColNum != 255 && markLineNum !=255) drawGlyph(markColNum, markLineNum*lineHeight, 69, u8x8_font_open_iconic_play_1x1); } //Display the current effect or palette (desiredEntry) @@ -657,15 +663,13 @@ class FourLineDisplayUsermod : public Usermod { uint8_t smallChars1 = 0; uint8_t smallChars2 = 0; uint8_t smallChars3 = 0; - uint8_t totalCount = 0; - char singleJsonSymbol; // Find the mode name in JSON printedChars = extractModeName(inputEffPal, qstring, lineBuffer, LINE_BUFFER_SIZE-1); if (lineHeight == 2) { // use this code for 8 line display if (printedChars < MAX_MODE_LINE_SPACE) { // use big font if the text fits - for (;printedChars < (MAX_MODE_LINE_SPACE-1); printedChars++) {lineBuffer[printedChars]=' '; } + for (;printedChars < (MAX_MODE_LINE_SPACE-1); printedChars++) lineBuffer[printedChars]=' '; lineBuffer[printedChars] = 0; drawString(1, row*lineHeight, lineBuffer); } else { // for long names divide the text into 2 lines and print them small @@ -750,20 +754,33 @@ class FourLineDisplayUsermod : public Usermod { // Print the overlay clear(); // First row string - if (line1) drawString(0, 0, line1); + if (line1) { + String l1 = line1; + l1.trim(); + center(l1, getCols()); + drawString(0, 0, l1.c_str()); + } // Second row with Wifi name - String ssidString = knownSsid.substring(0, getCols() > 1 ? getCols() - 2 : 0); // - drawString(0, lineHeight, ssidString.c_str()); + String line = knownSsid.substring(0, getCols() > 1 ? getCols() - 2 : 0); + if (line.length() < getCols()) center(line, getCols()); + drawString(0, lineHeight, line.c_str()); // Print `~` char to indicate that SSID is longer, than our display if (knownSsid.length() > getCols()) { drawString(getCols() - 1, 0, "~"); } - // Third row with IP and Psssword in AP Mode - drawString(0, lineHeight*2, (knownIp.toString()).c_str()); + // Third row with IP and Password in AP Mode + line = knownIp.toString(); + center(line, getCols()); + drawString(0, lineHeight*2, line.c_str()); if (apActive) { - String appassword = apPass; - drawString(0, lineHeight*3, appassword.c_str()); - } + line = apPass; + center(line, getCols()); + drawString(0, lineHeight*3, line.c_str()); + } else if (strcmp(serverDescription, "WLED") != 0) { + line = serverDescription; + center(line, getCols()); + drawString(0, lineHeight*3, line.c_str()); + } overlayUntil = millis() + showHowLong; } @@ -793,29 +810,38 @@ class FourLineDisplayUsermod : public Usermod { */ void showTime() { if (type == NONE || !enabled) return; - if (knownMinute != minute(localTime)) { //only redraw clock if it has changed + char lineBuffer[LINE_BUFFER_SIZE]; + static byte lastSecond; + byte secondCurrent = second(localTime); - //updateLocalTime(); - byte AmPmHour = hour(localTime); - boolean isitAM = true; - if (useAMPM) { - if (AmPmHour > 11) AmPmHour -= 12; - if (AmPmHour == 0) AmPmHour = 12; - if (hour(localTime) > 11) isitAM = false; - } - clear(); - drawStatusIcons(); //icons power, wifi, timer, etc + if (knownMinute != minute(localTime)) { //only redraw clock if it has changed + //updateLocalTime(); + byte AmPmHour = hour(localTime); + boolean isitAM = true; + if (useAMPM) { + if (AmPmHour > 11) AmPmHour -= 12; + if (AmPmHour == 0) AmPmHour = 12; + if (hour(localTime) > 11) isitAM = false; + } - sprintf_P(lineBuffer, PSTR("%s %2d "), monthShortStr(month(localTime)), day(localTime)); + drawStatusIcons(); //icons power, wifi, timer, etc + + sprintf_P(lineBuffer, PSTR("%s %2d "), monthShortStr(month(localTime)), day(localTime)); draw2x2String(DATE_INDENT, lineHeight==1 ? 0 : lineHeight, lineBuffer); // adjust for 8 line displays, draw month and day - sprintf_P(lineBuffer,PSTR("%2d:%02d"), (useAMPM ? AmPmHour : hour(localTime)), minute(localTime)); + sprintf_P(lineBuffer,PSTR("%2d:%02d"), (useAMPM ? AmPmHour : hour(localTime)), minute(localTime)); draw2x2String(TIME_INDENT+2, lineHeight*2, lineBuffer); //draw hour, min. blink ":" depending on odd/even seconds if (useAMPM) drawString(12, lineHeight*2, (isitAM ? "AM" : "PM"), true); //draw am/pm if using 12 time - knownMinute = minute(localTime); + knownMinute = minute(localTime); + } else { + if (secondCurrent == lastSecond) return; } + lastSecond = secondCurrent; + draw2x2String(6, lineHeight*2, secondCurrent%2 ? " " : ":"); + sprintf_P(lineBuffer, PSTR("%02d"), secondCurrent); + drawString(12, lineHeight*2+1, lineBuffer, true); // even with double sized rows print seconds in 1 line } /* diff --git a/usermods/usermod_v2_rotary_encoder_ui_ALT/usermod_v2_rotary_encoder_ui_ALT.h b/usermods/usermod_v2_rotary_encoder_ui_ALT/usermod_v2_rotary_encoder_ui_ALT.h index aee90e28..7216162c 100644 --- a/usermods/usermod_v2_rotary_encoder_ui_ALT/usermod_v2_rotary_encoder_ui_ALT.h +++ b/usermods/usermod_v2_rotary_encoder_ui_ALT/usermod_v2_rotary_encoder_ui_ALT.h @@ -55,7 +55,7 @@ private: int fadeAmount = 5; // Amount to change every step (brightness) unsigned long currentTime; unsigned long loopTime; - unsigned long buttonHoldTIme; + unsigned long buttonHoldTime; int8_t pinA = ENCODER_DT_PIN; // DT from encoder int8_t pinB = ENCODER_CLK_PIN; // CLK from encoder int8_t pinC = ENCODER_SW_PIN; // SW from encoder @@ -63,8 +63,8 @@ private: unsigned char button_state = HIGH; unsigned char prev_button_state = HIGH; bool networkShown = false; - uint16_t currentHue1 = 6425; // default reboot color - byte currentSat1 = 255; + uint16_t currentHue1 = 16; // default boot color + byte currentSat1 = 255; #ifdef USERMOD_FOUR_LINE_DISPLAY FourLineDisplayUsermod *display; @@ -97,9 +97,9 @@ private: public: /* - * setup() is called once at boot. WiFi is not yet connected at this point. - * You can use it to initialize variables, sensors or similar. - */ + * setup() is called once at boot. WiFi is not yet connected at this point. + * You can use it to initialize variables, sensors or similar. + */ void setup() { DEBUG_PRINTLN(F("Usermod Rotary Encoder init.")); @@ -141,24 +141,24 @@ public: } /* - * connected() is called every time the WiFi is (re)connected - * Use it to initialize network interfaces - */ + * connected() is called every time the WiFi is (re)connected + * Use it to initialize network interfaces + */ void connected() { //Serial.println("Connected to WiFi!"); } /* - * loop() is called continuously. Here you can check for events, read sensors, etc. - * - * Tips: - * 1. You can use "if (WLED_CONNECTED)" to check for a successful network connection. - * Additionally, "if (WLED_MQTT_CONNECTED)" is available to check for a connection to an MQTT broker. - * - * 2. Try to avoid using the delay() function. NEVER use delays longer than 10 milliseconds. - * Instead, use a timer check as shown here. - */ + * loop() is called continuously. Here you can check for events, read sensors, etc. + * + * Tips: + * 1. You can use "if (WLED_CONNECTED)" to check for a successful network connection. + * Additionally, "if (WLED_MQTT_CONNECTED)" is available to check for a connection to an MQTT broker. + * + * 2. Try to avoid using the delay() function. NEVER use delays longer than 10 milliseconds. + * Instead, use a timer check as shown here. + */ void loop() { currentTime = millis(); // get the current elapsed time @@ -168,19 +168,19 @@ public: // is not yet initialized when setup is called. if (!currentEffectAndPaletteInitialized) { - findCurrentEffectAndPalette();} + findCurrentEffectAndPalette(); + } - if(modes_alpha_indexes[effectCurrentIndex] != effectCurrent - || palettes_alpha_indexes[effectPaletteIndex] != effectPalette){ + if (modes_alpha_indexes[effectCurrentIndex] != effectCurrent || palettes_alpha_indexes[effectPaletteIndex] != effectPalette) { currentEffectAndPaletteInitialized = false; - } + } if (currentTime >= (loopTime + 2)) // 2ms since last check of encoder = 500Hz { button_state = digitalRead(pinC); if (prev_button_state != button_state) { - if (button_state == HIGH && (millis()-buttonHoldTIme < 3000)) + if (button_state == HIGH && (millis()-buttonHoldTime < 3000)) { prev_button_state = button_state; @@ -191,25 +191,25 @@ public: if (display != nullptr) { switch(newState) { case 0: - changedState = changeState(" Brightness", 1, 0, 1); + changedState = changeState(PSTR("Brightness"), 1, 0, 1); break; case 1: - changedState = changeState(" Speed", 1, 4, 2); + changedState = changeState(PSTR("Speed"), 1, 4, 2); break; case 2: - changedState = changeState(" Intensity", 1 ,8, 3); + changedState = changeState(PSTR("Intensity"), 1 ,8, 3); break; case 3: - changedState = changeState(" Color Palette", 2, 0, 4); + changedState = changeState(PSTR("Color Palette"), 2, 0, 4); break; case 4: - changedState = changeState(" Effect", 3, 0, 5); + changedState = changeState(PSTR("Effect"), 3, 0, 5); break; case 5: - changedState = changeState(" Main Color", 255, 255, 7); + changedState = changeState(PSTR("Main Color"), 255, 255, 7); break; case 6: - changedState = changeState(" Saturation", 255, 255, 8); + changedState = changeState(PSTR("Saturation"), 255, 255, 8); break; } } @@ -221,11 +221,15 @@ public: { prev_button_state = button_state; networkShown = false; - if(!prev_button_state)buttonHoldTIme = millis(); + if (!prev_button_state) buttonHoldTime = millis(); } } - if (!prev_button_state && (millis()-buttonHoldTIme > 3000) && !networkShown) displayNetworkInfo(); //long press for network info + if (!prev_button_state && (millis()-buttonHoldTime > 3000) && !networkShown) { + displayNetworkInfo(); //long press for network info + loopTime = currentTime; // Updates loopTime + return; + } Enc_A = digitalRead(pinA); // Read encoder pins Enc_B = digitalRead(pinB); @@ -289,9 +293,9 @@ public: } } - void displayNetworkInfo(){ + void displayNetworkInfo() { #ifdef USERMOD_FOUR_LINE_DISPLAY - display->networkOverlay(" NETWORK INFO", 15000); + display->networkOverlay(PSTR("NETWORK INFO"), 10000); networkShown = true; #endif } @@ -314,17 +318,20 @@ public: } boolean changeState(const char *stateName, byte markedLine, byte markedCol, byte glyph) { - #ifdef USERMOD_FOUR_LINE_DISPLAY - if (display != nullptr) { - if (display->wakeDisplay()) { - // Throw away wake up input - return false; - } - display->overlay(stateName, 750, glyph); - display->setMarkLine(markedLine, markedCol); - } - #endif - return true; + #ifdef USERMOD_FOUR_LINE_DISPLAY + if (display != nullptr) { + if (display->wakeDisplay()) { + // Throw away wake up input + return false; + } + String line = stateName; + //line.trim(); + display->center(line, display->getCols()); + display->overlay(line.c_str(), 750, glyph); + display->setMarkLine(markedLine, markedCol); + } + #endif + return true; } void lampUdated() { @@ -336,120 +343,121 @@ public: } void changeBrightness(bool increase) { - #ifdef USERMOD_FOUR_LINE_DISPLAY - if (display && display->wakeDisplay()) { - // Throw away wake up input - return; - } - #endif - if (increase) bri = (bri + fadeAmount <= 255) ? (bri + fadeAmount) : 255; - else bri = (bri - fadeAmount >= 0) ? (bri - fadeAmount) : 0; - lampUdated(); - #ifdef USERMOD_FOUR_LINE_DISPLAY - display->updateBrightness(); - #endif + #ifdef USERMOD_FOUR_LINE_DISPLAY + if (display && display->wakeDisplay()) { + // Throw away wake up input + return; + } + #endif + if (increase) bri = (bri + fadeAmount <= 255) ? (bri + fadeAmount) : 255; + else bri = (bri - fadeAmount >= 0) ? (bri - fadeAmount) : 0; + lampUdated(); + #ifdef USERMOD_FOUR_LINE_DISPLAY + display->updateBrightness(); + #endif } void changeEffect(bool increase) { - #ifdef USERMOD_FOUR_LINE_DISPLAY - if (display && display->wakeDisplay()) { - // Throw away wake up input - return; - } - #endif - if (increase) effectCurrentIndex = (effectCurrentIndex + 1 >= strip.getModeCount()) ? 0 : (effectCurrentIndex + 1); - else effectCurrentIndex = (effectCurrentIndex - 1 < 0) ? (strip.getModeCount() - 1) : (effectCurrentIndex - 1); - effectCurrent = modes_alpha_indexes[effectCurrentIndex]; - lampUdated(); - #ifdef USERMOD_FOUR_LINE_DISPLAY - display->showCurrentEffectOrPalette(effectCurrent, JSON_mode_names, 3); - #endif + #ifdef USERMOD_FOUR_LINE_DISPLAY + if (display && display->wakeDisplay()) { + // Throw away wake up input + return; + } + #endif + if (increase) effectCurrentIndex = (effectCurrentIndex + 1 >= strip.getModeCount()) ? 0 : (effectCurrentIndex + 1); + else effectCurrentIndex = (effectCurrentIndex - 1 < 0) ? (strip.getModeCount() - 1) : (effectCurrentIndex - 1); + effectCurrent = modes_alpha_indexes[effectCurrentIndex]; + lampUdated(); + #ifdef USERMOD_FOUR_LINE_DISPLAY + display->showCurrentEffectOrPalette(effectCurrent, JSON_mode_names, 3); + #endif } void changeEffectSpeed(bool increase) { - #ifdef USERMOD_FOUR_LINE_DISPLAY - if (display && display->wakeDisplay()) { - // Throw away wake up input - return; - } - #endif - if (increase) effectSpeed = (effectSpeed + fadeAmount <= 255) ? (effectSpeed + fadeAmount) : 255; - else effectSpeed = (effectSpeed - fadeAmount >= 0) ? (effectSpeed - fadeAmount) : 0; - lampUdated(); - #ifdef USERMOD_FOUR_LINE_DISPLAY - display->updateSpeed(); - #endif + #ifdef USERMOD_FOUR_LINE_DISPLAY + if (display && display->wakeDisplay()) { + // Throw away wake up input + return; + } + #endif + if (increase) effectSpeed = (effectSpeed + fadeAmount <= 255) ? (effectSpeed + fadeAmount) : 255; + else effectSpeed = (effectSpeed - fadeAmount >= 0) ? (effectSpeed - fadeAmount) : 0; + lampUdated(); + #ifdef USERMOD_FOUR_LINE_DISPLAY + display->updateSpeed(); + #endif } void changeEffectIntensity(bool increase) { - #ifdef USERMOD_FOUR_LINE_DISPLAY - if (display && display->wakeDisplay()) { - // Throw away wake up input - return; - } - #endif - if (increase) effectIntensity = (effectIntensity + fadeAmount <= 255) ? (effectIntensity + fadeAmount) : 255; - else effectIntensity = (effectIntensity - fadeAmount >= 0) ? (effectIntensity - fadeAmount) : 0; - lampUdated(); - #ifdef USERMOD_FOUR_LINE_DISPLAY - display->updateIntensity(); - #endif + #ifdef USERMOD_FOUR_LINE_DISPLAY + if (display && display->wakeDisplay()) { + // Throw away wake up input + return; + } + #endif + if (increase) effectIntensity = (effectIntensity + fadeAmount <= 255) ? (effectIntensity + fadeAmount) : 255; + else effectIntensity = (effectIntensity - fadeAmount >= 0) ? (effectIntensity - fadeAmount) : 0; + lampUdated(); + #ifdef USERMOD_FOUR_LINE_DISPLAY + display->updateIntensity(); + #endif } void changePalette(bool increase) { - #ifdef USERMOD_FOUR_LINE_DISPLAY - if (display && display->wakeDisplay()) { - // Throw away wake up input - return; - } - #endif - if (increase) effectPaletteIndex = (effectPaletteIndex + 1 >= strip.getPaletteCount()) ? 0 : (effectPaletteIndex + 1); - else effectPaletteIndex = (effectPaletteIndex - 1 < 0) ? (strip.getPaletteCount() - 1) : (effectPaletteIndex - 1); - effectPalette = palettes_alpha_indexes[effectPaletteIndex]; - lampUdated(); - #ifdef USERMOD_FOUR_LINE_DISPLAY - display->showCurrentEffectOrPalette(effectPalette, JSON_palette_names, 2); - #endif + #ifdef USERMOD_FOUR_LINE_DISPLAY + if (display && display->wakeDisplay()) { + // Throw away wake up input + return; + } + #endif + if (increase) effectPaletteIndex = (effectPaletteIndex + 1 >= strip.getPaletteCount()) ? 0 : (effectPaletteIndex + 1); + else effectPaletteIndex = (effectPaletteIndex - 1 < 0) ? (strip.getPaletteCount() - 1) : (effectPaletteIndex - 1); + effectPalette = palettes_alpha_indexes[effectPaletteIndex]; + lampUdated(); + #ifdef USERMOD_FOUR_LINE_DISPLAY + display->showCurrentEffectOrPalette(effectPalette, JSON_palette_names, 2); + #endif } void changeHue(bool increase){ - #ifdef USERMOD_FOUR_LINE_DISPLAY - if (display && display->wakeDisplay()) { - // Throw away wake up input - return; - } - #endif - - if(increase) currentHue1 += 321; - else currentHue1 -= 321; - colorHStoRGB(currentHue1, currentSat1, col); - lampUdated(); - #ifdef USERMOD_FOUR_LINE_DISPLAY - display->updateRedrawTime(); - #endif + #ifdef USERMOD_FOUR_LINE_DISPLAY + if (display && display->wakeDisplay()) { + // Throw away wake up input + return; + } + #endif + if (increase) { if (currentHue1<256) currentHue1 += 4; else currentHue1 = 0; } + else { if (currentHue1>3) currentHue1 -= 4; else currentHue1 = 256; } + colorHStoRGB(currentHue1*255, currentSat1, col); + strip.applyToAllSelected = true; + strip.setColor(0, colorFromRgbw(col)); + lampUdated(); + #ifdef USERMOD_FOUR_LINE_DISPLAY + display->updateRedrawTime(); + #endif } void changeSat(bool increase){ - #ifdef USERMOD_FOUR_LINE_DISPLAY - if (display && display->wakeDisplay()) { - // Throw away wake up input - return; - } - #endif - - if(increase) currentSat1 = (currentSat1 + 5 <= 255 ? (currentSat1 + 5) : 255); - else currentSat1 = (currentSat1 - 5 >= 0 ? (currentSat1 - 5) : 0); - colorHStoRGB(currentHue1, currentSat1, col); - lampUdated(); - #ifdef USERMOD_FOUR_LINE_DISPLAY - display->updateRedrawTime(); - #endif - + #ifdef USERMOD_FOUR_LINE_DISPLAY + if (display && display->wakeDisplay()) { + // Throw away wake up input + return; + } + #endif + if (increase) { if (currentSat1<252) currentSat1 += 4; } + else { if (currentSat1>3) currentSat1 -= 4; } + colorHStoRGB(currentHue1*256, currentSat1, col); + strip.applyToAllSelected = true; + strip.setColor(0, colorFromRgbw(col)); + lampUdated(); + #ifdef USERMOD_FOUR_LINE_DISPLAY + display->updateRedrawTime(); + #endif } /* diff --git a/wled00/wled.h b/wled00/wled.h index f8820c5e..a7830b92 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -8,7 +8,7 @@ */ // version code in format yymmddb (b = daily build) -#define VERSION 2112191 +#define VERSION 2112201 //uncomment this if you have a "my_config.h" file you'd like to use //#define WLED_USE_MY_CONFIG