Add color and brightness for Backlight LEDs
This commit is contained in:
parent
ce80c21264
commit
a5f257ec3e
|
@ -77,16 +77,41 @@ void togglePortPin(uint pin){
|
||||||
digitalWrite(pin, !digitalRead(pin));
|
digitalWrite(pin, !digitalRead(pin));
|
||||||
}
|
}
|
||||||
|
|
||||||
void toggleBacklightLED(){
|
CRGB colorMapping(String colorString){
|
||||||
|
CRGB color = CRGB::Red;
|
||||||
|
if(colorString == "Red"){color = CRGB::Red;}
|
||||||
|
if(colorString == "Orange"){color = CRGB::Orange;}
|
||||||
|
if(colorString == "Yellow"){color = CRGB::Yellow;}
|
||||||
|
if(colorString == "Green"){color = CRGB::Green;}
|
||||||
|
if(colorString == "Blue"){color = CRGB::Blue;}
|
||||||
|
if(colorString == "Aqua"){color = CRGB::Aqua;}
|
||||||
|
if(colorString == "Violet"){color = CRGB::Violet;}
|
||||||
|
if(colorString == "White"){color = CRGB::White;}
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
// All defined colors see pixeltypes.h in FastLED lib
|
||||||
|
void setBacklightLED(uint brightness, CRGB color){
|
||||||
|
FastLED.setBrightness(brightness); // Brightness for flash LED
|
||||||
|
backlight[0] = color; // Backlight LEDs on with color
|
||||||
|
backlight[1] = color;
|
||||||
|
backlight[2] = color;
|
||||||
|
backlight[3] = color;
|
||||||
|
backlight[4] = color;
|
||||||
|
backlight[5] = color;
|
||||||
|
FastLED.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void toggleBacklightLED(uint brightness, CRGB color){
|
||||||
statusBacklightLED = !statusBacklightLED;
|
statusBacklightLED = !statusBacklightLED;
|
||||||
FastLED.setBrightness(255); // Brightness for flash LED
|
FastLED.setBrightness(brightness); // Brightness for flash LED
|
||||||
if(statusBacklightLED == true){
|
if(statusBacklightLED == true){
|
||||||
backlight[0] = CRGB::White; // Backlight LEDs on
|
backlight[0] = color; // Backlight LEDs on
|
||||||
backlight[1] = CRGB::White;
|
backlight[1] = color;
|
||||||
backlight[2] = CRGB::White;
|
backlight[2] = color;
|
||||||
backlight[3] = CRGB::White;
|
backlight[3] = color;
|
||||||
backlight[4] = CRGB::White;
|
backlight[4] = color;
|
||||||
backlight[5] = CRGB::White;
|
backlight[5] = color;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
backlight[0] = CRGB::Black; // Backlight LEDs off
|
backlight[0] = CRGB::Black; // Backlight LEDs off
|
||||||
|
|
|
@ -31,7 +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
|
||||||
|
|
||||||
void toggleBacklightLED(); // Toggle backlight LEDs
|
CRGB colorMapping(String colorString); // Color mapping string to CRGB colors
|
||||||
|
void setBacklightLED(uint brightness, CRGB color);// Set backlight LEDs
|
||||||
|
void toggleBacklightLED(uint brightness, CRGB 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
|
||||||
|
|
|
@ -648,6 +648,41 @@
|
||||||
"obp60":"true"
|
"obp60":"true"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "blColor",
|
||||||
|
"label": "Backlight Color",
|
||||||
|
"type": "list",
|
||||||
|
"default": "Red",
|
||||||
|
"description": "Backlight color",
|
||||||
|
"list": [
|
||||||
|
"Red",
|
||||||
|
"Orange",
|
||||||
|
"Yellow",
|
||||||
|
"Green",
|
||||||
|
"Blue",
|
||||||
|
"Aqua",
|
||||||
|
"Violet",
|
||||||
|
"White"
|
||||||
|
],
|
||||||
|
"category": "OBP60 Display",
|
||||||
|
"capabilities": {
|
||||||
|
"obp60":"true"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "blBrightness",
|
||||||
|
"label": "Brightness [%]",
|
||||||
|
"type": "number",
|
||||||
|
"default": "50",
|
||||||
|
"check": "checkMinMax",
|
||||||
|
"min": 0,
|
||||||
|
"max": 100,
|
||||||
|
"description": "Backlight brightness [0...100%]",
|
||||||
|
"category": "OBP60 Display",
|
||||||
|
"capabilities": {
|
||||||
|
"obp60":"true"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "flashLED",
|
"name": "flashLED",
|
||||||
"label": "Flash LED Mode",
|
"label": "Flash LED Mode",
|
||||||
|
|
|
@ -49,14 +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());
|
||||||
if(String(backlightMode) == "On"){
|
if(String(backlightMode) == "On"){
|
||||||
// setPortPin(OBP_BACKLIGHT_LED, true);
|
setBacklightLED(brightness, CRGB::Red);
|
||||||
}
|
}
|
||||||
if(String(backlightMode) == "Off"){
|
if(String(backlightMode) == "Off"){
|
||||||
// setPortPin(OBP_BACKLIGHT_LED, false);
|
setBacklightLED(0, CRGB::Black);
|
||||||
}
|
}
|
||||||
if(String(backlightMode) == "Control by Key"){
|
if(String(backlightMode) == "Control by Key"){
|
||||||
// setPortPin(OBP_BACKLIGHT_LED, false);
|
setBacklightLED(0, CRGB::Black);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Settings flash LED mode
|
// Settings flash LED mode
|
||||||
|
@ -351,6 +353,9 @@ void OBP60Task(GwApi *api){
|
||||||
String backlight = api->getConfig()->getConfigItem(api->getConfig()->backlight,true)->asString();
|
String backlight = api->getConfig()->getConfigItem(api->getConfig()->backlight,true)->asString();
|
||||||
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();
|
||||||
|
CRGB color = colorMapping(backlightColor);
|
||||||
|
uint brightness = 2.55 * uint(api->getConfig()->getConfigItem(api->getConfig()->blBrightness,true)->asInt());
|
||||||
|
|
||||||
// refreshmode defined in init section
|
// refreshmode defined in init section
|
||||||
// displaycolor defined in init section
|
// displaycolor defined in init section
|
||||||
|
@ -417,7 +422,7 @@ void OBP60Task(GwApi *api){
|
||||||
if(String(backlight) == "Control by Key"){
|
if(String(backlight) == "Control by Key"){
|
||||||
if(keyboardMessage == 6){
|
if(keyboardMessage == 6){
|
||||||
LOG_DEBUG(GwLog::LOG,"Toggle Backlight LED");
|
LOG_DEBUG(GwLog::LOG,"Toggle Backlight LED");
|
||||||
toggleBacklightLED();
|
toggleBacklightLED(brightness, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// #9 Swipe right
|
// #9 Swipe right
|
||||||
|
|
Loading…
Reference in New Issue