diff --git a/include/led.h b/include/led.h index de4d2227..9fb7bc91 100644 --- a/include/led.h +++ b/include/led.h @@ -3,6 +3,11 @@ #ifdef HAS_RGB_LED #include + +#ifndef RGB_LED_COUNT +#define RGB_LED_COUNT 1 +#endif + #endif // value for HSL color diff --git a/src/hal/eboxtube.h b/src/hal/eboxtube.h index 86a69d7d..e95b6940 100644 --- a/src/hal/eboxtube.h +++ b/src/hal/eboxtube.h @@ -14,7 +14,8 @@ #define CFG_sx1276_radio 1 #define HAS_LED (22) // Green LED on board -#define HAS_RGB_LED SmartLed rgb_led(LED_WS2812, 1, GPIO_NUM_2) // WS2812B RGB LED on board +#define RGB_LED_COUNT 1 // we have 1 LED +#define HAS_RGB_LED SmartLed rgb_led(LED_WS2812, RGB_LED_COUNT, GPIO_NUM_2) // WS2812B RGB LED on board #define HAS_BUTTON (0) // button "FLASH" on board #define DISABLE_BROWNOUT 1 // comment out if you want to keep brownout feature diff --git a/src/hal/lopy4.h b/src/hal/lopy4.h index e0736229..4e625dfa 100644 --- a/src/hal/lopy4.h +++ b/src/hal/lopy4.h @@ -21,7 +21,8 @@ #define CFG_sx1276_radio 1 #define HAS_LED NOT_A_PIN // LoPy4 has no on board mono LED, we use on board RGB LED -#define HAS_RGB_LED SmartLed rgb_led(LED_WS2812, 1, GPIO_NUM_0) // WS2812B RGB LED on GPIO0 (P2) +#define RGB_LED_COUNT 1 // we have 1 LEDs +#define HAS_RGB_LED SmartLed rgb_led(LED_WS2812, RGB_LED_COUNT, GPIO_NUM_0) // WS2812B RGB LED on GPIO0 (P2) #define BOARD_HAS_PSRAM // use extra 4MB extern RAM // Note: Pins for LORA chip SPI interface come from board file pins_arduino.h diff --git a/src/hal/m5fire.h b/src/hal/m5fire.h index e02ede3a..5cb1b146 100644 --- a/src/hal/m5fire.h +++ b/src/hal/m5fire.h @@ -38,8 +38,9 @@ //#define BAT_MEASURE_ADC ADC1_GPIO35_CHANNEL // battery probe GPIO pin -> ADC1_CHANNEL_7 //#define BAT_VOLTAGE_DIVIDER 2 // voltage divider 100k/100k on board -#define HAS_LED NOT_A_PIN // no on board LED (?) -#define HAS_RGB_LED SmartLed rgb_led(LED_SK6812, 10, GPIO_NUM_15) // LED_SK6812 RGB LED on GPIO15 +#define HAS_LED NOT_A_PIN // no on board LED +#define RGB_LED_COUNT 5 // we use 5 of 10 LEDs (1 side) +#define HAS_RGB_LED SmartLed rgb_led(LED_SK6812, RGB_LED_COUNT, GPIO_NUM_15) // LED_SK6812 RGB LED on GPIO15 #define HAS_BUTTON (39) // on board button A // GPS settings diff --git a/src/led.cpp b/src/led.cpp index d7925b4e..5c91428b 100644 --- a/src/led.cpp +++ b/src/led.cpp @@ -63,9 +63,11 @@ RGBColor rgb_hsl2rgb(float h, float s, float l) { } void rgb_set_color(uint16_t hue) { + int i = RGB_LED_COUNT; if (hue == COLOR_NONE) { // Off - rgb_led[0] = Rgb(0, 0, 0); + while (i--) + rgb_led[i] = Rgb(0, 0, 0); } else { // see http://www.workwithcolor.com/blue-color-hue-range-01.htm // H (is color from 0..360) should be between 0.0 and 1.0 @@ -74,7 +76,8 @@ void rgb_set_color(uint16_t hue) { // cfg.rgblum is between 0 and 100 (percent) RGBColor target = rgb_hsl2rgb(hue / 360.0f, 1.0f, 0.005f * cfg.rgblum); // uint32_t color = target.R<<16 | target.G<<8 | target.B; - rgb_led[0] = Rgb(target.R, target.G, target.B); + while (i--) + rgb_led[i] = Rgb(target.R, target.G, target.B); } // Show rgb_led.show(); @@ -211,7 +214,7 @@ void ledLoop(void *parameter) { } // give yield to CPU delay(2); - } // while(1) -}; // ledloop() + } // while(1) +}; // ledloop() #endif // #if (HAS_LED != NOT_A_PIN) || defined(HAS_RGB_LED)