1+ #pragma once
12/*
23 WS2812FX.h - Library for WS2812 LED effects.
34 Harm Aldick - 2016
89 Adapted from code originally licensed under the MIT license
910
1011 Modified for WLED
12+
13+ Segment class/struct (c) 2022 Blaz Kristan (@blazoncek)
1114*/
1215
1316#ifndef WS2812FX_h
1417#define WS2812FX_h
1518
1619#include < vector>
20+ #include " wled.h"
1721
1822#include " const.h"
1923#include " bus_manager.h"
@@ -71,18 +75,15 @@ extern byte realtimeMode; // used in getMappedPixelIndex()
7175/* each segment uses 82 bytes of SRAM memory, so if you're application fails because of
7276 insufficient memory, decreasing MAX_NUM_SEGMENTS may help */
7377#ifdef ESP8266
74- #define MAX_NUM_SEGMENTS 16
78+ #define MAX_NUM_SEGMENTS 16
7579 /* How much data bytes all segments combined may allocate */
7680 #define MAX_SEGMENT_DATA 5120
81+ #elif defined(CONFIG_IDF_TARGET_ESP32S2)
82+ #define MAX_NUM_SEGMENTS 20
83+ #define MAX_SEGMENT_DATA (MAX_NUM_SEGMENTS*512 ) // 10k by default (S2 is short on free RAM)
7784#else
78- #ifndef MAX_NUM_SEGMENTS
79- #define MAX_NUM_SEGMENTS 32
80- #endif
81- #if defined(ARDUINO_ARCH_ESP32S2)
82- #define MAX_SEGMENT_DATA (MAX_NUM_SEGMENTS*768 ) // 24k by default (S2 is short on free RAM)
83- #else
84- #define MAX_SEGMENT_DATA (MAX_NUM_SEGMENTS*1280 ) // 40k by default
85- #endif
85+ #define MAX_NUM_SEGMENTS 32 // warning: going beyond 32 may consume too much RAM for stable operation
86+ #define MAX_SEGMENT_DATA (MAX_NUM_SEGMENTS*1280 ) // 40k by default
8687#endif
8788
8889/* How much data bytes each segment should max allocate to leave enough space for other segments,
@@ -543,6 +544,8 @@ typedef struct Segment {
543544 inline uint16_t groupLength () const { return grouping + spacing; }
544545 inline uint8_t getLightCapabilities () const { return _capabilities; }
545546 inline void deactivate () { setGeometry (0 ,0 ); }
547+ inline Segment &clearName () { if (name) free (name); name = nullptr ; return *this ; }
548+ inline Segment &setName (const String &name) { return setName (name.c_str ()); }
546549
547550 inline static unsigned getUsedSegmentData () { return Segment::_usedSegmentData; }
548551 inline static void addUsedSegmentData (int len) { Segment::_usedSegmentData += len; }
@@ -565,6 +568,7 @@ typedef struct Segment {
565568 Segment &setOption (uint8_t n, bool val);
566569 Segment &setMode (uint8_t fx, bool loadDefaults = false );
567570 Segment &setPalette (uint8_t pal);
571+ Segment &setName (const char * name);
568572 uint8_t differs (const Segment& b) const ;
569573 void refreshLightCapabilities ();
570574
@@ -736,7 +740,6 @@ class WS2812FX { // 96 bytes
736740 WS2812FX () :
737741 paletteFade (0 ),
738742 paletteBlend (0 ),
739- cctBlending (0 ),
740743 now (millis()),
741744 timebase (0 ),
742745 isMatrix (false ),
@@ -839,7 +842,6 @@ class WS2812FX { // 96 bytes
839842
840843 uint8_t
841844 paletteBlend,
842- cctBlending,
843845 getActiveSegmentsNum () const ,
844846 getFirstSelectedSegId () const ,
845847 getLastActiveSegmentId () const ,
0 commit comments