Change according new NeoPixelbus library

This commit is contained in:
Charles 2016-05-09 16:08:12 +02:00
parent 976095f3ef
commit 048167311d
2 changed files with 74 additions and 17 deletions

View File

@ -74,14 +74,22 @@ extern "C" {
#define BLINK_LED_MS 50 // 50 ms blink
#define RGB_LED_PIN 14
#define RED_LED_PIN 12
// value for RGB color
#define COLOR_RED rgb_brightness, 0, 0
#define COLOR_ORANGE rgb_brightness, rgb_brightness>>1, 0
#define COLOR_YELLOW rgb_brightness, rgb_brightness, 0
#define COLOR_GREEN 0, rgb_brightness, 0
#define COLOR_CYAN 0, rgb_brightness, rgb_brightness
#define COLOR_BLUE 0, 0, rgb_brightness
#define COLOR_MAGENTA rgb_brightness, 0, rgb_brightness
// value for HSL color
// see http://www.workwithcolor.com/blue-color-hue-range-01.htm
#define COLOR_RED 0
#define COLOR_ORANGE 30
#define COLOR_ORANGE_YELLOW 45
#define COLOR_YELLOW 60
#define COLOR_YELLOW_GREEN 90
#define COLOR_GREEN 120
#define COLOR_GREEN_CYAN 165
#define COLOR_CYAN 180
#define COLOR_CYAN_BLUE 210
#define COLOR_BLUE 240
#define COLOR_BLUE_MAGENTA 275
#define COLOR_MAGENTA 300
#define COLOR_PINK 350
// GPIO 1 TX on board blue led
#ifdef BLU_LED_PIN
@ -95,10 +103,11 @@ extern "C" {
#define LedRedON() {digitalWrite(RED_LED_PIN, 1);}
#define LedRedOFF() {digitalWrite(RED_LED_PIN, 0);}
// Light off the RGB LED
#define LedRGBOFF() { rgb_led.SetPixelColor(0,0,0,0); rgb_led.Show(); }
#define LedRGBON(x) { rgb_led.SetPixelColor(0,x); rgb_led.Show(); }
// Light off the RGB LED
#ifndef RGB_LED_PIN
#define LedRGBOFF() {}
#define LedRGBON(x) {}
#endif
// sysinfo informations
typedef struct
{
@ -110,7 +119,6 @@ typedef struct
extern ESP8266WebServer server;
extern WiFiUDP OTA;
extern TInfo tinfo;
extern NeoPixelBus rgb_led ;
extern uint8_t rgb_brightness;
extern unsigned long seconds;
extern _sysinfo sysinfo;

View File

@ -46,11 +46,15 @@ bool ota_blink;
// Teleinfo
TInfo tinfo;
// RGB Loed
NeoPixelBus rgb_led = NeoPixelBus(1, RGB_LED_PIN, NEO_RGB | NEO_KHZ800);
// RGB Led
#ifdef RGB_LED_PIN
//NeoPixelBus rgb_led = NeoPixelBus(1, RGB_LED_PIN, NEO_RGB | NEO_KHZ800);
NeoPixelBus<NeoGrbFeature, NeoEsp8266BitBang800KbpsMethod> rgb_led(1, RGB_LED_PIN);
#endif
// define whole brigtness level for RGBLED
uint8_t rgb_brightness = 127;
// define whole brigtness level for RGBLED (50%)
uint8_t rgb_brightness = 50;
// LED Blink timers
Ticker rgb_ticker;
Ticker blu_ticker;
@ -143,6 +147,51 @@ void LedOff(int led)
LedRGBOFF();
}
// Light off the RGB LED
#ifdef RGB_LED_PIN
/* ======================================================================
Function: LedRGBON
Purpose : Light RGB Led with HSB value
Input : Hue (0..255)
Saturation (0..255)
Brightness (0..255)
Output : -
Comments:
====================================================================== */
void LedRGBON (uint16_t hue)
{
if (config.config & CFG_RGB_LED) {
// Convert to neoPixel API values
// H (is color from 0..360) should be between 0.0 and 1.0
// L (is brightness from 0..100) should be between 0.0 and 0.5
RgbColor target = HslColor( hue / 360.0f, 1.0f, rgb_brightness * 0.005f );
// Set RGB Led
rgb_led.SetPixelColor(0, target);
rgb_led.Show();
}
}
/* ======================================================================
Function: LedRGBOFF
Purpose : light off the RGN LED
Input : -
Output : -
Comments: -
====================================================================== */
//void LedOff(int led)
void LedRGBOFF(void)
{
if (config.config & CFG_RGB_LED) {
rgb_led.SetPixelColor(0,RgbColor(0));
rgb_led.Show();
}
}
#endif
/* ======================================================================
Function: ADPSCallback
Purpose : called by library when we detected a ADPS on any phased