diff --git a/src/kaleidoscope/hardware/Atreus.h b/src/kaleidoscope/hardware/Atreus.h index 3fed014f..84de669d 100644 --- a/src/kaleidoscope/hardware/Atreus.h +++ b/src/kaleidoscope/hardware/Atreus.h @@ -48,16 +48,16 @@ class Atreus { static constexpr byte matrix_columns = 11; static constexpr byte matrix_rows = 4; - static constexpr uint8_t led_count = 0; + static constexpr int8_t led_count = 0; void syncLeds(void) {} void setCrgbAt(byte row, byte col, cRGB color) {} - void setCrgbAt(uint8_t i, cRGB crgb) {} - cRGB getCrgbAt(uint8_t i) { + void setCrgbAt(int8_t i, cRGB crgb) {} + cRGB getCrgbAt(int8_t i) { return CRGB(0, 0, 0); } - uint8_t getLedIndex(byte row, byte col) { - return 0; + int8_t getLedIndex(byte row, byte col) { + return -1; } void scanMatrix(void); diff --git a/src/kaleidoscope/hardware/ErgoDox.h b/src/kaleidoscope/hardware/ErgoDox.h index d0cad922..7e757f9c 100644 --- a/src/kaleidoscope/hardware/ErgoDox.h +++ b/src/kaleidoscope/hardware/ErgoDox.h @@ -51,16 +51,16 @@ class ErgoDox { static constexpr byte matrix_columns = 6; static constexpr byte matrix_rows = 14; - static constexpr uint8_t led_count = 0; + static constexpr int8_t led_count = 0; void syncLeds(void) {} void setCrgbAt(byte row, byte col, cRGB color) {} - void setCrgbAt(uint8_t i, cRGB crgb) {} - cRGB getCrgbAt(uint8_t i) { + void setCrgbAt(int8_t i, cRGB crgb) {} + cRGB getCrgbAt(int8_t i) { return CRGB(0, 0, 0); } - uint8_t getLedIndex(byte row, byte col) { - return 0; + int8_t getLedIndex(byte row, byte col) { + return -1; } void scanMatrix(void); diff --git a/src/kaleidoscope/hardware/Model01.cpp b/src/kaleidoscope/hardware/Model01.cpp index dd91ec77..539f6115 100644 --- a/src/kaleidoscope/hardware/Model01.cpp +++ b/src/kaleidoscope/hardware/Model01.cpp @@ -30,7 +30,7 @@ bool Model01::isLEDChanged = true; keydata_t Model01::leftHandMask; keydata_t Model01::rightHandMask; -static constexpr uint8_t key_led_map[4][16] PROGMEM = { +static constexpr int8_t key_led_map[4][16] PROGMEM = { {3, 4, 11, 12, 19, 20, 26, 27, 36, 37, 43, 44, 51, 52, 59, 60}, {2, 5, 10, 13, 18, 21, 25, 28, 35, 38, 42, 45, 50, 53, 58, 61}, {1, 6, 9, 14, 17, 22, 24, 29, 34, 39, 41, 46, 49, 54, 57, 62}, @@ -85,7 +85,7 @@ void Model01::setup(void) { } -void Model01::setCrgbAt(uint8_t i, cRGB crgb) { +void Model01::setCrgbAt(int8_t i, cRGB crgb) { if (i < 32) { cRGB oldColor = getCrgbAt(i); isLEDChanged |= !(oldColor.r == crgb.r && oldColor.g == crgb.g && oldColor.b == crgb.b); @@ -107,11 +107,11 @@ void Model01::setCrgbAt(byte row, byte col, cRGB color) { setCrgbAt(getLedIndex(row, col), color); } -uint8_t Model01::getLedIndex(byte row, byte col) { +int8_t Model01::getLedIndex(byte row, byte col) { return pgm_read_byte(&(key_led_map[row][col])); } -cRGB Model01::getCrgbAt(uint8_t i) { +cRGB Model01::getCrgbAt(int8_t i) { if (i < 32) { return leftHand.ledData.leds[i]; } else if (i < 64) { diff --git a/src/kaleidoscope/hardware/Model01.h b/src/kaleidoscope/hardware/Model01.h index 117bcdcd..a526557d 100644 --- a/src/kaleidoscope/hardware/Model01.h +++ b/src/kaleidoscope/hardware/Model01.h @@ -38,13 +38,13 @@ class Model01 { static constexpr byte matrix_rows = 4; static constexpr byte matrix_columns = 16; - static constexpr uint8_t led_count = 64; + static constexpr int8_t led_count = 64; void syncLeds(void); void setCrgbAt(byte row, byte col, cRGB color); - void setCrgbAt(uint8_t i, cRGB crgb); - cRGB getCrgbAt(uint8_t i); - uint8_t getLedIndex(byte row, byte col); + void setCrgbAt(int8_t i, cRGB crgb); + cRGB getCrgbAt(int8_t i); + int8_t getLedIndex(byte row, byte col); void scanMatrix(void); void readMatrix(void); diff --git a/src/kaleidoscope/plugin/LEDControl.cpp b/src/kaleidoscope/plugin/LEDControl.cpp index 65887e38..54b913ba 100644 --- a/src/kaleidoscope/plugin/LEDControl.cpp +++ b/src/kaleidoscope/plugin/LEDControl.cpp @@ -112,12 +112,12 @@ void LEDControl::set_all_leds_to(uint8_t r, uint8_t g, uint8_t b) { } void LEDControl::set_all_leds_to(cRGB color) { - for (uint8_t i = 0; i < LED_COUNT; i++) { + for (int8_t i = 0; i < LED_COUNT; i++) { setCrgbAt(i, color); } } -void LEDControl::setCrgbAt(uint8_t i, cRGB crgb) { +void LEDControl::setCrgbAt(int8_t i, cRGB crgb) { KeyboardHardware.setCrgbAt(i, crgb); } @@ -125,7 +125,7 @@ void LEDControl::setCrgbAt(byte row, byte col, cRGB color) { KeyboardHardware.setCrgbAt(row, col, color); } -cRGB LEDControl::getCrgbAt(uint8_t i) { +cRGB LEDControl::getCrgbAt(int8_t i) { return KeyboardHardware.getCrgbAt(i); } @@ -255,7 +255,7 @@ EventHandlerResult FocusLEDCommand::onFocusEvent(const char *command) { } case THEME: { if (Serial.peek() == '\n') { - for (uint8_t idx = 0; idx < LED_COUNT; idx++) { + for (int8_t idx = 0; idx < LED_COUNT; idx++) { cRGB c = ::LEDControl.getCrgbAt(idx); ::Focus.printColor(c.r, c.g, c.b); @@ -265,7 +265,7 @@ EventHandlerResult FocusLEDCommand::onFocusEvent(const char *command) { break; } - uint8_t idx = 0; + int8_t idx = 0; while (idx < LED_COUNT && Serial.peek() != '\n') { cRGB color; diff --git a/src/kaleidoscope/plugin/LEDControl.h b/src/kaleidoscope/plugin/LEDControl.h index e2d0d197..4d03461e 100644 --- a/src/kaleidoscope/plugin/LEDControl.h +++ b/src/kaleidoscope/plugin/LEDControl.h @@ -139,9 +139,9 @@ class LEDControl : public kaleidoscope::Plugin { static int8_t mode_add(LEDMode *mode); - static void setCrgbAt(uint8_t i, cRGB crgb); + static void setCrgbAt(int8_t i, cRGB crgb); static void setCrgbAt(byte row, byte col, cRGB color); - static cRGB getCrgbAt(uint8_t i); + static cRGB getCrgbAt(int8_t i); static void syncLeds(void); static void set_all_leds_to(uint8_t r, uint8_t g, uint8_t b); diff --git a/src/kaleidoscope/plugin/LEDEffect-Chase.cpp b/src/kaleidoscope/plugin/LEDEffect-Chase.cpp index 5777ba97..0234a544 100644 --- a/src/kaleidoscope/plugin/LEDEffect-Chase.cpp +++ b/src/kaleidoscope/plugin/LEDEffect-Chase.cpp @@ -30,7 +30,7 @@ void LEDChaseEffect::update(void) { // The red LED is at `pos`; the blue one follows behind. `chase_sign` is either +1 or // -1; `chase_pixels` is the gap between them. - byte pos2 = pos - (chase_sign * chase_pixels); + int8_t pos2 = pos - (chase_sign * chase_pixels); // First, we turn off the LEDs that were turned on in the previous update. `pos` is // always in the valid range (0 <= pos < LED_COUNT), but after it changes direction, for diff --git a/src/kaleidoscope/plugin/LEDEffect-Chase.h b/src/kaleidoscope/plugin/LEDEffect-Chase.h index 6174eae5..9aea1c3d 100644 --- a/src/kaleidoscope/plugin/LEDEffect-Chase.h +++ b/src/kaleidoscope/plugin/LEDEffect-Chase.h @@ -28,7 +28,7 @@ class LEDChaseEffect : public LEDMode { void update(void) final; private: - uint8_t pos = 0; + int8_t pos = 0; int8_t chase_sign = 1; //negative values when it's going backwar uint8_t chase_pixels = 5; uint8_t current_chase_counter = 0; diff --git a/src/kaleidoscope/plugin/LEDEffect-Rainbow.cpp b/src/kaleidoscope/plugin/LEDEffect-Rainbow.cpp index 1311842b..2b8b5b3e 100644 --- a/src/kaleidoscope/plugin/LEDEffect-Rainbow.cpp +++ b/src/kaleidoscope/plugin/LEDEffect-Rainbow.cpp @@ -61,7 +61,7 @@ void LEDRainbowWaveEffect::update(void) { rainbow_last_update = now; } - for (uint8_t i = 0; i < LED_COUNT; i++) { + for (int8_t i = 0; i < LED_COUNT; i++) { uint16_t key_hue = rainbow_hue + 16 * (i / 4); if (key_hue >= 255) { key_hue -= 255;