XY: minor bugfix
properly handle width=0 OR height=0
This commit is contained in:
parent
fa281a0df0
commit
196779ffb6
@ -191,7 +191,8 @@ uint32_t WS2812FX::getPixelColorXY(uint16_t x, uint16_t y) {
|
|||||||
uint16_t /*IRAM_ATTR*/ Segment::XY(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 width = virtualWidth(); // segment width in logical pixels
|
||||||
uint16_t height = virtualHeight(); // segment height in logical pixels
|
uint16_t height = virtualHeight(); // segment height in logical pixels
|
||||||
if ((width == 0) || (height == 0)) return 0; // softhack007 avoid div/0
|
if (width == 0) return 0; // softhack007 avoid div/0
|
||||||
|
if (height == 0) return (x%width); // softhack007 avoid div/0
|
||||||
return (x%width) + (y%height) * width;
|
return (x%width) + (y%height) * width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user