Replace uint16_t with unsigned for segment data

swap if statements in color_fade
This commit is contained in:
Blaz Kristan 2024-09-30 16:35:40 +02:00
parent 0ae73296cf
commit ee380c5377
3 changed files with 7 additions and 7 deletions

View File

@ -400,7 +400,7 @@ typedef struct Segment {
uint32_t _stepT; uint32_t _stepT;
uint32_t _callT; uint32_t _callT;
uint8_t *_dataT; uint8_t *_dataT;
uint16_t _dataLenT; unsigned _dataLenT;
TemporarySegmentData() TemporarySegmentData()
: _dataT(nullptr) // just in case... : _dataT(nullptr) // just in case...
, _dataLenT(0) , _dataLenT(0)
@ -418,8 +418,8 @@ typedef struct Segment {
uint8_t _reserved : 4; uint8_t _reserved : 4;
}; };
}; };
uint16_t _dataLen; unsigned _dataLen;
static uint16_t _usedSegmentData; static unsigned _usedSegmentData;
static uint8_t _segBri; // brightness of segment for current effect static uint8_t _segBri; // brightness of segment for current effect
static unsigned _vLength; // 1D dimension used for current effect static unsigned _vLength; // 1D dimension used for current effect
static unsigned _vWidth, _vHeight; // 2D dimensions used for current effect static unsigned _vWidth, _vHeight; // 2D dimensions used for current effect
@ -537,7 +537,7 @@ typedef struct Segment {
inline uint16_t groupLength() const { return grouping + spacing; } inline uint16_t groupLength() const { return grouping + spacing; }
inline uint8_t getLightCapabilities() const { return _capabilities; } inline uint8_t getLightCapabilities() const { return _capabilities; }
inline static uint16_t getUsedSegmentData() { return Segment::_usedSegmentData; } inline static unsigned getUsedSegmentData() { return Segment::_usedSegmentData; }
inline static void addUsedSegmentData(int len) { Segment::_usedSegmentData += len; } inline static void addUsedSegmentData(int len) { Segment::_usedSegmentData += len; }
#ifndef WLED_DISABLE_MODE_BLEND #ifndef WLED_DISABLE_MODE_BLEND
inline static void modeBlend(bool blend) { _modeBlend = blend; } inline static void modeBlend(bool blend) { _modeBlend = blend; }

View File

@ -80,7 +80,7 @@ static constexpr bool validatePinsAndTypes(const unsigned* types, unsigned numTy
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Segment class implementation // Segment class implementation
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
uint16_t Segment::_usedSegmentData = 0U; // amount of RAM all segments use for their data[] unsigned Segment::_usedSegmentData = 0U; // amount of RAM all segments use for their data[]
uint16_t Segment::maxWidth = DEFAULT_LED_COUNT; uint16_t Segment::maxWidth = DEFAULT_LED_COUNT;
uint16_t Segment::maxHeight = 1; uint16_t Segment::maxHeight = 1;
unsigned Segment::_vLength = 0; unsigned Segment::_vLength = 0;
@ -433,7 +433,7 @@ uint8_t Segment::currentMode() const {
return mode; return mode;
} }
uint32_t IRAM_ATTR_YN Segment::currentColor(uint8_t slot) const { uint32_t Segment::currentColor(uint8_t slot) const {
if (slot >= NUM_COLORS) slot = 0; if (slot >= NUM_COLORS) slot = 0;
#ifndef WLED_DISABLE_MODE_BLEND #ifndef WLED_DISABLE_MODE_BLEND
return isInTransition() ? color_blend(_t->_segT._colorT[slot], colors[slot], progress(), true) : colors[slot]; return isInTransition() ? color_blend(_t->_segT._colorT[slot], colors[slot], progress(), true) : colors[slot];

View File

@ -77,8 +77,8 @@ uint32_t color_add(uint32_t c1, uint32_t c2, bool preserveCR)
uint32_t color_fade(uint32_t c1, uint8_t amount, bool video) uint32_t color_fade(uint32_t c1, uint8_t amount, bool video)
{ {
if (c1 == BLACK || amount == 0) return BLACK;
if (amount == 255) return c1; if (amount == 255) return c1;
if (c1 == BLACK || amount == 0) return BLACK;
uint32_t scaledcolor; // color order is: W R G B from MSB to LSB uint32_t scaledcolor; // color order is: W R G B from MSB to LSB
uint32_t scale = amount; // 32bit for faster calculation uint32_t scale = amount; // 32bit for faster calculation
uint32_t addRemains = 0; uint32_t addRemains = 0;