You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: wled00/FX.h
+14-30Lines changed: 14 additions & 30 deletions
Original file line number
Diff line number
Diff line change
@@ -590,17 +590,17 @@ typedef struct Segment {
590
590
591
591
// transition functions
592
592
voidstartTransition(uint16_t dur); // transition has to start before actual segment values change
593
-
voidstopTransition(void); // ends transition mode by destroying transition structure
594
-
voidhandleTransition(void);
593
+
voidstopTransition(void); // ends transition mode by destroying transition structure (does nothing if not in transition)
594
+
inlinevoidhandleTransition(void) { if (progress() == 0xFFFFU) stopTransition(); }
595
595
#ifndef WLED_DISABLE_MODE_BLEND
596
596
voidswapSegenv(tmpsegd_t &tmpSegD); // copies segment data into specifed buffer, if buffer is not a transition buffer, segment data is overwritten from transition buffer
597
597
voidrestoreSegenv(tmpsegd_t &tmpSegD); // restores segment data from buffer, if buffer is not transition buffer, changed values are copied to transition buffer
598
598
#endif
599
-
uint16_tprogress(void); // transition progression between 0-65535
600
-
uint8_tcurrentBri(bool useCct = false); // current segment brightness/CCT (blended while in transition)
601
-
uint8_tcurrentMode(void); // currently active effect/mode (while in transition)
602
-
uint8_tcurrentPalette(void); // currently active palette (while in transition)
603
-
uint32_tcurrentColor(uint8_t slot); // currently active segment color (blended while in transition)
599
+
uint16_tprogress(void)const;// transition progression between 0-65535
600
+
uint8_tcurrentBri(bool useCct = false)const;// current segment brightness/CCT (blended while in transition)
601
+
uint8_tcurrentMode(void)const;// currently active effect/mode (while in transition)
602
+
uint8_tcurrentPalette(void)const;// currently active palette (while in transition)
603
+
uint32_tcurrentColor(uint8_t slot)const;// currently active segment color (blended while in transition)
// duty cycle resolution (_depth) can be extracted from this formula: CLOCK_FREQUENCY > _frequency * 2^_depth
413
+
for (_depth = MAX_BIT_WIDTH; _depth > 8; _depth--) if (((CLOCK_FREQUENCY/_frequency) >> _depth) > 0) break;
387
414
388
415
#ifdef ESP8266
389
-
// duty cycle resolution (_depth) can be extracted from this formula: 1MHz > _frequency * 2^_depth
390
-
if (_frequency > 1760) _depth = 8;
391
-
elseif (_frequency > 880) _depth = 9;
392
-
else _depth = 10; // WLED_PWM_FREQ <= 880Hz
393
416
analogWriteRange((1<<_depth)-1);
394
417
analogWriteFreq(_frequency);
395
418
#else
396
419
_ledcStart = pinManager.allocateLedc(numPins);
397
420
if (_ledcStart == 255) { //no more free LEDC channels
398
421
deallocatePins(); return;
399
422
}
400
-
// duty cycle resolution (_depth) can be extracted from this formula: 80MHz > _frequency * 2^_depth
401
-
if (_frequency > 78124) _depth = 9;
402
-
elseif (_frequency > 39062) _depth = 10;
403
-
elseif (_frequency > 19531) _depth = 11;
404
-
else _depth = 12; // WLED_PWM_FREQ <= 19531Hz
405
423
#endif
406
424
407
425
for (unsigned i = 0; i < numPins; i++) {
@@ -419,7 +437,7 @@ BusPwm::BusPwm(BusConfig &bc)
419
437
}
420
438
_data = _pwmdata; // avoid malloc() and use stack
421
439
_valid = true;
422
-
DEBUG_PRINTF_P(PSTR("%successfully inited PWM strip with type %uand pins %u,%u,%u,%u,%u\n"), _valid?"S":"Uns", bc.type, _pins[0], _pins[1], _pins[2], _pins[3], _pins[4]);
440
+
DEBUG_PRINTF_P(PSTR("%successfully inited PWM strip with type %u, frequency %u, bit depth %u and pins %u,%u,%u,%u,%u\n"), _valid?"S":"Uns", bc.type, _frequency, _depth, _pins[0], _pins[1], _pins[2], _pins[3], _pins[4]);
423
441
}
424
442
425
443
voidBusPwm::setPixelColor(uint16_t pix, uint32_t c) {
0 commit comments