Const functions.
This commit is contained in:
parent
67a51be9ee
commit
fa55896722
30
wled00/FX.h
30
wled00/FX.h
@ -491,18 +491,18 @@ typedef struct Segment {
|
||||
Segment& operator= (Segment &&orig) noexcept; // move assignment
|
||||
|
||||
#ifdef WLED_DEBUG
|
||||
size_t getSize() { return sizeof(Segment) + (data?_dataLen:0) + (name?strlen(name):0) + (_t?sizeof(Transition):0) + (!Segment::_globalLeds && leds?sizeof(CRGB)*length():0); }
|
||||
size_t getSize() const { return sizeof(Segment) + (data?_dataLen:0) + (name?strlen(name):0) + (_t?sizeof(Transition):0) + (!Segment::_globalLeds && leds?sizeof(CRGB)*length():0); }
|
||||
#endif
|
||||
|
||||
inline bool getOption(uint8_t n) { return ((options >> n) & 0x01); }
|
||||
inline bool isSelected(void) { return selected; }
|
||||
inline bool isActive(void) { return stop > start; }
|
||||
inline bool is2D(void) { return !(startY == 0 && stopY == 1); }
|
||||
inline uint16_t width(void) { return stop - start; } // segment width in physical pixels (length if 1D)
|
||||
inline uint16_t height(void) { return stopY - startY; } // segment height (if 2D) in physical pixels
|
||||
inline uint16_t length(void) { return width() * height(); } // segment length (count) in physical pixels
|
||||
inline uint16_t groupLength(void) { return grouping + spacing; }
|
||||
inline uint8_t getLightCapabilities(void) { return _capabilities; }
|
||||
inline bool getOption(uint8_t n) const { return ((options >> n) & 0x01); }
|
||||
inline bool isSelected(void) const { return selected; }
|
||||
inline bool isActive(void) const { return stop > start; }
|
||||
inline bool is2D(void) const { return !(startY == 0 && stopY == 1); }
|
||||
inline uint16_t width(void) const { return stop - start; } // segment width in physical pixels (length if 1D)
|
||||
inline uint16_t height(void) const { return stopY - startY; } // segment height (if 2D) in physical pixels
|
||||
inline uint16_t length(void) const { return width() * height(); } // segment length (count) in physical pixels
|
||||
inline uint16_t groupLength(void) const { return grouping + spacing; }
|
||||
inline uint8_t getLightCapabilities(void) const { return _capabilities; }
|
||||
|
||||
static uint16_t getUsedSegmentData(void) { return _usedSegmentData; }
|
||||
static void addUsedSegmentData(int len) { _usedSegmentData += len; }
|
||||
@ -511,11 +511,11 @@ typedef struct Segment {
|
||||
void setCCT(uint16_t k);
|
||||
void setOpacity(uint8_t o);
|
||||
void setOption(uint8_t n, bool val);
|
||||
uint8_t differs(Segment& b);
|
||||
uint8_t differs(Segment& b) const;
|
||||
void refreshLightCapabilities(void);
|
||||
|
||||
// runtime data functions
|
||||
inline uint16_t dataSize(void) { return _dataLen; }
|
||||
inline uint16_t dataSize(void) const { return _dataLen; }
|
||||
bool allocateData(size_t len);
|
||||
void deallocateData(void);
|
||||
void resetIfRequired(void);
|
||||
@ -540,7 +540,7 @@ typedef struct Segment {
|
||||
CRGBPalette16 ¤tPalette(CRGBPalette16 &tgt, uint8_t paletteID);
|
||||
|
||||
// 1D strip
|
||||
uint16_t virtualLength(void);
|
||||
uint16_t virtualLength(void) const;
|
||||
void setPixelColor(int n, uint32_t c); // set relative pixel within segment with color
|
||||
void setPixelColor(int n, byte r, byte g, byte b, byte w = 0) { setPixelColor(n, RGBW32(r,g,b,w)); } // automatically inline
|
||||
void setPixelColor(int n, CRGB c) { setPixelColor(n, RGBW32(c.r,c.g,c.b,0)); } // automatically inline
|
||||
@ -564,8 +564,8 @@ typedef struct Segment {
|
||||
uint32_t color_wheel(uint8_t pos);
|
||||
|
||||
// 2D matrix
|
||||
uint16_t virtualWidth(void);
|
||||
uint16_t virtualHeight(void);
|
||||
uint16_t virtualWidth(void) const;
|
||||
uint16_t virtualHeight(void) const;
|
||||
#ifndef WLED_DISABLE_2D
|
||||
uint16_t XY(uint16_t x, uint16_t y); // support function to get relative index within segment (for leds[])
|
||||
void setPixelColorXY(int x, int y, uint32_t c); // set relative pixel within segment with color
|
||||
|
@ -386,14 +386,14 @@ void Segment::setOption(uint8_t n, bool val) {
|
||||
}
|
||||
|
||||
// 2D matrix
|
||||
uint16_t Segment::virtualWidth() {
|
||||
uint16_t Segment::virtualWidth() const {
|
||||
uint16_t groupLen = groupLength();
|
||||
uint16_t vWidth = ((transpose ? height() : width()) + groupLen - 1) / groupLen;
|
||||
if (mirror) vWidth = (vWidth + 1) /2; // divide by 2 if mirror, leave at least a single LED
|
||||
return vWidth;
|
||||
}
|
||||
|
||||
uint16_t Segment::virtualHeight() {
|
||||
uint16_t Segment::virtualHeight() const {
|
||||
uint16_t groupLen = groupLength();
|
||||
uint16_t vHeight = ((transpose ? width() : height()) + groupLen - 1) / groupLen;
|
||||
if (mirror_y) vHeight = (vHeight + 1) /2; // divide by 2 if mirror, leave at least a single LED
|
||||
@ -401,7 +401,7 @@ uint16_t Segment::virtualHeight() {
|
||||
}
|
||||
|
||||
// 1D strip
|
||||
uint16_t Segment::virtualLength() {
|
||||
uint16_t Segment::virtualLength() const {
|
||||
#ifndef WLED_DISABLE_2D
|
||||
if (is2D()) {
|
||||
uint16_t vW = virtualWidth();
|
||||
@ -561,7 +561,7 @@ uint32_t Segment::getPixelColor(uint16_t i)
|
||||
return strip.getPixelColor(i);
|
||||
}
|
||||
|
||||
uint8_t Segment::differs(Segment& b) {
|
||||
uint8_t Segment::differs(Segment& b) const {
|
||||
uint8_t d = 0;
|
||||
if (start != b.start) d |= SEG_DIFFERS_BOUNDS;
|
||||
if (stop != b.stop) d |= SEG_DIFFERS_BOUNDS;
|
||||
@ -1394,7 +1394,7 @@ void WS2812FX::setTransitionMode(bool t)
|
||||
void WS2812FX::printSize()
|
||||
{
|
||||
size_t size = 0;
|
||||
for (Segment seg : _segments) size += seg.getSize();
|
||||
for (const Segment seg : _segments) size += seg.getSize();
|
||||
DEBUG_PRINTF("Segments: %d -> %uB\n", _segments.size(), size);
|
||||
DEBUG_PRINTF("Modes: %d*%d=%uB\n", sizeof(mode_ptr), _mode.size(), (_mode.capacity()*sizeof(mode_ptr)));
|
||||
DEBUG_PRINTF("Data: %d*%d=%uB\n", sizeof(const char *), _modeData.size(), (_modeData.capacity()*sizeof(const char *)));
|
||||
|
@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
// version code in format yymmddb (b = daily build)
|
||||
#define VERSION 2208171
|
||||
#define VERSION 2208172
|
||||
|
||||
//uncomment this if you have a "my_config.h" file you'd like to use
|
||||
//#define WLED_USE_MY_CONFIG
|
||||
|
Loading…
Reference in New Issue
Block a user