mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2025-12-15 23:13:07 +01:00
Refactor color detection and usage
This commit is contained in:
@@ -44,7 +44,6 @@ public:
|
||||
// Get config data
|
||||
String lengthformat = config->getString(config->lengthFormat);
|
||||
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 backlightMode = config->getString(config->backlight);
|
||||
@@ -108,25 +107,12 @@ public:
|
||||
// Draw page
|
||||
//***********************************************************
|
||||
|
||||
// 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 values GPS date
|
||||
getdisplay().setTextColor(textcolor);
|
||||
getdisplay().setFont(&Ubuntu_Bold8pt7b);
|
||||
getdisplay().setCursor(10, 65);
|
||||
if(holdvalues == false) getdisplay().print(svalue2); // Value
|
||||
@@ -136,10 +122,9 @@ public:
|
||||
getdisplay().print("Date"); // Name
|
||||
|
||||
// Horizintal separator left
|
||||
getdisplay().fillRect(0, 149, 60, 3, pixelcolor);
|
||||
getdisplay().fillRect(0, 149, 60, 3, commonData.fgcolor);
|
||||
|
||||
// Show values GPS time
|
||||
getdisplay().setTextColor(textcolor);
|
||||
getdisplay().setFont(&Ubuntu_Bold8pt7b);
|
||||
getdisplay().setCursor(10, 250);
|
||||
if(holdvalues == false) getdisplay().print(svalue1); // Value
|
||||
@@ -155,7 +140,6 @@ public:
|
||||
svalue5old = sunrise;
|
||||
}
|
||||
|
||||
getdisplay().setTextColor(textcolor);
|
||||
getdisplay().setFont(&Ubuntu_Bold8pt7b);
|
||||
getdisplay().setCursor(335, 65);
|
||||
if(holdvalues == false) getdisplay().print(sunrise); // Value
|
||||
@@ -165,7 +149,7 @@ public:
|
||||
getdisplay().print("SunR"); // Name
|
||||
|
||||
// Horizintal separator right
|
||||
getdisplay().fillRect(340, 149, 80, 3, pixelcolor);
|
||||
getdisplay().fillRect(340, 149, 80, 3, commonData.fgcolor);
|
||||
|
||||
// Show values sunset
|
||||
String sunset = "---";
|
||||
@@ -174,7 +158,6 @@ public:
|
||||
svalue6old = sunset;
|
||||
}
|
||||
|
||||
getdisplay().setTextColor(textcolor);
|
||||
getdisplay().setFont(&Ubuntu_Bold8pt7b);
|
||||
getdisplay().setCursor(335, 250);
|
||||
if(holdvalues == false) getdisplay().print(sunset); // Value
|
||||
@@ -189,8 +172,8 @@ public:
|
||||
int rInstrument = 110; // Radius of clock
|
||||
float pi = 3.141592;
|
||||
|
||||
getdisplay().fillCircle(200, 150, rInstrument + 10, pixelcolor); // Outer circle
|
||||
getdisplay().fillCircle(200, 150, rInstrument + 7, bgcolor); // Outer circle
|
||||
getdisplay().fillCircle(200, 150, rInstrument + 10, commonData.fgcolor); // Outer circle
|
||||
getdisplay().fillCircle(200, 150, rInstrument + 7, commonData.bgcolor); // Outer circle
|
||||
|
||||
for(int i=0; i<360; i=i+1)
|
||||
{
|
||||
@@ -231,7 +214,7 @@ public:
|
||||
if(i % 6 == 0){
|
||||
float x1c = 200 + rInstrument*sin(i/180.0*pi);
|
||||
float y1c = 150 - rInstrument*cos(i/180.0*pi);
|
||||
getdisplay().fillCircle((int)x1c, (int)y1c, 2, pixelcolor);
|
||||
getdisplay().fillCircle((int)x1c, (int)y1c, 2, commonData.fgcolor);
|
||||
sinx=sin(i/180.0*pi);
|
||||
cosx=cos(i/180.0*pi);
|
||||
}
|
||||
@@ -245,23 +228,20 @@ public:
|
||||
float yy2 = -(rInstrument+10);
|
||||
getdisplay().fillTriangle(200+(int)(cosx*xx1-sinx*yy1),150+(int)(sinx*xx1+cosx*yy1),
|
||||
200+(int)(cosx*xx2-sinx*yy1),150+(int)(sinx*xx2+cosx*yy1),
|
||||
200+(int)(cosx*xx1-sinx*yy2),150+(int)(sinx*xx1+cosx*yy2),pixelcolor);
|
||||
200+(int)(cosx*xx1-sinx*yy2),150+(int)(sinx*xx1+cosx*yy2),commonData.fgcolor);
|
||||
getdisplay().fillTriangle(200+(int)(cosx*xx2-sinx*yy1),150+(int)(sinx*xx2+cosx*yy1),
|
||||
200+(int)(cosx*xx1-sinx*yy2),150+(int)(sinx*xx1+cosx*yy2),
|
||||
200+(int)(cosx*xx2-sinx*yy2),150+(int)(sinx*xx2+cosx*yy2),pixelcolor);
|
||||
200+(int)(cosx*xx2-sinx*yy2),150+(int)(sinx*xx2+cosx*yy2),commonData.fgcolor);
|
||||
}
|
||||
}
|
||||
|
||||
// Print Unit in clock
|
||||
getdisplay().setTextColor(textcolor);
|
||||
getdisplay().setFont(&Ubuntu_Bold12pt7b);
|
||||
getdisplay().setCursor(175, 110);
|
||||
if(holdvalues == false){
|
||||
getdisplay().setFont(&Ubuntu_Bold12pt7b);
|
||||
getdisplay().setCursor(175, 110);
|
||||
getdisplay().print(unit2); // Unit
|
||||
}
|
||||
else{
|
||||
getdisplay().setFont(&Ubuntu_Bold12pt7b);
|
||||
getdisplay().setCursor(175, 110);
|
||||
getdisplay().print(unit2old); // Unit
|
||||
}
|
||||
|
||||
@@ -290,7 +270,7 @@ public:
|
||||
float yy2 = -(rInstrument * 0.5);
|
||||
getdisplay().fillTriangle(200+(int)(cosx*xx1-sinx*yy1),150+(int)(sinx*xx1+cosx*yy1),
|
||||
200+(int)(cosx*xx2-sinx*yy1),150+(int)(sinx*xx2+cosx*yy1),
|
||||
200+(int)(cosx*0-sinx*yy2),150+(int)(sinx*0+cosx*yy2),pixelcolor);
|
||||
200+(int)(cosx*0-sinx*yy2),150+(int)(sinx*0+cosx*yy2),commonData.fgcolor);
|
||||
// Inverted pointer
|
||||
// Pointer as triangle with center base 2*width
|
||||
float endwidth = 2; // End width of pointer
|
||||
@@ -300,7 +280,7 @@ public:
|
||||
float iy2 = -endwidth;
|
||||
getdisplay().fillTriangle(200+(int)(cosx*ix1-sinx*iy1),150+(int)(sinx*ix1+cosx*iy1),
|
||||
200+(int)(cosx*ix2-sinx*iy1),150+(int)(sinx*ix2+cosx*iy1),
|
||||
200+(int)(cosx*0-sinx*iy2),150+(int)(sinx*0+cosx*iy2),pixelcolor);
|
||||
200+(int)(cosx*0-sinx*iy2),150+(int)(sinx*0+cosx*iy2),commonData.fgcolor);
|
||||
}
|
||||
|
||||
// Draw minute pointer
|
||||
@@ -316,7 +296,7 @@ public:
|
||||
float yy2 = -(rInstrument - 15);
|
||||
getdisplay().fillTriangle(200+(int)(cosx*xx1-sinx*yy1),150+(int)(sinx*xx1+cosx*yy1),
|
||||
200+(int)(cosx*xx2-sinx*yy1),150+(int)(sinx*xx2+cosx*yy1),
|
||||
200+(int)(cosx*0-sinx*yy2),150+(int)(sinx*0+cosx*yy2),pixelcolor);
|
||||
200+(int)(cosx*0-sinx*yy2),150+(int)(sinx*0+cosx*yy2),commonData.fgcolor);
|
||||
// Inverted pointer
|
||||
// Pointer as triangle with center base 2*width
|
||||
float endwidth = 2; // End width of pointer
|
||||
@@ -326,16 +306,15 @@ public:
|
||||
float iy2 = -endwidth;
|
||||
getdisplay().fillTriangle(200+(int)(cosx*ix1-sinx*iy1),150+(int)(sinx*ix1+cosx*iy1),
|
||||
200+(int)(cosx*ix2-sinx*iy1),150+(int)(sinx*ix2+cosx*iy1),
|
||||
200+(int)(cosx*0-sinx*iy2),150+(int)(sinx*0+cosx*iy2),pixelcolor);
|
||||
200+(int)(cosx*0-sinx*iy2),150+(int)(sinx*0+cosx*iy2),commonData.fgcolor);
|
||||
}
|
||||
|
||||
// Center circle
|
||||
getdisplay().fillCircle(200, 150, startwidth + 6, bgcolor);
|
||||
getdisplay().fillCircle(200, 150, startwidth + 4, pixelcolor);
|
||||
getdisplay().fillCircle(200, 150, startwidth + 6, commonData.bgcolor);
|
||||
getdisplay().fillCircle(200, 150, startwidth + 4, commonData.fgcolor);
|
||||
|
||||
//*******************************************************************************************
|
||||
// Key Layout
|
||||
getdisplay().setTextColor(textcolor);
|
||||
getdisplay().setFont(&Ubuntu_Bold8pt7b);
|
||||
if(keylock == false){
|
||||
getdisplay().setCursor(130, 290);
|
||||
|
||||
Reference in New Issue
Block a user