From e2061464a5deb73b16ba242348e058297cde64d6 Mon Sep 17 00:00:00 2001 From: cschwinne Date: Fri, 7 May 2021 11:32:08 +0200 Subject: [PATCH] Fixed not turning on after pressing "Off" on IR remote twice (fixes #1950) Fixed OTA update file selection from Android app (TODO: file type verification in JS, since android can't deal with accept='.bin' attribute) --- CHANGELOG.md | 5 +++++ wled00/FX.cpp | 43 +++++++++++++++++++++++++++++++++++++++++- wled00/data/update.htm | 2 +- wled00/html_other.h | 8 ++++---- wled00/ir.cpp | 12 ++++++------ wled00/wled.h | 2 +- 6 files changed, 59 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d0d4cbf..16245868 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ### Builds after release 0.12.0 +#### Build 2105070 + +- Fixed not turning on after pressing "Off" on IR remote twice (#1950) +- Fixed OTA update file selection from Android app (TODO: file type verification in JS, since android can't deal with accept='.bin' attribute) + #### Build 2104220 - Version bump to 0.12.1-b1 "Hikari" diff --git a/wled00/FX.cpp b/wled00/FX.cpp index 21d156b1..ab4ee2b9 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -3852,13 +3852,18 @@ typedef struct TvSim { } tvSim; +#ifndef WLED_DISABLE_FX_HIGH_FLASH_USE + #include "tv_colors.h" + #define numTVPixels (sizeof(tv_colors) / 2) // 2 bytes per Pixel (5/6/5) +#endif + /* TV Simulator Modified and adapted to WLED by Def3nder, based on "Fake TV Light for Engineers" by Phillip Burgess https://learn.adafruit.com/fake-tv-light-for-engineers/arduino-sketch */ uint16_t WS2812FX::mode_tv_simulator(void) { uint16_t nr, ng, nb, r, g, b, i, hue; - uint8_t sat, bri, j; + uint8_t hi, lo, r8, g8, b8, sat, bri, j; if (!SEGENV.allocateData(sizeof(tvSim))) return mode_static(); //allocation failed TvSim* tvSimulator = reinterpret_cast(SEGENV.data); @@ -3872,6 +3877,35 @@ uint16_t WS2812FX::mode_tv_simulator(void) { SEGENV.aux1 = 0; } + #ifndef WLED_DISABLE_FX_HIGH_FLASH_USE + /* + * this code uses the real color data from tv_colos.h + */ + + // initialize start of the TV-Colors + if (SEGENV.aux1 == 0) { + tvSimulator->pixelNum = ((uint8_t)random8(18)) * numTVPixels / 18; // Begin at random movie (18 in total) + SEGENV.aux1 = 1; + } + + // Read next 16-bit (5/6/5) color + hi = pgm_read_byte(&tv_colors[tvSimulator->pixelNum * 2 ]); + lo = pgm_read_byte(&tv_colors[tvSimulator->pixelNum * 2 + 1]); + + // Expand to 24-bit (8/8/8) + r8 = (hi & 0xF8) | (hi >> 5); + g8 = ((hi << 5) & 0xff) | ((lo & 0xE0) >> 3) | ((hi & 0x06) >> 1); + b8 = ((lo << 3) & 0xff) | ((lo & 0x1F) >> 2); + + // Apply gamma correction, further expand to 16/16/16 + nr = (uint8_t)gamma8(r8) * 257; // New R/G/B + ng = (uint8_t)gamma8(g8) * 257; + nb = (uint8_t)gamma8(b8) * 257; + #else + /* + * this code calculates the color to be used and save 18k of flash memory + */ + // create a new sceene if (((millis() - tvSimulator->sceeneStart) >= tvSimulator->sceeneDuration) || SEGENV.aux1 == 0) { tvSimulator->sceeneStart = millis(); // remember the start of the new sceene @@ -3916,9 +3950,16 @@ uint16_t WS2812FX::mode_tv_simulator(void) { nr = (uint8_t)gamma8(tvSimulator->actualColorR) * 257; // New R/G/B ng = (uint8_t)gamma8(tvSimulator->actualColorG) * 257; nb = (uint8_t)gamma8(tvSimulator->actualColorB) * 257; + #endif if (SEGENV.aux0 == 0) { // initialize next iteration SEGENV.aux0 = 1; + + #ifndef WLED_DISABLE_FX_HIGH_FLASH_USE + // increase color-index for next loop + tvSimulator->pixelNum++; + if (tvSimulator->pixelNum >= numTVPixels) tvSimulator->pixelNum = 0; + #endif // randomize total duration and fade duration for the actual color tvSimulator->totalTime = random16(250, 2500); // Semi-random pixel-to-pixel time diff --git a/wled00/data/update.htm b/wled00/data/update.htm index f3a0a221..16dede5c 100644 --- a/wled00/data/update.htm +++ b/wled00/data/update.htm @@ -43,7 +43,7 @@ Installed version: ##VERSION##
Download the latest binary:
-
+

Updating...
Please do not close or refresh the page :)
diff --git a/wled00/html_other.h b/wled00/html_other.h index ad55de59..75489818 100644 --- a/wled00/html_other.h +++ b/wled00/html_other.h @@ -45,10 +45,10 @@ action="/update" id="uf" enctype="multipart/form-data" onsubmit="U()"> Installed version: 0.12.1-b1
Download the latest binary: -

-
Updating... -
Please do not close or refresh the page :)
)====="; +


Updating...
+Please do not close or refresh the page :)
)====="; // Autogenerated from wled00/data/welcome.htm, do not edit!! diff --git a/wled00/ir.cpp b/wled00/ir.cpp index fb8dafed..9cb3cea1 100644 --- a/wled00/ir.cpp +++ b/wled00/ir.cpp @@ -227,7 +227,7 @@ void decodeIR24(uint32_t code) switch (code) { case IR24_BRIGHTER : incBrightness(); break; case IR24_DARKER : decBrightness(); break; - case IR24_OFF : briLast = bri; bri = 0; break; + case IR24_OFF : if (bri > 0) briLast = bri; bri = 0; break; case IR24_ON : bri = briLast; break; case IR24_RED : colorFromUint32(COLOR_RED); break; case IR24_REDDISH : colorFromUint32(COLOR_REDDISH); break; @@ -259,7 +259,7 @@ void decodeIR24OLD(uint32_t code) switch (code) { case IR24_OLD_BRIGHTER : incBrightness(); break; case IR24_OLD_DARKER : decBrightness(); break; - case IR24_OLD_OFF : briLast = bri; bri = 0; break; + case IR24_OLD_OFF : if (bri > 0) briLast = bri; bri = 0; break; case IR24_OLD_ON : bri = briLast; break; case IR24_OLD_RED : colorFromUint32(COLOR_RED); break; case IR24_OLD_REDDISH : colorFromUint32(COLOR_REDDISH); break; @@ -292,7 +292,7 @@ void decodeIR24CT(uint32_t code) switch (code) { case IR24_CT_BRIGHTER : incBrightness(); break; case IR24_CT_DARKER : decBrightness(); break; - case IR24_CT_OFF : briLast = bri; bri = 0; break; + case IR24_CT_OFF : if (bri > 0) briLast = bri; bri = 0; break; case IR24_CT_ON : bri = briLast; break; case IR24_CT_RED : colorFromUint32(COLOR_RED); break; case IR24_CT_REDDISH : colorFromUint32(COLOR_REDDISH); break; @@ -327,7 +327,7 @@ void decodeIR40(uint32_t code) switch (code) { case IR40_BPLUS : incBrightness(); break; case IR40_BMINUS : decBrightness(); break; - case IR40_OFF : briLast = bri; bri = 0; break; + case IR40_OFF : if (bri > 0) briLast = bri; bri = 0; break; case IR40_ON : bri = briLast; break; case IR40_RED : colorFromUint24(COLOR_RED); break; case IR40_REDDISH : colorFromUint24(COLOR_REDDISH); break; @@ -384,7 +384,7 @@ void decodeIR44(uint32_t code) switch (code) { case IR44_BPLUS : incBrightness(); break; case IR44_BMINUS : decBrightness(); break; - case IR44_OFF : briLast = bri; bri = 0; break; + case IR44_OFF : if (bri > 0) briLast = bri; bri = 0; break; case IR44_ON : bri = briLast; break; case IR44_RED : colorFromUint24(COLOR_RED); break; case IR44_REDDISH : colorFromUint24(COLOR_REDDISH); break; @@ -447,7 +447,7 @@ void decodeIR21(uint32_t code) switch (code) { case IR21_BRIGHTER: incBrightness(); break; case IR21_DARKER: decBrightness(); break; - case IR21_OFF: briLast = bri; bri = 0; break; + case IR21_OFF: if (bri > 0) briLast = bri; bri = 0; break; case IR21_ON: bri = briLast; break; case IR21_RED: colorFromUint32(COLOR_RED); break; case IR21_REDDISH: colorFromUint32(COLOR_REDDISH); break; diff --git a/wled00/wled.h b/wled00/wled.h index b64199c9..9d27c780 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -8,7 +8,7 @@ */ // version code in format yymmddb (b = daily build) -#define VERSION 2104220 +#define VERSION 2105070 //uncomment this if you have a "my_config.h" file you'd like to use //#define WLED_USE_MY_CONFIG