From 601499b69b800e11511fa41afdbe5aea1560c2f4 Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Thu, 6 Jul 2023 10:02:01 +0200 Subject: [PATCH] XY: minor bugfix properly handle width=0 OR height=0 --- wled00/FX.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wled00/FX.h b/wled00/FX.h index 3d285296..9fcf3bc1 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -628,7 +628,8 @@ typedef struct Segment { inline uint16_t XY(uint_fast16_t x, uint_fast16_t y) { // support function to get relative index within segment (for leds[]) // WLEDMM inline for speed uint_fast16_t width = virtualWidth(); // segment width in logical pixels uint_fast16_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; } void setPixelColorXY(int x, int y, uint32_t c); // set relative pixel within segment with color