1
0
mirror of https://github.com/thooge/esp32-nmea2000-obp60.git synced 2026-02-10 22:53:07 +01:00

New function for backlight - 3 brigjhtness steps

This commit is contained in:
norbert-walter
2026-02-02 21:26:43 +01:00
parent 6a56a8fb56
commit 753e87068f
5 changed files with 40 additions and 5 deletions

View File

@@ -331,6 +331,40 @@ void toggleBacklightLED(uint brightness, const Color &color){
ledTaskData->setLedData(current);
}
void stepsBacklightLED(uint brightness, const Color &color){
static uint step = 0;
uint actBrightness = 0;
// Different brightness steps
if(step == 0){
actBrightness = brightness; // 100% from brightess
statusBacklightLED = true;
}
if(step == 1){
actBrightness = brightness * 0.5; // 50% from brightess
statusBacklightLED = true;
}
if(step == 2){
actBrightness = brightness * 0.2; // 20% from brightess
statusBacklightLED = true;
}
if(step == 3){
actBrightness = 0; // 0%
statusBacklightLED = false;
}
if(actBrightness < 5){ // Limiter if values too low
actBrightness = 5;
}
step = step + 1; // Increment step counter
if(step == 4){ // Reset counter
step = 0;
}
if (ledTaskData == nullptr) return;
Color nv=setBrightness(statusBacklightLED?color:COLOR_BLACK,actBrightness);
LedInterface current=ledTaskData->getLedData();
current.setBacklight(nv);
ledTaskData->setLedData(current);
}
void setFlashLED(bool status){
if (ledTaskData == nullptr) return;
Color c=status?COLOR_RED:COLOR_BLACK;

View File

@@ -96,6 +96,7 @@ void togglePortPin(uint pin); // Toggle extension port pin
Color colorMapping(const String &colorString); // Color mapping string to CHSV colors
void setBacklightLED(uint brightness, const Color &color);// Set backlight LEDs
void toggleBacklightLED(uint brightness,const Color &color);// Toggle backlight LEDs
void stepsBacklightLED(uint brightness, const Color &color);// Set backlight LEDs in 4 steps (100%, 50%, 10%, 0%)
BacklightMode backlightMapping(const String &backlightString);// Configuration string to value
void setFlashLED(bool status); // Set flash LED

View File

@@ -1273,9 +1273,9 @@
"type": "number",
"default": "50",
"check": "checkMinMax",
"min": 20,
"min": 5,
"max": 100,
"description": "Backlight brightness [20...100%]",
"description": "Backlight brightness [5...100%]",
"category": "OBP60 Display",
"capabilities": {
"obp60":"true"

View File

@@ -1285,9 +1285,9 @@
"type": "number",
"default": "50",
"check": "checkMinMax",
"min": 20,
"min": 5,
"max": 100,
"description": "Backlight brightness [20...100%]",
"description": "Backlight brightness [5...100%]",
"category": "OBP40 Display",
"capabilities": {
"obp40": "false"

View File

@@ -660,7 +660,7 @@ void OBP60Task(GwApi *api){
// if(String(backlight) == "Control by Key"){
if(keyboardMessage == 6){
LOG_DEBUG(GwLog::LOG,"Toggle Backlight LED");
toggleBacklightLED(commonData.backlight.brightness, commonData.backlight.color);
stepsBacklightLED(commonData.backlight.brightness, commonData.backlight.color);
}
}
#ifdef BOARD_OBP40S3