1
0
mirror of https://github.com/thooge/esp32-nmea2000-obp60.git synced 2025-12-15 15:03:07 +01:00

Refactor color detection and usage

This commit is contained in:
2024-12-09 14:01:23 +01:00
parent 4ad82299fc
commit 2659fb9fb7
24 changed files with 224 additions and 651 deletions

View File

@@ -29,7 +29,6 @@ public:
// Get config data
bool simulation = config->getBool(config->useSimuData);
String displaycolor = config->getString(config->displaycolor);
bool holdvalues = config->getBool(config->holdvalues);
String flashLED = config->getString(config->flashLED);
String batVoltage = config->getString(config->batteryVoltage);
@@ -85,25 +84,12 @@ public:
// Draw page
//***********************************************************
// Clear display, set background color and text color
int textcolor = GxEPD_BLACK;
int pixelcolor = GxEPD_BLACK;
int bgcolor = GxEPD_WHITE;
if(displaycolor == "Normal"){
textcolor = GxEPD_BLACK;
pixelcolor = GxEPD_BLACK;
bgcolor = GxEPD_WHITE;
}
else{
textcolor = GxEPD_WHITE;
pixelcolor = GxEPD_WHITE;
bgcolor = GxEPD_BLACK;
}
// Set display in partial refresh mode
getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update
getdisplay().setTextColor(commonData.fgcolor);
// Show name
getdisplay().setTextColor(textcolor);
getdisplay().setFont(&Ubuntu_Bold20pt7b);
getdisplay().setCursor(10, 65);
getdisplay().print("Power");
@@ -112,7 +98,6 @@ public:
getdisplay().print("Generator");
// Show voltage type
getdisplay().setTextColor(textcolor);
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
getdisplay().setCursor(10, 140);
int bvoltage = 0;
@@ -123,7 +108,6 @@ public:
getdisplay().print("V");
// Show solar power
getdisplay().setTextColor(textcolor);
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
getdisplay().setCursor(10, 200);
if(genPower <= 999) getdisplay().print(genPower, 0);
@@ -140,10 +124,9 @@ public:
getdisplay().print("Power Modul");
// Show generator
generatorGraphic(200, 95, pixelcolor, bgcolor);
generatorGraphic(200, 95, commonData.fgcolor, commonData.bgcolor);
// Show load level in percent
getdisplay().setTextColor(textcolor);
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
getdisplay().setCursor(150, 200);
getdisplay().print(genPercentage);
@@ -171,7 +154,6 @@ public:
getdisplay().print("Sensor Modul");
// Reading bus data or using simulation data
getdisplay().setTextColor(textcolor);
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
getdisplay().setCursor(260, 140);
if(simulation == true){
@@ -200,7 +182,6 @@ public:
getdisplay().print("V");
// Show actual current in A
getdisplay().setTextColor(textcolor);
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
getdisplay().setCursor(260, 200);
if((powerSensor == "INA219" || powerSensor == "INA226") && simulation == false){
@@ -213,7 +194,6 @@ public:
getdisplay().print("A");
// Show actual consumption in W
getdisplay().setTextColor(textcolor);
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
getdisplay().setCursor(260, 260);
if((powerSensor == "INA219" || powerSensor == "INA226") && simulation == false){
@@ -226,7 +206,6 @@ public:
getdisplay().print("W");
// Key Layout
getdisplay().setTextColor(textcolor);
getdisplay().setFont(&Ubuntu_Bold8pt7b);
if(keylock == false){
getdisplay().setCursor(130, 290);
@@ -264,4 +243,4 @@ PageDescription registerPageGenerator(
true // Show display header on/off
);
#endif
#endif