diff --git a/wled00/FX.h b/wled00/FX.h index 3aeca57124..85201969cb 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -42,7 +42,7 @@ #define DEFAULT_MODE (uint8_t)0 #define DEFAULT_SPEED (uint8_t)128 #define DEFAULT_INTENSITY (uint8_t)128 -#define DEFAULT_COLOR (uint32_t)0xFFAA00 +#define DEFAULT_COLOR (uint32_t)0xFFA000 #define DEFAULT_C1 (uint8_t)128 #define DEFAULT_C2 (uint8_t)128 #define DEFAULT_C3 (uint8_t)16 @@ -562,7 +562,7 @@ class Segment { public: Segment(uint16_t sStart=0, uint16_t sStop=30, uint16_t sStartY = 0, uint16_t sStopY = 1) - : colors{DEFAULT_COLOR,BLACK,BLACK} + : colors{DEFAULT_COLOR,BLACK,BLACK} // create "warm orange" segment by default , start(sStart) , stop(sStop > sStart ? sStop : sStart+1) // minimum length is 1 , startY(sStartY) @@ -596,6 +596,12 @@ class Segment { , _t(nullptr) { DEBUGFX_PRINTF_P(PSTR("-- Creating segment: %p [%d,%d:%d,%d]\n"), this, (int)start, (int)stop, (int)startY, (int)stopY); + uint32_t bootupTime = 2000; // 2s should be more than enough to init bootup-segments to black + #ifdef WLED_BOOTUPDELAY + bootupTime += WLED_BOOTUPDELAY; + #endif + if (millis() < bootupTime) + colors[0] = BLACK; // at bootup create black segments so boot-up fade-in does not turn to orange for presets // allocate render buffer (always entire segment), prefer PSRAM if DRAM is running low. Note: impact on FPS with PSRAM buffer is low (<2% with QSPI PSRAM) pixels = static_cast(allocate_buffer(length() * sizeof(uint32_t), BFRALLOC_PREFER_PSRAM | BFRALLOC_NOBYTEACCESS | BFRALLOC_CLEAR)); if (!pixels) { diff --git a/wled00/data/settings_leds.htm b/wled00/data/settings_leds.htm index f1471e9bf4..72a12b53d4 100644 --- a/wled00/data/settings_leds.htm +++ b/wled00/data/settings_leds.htm @@ -1126,8 +1126,7 @@

General settings

Power up

Turn LEDs on after power up/reset:
- with brightness: (1-255)
- (disable if using boot preset to turn LEDs on)

+ Bootup brightness: (1-255)

Apply preset at boot (0 = none)

diff --git a/wled00/wled.cpp b/wled00/wled.cpp index e91fcca8f5..9b40a70a9f 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -616,31 +616,33 @@ void WLED::beginStrip() // init offMode and relay offMode = false; // init to on state to allow proper relay init handleOnOff(true); // init relay and force off + if (rlyPin < 0) strip.show(); // ensure LEDs are off if no relay is used + // Note on how bootup behaviour works: + // if turnOnAtBoot is false: strip is set to black. It will fade in to startup brightness and orange when turned on + // if a bootup preset is set, it will fade to that preset if it has "on:true" set (to default brightness) or to that preset's brightness if set + // if turnOnAtBoot is true: the LEDs will fade in to orange and default brightness + // if a bootup preset is set, it will start at the default brightness except if "fade" transition is used, then it will still fade from black + // there is no way to have LEDs off at boot and upon turn-on have them immediatel jump to a target brightness but users can use a playlist to do that + + bri = 0; // start off black by default (on a fresh install this is overruled by briS as turnOnAtBoot is true) if (turnOnAtBoot) { - if (briS > 0) bri = briS; - else if (bri == 0) bri = 128; - } else { - // fix for #3196 - if (bootPreset > 0) { - // set all segments black (no transition) - for (unsigned i = 0; i < strip.getSegmentsNum(); i++) { - Segment &seg = strip.getSegment(i); - if (seg.isActive()) seg.colors[0] = BLACK; - } - colPri[0] = colPri[1] = colPri[2] = colPri[3] = 0; // needed for colorUpdated() - } - briLast = briS; bri = 0; - strip.fill(BLACK); - if (rlyPin < 0) - strip.show(); // ensure LEDs are off if no relay is used + bri = briS; // load startup brightness (set in UI), 0 is not allowed in UI } - colorUpdated(CALL_MODE_INIT); // will not send notification but will initiate transition + else briLast = briS; // go to startup brightness (set in UI) when turning on (can be overruled by a preset) + if (bootPreset > 0) { applyPreset(bootPreset, CALL_MODE_INIT); } + else { + // set color to warm welcoming orange (aka DEFAULT_COLOR) if no preset loaded (will fade to this color once turned on) + colPri[0] = 255; + colPri[1] = 160; + colPri[2] = colPri[3] = 0; + } - strip.setTransition(transitionDelayDefault); // restore transitions + colorUpdated(CALL_MODE_INIT); // will not send notification but will initiate transition, brightness is set immediately + strip.setTransition(transitionDelayDefault); // restore default transition time } void WLED::initAP(bool resetAP) diff --git a/wled00/wled.h b/wled00/wled.h index eb2df1875e..23c1995edf 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -413,8 +413,8 @@ WLED_GLOBAL bool gammaCorrectCol _INIT(true); // use gamma correction on col WLED_GLOBAL bool gammaCorrectBri _INIT(false); // use gamma correction on brightness WLED_GLOBAL float gammaCorrectVal _INIT(2.2f); // gamma correction value -WLED_GLOBAL byte colPri[] _INIT_N(({ 255, 160, 0, 0 })); // current RGB(W) primary color. colPri[] should be updated if you want to change the color. -WLED_GLOBAL byte colSec[] _INIT_N(({ 0, 0, 0, 0 })); // current RGB(W) secondary color +WLED_GLOBAL byte colPri[] _INIT_N(({ 0, 0, 0, 0 })); // current RGB(W) primary color. colPri[] should be updated if you want to change the color. +WLED_GLOBAL byte colSec[] _INIT_N(({ 0, 0, 0, 0 })); // current RGB(W) secondary color WLED_GLOBAL byte nightlightTargetBri _INIT(0); // brightness after nightlight is over WLED_GLOBAL byte nightlightDelayMins _INIT(60);