Skip to content

Commit

Permalink
minor corrections
Browse files Browse the repository at this point in the history
* fix some override problems bus_manager (canShow() must not be const!!!)
* fixing some "comparing integer with different signedness" warnings
  • Loading branch information
softhack007 committed Sep 21, 2024
1 parent 569ba1c commit 80a2f2b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
6 changes: 3 additions & 3 deletions wled00/FX_2Dfcn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,9 @@ void IRAM_ATTR_YN Segment::setPixelColorXY(int x, int y, uint32_t col) //WLEDMM:
return;
}

const int_fast16_t glen_ = groupLength(); // WLEDMM optimization
const int_fast16_t wid_ = width();
const int_fast16_t hei_ = height();
const uint_fast16_t glen_ = groupLength(); // WLEDMM optimization
const uint_fast16_t wid_ = width();
const uint_fast16_t hei_ = height();

x *= glen_; // expand to physical pixels
y *= glen_; // expand to physical pixels
Expand Down
18 changes: 9 additions & 9 deletions wled00/FX_fcn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1413,12 +1413,12 @@ void __attribute__((hot)) Segment::fill(uint32_t c) {
if (_bri_t < 255) scaled_col = color_fade(c, _bri_t);
}
// fill 2D segment
for(int y = 0; y < rows; y++) for (int x = 0; x < cols; x++) {
for(unsigned y = 0; y < rows; y++) for (unsigned x = 0; x < cols; x++) {
if (simpleSegment) setPixelColorXY_fast(x, y, c, scaled_col, cols, rows);
else setPixelColorXY_slow(x, y, c);
}
} else { // fill 1D strip
for (int x = 0; x < cols; x++) setPixelColor(x, c);
for (unsigned x = 0; x < cols; x++) setPixelColor(int(x), c);
}
}

Expand Down Expand Up @@ -1471,8 +1471,8 @@ void __attribute__((hot)) Segment::fade_out(uint8_t rate) {
int g2 = G(color2);
int b2 = B(color2);

for (int y = 0; y < rows; y++) for (int x = 0; x < cols; x++) {
uint32_t color = is2D() ? getPixelColorXY(x, y) : getPixelColor(x);
for (unsigned y = 0; y < rows; y++) for (unsigned x = 0; x < cols; x++) {
uint32_t color = is2D() ? getPixelColorXY(int(x), int(y)) : getPixelColor(int(x));
if (color == color2) continue; // WLEDMM speedup - pixel color = target color, so nothing to do
int w1 = W(color);
int r1 = R(color);
Expand All @@ -1492,8 +1492,8 @@ void __attribute__((hot)) Segment::fade_out(uint8_t rate) {
uint32_t colorNew = RGBW32(r1 + rdelta, g1 + gdelta, b1 + bdelta, w1 + wdelta); // WLEDMM

if (colorNew != color) { // WLEDMM speedup - do not repaint the same color
if (is2D()) setPixelColorXY(x, y, colorNew);
else setPixelColor(x, colorNew);
if (is2D()) setPixelColorXY(int(x), int(y), colorNew);
else setPixelColor(int(x), colorNew);
}
}
}
Expand All @@ -1507,11 +1507,11 @@ void __attribute__((hot)) Segment::fadeToBlackBy(uint8_t fadeBy) {

// WLEDMM minor optimization
if(is2D()) {
for (int y = 0; y < rows; y++) for (int x = 0; x < cols; x++) {
uint32_t cc = getPixelColorXY(x,y); // WLEDMM avoid RGBW32 -> CRGB -> RGBW32 conversion
for (unsigned y = 0; y < rows; y++) for (unsigned x = 0; x < cols; x++) {
uint32_t cc = getPixelColorXY(int(x),int(y)); // WLEDMM avoid RGBW32 -> CRGB -> RGBW32 conversion
uint32_t cc2 = color_fade(cc, scaledown); // fade
//if (cc2 != cc) // WLEDMM only re-paint if faded color is different - disabled - causes problem with text overlay
setPixelColorXY((uint16_t)x, (uint16_t)y, cc2);
setPixelColorXY(int(x), int(y), cc2);
}
} else {
for (uint_fast16_t x = 0; x < cols; x++) {
Expand Down
28 changes: 14 additions & 14 deletions wled00/bus_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ struct BusConfig {
else if (type > 47) nPins = 2;
else if (type > 40 && type < 46) nPins = NUM_PWM_PINS(type);
else if (type >= TYPE_HUB75MATRIX && type <= (TYPE_HUB75MATRIX + 10)) nPins = 0;
for (uint8_t i = 0; i < nPins; i++) pins[i] = ppins[i];
for (uint8_t i = 0; i < min(unsigned(nPins),5U); i++) pins[i] = ppins[i]; //softhack007 fix for potential array out-of-bounds access
}

//validates start and length and extends total if needed
Expand Down Expand Up @@ -135,21 +135,21 @@ class Bus {
virtual void setStatusPixel(uint32_t c) {}
virtual void setPixelColor(uint16_t pix, uint32_t c) = 0;
virtual uint32_t getPixelColor(uint16_t pix) const { return 0; }
virtual void setBrightness(uint8_t b, bool immediate=false) { _bri = b; };
virtual void setBrightness(uint8_t b, bool immediate=false) { _bri = b; }
virtual void cleanup() = 0;
virtual uint8_t getPins(uint8_t* pinArray) const { return 0; }
virtual uint16_t getLength() const { return _len; }
virtual inline uint16_t getLength() const { return _len; }
virtual void setColorOrder() {}
virtual uint8_t getColorOrder() const { return COL_ORDER_RGB; }
virtual uint8_t skippedLeds() { return 0; }
virtual uint8_t skippedLeds() const { return 0; }
virtual uint16_t getFrequency() const { return 0U; }
inline uint16_t getStart() const { return _start; }
inline void setStart(uint16_t start) { _start = start; }
inline uint8_t getType() const { return _type; }
inline bool isOk() const { return _valid; }
inline bool isOffRefreshRequired() const { return _needsRefresh; }
bool containsPixel(uint16_t pix) const { return pix >= _start && pix < _start+_len; }
virtual uint16_t getMaxPixels() const { return MAX_LEDS_PER_BUS; };
//inline bool containsPixel(uint16_t pix) const { return pix >= _start && pix < _start+_len; } // WLEDMM not used, plus wrong - it does not consider skipped pixels
virtual uint16_t getMaxPixels() const { return MAX_LEDS_PER_BUS; }

virtual bool hasRGB() const {
if ((_type >= TYPE_WS2812_1CH && _type <= TYPE_WS2812_WWA) || _type == TYPE_ANALOG_1CH || _type == TYPE_ANALOG_2CH || _type == TYPE_ONOFF) return false;
Expand Down Expand Up @@ -207,33 +207,33 @@ class BusDigital : public Bus {

inline void show();

bool canShow() const;
bool canShow() override;

void setBrightness(uint8_t b, bool immediate);

void setStatusPixel(uint32_t c);

void setPixelColor(uint16_t pix, uint32_t c);

uint32_t getPixelColor(uint16_t pix) const;
uint32_t getPixelColor(uint16_t pix) const override;

uint8_t getColorOrder() const {
return _colorOrder;
}

uint16_t getLength() const {
uint16_t getLength() const override {
return _len - _skip;
}

uint8_t getPins(uint8_t* pinArray) const;

void setColorOrder(uint8_t colorOrder);

uint8_t skippedLeds() const {
uint8_t skippedLeds() const override {
return _skip;
}

uint16_t getFrequency() const { return _frequencykHz; }
uint16_t getFrequency() const override { return _frequencykHz; }

void reinit();

Expand Down Expand Up @@ -267,7 +267,7 @@ class BusPwm : public Bus {

uint8_t getPins(uint8_t* pinArray) const;

uint16_t getFrequency() const { return _frequency; }
uint16_t getFrequency() const override { return _frequency; }

void cleanup() {
deallocatePins();
Expand Down Expand Up @@ -329,14 +329,14 @@ class BusNetwork : public Bus {

void show();

bool canShow() const {
bool canShow() override {
// this should be a return value from UDP routine if it is still sending data out
return !_broadcastLock;
}

uint8_t getPins(uint8_t* pinArray) const;

uint16_t getLength() const {
uint16_t getLength() const override {
return _len;
}

Expand Down

0 comments on commit 80a2f2b

Please sign in to comment.