Skip to content

Commit

Permalink
changed transitionprogress to static, private variable
Browse files Browse the repository at this point in the history
this is now more aligned with other variables using the same logic
  • Loading branch information
DedeHai committed Dec 7, 2024
1 parent 7f62152 commit 35d4438
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions wled00/FX.h
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ typedef struct Segment {
};
uint8_t startY; // start Y coodrinate 2D (top); there should be no more than 255 rows
uint8_t stopY; // stop Y coordinate 2D (bottom); there should be no more than 255 rows
uint16_t transitionprogress; // current transition progress 0 - 0xFFFF
// note: two bytes of padding are added here
char *name;

// runtime data
Expand Down Expand Up @@ -419,6 +419,7 @@ typedef struct Segment {
static CRGBPalette16 _newRandomPalette; // target random palette
static uint16_t _lastPaletteChange; // last random palette change time in millis()/1000
static uint16_t _lastPaletteBlend; // blend palette according to set Transition Delay in millis()%0xFFFF
static uint16_t _transitionprogress; // current transition progress 0 - 0xFFFF
#ifndef WLED_DISABLE_MODE_BLEND
static bool _modeBlend; // mode/effect blending semaphore
#endif
Expand Down Expand Up @@ -469,7 +470,6 @@ typedef struct Segment {
check3(false),
startY(0),
stopY(1),
transitionprogress(0xFFFF),
name(nullptr),
next_time(0),
step(0),
Expand Down Expand Up @@ -567,7 +567,7 @@ typedef struct Segment {
void restoreSegenv(tmpsegd_t &tmpSegD); // restores segment data from buffer, if buffer is not transition buffer, changed values are copied to transition buffer
#endif
[[gnu::hot]] void updateTransitionProgress(); // set current progression of transition
inline uint16_t progress() const { return transitionprogress; }; // transition progression between 0-65535
inline uint16_t progress() const { return _transitionprogress; }; // transition progression between 0-65535
[[gnu::hot]] uint8_t currentBri(bool useCct = false) const; // current segment brightness/CCT (blended while in transition)
uint8_t currentMode() const; // currently active effect/mode (while in transition)
[[gnu::hot]] uint32_t currentColor(uint8_t slot) const; // currently active segment color (blended while in transition)
Expand Down
5 changes: 3 additions & 2 deletions wled00/FX_fcn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ CRGBPalette16 Segment::_randomPalette = generateRandomPalette(); // was CRG
CRGBPalette16 Segment::_newRandomPalette = generateRandomPalette(); // was CRGBPalette16(DEFAULT_COLOR);
uint16_t Segment::_lastPaletteChange = 0; // perhaps it should be per segment
uint16_t Segment::_lastPaletteBlend = 0; //in millis (lowest 16 bits only)
uint16_t Segment::_transitionprogress = 0xFFFF;

#ifndef WLED_DISABLE_MODE_BLEND
bool Segment::_modeBlend = false;
Expand Down Expand Up @@ -318,10 +319,10 @@ void Segment::stopTransition() {

// transition progression between 0-65535
void Segment::updateTransitionProgress() {
transitionprogress = 0xFFFFU;
_transitionprogress = 0xFFFFU;
if (isInTransition()) {
unsigned diff = millis() - _t->_start;
if (_t->_dur > 0 && diff < _t->_dur) transitionprogress = diff * 0xFFFFU / _t->_dur;
if (_t->_dur > 0 && diff < _t->_dur) _transitionprogress = diff * 0xFFFFU / _t->_dur;
}
}

Expand Down

0 comments on commit 35d4438

Please sign in to comment.