inactive segments robustness improvement
* Avoid uint16 underflow in width() and height(): stop > start is possible, and means "inactive segment". Without these checks, it was possible that width() and height() produce VERY large values due to underflow.
This commit is contained in:
@@ -191,6 +191,7 @@ uint32_t WS2812FX::getPixelColorXY(uint16_t x, uint16_t y) {
|
||||
uint16_t /*IRAM_ATTR*/ Segment::XY(uint16_t x, uint16_t y) {
|
||||
uint16_t width = virtualWidth(); // segment width in logical pixels
|
||||
uint16_t height = virtualHeight(); // segment height in logical pixels
|
||||
if ((width == 0) || (height == 0)) return 0; // softhack007 avoid div/0
|
||||
return (x%width) + (y%height) * width;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user