Skip to content

Commit b48c70c

Browse files
committed
Pedantic integer math changes. Explicit uint16_t cast, fix "color-1". #208
1 parent 0668a6a commit b48c70c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

microcontroller-src/kv4p_ht_esp32_wroom_32/kv4p_ht_esp32_wroom_32.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -903,9 +903,9 @@ void measureLoopFrequency() {
903903
}
904904

905905
void neopixelColor(RGBColor C, uint8_t bright = 255) {
906-
uint8_t red = (C.red * bright) >> 8;
907-
uint8_t green = (C.green * bright) >> 8;
908-
uint8_t blue = (C.blue * bright) >> 8;
906+
uint8_t red = (uint16_t(C.red) * bright) / 255;
907+
uint8_t green = (uint16_t(C.green) * bright) / 255;
908+
uint8_t blue = (uint16_t(C.blue) * bright) / 255;
909909
neopixelWrite(PIXELS_PIN, red, green, blue);
910910
}
911911

0 commit comments

Comments
 (0)