1
0
mirror of https://github.com/thooge/esp32-nmea2000-obp60.git synced 2026-03-28 18:06:37 +01:00

Move config code into page constructors and some code cleanup

This commit is contained in:
2025-08-14 09:12:56 +02:00
parent 54b4954797
commit 8695d3eeb5
32 changed files with 317 additions and 398 deletions

View File

@@ -7,13 +7,18 @@
class PageFourValues2 : public Page
{
private:
String lengthformat;
public:
PageFourValues2(CommonData &common) : Page(common)
{
logger->logDebug(GwLog::LOG,"Instantiate PageFourValues2");
logger->logDebug(GwLog::LOG, "Instantiate PageFourValues2");
// Get config data
lengthformat = config->getString(config->lengthFormat);
}
virtual int handleKey(int key){
int handleKey(int key) {
// Code for keylock
if(key == 11){
commonData->keylock = !commonData->keylock; // Toggle keylock
@@ -22,7 +27,7 @@ public:
return key;
}
int displayPage(PageData &pageData){
int displayPage(PageData &pageData) {
// Old values for hold function
static String svalue1old = "";
@@ -33,14 +38,7 @@ public:
static String unit3old = "";
static String svalue4old = "";
static String unit4old = "";
// Get config data
String lengthformat = config->getString(config->lengthFormat);
// bool simulation = config->getBool(config->useSimuData);
bool holdvalues = config->getBool(config->holdvalues);
String flashLED = config->getString(config->flashLED);
String backlightMode = config->getString(config->backlight);
// Get boat values #1
GwApi::BoatValue *bvalue1 = pageData.values[0]; // First element in list (only one value by PageOneValue)
String name1 = xdrDelete(bvalue1->getName()); // Value name
@@ -89,7 +87,7 @@ public:
// Logging boat values
if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement?
LOG_DEBUG(GwLog::LOG,"Drawing at PageFourValues2, %s: %f, %s: %f, %s: %f, %s: %f", name1.c_str(), value1, name2.c_str(), value2, name3.c_str(), value3, name4.c_str(), value4);
logger->logDebug(GwLog::LOG, "Drawing at PageFourValues2, %s: %f, %s: %f, %s: %f, %s: %f", name1.c_str(), value1, name2.c_str(), value2, name3.c_str(), value3, name4.c_str(), value4);
// Draw page
//***********************************************************