mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2026-09-11 19:55:14 +02:00
Enable pages Battery2, Generator, Solar, RollPitch for small decimals
This commit is contained in:
@@ -5,6 +5,10 @@
|
||||
|
||||
class PageGenerator : public Page
|
||||
{
|
||||
static constexpr int8_t LEFT = 0;
|
||||
static constexpr int8_t CENTER = 1;
|
||||
static constexpr int8_t RIGHT = 2;
|
||||
|
||||
public:
|
||||
PageGenerator(CommonData &common){
|
||||
commonData = &common;
|
||||
@@ -32,6 +36,7 @@ public:
|
||||
int genPower = config->getInt(config->genPower);
|
||||
String backlightMode = config->getString(config->backlight);
|
||||
String powerSensor = config->getString(config->usePowSensor3);
|
||||
bool smallDecimals = config->getBool(config->smallDecimals);
|
||||
|
||||
double value1 = 0; // Solar voltage
|
||||
double value2 = 0; // Solar current
|
||||
@@ -95,20 +100,16 @@ public:
|
||||
getdisplay().print("Generator");
|
||||
|
||||
// Show voltage type
|
||||
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
|
||||
getdisplay().setCursor(10, 140);
|
||||
int bvoltage = 0;
|
||||
if(String(batVoltage) == "12V") bvoltage = 12;
|
||||
else bvoltage = 24;
|
||||
getdisplay().print(bvoltage);
|
||||
printBoatValue(String(bvoltage), 10, 140, LEFT, 20, smallDecimals);
|
||||
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
||||
getdisplay().print("V");
|
||||
|
||||
// Show solar power
|
||||
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
|
||||
getdisplay().setCursor(10, 200);
|
||||
if(genPower <= 999) getdisplay().print(genPower, 0);
|
||||
if(genPower > 999) getdisplay().print(float(genPower/1000.0), 1);
|
||||
String svalueGenPower = (genPower <= 999) ? String(genPower) : String(float(genPower/1000.0), 1);
|
||||
printBoatValue(svalueGenPower, 10, 200, LEFT, 20, smallDecimals);
|
||||
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
||||
if(genPower <= 999) getdisplay().print("W");
|
||||
if(genPower > 999) getdisplay().print("kW");
|
||||
@@ -124,9 +125,7 @@ public:
|
||||
generatorGraphic(200, 95, commonData->fgcolor, commonData->bgcolor);
|
||||
|
||||
// Show load level in percent
|
||||
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
|
||||
getdisplay().setCursor(150, 200);
|
||||
getdisplay().print(genPercentage);
|
||||
printBoatValue(String(genPercentage), 150, 200, LEFT, 20, smallDecimals);
|
||||
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
||||
getdisplay().print("%");
|
||||
getdisplay().setFont(&Ubuntu_Bold8pt8b);
|
||||
@@ -151,54 +150,37 @@ public:
|
||||
getdisplay().print("Sensor Modul");
|
||||
|
||||
// Reading bus data or using simulation data
|
||||
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
|
||||
getdisplay().setCursor(260, 140);
|
||||
if(simulation == true){
|
||||
if(batVoltage == "12V"){
|
||||
value1 = 12.0;
|
||||
}
|
||||
if(batVoltage == "24V"){
|
||||
value1 = 24.0;
|
||||
}
|
||||
value1 += float(random(0, 5)) / 10; // Simulation data
|
||||
getdisplay().print(value1,1);
|
||||
}
|
||||
else{
|
||||
// Check for valid real data, display also if hold values activated
|
||||
if(valid1 == true || holdvalues == true){
|
||||
// Resolution switching
|
||||
if(value1 <= 9.9) getdisplay().print(value1, 2);
|
||||
if(value1 > 9.9 && value1 <= 99.9)getdisplay().print(value1, 1);
|
||||
if(value1 > 99.9) getdisplay().print(value1, 0);
|
||||
}
|
||||
else{
|
||||
getdisplay().print("---"); // Missing bus data
|
||||
}
|
||||
String svalue1;
|
||||
if(valid1 == true || holdvalues == true){
|
||||
svalue1 = formatValue(value1, String("formatXdr:U:V"), *commonData);
|
||||
} else {
|
||||
svalue1 = "---"; // Missing bus data
|
||||
}
|
||||
printBoatValue(svalue1, 355, 140, RIGHT, 20, smallDecimals);
|
||||
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
||||
getdisplay().print("V");
|
||||
|
||||
// Show actual current in A
|
||||
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
|
||||
getdisplay().setCursor(260, 200);
|
||||
String svalue2;
|
||||
if((powerSensor == "INA219" || powerSensor == "INA226") && simulation == false){
|
||||
if(value2 <= 9.9) getdisplay().print(value2, 2);
|
||||
if(value2 > 9.9 && value2 <= 99.9)getdisplay().print(value2, 1);
|
||||
if(value2 > 99.9) getdisplay().print(value2, 0);
|
||||
svalue2 = formatValue(value2, String("formatXdr:I:A"), *commonData);
|
||||
}
|
||||
else getdisplay().print("---");
|
||||
else{
|
||||
svalue2 = "---";
|
||||
}
|
||||
printBoatValue(svalue2, 355, 200, RIGHT, 20, smallDecimals);
|
||||
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
||||
getdisplay().print("A");
|
||||
|
||||
// Show actual consumption in W
|
||||
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
|
||||
getdisplay().setCursor(260, 260);
|
||||
String svalue3;
|
||||
if((powerSensor == "INA219" || powerSensor == "INA226") && simulation == false){
|
||||
if(value3 <= 9.9) getdisplay().print(value3, 2);
|
||||
if(value3 > 9.9 && value3 <= 99.9)getdisplay().print(value3, 1);
|
||||
if(value3 > 99.9) getdisplay().print(value3, 0);
|
||||
svalue3 = formatValue(value3, String("formatXdr:G:"), *commonData);
|
||||
}
|
||||
else getdisplay().print("---");
|
||||
else{
|
||||
svalue3 = "---";
|
||||
}
|
||||
printBoatValue(svalue3, 355, 260, RIGHT, 20, smallDecimals);
|
||||
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
||||
getdisplay().print("W");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user