mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2025-12-15 15:03:07 +01:00
First version with GxEPD2 Lib
This commit is contained in:
@@ -81,79 +81,81 @@ public:
|
||||
pixelcolor = GxEPD_WHITE;
|
||||
bgcolor = GxEPD_BLACK;
|
||||
}
|
||||
// Clear display in obp60task.cpp in main loop
|
||||
/// Set display in partial refresh mode
|
||||
getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update
|
||||
getdisplay().fillScreen(bgcolor); // Clear display
|
||||
|
||||
// Show name
|
||||
display.setTextColor(textcolor);
|
||||
display.setFont(&Ubuntu_Bold20pt7b);
|
||||
display.setCursor(10, 65);
|
||||
display.print("Gen.");
|
||||
getdisplay().setTextColor(textcolor);
|
||||
getdisplay().setFont(&Ubuntu_Bold20pt7b);
|
||||
getdisplay().setCursor(10, 65);
|
||||
getdisplay().print("Gen.");
|
||||
|
||||
// Show voltage type
|
||||
display.setTextColor(textcolor);
|
||||
display.setFont(&DSEG7Classic_BoldItalic20pt7b);
|
||||
display.setCursor(10, 140);
|
||||
getdisplay().setTextColor(textcolor);
|
||||
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
|
||||
getdisplay().setCursor(10, 140);
|
||||
int bvoltage = 0;
|
||||
if(String(batVoltage) == "12V") bvoltage = 12;
|
||||
else bvoltage = 24;
|
||||
display.print(bvoltage);
|
||||
display.setFont(&Ubuntu_Bold16pt7b);
|
||||
display.print("V");
|
||||
getdisplay().print(bvoltage);
|
||||
getdisplay().setFont(&Ubuntu_Bold16pt7b);
|
||||
getdisplay().print("V");
|
||||
|
||||
// Show generator power level
|
||||
display.setTextColor(textcolor);
|
||||
display.setFont(&DSEG7Classic_BoldItalic20pt7b);
|
||||
display.setCursor(10, 200);
|
||||
if(generatorMaxPower <= 999) display.print(generatorMaxPower, 0);
|
||||
if(generatorMaxPower > 999) display.print(float(generatorMaxPower/1000.0), 1);
|
||||
display.setFont(&Ubuntu_Bold16pt7b);
|
||||
if(generatorMaxPower <= 999) display.print("W");
|
||||
if(generatorMaxPower > 999) display.print("kw");
|
||||
getdisplay().setTextColor(textcolor);
|
||||
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
|
||||
getdisplay().setCursor(10, 200);
|
||||
if(generatorMaxPower <= 999) getdisplay().print(generatorMaxPower, 0);
|
||||
if(generatorMaxPower > 999) getdisplay().print(float(generatorMaxPower/1000.0), 1);
|
||||
getdisplay().setFont(&Ubuntu_Bold16pt7b);
|
||||
if(generatorMaxPower <= 999) getdisplay().print("W");
|
||||
if(generatorMaxPower > 999) getdisplay().print("kw");
|
||||
|
||||
// Show info
|
||||
display.setFont(&Ubuntu_Bold8pt7b);
|
||||
display.setCursor(10, 235);
|
||||
display.print("Installed");
|
||||
display.setCursor(10, 255);
|
||||
display.print("Type");
|
||||
getdisplay().setFont(&Ubuntu_Bold8pt7b);
|
||||
getdisplay().setCursor(10, 235);
|
||||
getdisplay().print("Installed");
|
||||
getdisplay().setCursor(10, 255);
|
||||
getdisplay().print("Type");
|
||||
|
||||
// Show generator icon
|
||||
batteryGraphic(150, 45, genPercentage, pixelcolor, bgcolor);
|
||||
|
||||
// Show average settings
|
||||
display.setTextColor(textcolor);
|
||||
display.setFont(&Ubuntu_Bold8pt7b);
|
||||
display.setCursor(150, 145);
|
||||
display.print("Avg: 1s");
|
||||
getdisplay().setTextColor(textcolor);
|
||||
getdisplay().setFont(&Ubuntu_Bold8pt7b);
|
||||
getdisplay().setCursor(150, 145);
|
||||
getdisplay().print("Avg: 1s");
|
||||
|
||||
// Show power level in percent
|
||||
display.setTextColor(textcolor);
|
||||
display.setFont(&DSEG7Classic_BoldItalic20pt7b);
|
||||
display.setCursor(150, 200);
|
||||
display.print(genPercentage);
|
||||
display.setFont(&Ubuntu_Bold16pt7b);
|
||||
display.print("%");
|
||||
getdisplay().setTextColor(textcolor);
|
||||
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
|
||||
getdisplay().setCursor(150, 200);
|
||||
getdisplay().print(genPercentage);
|
||||
getdisplay().setFont(&Ubuntu_Bold16pt7b);
|
||||
getdisplay().print("%");
|
||||
|
||||
// Show sensor type info
|
||||
String i2cAddr = "";
|
||||
display.setFont(&Ubuntu_Bold8pt7b);
|
||||
display.setCursor(270, 60);
|
||||
if(powerSensor == "off") display.print("Internal");
|
||||
getdisplay().setFont(&Ubuntu_Bold8pt7b);
|
||||
getdisplay().setCursor(270, 60);
|
||||
if(powerSensor == "off") getdisplay().print("Internal");
|
||||
if(powerSensor == "INA219"){
|
||||
display.print("INA219");
|
||||
getdisplay().print("INA219");
|
||||
}
|
||||
if(powerSensor == "INA226"){
|
||||
display.print("INA226");
|
||||
getdisplay().print("INA226");
|
||||
i2cAddr = " (0x" + String(INA226_I2C_ADDR3, HEX) + ")";
|
||||
}
|
||||
display.print(i2cAddr);
|
||||
display.setCursor(270, 80);
|
||||
display.print("Sensor Modul");
|
||||
getdisplay().print(i2cAddr);
|
||||
getdisplay().setCursor(270, 80);
|
||||
getdisplay().print("Sensor Modul");
|
||||
|
||||
// Reading bus data or using simulation data
|
||||
display.setTextColor(textcolor);
|
||||
display.setFont(&DSEG7Classic_BoldItalic20pt7b);
|
||||
display.setCursor(260, 140);
|
||||
getdisplay().setTextColor(textcolor);
|
||||
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
|
||||
getdisplay().setCursor(260, 140);
|
||||
if(simulation == true){
|
||||
if(batVoltage == "12V"){
|
||||
value1 = 12.0;
|
||||
@@ -162,67 +164,67 @@ public:
|
||||
value1 = 24.0;
|
||||
}
|
||||
value1 += float(random(0, 5)) / 10; // Simulation data
|
||||
display.print(value1,1);
|
||||
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) display.print(value1, 2);
|
||||
if(value1 > 9.9 && value1 <= 99.9)display.print(value1, 1);
|
||||
if(value1 > 99.9) display.print(value1, 0);
|
||||
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{
|
||||
display.print("---"); // Missing bus data
|
||||
getdisplay().print("---"); // Missing bus data
|
||||
}
|
||||
}
|
||||
display.setFont(&Ubuntu_Bold16pt7b);
|
||||
display.print("V");
|
||||
getdisplay().setFont(&Ubuntu_Bold16pt7b);
|
||||
getdisplay().print("V");
|
||||
|
||||
// Show actual current in A
|
||||
display.setTextColor(textcolor);
|
||||
display.setFont(&DSEG7Classic_BoldItalic20pt7b);
|
||||
display.setCursor(260, 200);
|
||||
getdisplay().setTextColor(textcolor);
|
||||
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
|
||||
getdisplay().setCursor(260, 200);
|
||||
if((powerSensor == "INA219" || powerSensor == "INA226") && simulation == false){
|
||||
if(value2 <= 9.9) display.print(value2, 2);
|
||||
if(value2 > 9.9 && value2 <= 99.9)display.print(value2, 1);
|
||||
if(value2 > 99.9) display.print(value2, 0);
|
||||
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);
|
||||
}
|
||||
else display.print("---");
|
||||
display.setFont(&Ubuntu_Bold16pt7b);
|
||||
display.print("A");
|
||||
else getdisplay().print("---");
|
||||
getdisplay().setFont(&Ubuntu_Bold16pt7b);
|
||||
getdisplay().print("A");
|
||||
|
||||
// Show actual consumption in W
|
||||
display.setTextColor(textcolor);
|
||||
display.setFont(&DSEG7Classic_BoldItalic20pt7b);
|
||||
display.setCursor(260, 260);
|
||||
getdisplay().setTextColor(textcolor);
|
||||
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
|
||||
getdisplay().setCursor(260, 260);
|
||||
if((powerSensor == "INA219" || powerSensor == "INA226") && simulation == false){
|
||||
if(value3 <= 9.9) display.print(value3, 2);
|
||||
if(value3 > 9.9 && value3 <= 99.9)display.print(value3, 1);
|
||||
if(value3 > 99.9) display.print(value3, 0);
|
||||
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);
|
||||
}
|
||||
else display.print("---");
|
||||
display.setFont(&Ubuntu_Bold16pt7b);
|
||||
display.print("W");
|
||||
else getdisplay().print("---");
|
||||
getdisplay().setFont(&Ubuntu_Bold16pt7b);
|
||||
getdisplay().print("W");
|
||||
|
||||
// Key Layout
|
||||
display.setTextColor(textcolor);
|
||||
display.setFont(&Ubuntu_Bold8pt7b);
|
||||
getdisplay().setTextColor(textcolor);
|
||||
getdisplay().setFont(&Ubuntu_Bold8pt7b);
|
||||
if(keylock == false){
|
||||
display.setCursor(130, 290);
|
||||
display.print("[ <<<< " + String(commonData.data.actpage) + "/" + String(commonData.data.maxpage) + " >>>> ]");
|
||||
getdisplay().setCursor(130, 290);
|
||||
getdisplay().print("[ <<<< " + String(commonData.data.actpage) + "/" + String(commonData.data.maxpage) + " >>>> ]");
|
||||
if(String(backlightMode) == "Control by Key"){ // Key for illumination
|
||||
display.setCursor(343, 290);
|
||||
display.print("[ILUM]");
|
||||
getdisplay().setCursor(343, 290);
|
||||
getdisplay().print("[ILUM]");
|
||||
}
|
||||
}
|
||||
else{
|
||||
display.setCursor(130, 290);
|
||||
display.print(" [ Keylock active ]");
|
||||
getdisplay().setCursor(130, 290);
|
||||
getdisplay().print(" [ Keylock active ]");
|
||||
}
|
||||
|
||||
// Update display
|
||||
display.updateWindow(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, true); // Partial update (fast)
|
||||
getdisplay().nextPage(); // Partial update (fast)
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user