Fix brightness control for backlight LEDs
This commit is contained in:
parent
6e7dfc6fd9
commit
74d13df414
|
@ -77,23 +77,25 @@ void togglePortPin(uint pin){
|
||||||
digitalWrite(pin, !digitalRead(pin));
|
digitalWrite(pin, !digitalRead(pin));
|
||||||
}
|
}
|
||||||
|
|
||||||
CRGB colorMapping(String colorString){
|
// Valid colors see hue
|
||||||
CRGB color = CRGB::Red;
|
CHSV colorMapping(String colorString){
|
||||||
if(colorString == "Red"){color = CRGB::Red;}
|
CHSV color = CHSV(HUE_RED, 255, 255);
|
||||||
if(colorString == "Orange"){color = CRGB::Orange;}
|
if(colorString == "Red"){color = CHSV(HUE_RED, 255, 255);}
|
||||||
if(colorString == "Yellow"){color = CRGB::Yellow;}
|
if(colorString == "Orange"){color = CHSV(HUE_ORANGE, 255, 255);}
|
||||||
if(colorString == "Green"){color = CRGB::Green;}
|
if(colorString == "Yellow"){color = CHSV(HUE_YELLOW, 255, 255);}
|
||||||
if(colorString == "Blue"){color = CRGB::Blue;}
|
if(colorString == "Green"){color = CHSV(HUE_GREEN, 255, 255);}
|
||||||
if(colorString == "Aqua"){color = CRGB::Aqua;}
|
if(colorString == "Blue"){color = CHSV(HUE_BLUE, 255, 255);}
|
||||||
if(colorString == "Violet"){color = CRGB::Violet;}
|
if(colorString == "Aqua"){color = CHSV(HUE_AQUA, 255, 255);}
|
||||||
if(colorString == "White"){color = CRGB::White;}
|
if(colorString == "Violet"){color = CHSV(HUE_PURPLE, 255, 255);}
|
||||||
|
if(colorString == "White"){color = CHSV(HUE_AQUA, 0, 255);}
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
// All defined colors see pixeltypes.h in FastLED lib
|
// All defined colors see pixeltypes.h in FastLED lib
|
||||||
void setBacklightLED(uint brightness, CRGB color){
|
void setBacklightLED(uint brightness, CHSV color){
|
||||||
FastLED.setBrightness(brightness); // Brightness for flash LED
|
FastLED.setBrightness(255); // Brightness for flash LED
|
||||||
backlight[0] = color; // Backlight LEDs on with color
|
color.value = brightness;
|
||||||
|
backlight[0] = color; // Backlight LEDs on with color
|
||||||
backlight[1] = color;
|
backlight[1] = color;
|
||||||
backlight[2] = color;
|
backlight[2] = color;
|
||||||
backlight[3] = color;
|
backlight[3] = color;
|
||||||
|
@ -102,11 +104,12 @@ void setBacklightLED(uint brightness, CRGB color){
|
||||||
FastLED.show();
|
FastLED.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void toggleBacklightLED(uint brightness, CRGB color){
|
void toggleBacklightLED(uint brightness, CHSV color){
|
||||||
statusBacklightLED = !statusBacklightLED;
|
statusBacklightLED = !statusBacklightLED;
|
||||||
FastLED.setBrightness(brightness); // Brightness for flash LED
|
FastLED.setBrightness(255); // Brightness for flash LED
|
||||||
if(statusBacklightLED == true){
|
if(statusBacklightLED == true){
|
||||||
backlight[0] = color; // Backlight LEDs on
|
color.value = brightness;
|
||||||
|
backlight[0] = color; // Backlight LEDs on with color
|
||||||
backlight[1] = color;
|
backlight[1] = color;
|
||||||
backlight[2] = color;
|
backlight[2] = color;
|
||||||
backlight[3] = color;
|
backlight[3] = color;
|
||||||
|
@ -114,12 +117,12 @@ void toggleBacklightLED(uint brightness, CRGB color){
|
||||||
backlight[5] = color;
|
backlight[5] = color;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
backlight[0] = CRGB::Black; // Backlight LEDs off
|
backlight[0] = CHSV(HUE_BLUE, 255, 0); // Backlight LEDs off (blue without britghness)
|
||||||
backlight[1] = CRGB::Black;
|
backlight[1] = CHSV(HUE_BLUE, 255, 0);
|
||||||
backlight[2] = CRGB::Black;
|
backlight[2] = CHSV(HUE_BLUE, 255, 0);
|
||||||
backlight[3] = CRGB::Black;
|
backlight[3] = CHSV(HUE_BLUE, 255, 0);
|
||||||
backlight[4] = CRGB::Black;
|
backlight[4] = CHSV(HUE_BLUE, 255, 0);
|
||||||
backlight[5] = CRGB::Black;
|
backlight[5] = CHSV(HUE_BLUE, 255, 0);
|
||||||
}
|
}
|
||||||
FastLED.show();
|
FastLED.show();
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,9 +31,9 @@ void setPortPin(uint pin, bool value); // Set port pin for extension po
|
||||||
|
|
||||||
void togglePortPin(uint pin); // Toggle extension port pin
|
void togglePortPin(uint pin); // Toggle extension port pin
|
||||||
|
|
||||||
CRGB colorMapping(String colorString); // Color mapping string to CRGB colors
|
CHSV colorMapping(String colorString); // Color mapping string to CHSV colors
|
||||||
void setBacklightLED(uint brightness, CRGB color);// Set backlight LEDs
|
void setBacklightLED(uint brightness, CHSV color);// Set backlight LEDs
|
||||||
void toggleBacklightLED(uint brightness, CRGB color);// Toggle backlight LEDs
|
void toggleBacklightLED(uint brightness, CHSV color);// Toggle backlight LEDs
|
||||||
|
|
||||||
void setFlashLED(bool status); // Set flash LED
|
void setFlashLED(bool status); // Set flash LED
|
||||||
void blinkingFlashLED(); // Blinking function for flash LED
|
void blinkingFlashLED(); // Blinking function for flash LED
|
||||||
|
|
|
@ -675,9 +675,9 @@
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"default": "50",
|
"default": "50",
|
||||||
"check": "checkMinMax",
|
"check": "checkMinMax",
|
||||||
"min": 0,
|
"min": 20,
|
||||||
"max": 100,
|
"max": 100,
|
||||||
"description": "Backlight brightness [0...100%]",
|
"description": "Backlight brightness [20...100%]",
|
||||||
"category": "OBP60 Display",
|
"category": "OBP60 Display",
|
||||||
"capabilities": {
|
"capabilities": {
|
||||||
"obp60":"true"
|
"obp60":"true"
|
||||||
|
|
|
@ -49,16 +49,16 @@ void OBP60Init(GwApi *api){
|
||||||
// Settings for backlight
|
// Settings for backlight
|
||||||
String backlightMode = api->getConfig()->getConfigItem(api->getConfig()->backlight,true)->asString();
|
String backlightMode = api->getConfig()->getConfigItem(api->getConfig()->backlight,true)->asString();
|
||||||
api->getLogger()->logDebug(GwLog::DEBUG,"Backlight Mode is: %s", backlightMode);
|
api->getLogger()->logDebug(GwLog::DEBUG,"Backlight Mode is: %s", backlightMode);
|
||||||
String backlightColor = api->getConfig()->getConfigItem(api->getConfig()->blColor,true)->asString();
|
|
||||||
uint brightness = uint(api->getConfig()->getConfigItem(api->getConfig()->blBrightness,true)->asInt());
|
uint brightness = uint(api->getConfig()->getConfigItem(api->getConfig()->blBrightness,true)->asInt());
|
||||||
|
String backlightColor = api->getConfig()->getConfigItem(api->getConfig()->blColor,true)->asString();
|
||||||
if(String(backlightMode) == "On"){
|
if(String(backlightMode) == "On"){
|
||||||
setBacklightLED(brightness, CRGB::Red);
|
setBacklightLED(brightness, colorMapping(backlightColor));
|
||||||
}
|
}
|
||||||
if(String(backlightMode) == "Off"){
|
if(String(backlightMode) == "Off"){
|
||||||
setBacklightLED(0, CRGB::Black);
|
setBacklightLED(0, CHSV(HUE_BLUE, 255, 0)); // Backlight LEDs off (blue without britghness)
|
||||||
}
|
}
|
||||||
if(String(backlightMode) == "Control by Key"){
|
if(String(backlightMode) == "Control by Key"){
|
||||||
setBacklightLED(0, CRGB::Black);
|
setBacklightLED(0, CHSV(HUE_BLUE, 255, 0)); // Backlight LEDs off (blue without britghness)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Settings flash LED mode
|
// Settings flash LED mode
|
||||||
|
@ -354,7 +354,7 @@ void OBP60Task(GwApi *api){
|
||||||
String gpsOn=api->getConfig()->getConfigItem(api->getConfig()->useGPS,true)->asString();
|
String gpsOn=api->getConfig()->getConfigItem(api->getConfig()->useGPS,true)->asString();
|
||||||
String tz = api->getConfig()->getConfigItem(api->getConfig()->timeZone,true)->asString();
|
String tz = api->getConfig()->getConfigItem(api->getConfig()->timeZone,true)->asString();
|
||||||
String backlightColor = api->getConfig()->getConfigItem(api->getConfig()->blColor,true)->asString();
|
String backlightColor = api->getConfig()->getConfigItem(api->getConfig()->blColor,true)->asString();
|
||||||
CRGB color = colorMapping(backlightColor);
|
CHSV color = colorMapping(backlightColor);
|
||||||
uint brightness = 2.55 * uint(api->getConfig()->getConfigItem(api->getConfig()->blBrightness,true)->asInt());
|
uint brightness = 2.55 * uint(api->getConfig()->getConfigItem(api->getConfig()->blBrightness,true)->asInt());
|
||||||
|
|
||||||
// refreshmode defined in init section
|
// refreshmode defined in init section
|
||||||
|
@ -371,7 +371,6 @@ void OBP60Task(GwApi *api){
|
||||||
|
|
||||||
LOG_DEBUG(GwLog::LOG,"obp60task: start mainloop");
|
LOG_DEBUG(GwLog::LOG,"obp60task: start mainloop");
|
||||||
// Set start page
|
// Set start page
|
||||||
// int pageNumber = 0;
|
|
||||||
int pageNumber = int(api->getConfig()->getConfigItem(api->getConfig()->startPage,true)->asInt()) - 1;
|
int pageNumber = int(api->getConfig()->getConfigItem(api->getConfig()->startPage,true)->asInt()) - 1;
|
||||||
int lastPage=pageNumber;
|
int lastPage=pageNumber;
|
||||||
|
|
||||||
|
@ -470,7 +469,7 @@ void OBP60Task(GwApi *api){
|
||||||
setBacklightLED(brightness, color);
|
setBacklightLED(brightness, color);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
setBacklightLED(brightness, CRGB::Black);
|
setBacklightLED(0, CHSV(HUE_BLUE, 255, 0)); // Backlight LEDs off (blue without britghness)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue