3333
3434bool canUseSerial (void ); // WLEDMM implemented in wled_serial.cpp
3535void strip_wait_until_idle (String whoCalledMe); // WLEDMM implemented in FX_fcn.cpp
36- bool strip_uses_global_leds (void ); // WLEDMM implemented in FX_fcn.cpp
36+ bool strip_uses_global_leds (void ) __attribute__((pure)); // WLEDMM implemented in FX_fcn.cpp
3737
3838#define FASTLED_INTERNAL // remove annoying pragma messages
3939#define USE_GET_MILLISECOND_TIMER
@@ -640,7 +640,7 @@ typedef struct Segment {
640640 void setPixelColor (float i, uint32_t c, bool aa = true );
641641 inline void setPixelColor (float i, uint8_t r, uint8_t g, uint8_t b, uint8_t w = 0 , bool aa = true ) { setPixelColor (i, RGBW32 (r,g,b,w), aa); }
642642 inline void setPixelColor (float i, CRGB c, bool aa = true ) { setPixelColor (i, RGBW32 (c.r ,c.g ,c.b ,0 ), aa); }
643- uint32_t __attribute__ ((pure)) getPixelColor(int i); // WLEDMM attribute added
643+ uint32_t __attribute__ ((pure)) getPixelColor(int i) const ; // WLEDMM attribute added
644644 // 1D support functions (some implement 2D as well)
645645 void blur (uint8_t , bool smear = false );
646646 void fill (uint32_t c);
@@ -652,7 +652,7 @@ typedef struct Segment {
652652 inline void addPixelColor (int n, byte r, byte g, byte b, byte w = 0 , bool fast = false ) { addPixelColor (n, RGBW32 (r,g,b,w), fast); } // automatically inline
653653 inline void addPixelColor (int n, CRGB c, bool fast = false ) { addPixelColor (n, RGBW32 (c.r ,c.g ,c.b ,0 ), fast); } // automatically inline
654654 void fadePixelColor (uint16_t n, uint8_t fade);
655- uint8_t get_random_wheel_index (uint8_t pos);
655+ uint8_t get_random_wheel_index (uint8_t pos) const ;
656656 uint32_t __attribute__ ((pure)) color_from_palette(uint_fast16_t , bool mapping, bool wrap, uint8_t mcol, uint8_t pbri = 255 );
657657 uint32_t __attribute__ ((pure)) color_wheel(uint8_t pos);
658658
@@ -693,7 +693,7 @@ typedef struct Segment {
693693 void deletejMap (); // WLEDMM jMap
694694
695695 #ifndef WLED_DISABLE_2D
696- inline uint16_t XY (uint_fast16_t x, uint_fast16_t y) { // support function to get relative index within segment (for leds[]) // WLEDMM inline for speed
696+ inline uint16_t XY (uint_fast16_t x, uint_fast16_t y) const { // support function to get relative index within segment (for leds[]) // WLEDMM inline for speed
697697 uint_fast16_t width = max (uint16_t (1 ), virtualWidth ()); // segment width in logical pixels -- softhack007 avoid div/0
698698 uint_fast16_t height = max (uint16_t (1 ), virtualHeight ()); // segment height in logical pixels -- softhack007 avoid div/0
699699 return (x%width) + (y%height) * width;
@@ -726,7 +726,7 @@ typedef struct Segment {
726726 inline void setPixelColorXY (float x, float y, byte r, byte g, byte b, byte w = 0 , bool aa = true ) { setPixelColorXY (x, y, RGBW32 (r,g,b,w), aa); }
727727 inline void setPixelColorXY (float x, float y, CRGB c, bool aa = true ) { setPixelColorXY (x, y, RGBW32 (c.r ,c.g ,c.b ,0 ), aa); }
728728 // #endif
729- uint32_t __attribute__ ((pure)) getPixelColorXY(int x, int y);
729+ uint32_t __attribute__ ((pure)) getPixelColorXY(int x, int y) const ;
730730 // 2D support functions
731731 void blendPixelColorXY (uint16_t x, uint16_t y, uint32_t color, uint8_t blend);
732732 inline void blendPixelColorXY (uint16_t x, uint16_t y, CRGB c, uint8_t blend) { blendPixelColorXY (x, y, RGBW32 (c.r ,c.g ,c.b ,0 ), blend); }
@@ -792,7 +792,7 @@ typedef struct Segment {
792792 inline void drawCharacter (unsigned char chr, int16_t x, int16_t y, uint8_t w, uint8_t h, CRGB c, CRGB c2, int8_t rotate = 0 ) {}
793793 inline void wu_pixel (uint32_t x, uint32_t y, CRGB c) {}
794794 #endif
795- uint8_t * getAudioPalette (int pal); // WLEDMM netmindz ar palette
795+ uint8_t * getAudioPalette (int pal) const ; // WLEDMM netmindz ar palette
796796} segment;
797797// static int segSize = sizeof(Segment);
798798
@@ -915,64 +915,64 @@ class WS2812FX { // 96 bytes
915915
916916 bool
917917 checkSegmentAlignment (void ),
918- hasRGBWBus (void ),
919- hasCCTBus (void ),
918+ hasRGBWBus (void ) const ,
919+ hasCCTBus (void ) const ,
920920 // return true if the strip is being sent pixel updates
921- isUpdating (void ),
921+ isUpdating (void ) const ,
922922 deserializeMap (uint8_t n=0 ),
923923 useLedsArray = false ;
924924
925- inline bool isServicing (void ) { return _isServicing; }
926- inline bool hasWhiteChannel (void ) {return _hasWhiteChannel;}
927- inline bool isOffRefreshRequired (void ) {return _isOffRefreshRequired;}
925+ inline bool isServicing (void ) const { return _isServicing; }
926+ inline bool hasWhiteChannel (void ) const {return _hasWhiteChannel;}
927+ inline bool isOffRefreshRequired (void ) const {return _isOffRefreshRequired;}
928928
929929 uint8_t
930930 paletteFade,
931931 paletteBlend,
932932 milliampsPerLed,
933933 cctBlending,
934- getActiveSegmentsNum (void ),
935- getFirstSelectedSegId (void ),
936- getLastActiveSegmentId (void ),
937- getActiveSegsLightCapabilities (bool selectedOnly = false ),
934+ getActiveSegmentsNum (void ) const ,
935+ getFirstSelectedSegId (void ) __attribute__((pure)) ,
936+ getLastActiveSegmentId (void ) const ,
937+ getActiveSegsLightCapabilities (bool selectedOnly = false ) __attribute__((pure)) ,
938938 setPixelSegment (uint8_t n);
939939
940- inline uint8_t getBrightness (void ) { return _brightness; }
941- inline uint8_t getMaxSegments (void ) { return MAX_NUM_SEGMENTS; } // returns maximum number of supported segments (fixed value)
942- inline uint8_t getSegmentsNum (void ) { return _segments.size (); } // returns currently present segments
943- inline uint8_t getCurrSegmentId (void ) { return _segment_index; }
944- inline uint8_t getMainSegmentId (void ) { return _mainSegment; }
945- inline uint8_t getPaletteCount () { return 13 + GRADIENT_PALETTE_COUNT; } // will only return built-in palette count
946- inline uint8_t getTargetFps () { return _targetFps; }
947- inline uint8_t getModeCount () { return _modeCount; }
940+ inline uint8_t getBrightness (void ) const { return _brightness; }
941+ inline uint8_t getMaxSegments (void ) const { return MAX_NUM_SEGMENTS; } // returns maximum number of supported segments (fixed value)
942+ inline uint8_t getSegmentsNum (void ) const { return _segments.size (); } // returns currently present segments
943+ inline uint8_t getCurrSegmentId (void ) const { return _segment_index; }
944+ inline uint8_t getMainSegmentId (void ) const { return _mainSegment; }
945+ inline uint8_t getPaletteCount () const { return 13 + GRADIENT_PALETTE_COUNT; } // will only return built-in palette count
946+ inline uint8_t getTargetFps () const { return _targetFps; }
947+ inline uint8_t getModeCount () const { return _modeCount; }
948948
949949 uint16_t
950950 ablMilliampsMax,
951951 currentMilliamps,
952- getLengthPhysical (void ),
953- __attribute__ ((pure)) getLengthTotal(void ), // will include virtual/nonexistent pixels in matrix //WLEDMM attribute added
954- getFps ();
952+ getLengthPhysical (void ) const ,
953+ __attribute__ ((pure)) getLengthTotal(void ) const , // will include virtual/nonexistent pixels in matrix //WLEDMM attribute added
954+ getFps () const ;
955955
956- inline uint16_t getFrameTime (void ) { return _frametime; }
957- inline uint16_t getMinShowDelay (void ) { return MIN_SHOW_DELAY; }
958- inline uint16_t getLength (void ) { return _length; } // 2D matrix may have less pixels than W*H
959- inline uint16_t getTransition (void ) { return _transitionDur; }
956+ inline uint16_t getFrameTime (void ) const { return _frametime; }
957+ inline uint16_t getMinShowDelay (void ) const { return MIN_SHOW_DELAY; }
958+ inline uint16_t getLength (void ) const { return _length; } // 2D matrix may have less pixels than W*H
959+ inline uint16_t getTransition (void ) const { return _transitionDur; }
960960
961961 uint32_t
962962 now,
963963 timebase;
964- uint32_t __attribute__ ((pure)) getPixelColor(uint_fast16_t ); // WLEDMM attribute pure = does not have side-effects
964+ uint32_t __attribute__ ((pure)) getPixelColor(uint_fast16_t ) const ; // WLEDMM attribute pure = does not have side-effects
965965
966- inline uint32_t getLastShow (void ) { return _lastShow; }
967- inline uint32_t segColor (uint8_t i) { return _colors_t [i]; }
966+ inline uint32_t getLastShow (void ) const { return _lastShow; }
967+ inline uint32_t segColor (uint8_t i) const { return _colors_t [i]; }
968968
969969 const char *
970- getModeData (uint8_t id = 0 ) { return (id && id<_modeCount) ? _modeData[id] : PSTR (" Solid" ); }
970+ getModeData (uint8_t id = 0 ) const { return (id && id<_modeCount) ? _modeData[id] : PSTR (" Solid" ); }
971971
972972 const char **
973973 getModeDataSrc (void ) { return &(_modeData[0 ]); } // vectors use arrays for underlying data
974974
975- Segment& getSegment (uint8_t id);
975+ Segment& getSegment (uint8_t id) __attribute__((pure)) ;
976976 inline Segment& getFirstSelectedSeg (void ) { return _segments[getFirstSelectedSegId ()]; }
977977 inline Segment& getMainSegment (void ) { return _segments[getMainSegmentId ()]; }
978978 inline Segment* getSegments (void ) { return &(_segments[0 ]); }
@@ -1039,7 +1039,7 @@ class WS2812FX { // 96 bytes
10391039 inline void setPixelColorXY (int x, int y, CRGB c) { setPixelColorXY (x, y, RGBW32 (c.r ,c.g ,c.b ,0 )); }
10401040
10411041 uint32_t
1042- getPixelColorXY (uint16_t , uint16_t );
1042+ getPixelColorXY (uint16_t , uint16_t ) const ;
10431043
10441044 // end 2D support
10451045
0 commit comments