Skip to content

Commit d6b366c

Browse files
committed
Finished multi segment transitions
1 parent 42a7c84 commit d6b366c

File tree

4 files changed

+30
-24
lines changed

4 files changed

+30
-24
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
### Development versions after 0.11.1 release
44

5+
#### Build 2101130
6+
7+
- Added color transitions for all segments and slots and for segment brightness
8+
- Fixed bug that prevented setting a boot preset higher than 25
9+
510
#### Build 2101040
611

712
- Replaced Red & Blue effect with Aurora effect (PR #1589)

wled00/FX.h

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -270,30 +270,31 @@ class WS2812FX {
270270
void setOpacity(uint8_t o, uint8_t segn) {
271271
if (segn >= MAX_NUM_SEGMENTS) return;
272272
if (opacity == o) return;
273-
ColorTransition::startTransition(o, colors[0], instance->_transitionDur, segn, 0);
273+
ColorTransition::startTransition(opacity, colors[0], instance->_transitionDur, segn, 0);
274274
opacity = o;
275275
}
276-
uint8_t actualOpacity() { //respects On/Off state
276+
/*uint8_t actualOpacity() { //respects On/Off state
277277
if (!getOption(SEG_OPTION_ON)) return 0;
278278
return opacity;
279-
}
279+
}*/
280280
void setOption(uint8_t n, bool val, uint8_t segn = 255)
281281
{
282-
bool prevOn = false;
283-
if (n == SEG_OPTION_ON) prevOn = getOption(SEG_OPTION_ON);
282+
//bool prevOn = false;
283+
//if (n == SEG_OPTION_ON) prevOn = getOption(SEG_OPTION_ON);
284284
if (val) {
285285
options |= 0x01 << n;
286286
} else
287287
{
288288
options &= ~(0x01 << n);
289289
}
290-
if (n == SEG_OPTION_ON && segn < MAX_NUM_SEGMENTS && getOption(SEG_OPTION_ON) != prevOn) {
290+
//transitions on segment on/off don't work correctly at this point
291+
/*if (n == SEG_OPTION_ON && segn < MAX_NUM_SEGMENTS && getOption(SEG_OPTION_ON) != prevOn) {
291292
if (getOption(SEG_OPTION_ON)) {
292293
ColorTransition::startTransition(0, colors[0], instance->_transitionDur, segn, 0);
293294
} else {
294295
ColorTransition::startTransition(opacity, colors[0], instance->_transitionDur, segn, 0);
295296
}
296-
}
297+
}*/
297298
}
298299
bool getOption(uint8_t n)
299300
{
@@ -384,8 +385,8 @@ class WS2812FX {
384385
uint8_t segment = 0xFF; //lower 6 bits: the segment this transition is for (255 indicates transition not in use/available) upper 2 bits: color channel
385386
uint8_t briOld = 0;
386387
static void startTransition(uint8_t oldBri, uint32_t oldCol, uint16_t dur, uint8_t segn, uint8_t slot) {
387-
Serial.printf("Starting t: Bri %u Col %u Dur %u Seg %u Slot %u\n", oldBri, oldCol, dur, segn, slot);
388-
if (segn >= MAX_NUM_SEGMENTS || slot >= NUM_COLORS || dur == 0) return;
388+
if (segn >= MAX_NUM_SEGMENTS || slot >= NUM_COLORS || dur == 0) return;
389+
if (instance->_brightness == 0) return; //do not need transitions if master bri is off
389390
uint8_t tIndex = 0xFF; //none found
390391
uint16_t tProgression = 0;
391392
uint8_t s = segn + (slot << 6); //merge slot and segment into one byte
@@ -426,21 +427,21 @@ class WS2812FX {
426427
t.transitionStart = millis();
427428
t.segment = s;
428429
instance->_segments[segn].setOption(SEG_OPTION_TRANSITIONAL, true);
429-
//Serial.printf("S: %u, TNr: %u, St: %u\n", s, tIndex, t.transitionStart);
430-
//instance->transitions[tIndex] = t;
430+
//refresh immediately, required for Solid mode
431+
if (instance->_segment_runtimes[segn].next_time > t.transitionStart + 22) instance->_segment_runtimes[segn].next_time = t.transitionStart;
431432
}
432433
uint16_t progress(bool allowEnd = false) { //transition progression between 0-65535
433434
uint32_t timeNow = millis();
434-
//Serial.printf("ProgressR %u, St: %u, S: %u\n",timeNow - transitionStart, transitionStart, segment);
435-
if (timeNow - transitionStart > transitionDur) return 0xFFFF;
435+
if (timeNow - transitionStart > transitionDur) {
436+
if (allowEnd) {
437+
uint8_t segn = segment & 0x3F;
438+
if (segn < MAX_NUM_SEGMENTS) instance->_segments[segn].setOption(SEG_OPTION_TRANSITIONAL, false);
439+
segment = 0xFF;
440+
}
441+
return 0xFFFF;
442+
}
436443
uint32_t elapsed = timeNow - transitionStart;
437444
uint32_t prog = elapsed * 0xFFFF / transitionDur;
438-
//Serial.printf("Progress %u\n",prog);
439-
if (prog > 0xFFFF && allowEnd) {
440-
uint8_t segn = segment & 0x3F;
441-
if (segn < MAX_NUM_SEGMENTS) instance->_segments[segn].setOption(SEG_OPTION_TRANSITIONAL, false);
442-
segment = 0xFF;
443-
}
444445
return (prog > 0xFFFF) ? 0xFFFF : prog;
445446
}
446447
uint32_t currentColor(uint32_t colorNew) {
@@ -449,9 +450,9 @@ class WS2812FX {
449450
uint8_t currentBri() {
450451
uint8_t segn = segment & 0x3F;
451452
if (segn >= MAX_NUM_SEGMENTS) return 0;
452-
uint8_t briNew = instance->_segments[segn].actualOpacity();
453-
uint32_t prog = progress();
454-
return ((briNew * prog) + (briOld * (0xFFFF - prog))) >> 16;
453+
uint8_t briNew = instance->_segments[segn].opacity;
454+
uint32_t prog = progress() + 1;
455+
return ((briNew * prog) + (briOld * (0x10000 - prog))) >> 16;
455456
}
456457
} color_transition;
457458

wled00/set.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
9090
saveCurrPresetCycConf = request->hasArg(F("PC"));
9191
turnOnAtBoot = request->hasArg(F("BO"));
9292
t = request->arg(F("BP")).toInt();
93-
if (t <= 25) bootPreset = t;
93+
if (t <= 250) bootPreset = t;
9494
strip.gammaCorrectBri = request->hasArg(F("GB"));
9595
strip.gammaCorrectCol = request->hasArg(F("GC"));
9696

wled00/wled.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99

1010
// version code in format yymmddb (b = daily build)
11-
#define VERSION 2101080
11+
#define VERSION 2101130
1212

1313
//uncomment this if you have a "my_config.h" file you'd like to use
1414
//#define WLED_USE_MY_CONFIG

0 commit comments

Comments
 (0)