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

One value page working

This commit is contained in:
norbert-walter
2022-02-13 22:15:09 +01:00
parent 10d6b3fa50
commit 9f6aebe978
11 changed files with 155 additions and 62 deletions

View File

@@ -1,15 +1,93 @@
#include "Pagedata.h"
#include "OBP60ExtensionPort.h"
class PageOneValue : public Page{
public:
virtual void display(CommonData &commonData, PageData &pageData){
virtual void displayPage(CommonData &commonData, PageData &pageData){
GwConfigHandler *config = commonData.config;
GwLog *logger=commonData.logger;
// Get config data
String lengthformat = config->getString(config->lengthFormat);
bool simulation = config->getBool(config->useSimuData);
bool holdvalues = config->getBool(config->holdvalues);
// Get boat values
GwApi::BoatValue *value=pageData.values[0];
String name1 = value->getName().c_str();
double value1 = value->value;
bool valid1 = value->valid;
String format1 = value->getFormat().c_str();
// Logging boat values
if (value == NULL) return;
LOG_DEBUG(GwLog::LOG,"drawing at PageOneValue, p=%s,v=%f",
value->getName().c_str(),
value->valid?value->value:-1.0
);
LOG_DEBUG(GwLog::LOG,"drawing at PageOneValue, p=%s, v=%f", name1, value1);
// Draw page
//***********************************************************
// Clear display
display.fillRect(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, GxEPD_WHITE); // Draw white sreen
// Show name
display.setFont(&Ubuntu_Bold32pt7b);
display.setTextColor(GxEPD_BLACK);
display.setCursor(20, 100);
display.print(name1); // Page name
display.setFont(&Ubuntu_Bold20pt7b);
display.setCursor(270, 100);
// Show unit
if(String(lengthformat) == "m"){
display.print("m");
}
if(String(lengthformat) == "ft"){
display.print("ft");
}
display.setFont(&DSEG7Classic_BoldItalic60pt7b);
display.setCursor(20, 240);
// Reading bus data or using simulation data
if(simulation == true){
value1 = 84;
value1 += float(random(0, 120)) / 10; // Simulation data
display.print(value1,1);
}
else{
// Check vor valid real data, display also if hold values activated
if(valid1 == true || holdvalues == true){
// Unit conversion
if(String(lengthformat) == "m"){
value1 = value1; // Real bus data m
}
if(String(lengthformat) == "ft"){
value1 = value1 * 3.28084; // Bus data in ft
}
// Resolution switching
if(value1 <= 99.9){
display.print(value1,1);
}
else{
display.print(value1,0);
}
}
else{
display.print("---"); // Missing bus data
}
}
// Key Layout
display.setFont(&Ubuntu_Bold8pt7b);
display.setTextColor(GxEPD_BLACK);
display.setCursor(0, 290);
display.print(" [ < ]");
display.setCursor(290, 290);
display.print("[ > ]");
display.setCursor(343, 290);
display.print("[ILUM]");
// Update display
display.updateWindow(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, true); // Partial update (fast)
};
};