parent
f9bce54104
commit
00b0193a43
@ -81,7 +81,6 @@
|
|||||||
#define SEGLEN _virtualSegmentLength
|
#define SEGLEN _virtualSegmentLength
|
||||||
#define SEGACT SEGMENT.stop
|
#define SEGACT SEGMENT.stop
|
||||||
#define SPEED_FORMULA_L 5U + (50U*(255U - SEGMENT.speed))/SEGLEN
|
#define SPEED_FORMULA_L 5U + (50U*(255U - SEGMENT.speed))/SEGLEN
|
||||||
#define RESET_RUNTIME memset(_segment_runtimes, 0, sizeof(_segment_runtimes))
|
|
||||||
|
|
||||||
// some common colors
|
// some common colors
|
||||||
#define RED (uint32_t)0xFF0000
|
#define RED (uint32_t)0xFF0000
|
||||||
@ -409,8 +408,9 @@ class WS2812FX {
|
|||||||
* Flags that before the next effect is calculated,
|
* Flags that before the next effect is calculated,
|
||||||
* the internal segment state should be reset.
|
* the internal segment state should be reset.
|
||||||
* Call resetIfRequired before calling the next effect function.
|
* Call resetIfRequired before calling the next effect function.
|
||||||
|
* Safe to call from interrupts and network requests.
|
||||||
*/
|
*/
|
||||||
inline void reset() { _requiresReset = true; }
|
inline void markForReset() { _requiresReset = true; }
|
||||||
private:
|
private:
|
||||||
uint16_t _dataLen = 0;
|
uint16_t _dataLen = 0;
|
||||||
bool _requiresReset = false;
|
bool _requiresReset = false;
|
||||||
|
@ -67,7 +67,12 @@
|
|||||||
//do not call this method from system context (network callback)
|
//do not call this method from system context (network callback)
|
||||||
void WS2812FX::finalizeInit(void)
|
void WS2812FX::finalizeInit(void)
|
||||||
{
|
{
|
||||||
RESET_RUNTIME;
|
//reset segment runtimes
|
||||||
|
for (uint8_t i = 0; i < MAX_NUM_SEGMENTS; i++) {
|
||||||
|
_segment_runtimes[i].markForReset();
|
||||||
|
_segment_runtimes[i].resetIfRequired();
|
||||||
|
}
|
||||||
|
|
||||||
_hasWhiteChannel = _isOffRefreshRequired = false;
|
_hasWhiteChannel = _isOffRefreshRequired = false;
|
||||||
|
|
||||||
//if busses failed to load, add default (fresh install, FS issue, ...)
|
//if busses failed to load, add default (fresh install, FS issue, ...)
|
||||||
@ -373,7 +378,7 @@ void WS2812FX::setMode(uint8_t segid, uint8_t m) {
|
|||||||
|
|
||||||
if (_segments[segid].mode != m)
|
if (_segments[segid].mode != m)
|
||||||
{
|
{
|
||||||
_segment_runtimes[segid].reset();
|
_segment_runtimes[segid].markForReset();
|
||||||
_segments[segid].mode = m;
|
_segments[segid].mode = m;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -612,12 +617,12 @@ void WS2812FX::setSegment(uint8_t n, uint16_t i1, uint16_t i2, uint8_t grouping,
|
|||||||
seg.spacing = spacing;
|
seg.spacing = spacing;
|
||||||
}
|
}
|
||||||
if (offset < UINT16_MAX) seg.offset = offset;
|
if (offset < UINT16_MAX) seg.offset = offset;
|
||||||
_segment_runtimes[n].reset();
|
_segment_runtimes[n].markForReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WS2812FX::restartRuntime() {
|
void WS2812FX::restartRuntime() {
|
||||||
for (uint8_t i = 0; i < MAX_NUM_SEGMENTS; i++) {
|
for (uint8_t i = 0; i < MAX_NUM_SEGMENTS; i++) {
|
||||||
_segment_runtimes[i].reset();
|
_segment_runtimes[i].markForReset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -648,9 +653,9 @@ void WS2812FX::resetSegments() {
|
|||||||
_segments[i].cct = 127;
|
_segments[i].cct = 127;
|
||||||
_segments[i].speed = DEFAULT_SPEED;
|
_segments[i].speed = DEFAULT_SPEED;
|
||||||
_segments[i].intensity = DEFAULT_INTENSITY;
|
_segments[i].intensity = DEFAULT_INTENSITY;
|
||||||
_segment_runtimes[i].reset();
|
_segment_runtimes[i].markForReset();
|
||||||
}
|
}
|
||||||
_segment_runtimes[0].reset();
|
_segment_runtimes[0].markForReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WS2812FX::makeAutoSegments() {
|
void WS2812FX::makeAutoSegments() {
|
||||||
|
Loading…
Reference in New Issue
Block a user