enhanced RGB LED control for M5fire
This commit is contained in:
parent
67cede2886
commit
59930870fd
@ -4,6 +4,10 @@
|
||||
#include <SmartLeds.h>
|
||||
#include "lorawan.h"
|
||||
|
||||
#ifndef RGB_LED_COUNT
|
||||
#define RGB_LED_COUNT 1
|
||||
#endif
|
||||
|
||||
// value for HSL color
|
||||
// see http://www.workwithcolor.com/blue-color-hue-range-01.htm
|
||||
#define COLOR_RED 0
|
||||
|
@ -38,7 +38,8 @@
|
||||
//#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 RGB_LED_COUNT 10
|
||||
#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
|
||||
|
12
src/led.cpp
12
src/led.cpp
@ -64,8 +64,9 @@ RGBColor rgb_hsl2rgb(float h, float s, float l) {
|
||||
|
||||
void rgb_set_color(uint16_t hue) {
|
||||
if (hue == COLOR_NONE) {
|
||||
// Off
|
||||
rgb_led[0] = Rgb(0, 0, 0);
|
||||
// set Off
|
||||
for (int i = 0; i < RGB_LED_COUNT; 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 +75,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);
|
||||
for (int i = 0; i < RGB_LED_COUNT; i++)
|
||||
rgb_led[i] = Rgb(target.R, target.G, target.B);
|
||||
}
|
||||
// Show
|
||||
rgb_led.show();
|
||||
@ -211,7 +213,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)
|
||||
|
Loading…
Reference in New Issue
Block a user