* separate mutexes for improved performance:
- busses.show and effect drawing
- critical changes to segment vector
- block out critical segment changes while strip.service() loops over segments
* UDP realtime acquires mutex before drawing
- prevents corrupted outputs, caused by parallel tasks updating pixels while busses.show() runs
* segment::fill() is also called outside the service loop - make sure that size is always calculated correctly
* leave _currentSeg in a meaningful state after strip.service()
revised mutex and critical section handling for segment drawing
- simplified code with macros (no more #if ESP32 ... #endif)
- remove some critical sections (prevents interrupt stalling)
- added mutex to functions that change the list of segments
- added mutexes to all (potential) background drawing code
- use recursive mutexes to prevent accidental self-locking of tasks
* protect pixel buffer changes with critical section
* protect segment list modification with critical section
* make _isServicing and _triggered atomic (move out of packed bitarray)
* allow custom timeout for waitUntilIdle - DDP needs a longer timeout
* protect strip.show() and effect drawing functions with mutex, to prevent crashes
* introducing WLED_MAX_SEGNAME_LEN from upstream
* default: max name length = 48
* hopefully found all places where the segment name length was hardcoded (32, 33, 34)
* some comments still refer to "32" but wtf
- if a segment is destroyed or turned inactive, disable the gif player: only one gif player instance can run at a time, if a inactive or destroyed segment uses it, the effect is broken for other segments.
- copy FX ironically copied the source segment on each call, should use reference not a copy!
* make sure that filenames can hold 32chars of segment.name
* fix logic error in Segment::drawCharacter
* protect free(Segment::_globalLeds) with a critical section
* increased ArrayAndSize.size from 8bit to 16bit
* prevent out-of-bounds access in JMapC::getPixelColor
* do not delete[] SEGMENT.name from outside of segment class !!
* make sure that fileName is big enough for segmentName".json"
* fix possible buffer overflow in f.readBytesUntil
* stop reading map{ } entries when customMappingSize is reached
* raise "low mem" error when malloc failed
The segment copy constructors can temporarily exceed the budget of MAX_SEGMENT_DATA. The original segment will be de-allocated a few milliseconds later.
This change introduced an "overdraft" budget of 50% that can be used for temporary segment copies.
prevent errors / crashes when drawing "i" images from a preset.
- prevent out-of-bounds writing (segment smaller than image)
- make sure that segment properties are cached correctly
- always do "show" when strip was triggered (avoids lost frames)
* moved sPC and gPC functions out of their .cpp files into FX.h, so the compiler can optimize better.
depending of effect used, this gives a 2% up to 8% speedup.
For maintainers of custom effects: replace "return mode_solid()" with "return mode_oops()"
Effect errors fall back to Akemi (2D) or Rainbow(1D) instead of SOLID ORANGE.
* a few new error constants
* WLED_O2_ATTR - ask the compiler for stronger optimization of a single function
* WLED_O3_ATTR (WLEDMM) optimize even more
* make XY() and _setPixelColorXY_raw() const (minor speedup)
* segment is a struct not a class: friend class Segment --> friend struct Segment
* fix missing braces around two macros
* use non-throwing "new" where possible
* improve robustness of transition code