From e4af7cf731cad3b66d2b5173717a86b9a2550e0c Mon Sep 17 00:00:00 2001 From: Thomas Hooge Date: Fri, 10 Jan 2025 19:41:55 +0100 Subject: [PATCH] Move page number, swipe and lock indicator to header --- lib/obp60task/OBP60Extensions.cpp | 19 ++++--- lib/obp60task/OBP60Extensions.h | 20 +++++++- lib/obp60task/PageApparentWind.cpp | 40 ++++++--------- lib/obp60task/PageBME280.cpp | 36 ++++++------- lib/obp60task/PageBattery.cpp | 56 +++++++++----------- lib/obp60task/PageBattery2.cpp | 60 ++++++++++------------ lib/obp60task/PageClock.cpp | 69 +++++++++++-------------- lib/obp60task/PageDST810.cpp | 50 ++++++++---------- lib/obp60task/PageFluid.cpp | 66 +++++++++++------------- lib/obp60task/PageFourValues.cpp | 48 ++++++++--------- lib/obp60task/PageFourValues2.cpp | 48 ++++++++--------- lib/obp60task/PageGenerator.cpp | 34 +++++------- lib/obp60task/PageKeelPosition.cpp | 55 +++++++++----------- lib/obp60task/PageOneValue.cpp | 33 +++++------- lib/obp60task/PageRollPitch.cpp | 62 ++++++++++------------ lib/obp60task/PageRudderPosition.cpp | 48 ++++++++--------- lib/obp60task/PageSolar.cpp | 35 +++++-------- lib/obp60task/PageThreeValues.cpp | 42 +++++++-------- lib/obp60task/PageTwoValues.cpp | 32 ++++++------ lib/obp60task/PageVoltage.cpp | 73 ++++++++++++-------------- lib/obp60task/PageWhite.cpp | 16 +++--- lib/obp60task/PageWindRose.cpp | 77 +++++++++++++--------------- lib/obp60task/PageWindRoseFlex.cpp | 77 +++++++++++++--------------- lib/obp60task/PageXTETrack.cpp | 51 +++++++++--------- lib/obp60task/Pagedata.h | 7 ++- lib/obp60task/obp60task.cpp | 5 +- 26 files changed, 527 insertions(+), 632 deletions(-) diff --git a/lib/obp60task/OBP60Extensions.cpp b/lib/obp60task/OBP60Extensions.cpp index 2fa4bc6..85393e1 100644 --- a/lib/obp60task/OBP60Extensions.cpp +++ b/lib/obp60task/OBP60Extensions.cpp @@ -314,16 +314,23 @@ void displayHeader(CommonData &commonData, GwApi::BoatValue *date, GwApi::BoatVa usbRxOld = commonData.status.usbRx; usbTxOld = commonData.status.usbTx; + // Display key lock status + if (commonData.keylock) { + getdisplay().drawXBitmap(150, 1, lock_bits, icon_width, icon_height, commonData.fgcolor); + } else { + getdisplay().drawXBitmap(150, 1, swipe_bits, icon_width, icon_height, commonData.fgcolor); + } + + // Current page number in a small box + getdisplay().setFont(&Ubuntu_Bold8pt7b); + getdisplay().drawRect(170, 2, 20, 15, textcolor); + drawTextCenter(179, 9, String(commonData.data.actpage)); + // Heartbeat as dot getdisplay().setTextColor(textcolor); getdisplay().setFont(&Ubuntu_Bold32pt7b); getdisplay().setCursor(205, 14); - if(heartbeat == true){ - getdisplay().print("."); - } - else{ - getdisplay().print(" "); - } + getdisplay().print(heartbeat ? "." : " "); heartbeat = !heartbeat; // Date and time diff --git a/lib/obp60task/OBP60Extensions.h b/lib/obp60task/OBP60Extensions.h index 5ab4caa..effeddd 100644 --- a/lib/obp60task/OBP60Extensions.h +++ b/lib/obp60task/OBP60Extensions.h @@ -9,6 +9,8 @@ // FRAM address reservations 32kB: 0x0000 - 0x7FFF // 0x0000 - 0x03ff: single variables +#define FRAM_PAGE_NO 0x0002 +// Voltage page #define FRAM_VOLTAGE_AVG 0x000A #define FRAM_VOLTAGE_TREND 0x000B #define FRAM_VOLTAGE_MODE 0x000C @@ -19,7 +21,7 @@ extern Adafruit_FRAM_I2C fram; extern bool hasFRAM; -// Fonts declarations for display (#inclues see OBP60Extensions.cpp) +// Fonts declarations for display (#includes see OBP60Extensions.cpp) extern const GFXfont Ubuntu_Bold8pt7b; extern const GFXfont Ubuntu_Bold10pt7b; extern const GFXfont Ubuntu_Bold12pt7b; @@ -32,7 +34,21 @@ extern const GFXfont DSEG7Classic_BoldItalic30pt7b; extern const GFXfont DSEG7Classic_BoldItalic42pt7b; extern const GFXfont DSEG7Classic_BoldItalic60pt7b; -// Gloabl functions +// Icons +#define icon_width 16 +#define icon_height 16 + +static unsigned char swipe_bits[] PROGMEM = { + 0x80, 0x03, 0xe0, 0x06, 0xb0, 0x0a, 0xa8, 0x0a, 0xa8, 0x0a, 0xa8, 0x3a, + 0x28, 0x28, 0x08, 0x28, 0x08, 0x28, 0x08, 0x26, 0x08, 0x21, 0x08, 0x10, + 0x10, 0x08, 0x10, 0x04, 0x10, 0x04, 0x00, 0x00 }; + +static unsigned char lock_bits[] PROGMEM = { + 0xc0, 0x03, 0x60, 0x06, 0x30, 0x0c, 0x10, 0x08, 0x10, 0x08, 0x10, 0x08, + 0xfc, 0x3f, 0x04, 0x20, 0x04, 0x20, 0x84, 0x21, 0x84, 0x21, 0x84, 0x21, + 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0xfc, 0x3f }; + +// Global functions #ifdef DISPLAY_GDEW042T2 GxEPD2_BW & getdisplay(); #endif diff --git a/lib/obp60task/PageApparentWind.cpp b/lib/obp60task/PageApparentWind.cpp index 50be31c..6f0713b 100644 --- a/lib/obp60task/PageApparentWind.cpp +++ b/lib/obp60task/PageApparentWind.cpp @@ -5,12 +5,12 @@ class PageApparentWind : public Page { -bool keylock = false; // Keylock int16_t lp = 80; // Pointer length public: PageApparentWind(CommonData &common){ - common.logger->logDebug(GwLog::LOG,"Show PageApparentWind"); + commonData = &common; + common.logger->logDebug(GwLog::LOG,"Instantiate PageApparentWind"); } // Key functions @@ -33,18 +33,18 @@ public: return 0; // Commit the key } - // Keylock function - if(key == 11){ // Code for keylock - keylock = !keylock; // Toggle keylock + // Code for keylock + if(key == 11){ + commonData->keylock = !commonData->keylock; return 0; // Commit the key } return key; } - virtual void displayPage(CommonData &commonData, PageData &pageData) + virtual void displayPage(PageData &pageData) { - GwConfigHandler *config = commonData.config; - GwLog *logger=commonData.logger; + GwConfigHandler *config = commonData->config; + GwLog *logger = commonData->logger; static String svalue1old = ""; static String unit1old = ""; @@ -64,8 +64,8 @@ public: name1 = name1.substring(0, 6); // String length limit for value name double value1 = bvalue1->value; // Value as double in SI unit // bool valid1 = bvalue1->valid; // Valid information - String svalue1 = formatValue(bvalue1, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit1 = formatValue(bvalue1, commonData).unit; // Unit of value + String svalue1 = formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit1 = formatValue(bvalue1, *commonData).unit; // Unit of value // Get boat values for AWD GwApi::BoatValue *bvalue2 = pageData.values[1]; // First element in list (only one value by PageOneValue) @@ -73,8 +73,8 @@ public: name2 = name2.substring(0, 6); // String length limit for value name double value2 = bvalue2->value; // Value as double in SI unit // bool valid2 = bvalue2->valid; // Valid information - String svalue2 = formatValue(bvalue2, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit2 = formatValue(bvalue2, commonData).unit; // Unit of value + String svalue2 = formatValue(bvalue2, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit2 = formatValue(bvalue2, *commonData).unit; // Unit of value // Optical warning by limit violation (unused) if(String(flashLED) == "Limit Violation"){ @@ -92,7 +92,7 @@ public: // Set display in partial refresh mode getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update - getdisplay().setTextColor(commonData.fgcolor); + getdisplay().setTextColor(commonData->fgcolor); // Show values AWS getdisplay().setFont(&Ubuntu_Bold20pt7b); @@ -139,8 +139,8 @@ public: static int16_t y2 = y0; //Draw instrument - getdisplay().fillCircle(x0, y0, lp + 5, commonData.fgcolor); - getdisplay().fillCircle(x0, y0, lp + 1, commonData.bgcolor); + getdisplay().fillCircle(x0, y0, lp + 5, commonData->fgcolor); + getdisplay().fillCircle(x0, y0, lp + 1, commonData->bgcolor); // Calculation end point of pointer value2 = value2 - 3.14 / 2; @@ -148,22 +148,16 @@ public: y1 = y0 + sin(value2) * lp * 0.6; x2 = x0 + cos(value2) * lp; y2 = y0 + sin(value2) * lp; - getdisplay().drawLine(x1, y1, x2, y2, commonData.fgcolor); + getdisplay().drawLine(x1, y1, x2, y2, commonData->fgcolor); // Key Layout getdisplay().setFont(&Ubuntu_Bold8pt7b); - if(keylock == false){ - getdisplay().setCursor(130, 290); - getdisplay().print("[ <<<< " + String(commonData.data.actpage) + "/" + String(commonData.data.maxpage) + " >>>> ]"); + if(commonData->keylock == false){ if(String(backlightMode) == "Control by Key"){ // Key for illumination getdisplay().setCursor(343, 290); getdisplay().print("[ILUM]"); } } - else{ - getdisplay().setCursor(130, 290); - getdisplay().print(" [ Keylock active ]"); - } // Update display getdisplay().nextPage(); // Partial update (fast) diff --git a/lib/obp60task/PageBME280.cpp b/lib/obp60task/PageBME280.cpp index d7893d2..3b68de6 100644 --- a/lib/obp60task/PageBME280.cpp +++ b/lib/obp60task/PageBME280.cpp @@ -5,24 +5,24 @@ class PageBME280 : public Page { - bool keylock = false; // Keylock - public: PageBME280(CommonData &common){ - common.logger->logDebug(GwLog::LOG,"Show PageBME280"); + commonData = &common; + common.logger->logDebug(GwLog::LOG,"Instantiate PageBME280"); } virtual int handleKey(int key){ - if(key == 11){ // Code for keylock - keylock = !keylock; // Toggle keylock + // Code for keylock + if(key == 11){ + commonData->keylock = !commonData->keylock; return 0; // Commit the key } return key; } - virtual void displayPage(CommonData &commonData, PageData &pageData){ - GwConfigHandler *config = commonData.config; - GwLog *logger=commonData.logger; + virtual void displayPage(PageData &pageData){ + GwConfigHandler *config = commonData->config; + GwLog *logger = commonData->logger; double value1 = 0; double value2 = 0; @@ -42,7 +42,7 @@ class PageBME280 : public Page String name1 = "Temp"; // Value name name1 = name1.substring(0, 6); // String length limit for value name if(simulation == false){ - value1 = commonData.data.airTemperature; // Value as double in SI unit + value1 = commonData->data.airTemperature; // Value as double in SI unit } else{ value1 = 23.0 + float(random(0, 10)) / 10.0; @@ -60,7 +60,7 @@ class PageBME280 : public Page String name2 = "Humid"; // Value name name2 = name2.substring(0, 6); // String length limit for value name if(simulation == false){ - value2 = commonData.data.airHumidity; // Value as double in SI unit + value2 = commonData->data.airHumidity; // Value as double in SI unit } else{ value2 = 43 + float(random(0, 4)); @@ -78,7 +78,7 @@ class PageBME280 : public Page String name3 = "Press"; // Value name name3 = name3.substring(0, 6); // String length limit for value name if(simulation == false){ - value3 = commonData.data.airPressure; // Value as double in SI unit + value3 = commonData->data.airPressure; // Value as double in SI unit } else{ value3 = 1006 + float(random(0, 5)); @@ -107,7 +107,7 @@ class PageBME280 : public Page // Set display in partial refresh mode getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update - getdisplay().setTextColor(commonData.fgcolor); + getdisplay().setTextColor(commonData->fgcolor); // ############### Value 1 ################ @@ -131,7 +131,7 @@ class PageBME280 : public Page // ############### Horizontal Line ################ // Horizontal line 3 pix - getdisplay().fillRect(0, 105, 400, 3, commonData.fgcolor); + getdisplay().fillRect(0, 105, 400, 3, commonData->fgcolor); // ############### Value 2 ################ @@ -155,7 +155,7 @@ class PageBME280 : public Page // ############### Horizontal Line ################ // Horizontal line 3 pix - getdisplay().fillRect(0, 195, 400, 3, commonData.fgcolor); + getdisplay().fillRect(0, 195, 400, 3, commonData->fgcolor); // ############### Value 3 ################ @@ -180,18 +180,12 @@ class PageBME280 : public Page // Key Layout getdisplay().setFont(&Ubuntu_Bold8pt7b); - if(keylock == false){ - getdisplay().setCursor(130, 290); - getdisplay().print("[ <<<< " + String(commonData.data.actpage) + "/" + String(commonData.data.maxpage) + " >>>> ]"); + if(commonData->keylock == false){ if(String(backlightMode) == "Control by Key"){ // Key for illumination getdisplay().setCursor(343, 290); getdisplay().print("[ILUM]"); } } - else{ - getdisplay().setCursor(130, 290); - getdisplay().print(" [ Keylock active ]"); - } // Update display getdisplay().nextPage(); // Partial update (fast) diff --git a/lib/obp60task/PageBattery.cpp b/lib/obp60task/PageBattery.cpp index 6322981..1b12d93 100644 --- a/lib/obp60task/PageBattery.cpp +++ b/lib/obp60task/PageBattery.cpp @@ -5,12 +5,12 @@ class PageBattery : public Page { - bool keylock = false; // Keylock int average = 0; // Average type [0...3], 0=off, 1=10s, 2=60s, 3=300s public: PageBattery(CommonData &common){ - common.logger->logDebug(GwLog::LOG,"Show PageBattery"); + commonData = &common; + common.logger->logDebug(GwLog::LOG,"Instantiate PageBattery"); } virtual int handleKey(int key){ @@ -23,15 +23,15 @@ class PageBattery : public Page // Code for keylock if(key == 11){ - keylock = !keylock; // Toggle keylock + commonData->keylock = !commonData->keylock; return 0; // Commit the key } return key; } - virtual void displayPage(CommonData &commonData, PageData &pageData){ - GwConfigHandler *config = commonData.config; - GwLog *logger=commonData.logger; + virtual void displayPage(PageData &pageData){ + GwConfigHandler *config = commonData->config; + GwLog *logger = commonData->logger; // Old values for hold function double value1 = 0; @@ -58,19 +58,19 @@ class PageBattery : public Page // Switch average values switch (average) { case 0: - value1 = commonData.data.batteryVoltage; // Live data + value1 = commonData->data.batteryVoltage; // Live data break; case 1: - value1 = commonData.data.batteryVoltage10; // Average 10s + value1 = commonData->data.batteryVoltage10; // Average 10s break; case 2: - value1 = commonData.data.batteryVoltage60; // Average 60s + value1 = commonData->data.batteryVoltage60; // Average 60s break; case 3: - value1 = commonData.data.batteryVoltage300; // Average 300s + value1 = commonData->data.batteryVoltage300; // Average 300s break; default: - value1 = commonData.data.batteryVoltage; // Default + value1 = commonData->data.batteryVoltage; // Default break; } } @@ -87,19 +87,19 @@ class PageBattery : public Page if(String(powsensor1) == "INA219" || String(powsensor1) == "INA226"){ switch (average) { case 0: - value2 = commonData.data.batteryCurrent; // Live data + value2 = commonData->data.batteryCurrent; // Live data break; case 1: - value2 = commonData.data.batteryCurrent10; // Average 10s + value2 = commonData->data.batteryCurrent10; // Average 10s break; case 2: - value2 = commonData.data.batteryCurrent60; // Average 60s + value2 = commonData->data.batteryCurrent60; // Average 60s break; case 3: - value2 = commonData.data.batteryCurrent300; // Average 300s + value2 = commonData->data.batteryCurrent300; // Average 300s break; default: - value2 = commonData.data.batteryCurrent; // Default + value2 = commonData->data.batteryCurrent; // Default break; } } @@ -116,19 +116,19 @@ class PageBattery : public Page if(String(powsensor1) == "INA219" || String(powsensor1) == "INA226"){ switch (average) { case 0: - value3 = commonData.data.batteryPower; // Live data + value3 = commonData->data.batteryPower; // Live data break; case 1: - value3 = commonData.data.batteryPower10; // Average 10s + value3 = commonData->data.batteryPower10; // Average 10s break; case 2: - value3 = commonData.data.batteryPower60; // Average 60s + value3 = commonData->data.batteryPower60; // Average 60s break; case 3: - value3 = commonData.data.batteryPower300; // Average 300s + value3 = commonData->data.batteryPower300; // Average 300s break; default: - value3 = commonData.data.batteryPower; // Default + value3 = commonData->data.batteryPower; // Default break; } } @@ -156,7 +156,7 @@ class PageBattery : public Page getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update // Show average settings - getdisplay().setTextColor(commonData.fgcolor); + getdisplay().setTextColor(commonData->fgcolor); getdisplay().setFont(&Ubuntu_Bold8pt7b); switch (average) { case 0: @@ -228,7 +228,7 @@ class PageBattery : public Page // ############### Horizontal Line ################ // Horizontal line 3 pix - getdisplay().fillRect(0, 105, 400, 3, commonData.fgcolor); + getdisplay().fillRect(0, 105, 400, 3, commonData->fgcolor); // ############### Value 2 ################ @@ -257,7 +257,7 @@ class PageBattery : public Page // ############### Horizontal Line ################ // Horizontal line 3 pix - getdisplay().fillRect(0, 195, 400, 3, commonData.fgcolor); + getdisplay().fillRect(0, 195, 400, 3, commonData->fgcolor); // ############### Value 3 ################ @@ -288,20 +288,14 @@ class PageBattery : public Page // Key Layout getdisplay().setFont(&Ubuntu_Bold8pt7b); - if(keylock == false){ + if(commonData->keylock == false){ getdisplay().setCursor(10, 290); getdisplay().print("[AVG]"); - getdisplay().setCursor(130, 290); - getdisplay().print("[ <<<< " + String(commonData.data.actpage) + "/" + String(commonData.data.maxpage) + " >>>> ]"); if(String(backlightMode) == "Control by Key"){ // Key for illumination getdisplay().setCursor(343, 290); getdisplay().print("[ILUM]"); } } - else{ - getdisplay().setCursor(130, 290); - getdisplay().print(" [ Keylock active ]"); - } // Update display getdisplay().nextPage(); // Partial update (fast) diff --git a/lib/obp60task/PageBattery2.cpp b/lib/obp60task/PageBattery2.cpp index 8c3bd44..4cb4a40 100644 --- a/lib/obp60task/PageBattery2.cpp +++ b/lib/obp60task/PageBattery2.cpp @@ -7,14 +7,14 @@ class PageBattery2 : public Page { bool init = false; // Marker for init done -bool keylock = false; // Keylock int average = 0; // Average type [0...3], 0=off, 1=10s, 2=60s, 3=300s bool trend = true; // Trend indicator [0|1], 0=off, 1=on double raw = 0; public: PageBattery2(CommonData &common){ - common.logger->logDebug(GwLog::LOG,"Show PageBattery2"); + commonData = &common; + common.logger->logDebug(GwLog::LOG,"Instantiate PageBattery2"); } virtual int handleKey(int key){ // Change average @@ -32,16 +32,16 @@ public: // Code for keylock if(key == 11){ - keylock = !keylock; // Toggle keylock + commonData->keylock = !commonData->keylock; return 0; // Commit the key } return key; } - virtual void displayPage(CommonData &commonData, PageData &pageData) + virtual void displayPage(PageData &pageData) { - GwConfigHandler *config = commonData.config; - GwLog *logger=commonData.logger; + GwConfigHandler *config = commonData->config; + GwLog *logger = commonData->logger; // Polynominal coefficients second order for battery energy level calculation // index 0 = Pb, 1 = Gel, 2 = AGM, 3 = LiFePo4 @@ -71,42 +71,42 @@ public: // Create trend value if(init == false){ // Load start values for first page run - valueTrend = commonData.data.batteryVoltage10; + valueTrend = commonData->data.batteryVoltage10; init = true; } else{ // Reading trend value - valueTrend = commonData.data.batteryVoltage10; + valueTrend = commonData->data.batteryVoltage10; } // Get raw value for trend indicator - raw = commonData.data.batteryVoltage; // Live data + raw = commonData->data.batteryVoltage; // Live data // Switch average values switch (average) { case 0: - value1 = commonData.data.batteryVoltage; // Live data - value2 = commonData.data.batteryCurrent; - value3 = commonData.data.batteryPower; + value1 = commonData->data.batteryVoltage; // Live data + value2 = commonData->data.batteryCurrent; + value3 = commonData->data.batteryPower; break; case 1: - value1 = commonData.data.batteryVoltage10; // Average 10s - value2 = commonData.data.batteryCurrent10; - value3 = commonData.data.batteryPower10; + value1 = commonData->data.batteryVoltage10; // Average 10s + value2 = commonData->data.batteryCurrent10; + value3 = commonData->data.batteryPower10; break; case 2: - value1 = commonData.data.batteryVoltage60; // Average 60s - value2 = commonData.data.batteryCurrent60; - value3 = commonData.data.batteryPower60; + value1 = commonData->data.batteryVoltage60; // Average 60s + value2 = commonData->data.batteryCurrent60; + value3 = commonData->data.batteryPower60; break; case 3: - value1 = commonData.data.batteryVoltage300; // Average 300s - value2 = commonData.data.batteryCurrent300; - value3 = commonData.data.batteryPower300; + value1 = commonData->data.batteryVoltage300; // Average 300s + value2 = commonData->data.batteryCurrent300; + value3 = commonData->data.batteryPower300; break; default: - value1 = commonData.data.batteryVoltage; // Default - value2 = commonData.data.batteryCurrent; - value3 = commonData.data.batteryPower; + value1 = commonData->data.batteryVoltage; // Default + value2 = commonData->data.batteryCurrent; + value3 = commonData->data.batteryPower; break; } bool valid1 = true; @@ -180,7 +180,7 @@ public: // Set display in partial refresh mode getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update - getdisplay().setTextColor(commonData.fgcolor); + getdisplay().setTextColor(commonData->fgcolor); // Show name getdisplay().setFont(&Ubuntu_Bold20pt7b); @@ -219,7 +219,7 @@ public: getdisplay().print("Battery Type"); // Show battery with fill level - batteryGraphic(150, 45, batPercentage, commonData.fgcolor, commonData.bgcolor); + batteryGraphic(150, 45, batPercentage, commonData->fgcolor, commonData->bgcolor); // Show average settings getdisplay().setFont(&Ubuntu_Bold8pt7b); @@ -330,20 +330,14 @@ public: // Key Layout getdisplay().setFont(&Ubuntu_Bold8pt7b); - if(keylock == false){ + if(commonData->keylock == false){ getdisplay().setCursor(10, 290); getdisplay().print("[AVG]"); - getdisplay().setCursor(130, 290); - getdisplay().print("[ <<<< " + String(commonData.data.actpage) + "/" + String(commonData.data.maxpage) + " >>>> ]"); if(String(backlightMode) == "Control by Key"){ // Key for illumination getdisplay().setCursor(343, 290); getdisplay().print("[ILUM]"); } } - else{ - getdisplay().setCursor(130, 290); - getdisplay().print(" [ Keylock active ]"); - } // Update display getdisplay().nextPage(); // Partial update (fast) diff --git a/lib/obp60task/PageClock.cpp b/lib/obp60task/PageClock.cpp index c93949b..f99679a 100644 --- a/lib/obp60task/PageClock.cpp +++ b/lib/obp60task/PageClock.cpp @@ -5,27 +5,26 @@ class PageClock : public Page { -bool keylock = false; // Keylock - public: PageClock(CommonData &common){ - common.logger->logDebug(GwLog::LOG,"Show PageClock"); + commonData = &common; + common.logger->logDebug(GwLog::LOG,"Instantiate PageClock"); } // Key functions virtual int handleKey(int key){ - // Keylock function - if(key == 11){ // Code for keylock - keylock = !keylock; // Toggle keylock + // Code for keylock + if(key == 11){ + commonData->keylock = !commonData->keylock; return 0; // Commit the key } return key; } - virtual void displayPage(CommonData &commonData, PageData &pageData) + virtual void displayPage(PageData &pageData) { - GwConfigHandler *config = commonData.config; - GwLog *logger=commonData.logger; + GwConfigHandler *config = commonData->config; + GwLog *logger = commonData->logger; static String svalue1old = ""; static String unit1old = ""; @@ -61,8 +60,8 @@ public: value1 = 38160; // Simulation data for time value 11:36 in seconds } // Other simulation data see OBP60Formater.cpp bool valid1 = bvalue1->valid; // Valid information - String svalue1 = formatValue(bvalue1, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit1 = formatValue(bvalue1, commonData).unit; // Unit of value + String svalue1 = formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit1 = formatValue(bvalue1, *commonData).unit; // Unit of value if(valid1 == true){ svalue1old = svalue1; // Save old value unit1old = unit1; // Save old unit @@ -74,8 +73,8 @@ public: name2 = name2.substring(0, 6); // String length limit for value name value2 = bvalue2->value; // Value as double in SI unit bool valid2 = bvalue2->valid; // Valid information - String svalue2 = formatValue(bvalue2, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit2 = formatValue(bvalue2, commonData).unit; // Unit of value + String svalue2 = formatValue(bvalue2, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit2 = formatValue(bvalue2, *commonData).unit; // Unit of value if(valid2 == true){ svalue2old = svalue2; // Save old value unit2old = unit2; // Save old unit @@ -87,8 +86,8 @@ public: name3 = name3.substring(0, 6); // String length limit for value name value3 = bvalue3->value; // Value as double in SI unit bool valid3 = bvalue3->valid; // Valid information - String svalue3 = formatValue(bvalue3, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit3 = formatValue(bvalue3, commonData).unit; // Unit of value + String svalue3 = formatValue(bvalue3, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit3 = formatValue(bvalue3, *commonData).unit; // Unit of value if(valid3 == true){ svalue3old = svalue3; // Save old value unit3old = unit3; // Save old unit @@ -110,7 +109,7 @@ public: // Set display in partial refresh mode getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update - getdisplay().setTextColor(commonData.fgcolor); + getdisplay().setTextColor(commonData->fgcolor); // Show values GPS date getdisplay().setFont(&Ubuntu_Bold8pt7b); @@ -122,7 +121,7 @@ public: getdisplay().print("Date"); // Name // Horizintal separator left - getdisplay().fillRect(0, 149, 60, 3, commonData.fgcolor); + getdisplay().fillRect(0, 149, 60, 3, commonData->fgcolor); // Show values GPS time getdisplay().setFont(&Ubuntu_Bold8pt7b); @@ -136,7 +135,7 @@ public: // Show values sunrise String sunrise = "---"; if(valid1 == true && valid2 == true && valid3 == true){ - sunrise = String(commonData.sundata.sunriseHour) + ":" + String(commonData.sundata.sunriseMinute + 100).substring(1); + sunrise = String(commonData->sundata.sunriseHour) + ":" + String(commonData->sundata.sunriseMinute + 100).substring(1); svalue5old = sunrise; } @@ -149,12 +148,12 @@ public: getdisplay().print("SunR"); // Name // Horizintal separator right - getdisplay().fillRect(340, 149, 80, 3, commonData.fgcolor); + getdisplay().fillRect(340, 149, 80, 3, commonData->fgcolor); // Show values sunset String sunset = "---"; if(valid1 == true && valid2 == true && valid3 == true){ - sunset = String(commonData.sundata.sunsetHour) + ":" + String(commonData.sundata.sunsetMinute + 100).substring(1); + sunset = String(commonData->sundata.sunsetHour) + ":" + String(commonData->sundata.sunsetMinute + 100).substring(1); svalue6old = sunset; } @@ -172,8 +171,8 @@ public: int rInstrument = 110; // Radius of clock float pi = 3.141592; - getdisplay().fillCircle(200, 150, rInstrument + 10, commonData.fgcolor); // Outer circle - getdisplay().fillCircle(200, 150, rInstrument + 7, commonData.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) { @@ -214,7 +213,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, commonData.fgcolor); + getdisplay().fillCircle((int)x1c, (int)y1c, 2, commonData->fgcolor); sinx=sin(i/180.0*pi); cosx=cos(i/180.0*pi); } @@ -228,10 +227,10 @@ 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),commonData.fgcolor); + 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),commonData.fgcolor); + 200+(int)(cosx*xx2-sinx*yy2),150+(int)(sinx*xx2+cosx*yy2),commonData->fgcolor); } } @@ -270,7 +269,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),commonData.fgcolor); + 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 @@ -280,7 +279,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),commonData.fgcolor); + 200+(int)(cosx*0-sinx*iy2),150+(int)(sinx*0+cosx*iy2),commonData->fgcolor); } // Draw minute pointer @@ -296,7 +295,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),commonData.fgcolor); + 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 @@ -306,28 +305,22 @@ 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),commonData.fgcolor); + 200+(int)(cosx*0-sinx*iy2),150+(int)(sinx*0+cosx*iy2),commonData->fgcolor); } // Center circle - getdisplay().fillCircle(200, 150, startwidth + 6, commonData.bgcolor); - getdisplay().fillCircle(200, 150, startwidth + 4, commonData.fgcolor); + getdisplay().fillCircle(200, 150, startwidth + 6, commonData->bgcolor); + getdisplay().fillCircle(200, 150, startwidth + 4, commonData->fgcolor); //******************************************************************************************* // Key Layout getdisplay().setFont(&Ubuntu_Bold8pt7b); - if(keylock == false){ - getdisplay().setCursor(130, 290); - getdisplay().print("[ <<<< " + String(commonData.data.actpage) + "/" + String(commonData.data.maxpage) + " >>>> ]"); + if(commonData->keylock == false){ if(String(backlightMode) == "Control by Key"){ // Key for illumination getdisplay().setCursor(343, 290); getdisplay().print("[ILUM]"); } } - else{ - getdisplay().setCursor(130, 290); - getdisplay().print(" [ Keylock active ]"); - } // Update display getdisplay().nextPage(); // Partial update (fast) diff --git a/lib/obp60task/PageDST810.cpp b/lib/obp60task/PageDST810.cpp index 89f6e7b..568e3e2 100644 --- a/lib/obp60task/PageDST810.cpp +++ b/lib/obp60task/PageDST810.cpp @@ -5,24 +5,24 @@ class PageDST810 : public Page { - bool keylock = false; // Keylock - - public: +public: PageDST810(CommonData &common){ - common.logger->logDebug(GwLog::LOG,"Show PageDST810"); + commonData = &common; + common.logger->logDebug(GwLog::LOG,"Instantiate PageDST810"); } virtual int handleKey(int key){ - if(key == 11){ // Code for keylock - keylock = !keylock; // Toggle keylock + // Code for keylock + if(key == 11){ + commonData->keylock = !commonData->keylock; return 0; // Commit the key } return key; } - virtual void displayPage(CommonData &commonData, PageData &pageData){ - GwConfigHandler *config = commonData.config; - GwLog *logger=commonData.logger; + virtual void displayPage(PageData &pageData){ + GwConfigHandler *config = commonData->config; + GwLog *logger = commonData->logger; // Old values for hold function static String svalue1old = ""; @@ -47,8 +47,8 @@ class PageDST810 : public Page name1 = name1.substring(0, 6); // String length limit for value name double value1 = bvalue1->value; // Value as double in SI unit bool valid1 = bvalue1->valid; // Valid information - String svalue1 = formatValue(bvalue1, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit1 = formatValue(bvalue1, commonData).unit; // Unit of value + String svalue1 = formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit1 = formatValue(bvalue1, *commonData).unit; // Unit of value // Get boat values #2 GwApi::BoatValue *bvalue2 = pageData.values[1]; // Second element in list (only one value by PageOneValue) @@ -56,8 +56,8 @@ class PageDST810 : public Page name2 = name2.substring(0, 6); // String length limit for value name double value2 = bvalue2->value; // Value as double in SI unit bool valid2 = bvalue2->valid; // Valid information - String svalue2 = formatValue(bvalue2, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit2 = formatValue(bvalue2, commonData).unit; // Unit of value + String svalue2 = formatValue(bvalue2, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit2 = formatValue(bvalue2, *commonData).unit; // Unit of value // Get boat values #3 GwApi::BoatValue *bvalue3 = pageData.values[2]; // Second element in list (only one value by PageOneValue) @@ -65,8 +65,8 @@ class PageDST810 : public Page name3 = name3.substring(0, 6); // String length limit for value name double value3 = bvalue3->value; // Value as double in SI unit bool valid3 = bvalue3->valid; // Valid information - String svalue3 = formatValue(bvalue3, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit3 = formatValue(bvalue3, commonData).unit; // Unit of value + String svalue3 = formatValue(bvalue3, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit3 = formatValue(bvalue3, *commonData).unit; // Unit of value // Get boat values #4 GwApi::BoatValue *bvalue4 = pageData.values[3]; // Second element in list (only one value by PageOneValue) @@ -74,8 +74,8 @@ class PageDST810 : public Page name4 = name4.substring(0, 6); // String length limit for value name double value4 = bvalue4->value; // Value as double in SI unit bool valid4 = bvalue4->valid; // Valid information - String svalue4 = formatValue(bvalue4, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit4 = formatValue(bvalue4, commonData).unit; // Unit of value + String svalue4 = formatValue(bvalue4, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit4 = formatValue(bvalue4, *commonData).unit; // Unit of value // Optical warning by limit violation (unused) if(String(flashLED) == "Limit Violation"){ @@ -93,7 +93,7 @@ class PageDST810 : public Page // Set display in partial refresh mode getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update - getdisplay().setTextColor(commonData.fgcolor); + getdisplay().setTextColor(commonData->fgcolor); // ############### Value 1 ################ @@ -131,7 +131,7 @@ class PageDST810 : public Page // ############### Horizontal Line ################ // Horizontal line 3 pix - getdisplay().fillRect(0, 105, 400, 3, commonData.fgcolor); + getdisplay().fillRect(0, 105, 400, 3, commonData->fgcolor); // ############### Value 2 ################ @@ -169,7 +169,7 @@ class PageDST810 : public Page // ############### Horizontal Line ################ // Horizontal line 3 pix - getdisplay().fillRect(0, 195, 400, 3, commonData.fgcolor); + getdisplay().fillRect(0, 195, 400, 3, commonData->fgcolor); // ############### Value 3 ################ @@ -207,7 +207,7 @@ class PageDST810 : public Page // ############### Vertical Line ################ // Vertical line 3 pix - getdisplay().fillRect(200, 195, 3, 75, commonData.fgcolor); + getdisplay().fillRect(200, 195, 3, 75, commonData->fgcolor); // ############### Value 4 ################ @@ -247,18 +247,12 @@ class PageDST810 : public Page // Key Layout getdisplay().setFont(&Ubuntu_Bold8pt7b); - if(keylock == false){ - getdisplay().setCursor(130, 290); - getdisplay().print("[ <<<< " + String(commonData.data.actpage) + "/" + String(commonData.data.maxpage) + " >>>> ]"); + if(commonData->keylock == false){ if(String(backlightMode) == "Control by Key"){ // Key for illumination getdisplay().setCursor(343, 290); getdisplay().print("[ILUM]"); } } - else{ - getdisplay().setCursor(130, 290); - getdisplay().print(" [ Keylock active ]"); - } // Update display getdisplay().nextPage(); // Partial update (fast) diff --git a/lib/obp60task/PageFluid.cpp b/lib/obp60task/PageFluid.cpp index 9d4a092..6c12635 100644 --- a/lib/obp60task/PageFluid.cpp +++ b/lib/obp60task/PageFluid.cpp @@ -57,31 +57,33 @@ static unsigned char gasoline_bits[] = { 0x98, 0xcf, 0x38, 0xe7, 0x78, 0xf0, 0xf8, 0xfa, 0xf8, 0xfa, 0x78, 0xf0, 0x38, 0xe7, 0x98, 0xcf, 0xf8, 0xff, 0xf0, 0x7f }; -class PageFluid : public Page{ - bool keylock = false; // Keylock +class PageFluid : public Page +{ int fluidtype; public: PageFluid(CommonData &common){ + commonData = &common; common.logger->logDebug(GwLog::LOG,"Instantiate PageFluid"); } virtual int handleKey(int key){ - if(key == 11){ // Code for keylock - keylock = !keylock; // Toggle keylock + // Code for keylock + if(key == 11){ + commonData->keylock = !commonData->keylock; return 0; // Commit the key } return key; } - virtual void displayNew(CommonData &commonData, PageData &pageData){ - fluidtype = commonData.config->getInt("page" + String(pageData.pageNumber) + "fluid", 0); - commonData.logger->logDebug(GwLog::LOG,"New PageFluid: fluidtype=%d", fluidtype); + virtual void displayNew(PageData &pageData){ + fluidtype = commonData->config->getInt("page" + String(pageData.pageNumber) + "fluid", 0); + commonData->logger->logDebug(GwLog::LOG,"New PageFluid: fluidtype=%d", fluidtype); } - virtual void displayPage(CommonData &commonData, PageData &pageData){ - GwConfigHandler *config = commonData.config; - GwLog *logger=commonData.logger; + virtual void displayPage(PageData &pageData){ + GwConfigHandler *config = commonData->config; + GwLog *logger = commonData->logger; // Get config data String flashLED = config->getString(config->flashLED); @@ -107,7 +109,7 @@ class PageFluid : public Page{ // Set display in partial refresh mode getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); - getdisplay().setTextColor(commonData.fgcolor); + getdisplay().setTextColor(commonData->fgcolor); // descriptions getdisplay().setFont(&Ubuntu_Bold12pt7b); @@ -125,11 +127,11 @@ class PageFluid : public Page{ uint8_t r = 110; // circular frame - getdisplay().drawCircle(c.x, c.y, r+5, commonData.fgcolor); - getdisplay().fillCircle(c.x, c.y, r+2, commonData.fgcolor); - getdisplay().fillCircle(c.x, c.y, r-1, commonData.bgcolor); + getdisplay().drawCircle(c.x, c.y, r+5, commonData->fgcolor); + getdisplay().fillCircle(c.x, c.y, r+2, commonData->fgcolor); + getdisplay().fillCircle(c.x, c.y, r-1, commonData->bgcolor); // center of pointer as dot - getdisplay().fillCircle(c.x, c.y, 8, commonData.fgcolor); + getdisplay().fillCircle(c.x, c.y, 8, commonData->fgcolor); // value down centered char buffer[6]; @@ -143,19 +145,19 @@ class PageFluid : public Page{ // draw symbol (as bitmap) switch (fluidtype) { case 0: - getdisplay().drawXBitmap(c.x-8, c.y-50, fuel_bits, fuel_width, fuel_height, commonData.fgcolor); + getdisplay().drawXBitmap(c.x-8, c.y-50, fuel_bits, fuel_width, fuel_height, commonData->fgcolor); break; case 1: - getdisplay().drawXBitmap(c.x-8, c.y-50, water_bits, water_width, water_height, commonData.fgcolor); + getdisplay().drawXBitmap(c.x-8, c.y-50, water_bits, water_width, water_height, commonData->fgcolor); break; case 4: - getdisplay().drawXBitmap(c.x-8, c.y-50, oil_bits, oil_width, oil_height, commonData.fgcolor); + getdisplay().drawXBitmap(c.x-8, c.y-50, oil_bits, oil_width, oil_height, commonData->fgcolor); break; case 5: - getdisplay().drawXBitmap(c.x-8, c.y-50, waste_bits, waste_width, waste_height, commonData.fgcolor); + getdisplay().drawXBitmap(c.x-8, c.y-50, waste_bits, waste_width, waste_height, commonData->fgcolor); break; case 6: - getdisplay().drawXBitmap(c.x-8, c.y-50, gasoline_bits, gasoline_width, gasoline_height, commonData.fgcolor); + getdisplay().drawXBitmap(c.x-8, c.y-50, gasoline_bits, gasoline_width, gasoline_height, commonData->fgcolor); break; } @@ -184,11 +186,11 @@ class PageFluid : public Page{ {c.x + 2, c.y - (r - 16)}, {c.x - 2, c.y - (r - 16)} }; - fillPoly4(rotatePoints(c, pts, -120), commonData.fgcolor); - fillPoly4(rotatePoints(c, pts, -60), commonData.fgcolor); - fillPoly4(rotatePoints(c, pts, 0), commonData.fgcolor); - fillPoly4(rotatePoints(c, pts, 60), commonData.fgcolor); - fillPoly4(rotatePoints(c, pts, 120), commonData.fgcolor); + fillPoly4(rotatePoints(c, pts, -120), commonData->fgcolor); + fillPoly4(rotatePoints(c, pts, -60), commonData->fgcolor); + fillPoly4(rotatePoints(c, pts, 0), commonData->fgcolor); + fillPoly4(rotatePoints(c, pts, 60), commonData->fgcolor); + fillPoly4(rotatePoints(c, pts, 120), commonData->fgcolor); // dots // rotate 0 to 360 in 12 degree steps @@ -197,7 +199,7 @@ class PageFluid : public Page{ continue; } p = rotatePoint(c, {c.x, c.y - r + 10}, angle); - getdisplay().fillCircle(p.x, p.y, 3, commonData.fgcolor); + getdisplay().fillCircle(p.x, p.y, 3, commonData->fgcolor); } // pointer @@ -208,25 +210,19 @@ class PageFluid : public Page{ {c.x + 6, c.y + 15}, {c.x - 6, c.y + 15} }; - fillPoly4(rotatePoints(c, pts, -120 + bvalue1->value * 2.4), commonData.fgcolor); + fillPoly4(rotatePoints(c, pts, -120 + bvalue1->value * 2.4), commonData->fgcolor); // Pointer axis is white - getdisplay().fillCircle(c.x, c.y, 6, commonData.bgcolor); + getdisplay().fillCircle(c.x, c.y, 6, commonData->bgcolor); } // Key Layout getdisplay().setFont(&Ubuntu_Bold8pt7b); - if(keylock == false){ - getdisplay().setCursor(130, 296); - getdisplay().print("[ <<<< " + String(commonData.data.actpage) + "/" + String(commonData.data.maxpage) + " >>>> ]"); + if(commonData->keylock == false){ if(String(backlightMode) == "Control by Key"){ // Key for illumination getdisplay().setCursor(343, 296); getdisplay().print("[ILUM]"); } } - else{ - getdisplay().setCursor(130, 296); - getdisplay().print(" [ Keylock active ]"); - } // Update display getdisplay().nextPage(); // Partial update (fast) diff --git a/lib/obp60task/PageFourValues.cpp b/lib/obp60task/PageFourValues.cpp index 1bad689..e0c418f 100644 --- a/lib/obp60task/PageFourValues.cpp +++ b/lib/obp60task/PageFourValues.cpp @@ -5,24 +5,24 @@ class PageFourValues : public Page { - bool keylock = false; // Keylock - public: PageFourValues(CommonData &common){ - common.logger->logDebug(GwLog::LOG,"Show PageFourValues"); + commonData = &common; + common.logger->logDebug(GwLog::LOG,"Instantiate PageFourValues"); } virtual int handleKey(int key){ - if(key == 11){ // Code for keylock - keylock = !keylock; // Toggle keylock + // Code for keylock + if(key == 11){ + commonData->keylock = !commonData->keylock; return 0; // Commit the key } return key; } - virtual void displayPage(CommonData &commonData, PageData &pageData){ - GwConfigHandler *config = commonData.config; - GwLog *logger=commonData.logger; + virtual void displayPage(PageData &pageData){ + GwConfigHandler *config = commonData->config; + GwLog *logger = commonData->logger; // Old values for hold function static String svalue1old = ""; @@ -47,8 +47,8 @@ class PageFourValues : public Page name1 = name1.substring(0, 6); // String length limit for value name double value1 = bvalue1->value; // Value as double in SI unit bool valid1 = bvalue1->valid; // Valid information - String svalue1 = formatValue(bvalue1, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit1 = formatValue(bvalue1, commonData).unit; // Unit of value + String svalue1 = formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit1 = formatValue(bvalue1, *commonData).unit; // Unit of value // Get boat values #2 GwApi::BoatValue *bvalue2 = pageData.values[1]; // Second element in list (only one value by PageOneValue) @@ -56,8 +56,8 @@ class PageFourValues : public Page name2 = name2.substring(0, 6); // String length limit for value name double value2 = bvalue2->value; // Value as double in SI unit bool valid2 = bvalue2->valid; // Valid information - String svalue2 = formatValue(bvalue2, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit2 = formatValue(bvalue2, commonData).unit; // Unit of value + String svalue2 = formatValue(bvalue2, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit2 = formatValue(bvalue2, *commonData).unit; // Unit of value // Get boat values #3 GwApi::BoatValue *bvalue3 = pageData.values[2]; // Second element in list (only one value by PageOneValue) @@ -65,8 +65,8 @@ class PageFourValues : public Page name3 = name3.substring(0, 6); // String length limit for value name double value3 = bvalue3->value; // Value as double in SI unit bool valid3 = bvalue3->valid; // Valid information - String svalue3 = formatValue(bvalue3, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit3 = formatValue(bvalue3, commonData).unit; // Unit of value + String svalue3 = formatValue(bvalue3, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit3 = formatValue(bvalue3, *commonData).unit; // Unit of value // Get boat values #4 GwApi::BoatValue *bvalue4 = pageData.values[3]; // Second element in list (only one value by PageOneValue) @@ -74,8 +74,8 @@ class PageFourValues : public Page name4 = name4.substring(0, 6); // String length limit for value name double value4 = bvalue4->value; // Value as double in SI unit bool valid4 = bvalue4->valid; // Valid information - String svalue4 = formatValue(bvalue4, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit4 = formatValue(bvalue4, commonData).unit; // Unit of value + String svalue4 = formatValue(bvalue4, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit4 = formatValue(bvalue4, *commonData).unit; // Unit of value // Optical warning by limit violation (unused) if(String(flashLED) == "Limit Violation"){ @@ -93,7 +93,7 @@ class PageFourValues : public Page // Set display in partial refresh mode getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update - getdisplay().setTextColor(commonData.fgcolor); + getdisplay().setTextColor(commonData->fgcolor); // ############### Value 1 ################ @@ -141,7 +141,7 @@ class PageFourValues : public Page // ############### Horizontal Line ################ // Horizontal line 3 pix - getdisplay().fillRect(0, 80, 400, 3, commonData.fgcolor); + getdisplay().fillRect(0, 80, 400, 3, commonData->fgcolor); // ############### Value 2 ################ @@ -189,7 +189,7 @@ class PageFourValues : public Page // ############### Horizontal Line ################ // Horizontal line 3 pix - getdisplay().fillRect(0, 146, 400, 3, commonData.fgcolor); + getdisplay().fillRect(0, 146, 400, 3, commonData->fgcolor); // ############### Value 3 ################ @@ -237,7 +237,7 @@ class PageFourValues : public Page // ############### Horizontal Line ################ // Horizontal line 3 pix - getdisplay().fillRect(0, 214, 400, 3, commonData.fgcolor); + getdisplay().fillRect(0, 214, 400, 3, commonData->fgcolor); // ############### Value 4 ################ @@ -287,18 +287,12 @@ class PageFourValues : public Page // Key Layout getdisplay().setFont(&Ubuntu_Bold8pt7b); - if(keylock == false){ - getdisplay().setCursor(130, 290); - getdisplay().print("[ <<<< " + String(commonData.data.actpage) + "/" + String(commonData.data.maxpage) + " >>>> ]"); + if(commonData->keylock == false){ if(String(backlightMode) == "Control by Key"){ // Key for illumination getdisplay().setCursor(343, 290); getdisplay().print("[ILUM]"); } } - else{ - getdisplay().setCursor(130, 290); - getdisplay().print(" [ Keylock active ]"); - } // Update display getdisplay().nextPage(); // Partial update (fast) diff --git a/lib/obp60task/PageFourValues2.cpp b/lib/obp60task/PageFourValues2.cpp index c7f5a1a..9f3f07b 100644 --- a/lib/obp60task/PageFourValues2.cpp +++ b/lib/obp60task/PageFourValues2.cpp @@ -5,24 +5,24 @@ class PageFourValues2 : public Page { - bool keylock = false; // Keylock - public: PageFourValues2(CommonData &common){ - common.logger->logDebug(GwLog::LOG,"Show PageFourValues2"); + commonData = &common; + common.logger->logDebug(GwLog::LOG,"Instantiate PageFourValues2"); } virtual int handleKey(int key){ - if(key == 11){ // Code for keylock - keylock = !keylock; // Toggle keylock + // Code for keylock + if(key == 11){ + commonData->keylock = !commonData->keylock; // Toggle keylock return 0; // Commit the key } return key; } - virtual void displayPage(CommonData &commonData, PageData &pageData){ - GwConfigHandler *config = commonData.config; - GwLog *logger=commonData.logger; + virtual void displayPage(PageData &pageData){ + GwConfigHandler *config = commonData->config; + GwLog *logger = commonData->logger; // Old values for hold function static String svalue1old = ""; @@ -47,8 +47,8 @@ class PageFourValues2 : public Page name1 = name1.substring(0, 6); // String length limit for value name double value1 = bvalue1->value; // Value as double in SI unit bool valid1 = bvalue1->valid; // Valid information - String svalue1 = formatValue(bvalue1, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit1 = formatValue(bvalue1, commonData).unit; // Unit of value + String svalue1 = formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit1 = formatValue(bvalue1, *commonData).unit; // Unit of value // Get boat values #2 GwApi::BoatValue *bvalue2 = pageData.values[1]; // Second element in list (only one value by PageOneValue) @@ -56,8 +56,8 @@ class PageFourValues2 : public Page name2 = name2.substring(0, 6); // String length limit for value name double value2 = bvalue2->value; // Value as double in SI unit bool valid2 = bvalue2->valid; // Valid information - String svalue2 = formatValue(bvalue2, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit2 = formatValue(bvalue2, commonData).unit; // Unit of value + String svalue2 = formatValue(bvalue2, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit2 = formatValue(bvalue2, *commonData).unit; // Unit of value // Get boat values #3 GwApi::BoatValue *bvalue3 = pageData.values[2]; // Second element in list (only one value by PageOneValue) @@ -65,8 +65,8 @@ class PageFourValues2 : public Page name3 = name3.substring(0, 6); // String length limit for value name double value3 = bvalue3->value; // Value as double in SI unit bool valid3 = bvalue3->valid; // Valid information - String svalue3 = formatValue(bvalue3, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit3 = formatValue(bvalue3, commonData).unit; // Unit of value + String svalue3 = formatValue(bvalue3, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit3 = formatValue(bvalue3, *commonData).unit; // Unit of value // Get boat values #4 GwApi::BoatValue *bvalue4 = pageData.values[3]; // Second element in list (only one value by PageOneValue) @@ -74,8 +74,8 @@ class PageFourValues2 : public Page name4 = name4.substring(0, 6); // String length limit for value name double value4 = bvalue4->value; // Value as double in SI unit bool valid4 = bvalue4->valid; // Valid information - String svalue4 = formatValue(bvalue4, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit4 = formatValue(bvalue4, commonData).unit; // Unit of value + String svalue4 = formatValue(bvalue4, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit4 = formatValue(bvalue4, *commonData).unit; // Unit of value // Optical warning by limit violation (unused) if(String(flashLED) == "Limit Violation"){ @@ -93,7 +93,7 @@ class PageFourValues2 : public Page // Set display in partial refresh mode getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update - getdisplay().setTextColor(commonData.fgcolor); + getdisplay().setTextColor(commonData->fgcolor); // ############### Value 1 ################ @@ -141,7 +141,7 @@ class PageFourValues2 : public Page // ############### Horizontal Line ################ // Horizontal line 3 pix - getdisplay().fillRect(0, 105, 400, 3, commonData.fgcolor); + getdisplay().fillRect(0, 105, 400, 3, commonData->fgcolor); // ############### Value 2 ################ @@ -189,7 +189,7 @@ class PageFourValues2 : public Page // ############### Horizontal Line ################ // Horizontal line 3 pix - getdisplay().fillRect(0, 195, 400, 3, commonData.fgcolor); + getdisplay().fillRect(0, 195, 400, 3, commonData->fgcolor); // ############### Value 3 ################ @@ -237,7 +237,7 @@ class PageFourValues2 : public Page // ############### Vertical Line ################ // Vertical line 3 pix - getdisplay().fillRect(200, 195, 3, 75, commonData.fgcolor); + getdisplay().fillRect(200, 195, 3, 75, commonData->fgcolor); // ############### Value 4 ################ @@ -287,18 +287,12 @@ class PageFourValues2 : public Page // Key Layout getdisplay().setFont(&Ubuntu_Bold8pt7b); - if(keylock == false){ - getdisplay().setCursor(130, 290); - getdisplay().print("[ <<<< " + String(commonData.data.actpage) + "/" + String(commonData.data.maxpage) + " >>>> ]"); + if(commonData->keylock == false){ if(String(backlightMode) == "Control by Key"){ // Key for illumination getdisplay().setCursor(343, 290); getdisplay().print("[ILUM]"); } } - else{ - getdisplay().setCursor(130, 290); - getdisplay().print(" [ Keylock active ]"); - } // Update display getdisplay().nextPage(); // Partial update (fast) diff --git a/lib/obp60task/PageGenerator.cpp b/lib/obp60task/PageGenerator.cpp index aa8ac8d..fc0c402 100644 --- a/lib/obp60task/PageGenerator.cpp +++ b/lib/obp60task/PageGenerator.cpp @@ -6,26 +6,24 @@ class PageGenerator : public Page { -bool init = false; // Marker for init done -bool keylock = false; // Keylock - public: PageGenerator(CommonData &common){ - common.logger->logDebug(GwLog::LOG,"Show PageGenerator"); + commonData = &common; + common.logger->logDebug(GwLog::LOG,"Instantiate PageGenerator"); } virtual int handleKey(int key){ // Code for keylock if(key == 11){ - keylock = !keylock; // Toggle keylock + commonData->keylock = !commonData->keylock; return 0; // Commit the key } return key; } - virtual void displayPage(CommonData &commonData, PageData &pageData) + virtual void displayPage(PageData &pageData) { - GwConfigHandler *config = commonData.config; - GwLog *logger=commonData.logger; + GwConfigHandler *config = commonData->config; + GwLog *logger = commonData->logger; // Get config data bool simulation = config->getBool(config->useSimuData); @@ -47,13 +45,13 @@ public: // Get raw value for trend indicator if(powerSensor != "off"){ - value1 = commonData.data.generatorVoltage; // Use voltage from external sensor + value1 = commonData->data.generatorVoltage; // Use voltage from external sensor } else{ - value1 = commonData.data.batteryVoltage; // Use internal voltage sensor + value1 = commonData->data.batteryVoltage; // Use internal voltage sensor } - value2 = commonData.data.generatorCurrent; - value3 = commonData.data.generatorPower; + value2 = commonData->data.generatorCurrent; + value3 = commonData->data.generatorPower; genPercentage = value3 * 100 / (double)genPower; // Load value // Limits for battery level if(genPercentage < 0) genPercentage = 0; @@ -87,7 +85,7 @@ public: // Set display in partial refresh mode getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update - getdisplay().setTextColor(commonData.fgcolor); + getdisplay().setTextColor(commonData->fgcolor); // Show name getdisplay().setFont(&Ubuntu_Bold20pt7b); @@ -124,7 +122,7 @@ public: getdisplay().print("Power Modul"); // Show generator - generatorGraphic(200, 95, commonData.fgcolor, commonData.bgcolor); + generatorGraphic(200, 95, commonData->fgcolor, commonData->bgcolor); // Show load level in percent getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b); @@ -207,18 +205,12 @@ public: // Key Layout getdisplay().setFont(&Ubuntu_Bold8pt7b); - if(keylock == false){ - getdisplay().setCursor(130, 290); - getdisplay().print("[ <<<< " + String(commonData.data.actpage) + "/" + String(commonData.data.maxpage) + " >>>> ]"); + if(commonData->keylock == false){ if(String(backlightMode) == "Control by Key"){ // Key for illumination getdisplay().setCursor(343, 290); getdisplay().print("[ILUM]"); } } - else{ - getdisplay().setCursor(130, 290); - getdisplay().print(" [ Keylock active ]"); - } // Update display getdisplay().nextPage(); // Partial update (fast) diff --git a/lib/obp60task/PageKeelPosition.cpp b/lib/obp60task/PageKeelPosition.cpp index 1d02c3e..6ecaf61 100644 --- a/lib/obp60task/PageKeelPosition.cpp +++ b/lib/obp60task/PageKeelPosition.cpp @@ -5,27 +5,26 @@ class PageKeelPosition : public Page { -bool keylock = false; // Keylock - public: PageKeelPosition(CommonData &common){ - common.logger->logDebug(GwLog::LOG,"Show PageKeelPosition"); + commonData = &common; + common.logger->logDebug(GwLog::LOG,"Instantiate PageKeelPosition"); } // Key functions virtual int handleKey(int key){ - // Keylock function - if(key == 11){ // Code for keylock - keylock = !keylock; // Toggle keylock + // Code for keylock + if(key == 11){ + commonData->keylock = !commonData->keylock; return 0; // Commit the key } return key; } - virtual void displayPage(CommonData &commonData, PageData &pageData) + virtual void displayPage(PageData &pageData) { - GwConfigHandler *config = commonData.config; - GwLog *logger=commonData.logger; + GwConfigHandler *config = commonData->config; + GwLog *logger = commonData->logger; double value1 = 0; double value1old = 0; @@ -40,9 +39,9 @@ public: String rotfunction = config->getString(config->rotFunction); // Get boat values for Keel position - bool valid1 = commonData.data.validRotAngle; // Valid information + bool valid1 = commonData->data.validRotAngle; // Valid information if(simulation == false && rotsensor == "AS5600" && rotfunction == "Keel"){ - value1 = commonData.data.rotationAngle; // Raw value without unit convertion + value1 = commonData->data.rotationAngle; // Raw value without unit convertion } else{ value1 = 0; @@ -77,9 +76,9 @@ public: int rInstrument = 110; // Radius of KeelPosition float pi = 3.141592; - getdisplay().fillCircle(200, 150, rInstrument + 10, commonData.fgcolor); // Outer circle - getdisplay().fillCircle(200, 150, rInstrument + 7, commonData.bgcolor); // Outer circle - getdisplay().fillRect(0, 30, 400, 122, commonData.bgcolor); // Delete half top circle + getdisplay().fillCircle(200, 150, rInstrument + 10, commonData->fgcolor); // Outer circle + getdisplay().fillCircle(200, 150, rInstrument + 7, commonData->bgcolor); // Outer circle + getdisplay().fillRect(0, 30, 400, 122, commonData->bgcolor); // Delete half top circle for(int i=90; i<=270; i=i+10) { @@ -117,7 +116,7 @@ public: // Draw sub scale with dots 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, commonData.fgcolor); + getdisplay().fillCircle((int)x1c, (int)y1c, 2, commonData->fgcolor); float sinx=sin(i/180.0*pi); float cosx=cos(i/180.0*pi); @@ -130,10 +129,10 @@ 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),commonData.fgcolor); + 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),commonData.fgcolor); + 200+(int)(cosx*xx2-sinx*yy2),150+(int)(sinx*xx2+cosx*yy2),commonData->fgcolor); } } @@ -167,7 +166,7 @@ public: float yy2 = -(rInstrument * 0.6); 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),commonData.fgcolor); + 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 @@ -177,17 +176,17 @@ 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),commonData.fgcolor); + 200+(int)(cosx*0-sinx*iy2),150+(int)(sinx*0+cosx*iy2),commonData->fgcolor); // Draw counterweight - getdisplay().fillCircle(200+(int)(cosx*0-sinx*yy2),150+(int)(sinx*0+cosx*yy2), 5, commonData.fgcolor); + getdisplay().fillCircle(200+(int)(cosx*0-sinx*yy2),150+(int)(sinx*0+cosx*yy2), 5, commonData->fgcolor); } // Center circle - getdisplay().fillCircle(200, 140, startwidth + 22, commonData.bgcolor); - getdisplay().fillCircle(200, 140, startwidth + 20, commonData.fgcolor); // Boat circle - getdisplay().fillRect(200 - 30, 140 - 30, 2 * 30, 30, commonData.bgcolor); // Delete half top of boat circle - getdisplay().fillRect(150, 150, 100, 4, commonData.fgcolor); // Water line + getdisplay().fillCircle(200, 140, startwidth + 22, commonData->bgcolor); + getdisplay().fillCircle(200, 140, startwidth + 20, commonData->fgcolor); // Boat circle + getdisplay().fillRect(200 - 30, 140 - 30, 2 * 30, 30, commonData->bgcolor); // Delete half top of boat circle + getdisplay().fillRect(150, 150, 100, 4, commonData->fgcolor); // Water line // Print label getdisplay().setFont(&Ubuntu_Bold16pt7b); @@ -210,18 +209,12 @@ public: //******************************************************************************************* // Key Layout getdisplay().setFont(&Ubuntu_Bold8pt7b); - if(keylock == false){ - getdisplay().setCursor(130, 290); - getdisplay().print("[ <<<< " + String(commonData.data.actpage) + "/" + String(commonData.data.maxpage) + " >>>> ]"); + if(commonData->keylock == false){ if(String(backlightMode) == "Control by Key"){ // Key for illumination getdisplay().setCursor(343, 290); getdisplay().print("[ILUM]"); } } - else{ - getdisplay().setCursor(130, 290); - getdisplay().print(" [ Keylock active ]"); - } // Update display getdisplay().nextPage(); // Partial update (fast) diff --git a/lib/obp60task/PageOneValue.cpp b/lib/obp60task/PageOneValue.cpp index 708c611..6910890 100644 --- a/lib/obp60task/PageOneValue.cpp +++ b/lib/obp60task/PageOneValue.cpp @@ -3,25 +3,26 @@ #include "Pagedata.h" #include "OBP60Extensions.h" -class PageOneValue : public Page{ - bool keylock = false; // Keylock - +class PageOneValue : public Page +{ public: PageOneValue(CommonData &common){ - common.logger->logDebug(GwLog::LOG,"Show PageOneValue"); + commonData = &common; + common.logger->logDebug(GwLog::LOG,"Instantiate PageOneValue"); } virtual int handleKey(int key){ - if(key == 11){ // Code for keylock - keylock = !keylock; // Toggle keylock + // Code for keylock + if(key == 11){ + commonData->keylock = !commonData->keylock; return 0; // Commit the key } return key; } - virtual void displayPage(CommonData &commonData, PageData &pageData){ - GwConfigHandler *config = commonData.config; - GwLog *logger=commonData.logger; + virtual void displayPage(PageData &pageData){ + GwConfigHandler *config = commonData->config; + GwLog *logger = commonData->logger; // Old values for hold function static String svalue1old = ""; @@ -40,8 +41,8 @@ class PageOneValue : public Page{ name1 = name1.substring(0, 6); // String length limit for value name double value1 = bvalue1->value; // Value as double in SI unit bool valid1 = bvalue1->valid; // Valid information - String svalue1 = formatValue(bvalue1, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit1 = formatValue(bvalue1, commonData).unit; // Unit of value + String svalue1 = formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit1 = formatValue(bvalue1, *commonData).unit; // Unit of value // Optical warning by limit violation (unused) if(String(flashLED) == "Limit Violation"){ @@ -60,7 +61,7 @@ class PageOneValue : public Page{ getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update // Show name - getdisplay().setTextColor(commonData.fgcolor); + getdisplay().setTextColor(commonData->fgcolor); getdisplay().setFont(&Ubuntu_Bold32pt7b); getdisplay().setCursor(20, 100); getdisplay().print(name1); // Page name @@ -103,18 +104,12 @@ class PageOneValue : public Page{ // Key Layout getdisplay().setFont(&Ubuntu_Bold8pt7b); - if(keylock == false){ - getdisplay().setCursor(130, 290); - getdisplay().print("[ <<<< " + String(commonData.data.actpage) + "/" + String(commonData.data.maxpage) + " >>>> ]"); + if(commonData->keylock == false){ if(String(backlightMode) == "Control by Key"){ // Key for illumination getdisplay().setCursor(343, 290); getdisplay().print("[ILUM]"); } } - else{ - getdisplay().setCursor(130, 290); - getdisplay().print(" [ Keylock active ]"); - } // Update display getdisplay().nextPage(); // Partial update (fast) diff --git a/lib/obp60task/PageRollPitch.cpp b/lib/obp60task/PageRollPitch.cpp index bb5b0e3..019a3b7 100644 --- a/lib/obp60task/PageRollPitch.cpp +++ b/lib/obp60task/PageRollPitch.cpp @@ -5,27 +5,25 @@ class PageRollPitch : public Page { -bool keylock = false; // Keylock - public: PageRollPitch(CommonData &common){ - common.logger->logDebug(GwLog::LOG,"Show PageRollPitch"); + commonData = &common; + common.logger->logDebug(GwLog::LOG,"Instantiate PageRollPitch"); } // Key functions virtual int handleKey(int key){ - // Keylock function - if(key == 11){ // Code for keylock - keylock = !keylock; // Toggle keylock + // Code for keylock + if(key == 11){ + commonData->keylock = !commonData->keylock; return 0; // Commit the key } return key; } - virtual void displayPage(CommonData &commonData, PageData &pageData) - { - GwConfigHandler *config = commonData.config; - GwLog *logger=commonData.logger; + virtual void displayPage(PageData &pageData){ + GwConfigHandler *config = commonData->config; + GwLog *logger = commonData->logger; double value1 = 0; double value2 = 0; @@ -120,7 +118,7 @@ public: // Set display in partial refresh mode getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update - getdisplay().setTextColor(commonData.fgcolor); + getdisplay().setTextColor(commonData->fgcolor); // Show roll limit getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b); @@ -136,7 +134,7 @@ public: getdisplay().print("DEG"); // Horizintal separator left - getdisplay().fillRect(0, 149, 60, 3, commonData.fgcolor); + getdisplay().fillRect(0, 149, 60, 3, commonData->fgcolor); // Show roll value getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b); @@ -151,7 +149,7 @@ public: getdisplay().print("Deg"); // Horizintal separator right - getdisplay().fillRect(340, 149, 80, 3, commonData.fgcolor); + getdisplay().fillRect(340, 149, 80, 3, commonData->fgcolor); // Show pitch value getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b); @@ -171,8 +169,8 @@ public: int rInstrument = 100; // Radius of instrument float pi = 3.141592; - getdisplay().fillCircle(200, 150, rInstrument + 10, commonData.fgcolor); // Outer circle - getdisplay().fillCircle(200, 150, rInstrument + 7, commonData.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+10) { @@ -207,7 +205,7 @@ public: // Draw sub scale with dots 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, commonData.fgcolor); + getdisplay().fillCircle((int)x1c, (int)y1c, 2, commonData->fgcolor); float sinx=sin(i/180.0*pi); float cosx=cos(i/180.0*pi); @@ -220,10 +218,10 @@ 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),commonData.fgcolor); + 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),commonData.fgcolor); + 200+(int)(cosx*xx2-sinx*yy2),150+(int)(sinx*xx2+cosx*yy2),commonData->fgcolor); } } } @@ -244,7 +242,7 @@ public: float yy2 = -(rInstrument * 0.7); 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),commonData.fgcolor); + 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 @@ -254,26 +252,26 @@ 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),commonData.fgcolor); + 200+(int)(cosx*0-sinx*iy2),150+(int)(sinx*0+cosx*iy2),commonData->fgcolor); // Draw counterweight - getdisplay().fillCircle(200+(int)(cosx*0-sinx*yy2),150+(int)(sinx*0+cosx*yy2), 5, commonData.fgcolor); + getdisplay().fillCircle(200+(int)(cosx*0-sinx*yy2),150+(int)(sinx*0+cosx*yy2), 5, commonData->fgcolor); } // Center circle - getdisplay().fillCircle(200, 150, startwidth + 22, commonData.bgcolor); - getdisplay().fillCircle(200, 150, startwidth + 20, commonData.fgcolor); // Boat circle + getdisplay().fillCircle(200, 150, startwidth + 22, commonData->bgcolor); + getdisplay().fillCircle(200, 150, startwidth + 20, commonData->fgcolor); // Boat circle int x0 = 200; int y0 = 150; int x1 = x0 + 50*cos(value1); int y1 = y0 + 50*sin(value1); int x2 = x0 + 50*cos(value1 - pi/2); int y2 = y0 + 50*sin(value1 - pi/2); - getdisplay().fillTriangle(x0, y0, x1, y1, x2, y2, commonData.bgcolor); // Clear half top side of boat circle (right triangle) + getdisplay().fillTriangle(x0, y0, x1, y1, x2, y2, commonData->bgcolor); // Clear half top side of boat circle (right triangle) x1 = x0 + 50*cos(value1 + pi); y1 = y0 + 50*sin(value1 + pi); - getdisplay().fillTriangle(x0, y0, x1, y1, x2, y2, commonData.bgcolor); // Clear half top side of boat circle (left triangle) - getdisplay().fillRect(150, 160, 100, 4, commonData.fgcolor); // Water line + getdisplay().fillTriangle(x0, y0, x1, y1, x2, y2, commonData->bgcolor); // Clear half top side of boat circle (left triangle) + getdisplay().fillRect(150, 160, 100, 4, commonData->fgcolor); // Water line // Draw roll pointer startwidth = 4; // Start width of pointer @@ -288,7 +286,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),commonData.fgcolor); + 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 @@ -298,7 +296,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),commonData.fgcolor); + 200+(int)(cosx*0-sinx*iy2),150+(int)(sinx*0+cosx*iy2),commonData->fgcolor); } else{ // Print sensor info @@ -310,18 +308,12 @@ public: //******************************************************************************************* // Key Layout getdisplay().setFont(&Ubuntu_Bold8pt7b); - if(keylock == false){ - getdisplay().setCursor(130, 290); - getdisplay().print("[ <<<< " + String(commonData.data.actpage) + "/" + String(commonData.data.maxpage) + " >>>> ]"); + if(commonData->keylock == false){ if(String(backlightMode) == "Control by Key"){ // Key for illumination getdisplay().setCursor(343, 290); getdisplay().print("[ILUM]"); } } - else{ - getdisplay().setCursor(130, 290); - getdisplay().print(" [ Keylock active ]"); - } // Update display getdisplay().nextPage(); // Partial update (fast) diff --git a/lib/obp60task/PageRudderPosition.cpp b/lib/obp60task/PageRudderPosition.cpp index 5f88f0e..afceeb4 100644 --- a/lib/obp60task/PageRudderPosition.cpp +++ b/lib/obp60task/PageRudderPosition.cpp @@ -5,27 +5,25 @@ class PageRudderPosition : public Page { -bool keylock = false; // Keylock - public: PageRudderPosition(CommonData &common){ + commonData = &common; common.logger->logDebug(GwLog::LOG,"Show PageRudderPosition"); } // Key functions virtual int handleKey(int key){ - // Keylock function - if(key == 11){ // Code for keylock - keylock = !keylock; // Toggle keylock + // Code for keylock + if(key == 11){ + commonData->keylock = !commonData->keylock; return 0; // Commit the key } return key; } - virtual void displayPage(CommonData &commonData, PageData &pageData) - { - GwConfigHandler *config = commonData.config; - GwLog *logger=commonData.logger; + virtual void displayPage(PageData &pageData){ + GwConfigHandler *config = commonData->config; + GwLog *logger = commonData->logger; static String unit1old = ""; double value1 = 0.1; @@ -44,8 +42,8 @@ public: name1 = name1.substring(0, 6); // String length limit for value name value1 = bvalue1->value; // Raw value without unit convertion bool valid1 = bvalue1->valid; // Valid information - String svalue1 = formatValue(bvalue1, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit1 = formatValue(bvalue1, commonData).unit; // Unit of value + String svalue1 = formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit1 = formatValue(bvalue1, *commonData).unit; // Unit of value if(valid1 == true){ value1old = value1; // Save old value unit1old = unit1; // Save old unit @@ -82,9 +80,9 @@ public: int rInstrument = 110; // Radius of RudderPosition float pi = 3.141592; - getdisplay().fillCircle(200, 150, rInstrument + 10, commonData.fgcolor); // Outer circle - getdisplay().fillCircle(200, 150, rInstrument + 7, commonData.bgcolor); // Outer circle - getdisplay().fillRect(0, 30, 400, 122, commonData.bgcolor); // Delete half top circle + getdisplay().fillCircle(200, 150, rInstrument + 10, commonData->fgcolor); // Outer circle + getdisplay().fillCircle(200, 150, rInstrument + 7, commonData->bgcolor); // Outer circle + getdisplay().fillRect(0, 30, 400, 122, commonData->bgcolor); // Delete half top circle for(int i=90; i<=270; i=i+10) { @@ -122,7 +120,7 @@ public: // Draw sub scale with dots 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, commonData.fgcolor); + getdisplay().fillCircle((int)x1c, (int)y1c, 2, commonData->fgcolor); float sinx=sin(i/180.0*pi); float cosx=cos(i/180.0*pi); @@ -135,10 +133,10 @@ 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),commonData.fgcolor); + 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),commonData.fgcolor); + 200+(int)(cosx*xx2-sinx*yy2),150+(int)(sinx*xx2+cosx*yy2),commonData->fgcolor); } } @@ -190,7 +188,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),commonData.fgcolor); + 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 @@ -200,28 +198,22 @@ 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),commonData.fgcolor); + 200+(int)(cosx*0-sinx*iy2),150+(int)(sinx*0+cosx*iy2),commonData->fgcolor); } // Center circle - getdisplay().fillCircle(200, 150, startwidth + 6, commonData.bgcolor); - getdisplay().fillCircle(200, 150, startwidth + 4, commonData.fgcolor); + getdisplay().fillCircle(200, 150, startwidth + 6, commonData->bgcolor); + getdisplay().fillCircle(200, 150, startwidth + 4, commonData->fgcolor); //******************************************************************************************* // Key Layout getdisplay().setFont(&Ubuntu_Bold8pt7b); - if(keylock == false){ - getdisplay().setCursor(130, 290); - getdisplay().print("[ <<<< " + String(commonData.data.actpage) + "/" + String(commonData.data.maxpage) + " >>>> ]"); + if(commonData->keylock == false){ if(String(backlightMode) == "Control by Key"){ // Key for illumination getdisplay().setCursor(343, 290); getdisplay().print("[ILUM]"); } } - else{ - getdisplay().setCursor(130, 290); - getdisplay().print(" [ Keylock active ]"); - } // Update display getdisplay().nextPage(); // Partial update (fast) diff --git a/lib/obp60task/PageSolar.cpp b/lib/obp60task/PageSolar.cpp index d3b1acd..786dfe7 100644 --- a/lib/obp60task/PageSolar.cpp +++ b/lib/obp60task/PageSolar.cpp @@ -6,26 +6,23 @@ class PageSolar : public Page { -bool init = false; // Marker for init done -bool keylock = false; // Keylock - public: PageSolar(CommonData &common){ - common.logger->logDebug(GwLog::LOG,"Show PageSolar"); + commonData = &common; + common.logger->logDebug(GwLog::LOG,"Instantiate PageSolar"); } virtual int handleKey(int key){ // Code for keylock if(key == 11){ - keylock = !keylock; // Toggle keylock + commonData->keylock = !commonData->keylock; return 0; // Commit the key } return key; } - virtual void displayPage(CommonData &commonData, PageData &pageData) - { - GwConfigHandler *config = commonData.config; - GwLog *logger=commonData.logger; + virtual void displayPage(PageData &pageData){ + GwConfigHandler *config = commonData->config; + GwLog *logger = commonData->logger; // Get config data bool simulation = config->getBool(config->useSimuData); @@ -47,13 +44,13 @@ public: // Get raw value for trend indicator if(powerSensor != "off"){ - value1 = commonData.data.solarVoltage; // Use voltage from external sensor + value1 = commonData->data.solarVoltage; // Use voltage from external sensor } else{ - value1 = commonData.data.batteryVoltage; // Use internal voltage sensor + value1 = commonData->data.batteryVoltage; // Use internal voltage sensor } - value2 = commonData.data.solarCurrent; - value3 = commonData.data.solarPower; + value2 = commonData->data.solarCurrent; + value3 = commonData->data.solarPower; solPercentage = value3 * 100 / (double)solPower; // Load value // Limits for battery level if(solPercentage < 0) solPercentage = 0; @@ -87,7 +84,7 @@ public: // Set display in partial refresh mode getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update - getdisplay().setTextColor(commonData.fgcolor); + getdisplay().setTextColor(commonData->fgcolor); // Show name getdisplay().setFont(&Ubuntu_Bold20pt7b); @@ -121,7 +118,7 @@ public: getdisplay().print("Solar Modul"); // Show solar panel - solarGraphic(150, 45, commonData.fgcolor, commonData.bgcolor); + solarGraphic(150, 45, commonData->fgcolor, commonData->bgcolor); // Show load level in percent getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b); @@ -204,18 +201,12 @@ public: // Key Layout getdisplay().setFont(&Ubuntu_Bold8pt7b); - if(keylock == false){ - getdisplay().setCursor(130, 290); - getdisplay().print("[ <<<< " + String(commonData.data.actpage) + "/" + String(commonData.data.maxpage) + " >>>> ]"); + if(commonData->keylock == false){ if(String(backlightMode) == "Control by Key"){ // Key for illumination getdisplay().setCursor(343, 290); getdisplay().print("[ILUM]"); } } - else{ - getdisplay().setCursor(130, 290); - getdisplay().print(" [ Keylock active ]"); - } // Update display getdisplay().nextPage(); // Partial update (fast) diff --git a/lib/obp60task/PageThreeValues.cpp b/lib/obp60task/PageThreeValues.cpp index 08de8f3..a4fbf90 100644 --- a/lib/obp60task/PageThreeValues.cpp +++ b/lib/obp60task/PageThreeValues.cpp @@ -5,24 +5,24 @@ class PageThreeValues : public Page { - bool keylock = false; // Keylock - public: PageThreeValues(CommonData &common){ - common.logger->logDebug(GwLog::LOG,"Show PageThreeValue"); + commonData = &common; + common.logger->logDebug(GwLog::LOG,"Instantiate PageThreeValue"); } virtual int handleKey(int key){ - if(key == 11){ // Code for keylock - keylock = !keylock; // Toggle keylock + // Code for keylock + if(key == 11){ + commonData->keylock = !commonData->keylock; return 0; // Commit the key } return key; } - virtual void displayPage(CommonData &commonData, PageData &pageData){ - GwConfigHandler *config = commonData.config; - GwLog *logger=commonData.logger; + virtual void displayPage(PageData &pageData){ + GwConfigHandler *config = commonData->config; + GwLog *logger = commonData->logger; // Old values for hold function static String svalue1old = ""; @@ -45,8 +45,8 @@ class PageThreeValues : public Page name1 = name1.substring(0, 6); // String length limit for value name double value1 = bvalue1->value; // Value as double in SI unit bool valid1 = bvalue1->valid; // Valid information - String svalue1 = formatValue(bvalue1, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit1 = formatValue(bvalue1, commonData).unit; // Unit of value + String svalue1 = formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit1 = formatValue(bvalue1, *commonData).unit; // Unit of value // Get boat values #2 GwApi::BoatValue *bvalue2 = pageData.values[1]; // Second element in list (only one value by PageOneValue) @@ -54,8 +54,8 @@ class PageThreeValues : public Page name2 = name2.substring(0, 6); // String length limit for value name double value2 = bvalue2->value; // Value as double in SI unit bool valid2 = bvalue2->valid; // Valid information - String svalue2 = formatValue(bvalue2, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit2 = formatValue(bvalue2, commonData).unit; // Unit of value + String svalue2 = formatValue(bvalue2, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit2 = formatValue(bvalue2, *commonData).unit; // Unit of value // Get boat values #3 GwApi::BoatValue *bvalue3 = pageData.values[2]; // Second element in list (only one value by PageOneValue) @@ -63,8 +63,8 @@ class PageThreeValues : public Page name3 = name3.substring(0, 6); // String length limit for value name double value3 = bvalue3->value; // Value as double in SI unit bool valid3 = bvalue3->valid; // Valid information - String svalue3 = formatValue(bvalue3, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit3 = formatValue(bvalue3, commonData).unit; // Unit of value + String svalue3 = formatValue(bvalue3, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit3 = formatValue(bvalue3, *commonData).unit; // Unit of value // Optical warning by limit violation (unused) if(String(flashLED) == "Limit Violation"){ @@ -85,7 +85,7 @@ class PageThreeValues : public Page // ############### Value 1 ################ // Show name - getdisplay().setTextColor(commonData.fgcolor); + getdisplay().setTextColor(commonData->fgcolor); getdisplay().setFont(&Ubuntu_Bold20pt7b); getdisplay().setCursor(20, 55); getdisplay().print(name1); // Page name @@ -129,7 +129,7 @@ class PageThreeValues : public Page // ############### Horizontal Line ################ // Horizontal line 3 pix - getdisplay().fillRect(0, 105, 400, 3, commonData.fgcolor); + getdisplay().fillRect(0, 105, 400, 3, commonData->fgcolor); // ############### Value 2 ################ @@ -177,7 +177,7 @@ class PageThreeValues : public Page // ############### Horizontal Line ################ // Horizontal line 3 pix - getdisplay().fillRect(0, 195, 400, 3, commonData.fgcolor); + getdisplay().fillRect(0, 195, 400, 3, commonData->fgcolor); // ############### Value 3 ################ @@ -227,18 +227,12 @@ class PageThreeValues : public Page // Key Layout getdisplay().setFont(&Ubuntu_Bold8pt7b); - if(keylock == false){ - getdisplay().setCursor(130, 290); - getdisplay().print("[ <<<< " + String(commonData.data.actpage) + "/" + String(commonData.data.maxpage) + " >>>> ]"); + if(commonData->keylock == false){ if(String(backlightMode) == "Control by Key"){ // Key for illumination getdisplay().setCursor(343, 290); getdisplay().print("[ILUM]"); } } - else{ - getdisplay().setCursor(130, 290); - getdisplay().print(" [ Keylock active ]"); - } // Update display getdisplay().nextPage(); // Partial update (fast) diff --git a/lib/obp60task/PageTwoValues.cpp b/lib/obp60task/PageTwoValues.cpp index 01469d9..e8dcf40 100644 --- a/lib/obp60task/PageTwoValues.cpp +++ b/lib/obp60task/PageTwoValues.cpp @@ -5,24 +5,24 @@ class PageTwoValues : public Page { - bool keylock = false; // Keylock - public: PageTwoValues(CommonData &common){ - common.logger->logDebug(GwLog::LOG,"Show PageTwoValue"); + commonData = &common; + common.logger->logDebug(GwLog::LOG,"Instantiate PageTwoValue"); } virtual int handleKey(int key){ - if(key == 11){ // Code for keylock - keylock = !keylock; // Toggle keylock + // Code for keylock + if(key == 11){ + commonData->keylock = !commonData->keylock; return 0; // Commit the key } return key; } - virtual void displayPage(CommonData &commonData, PageData &pageData){ - GwConfigHandler *config = commonData.config; - GwLog *logger=commonData.logger; + virtual void displayPage(PageData &pageData){ + GwConfigHandler *config = commonData->config; + GwLog *logger = commonData->logger; // Old values for hold function static String svalue1old = ""; @@ -43,8 +43,8 @@ class PageTwoValues : public Page name1 = name1.substring(0, 6); // String length limit for value name double value1 = bvalue1->value; // Value as double in SI unit bool valid1 = bvalue1->valid; // Valid information - String svalue1 = formatValue(bvalue1, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit1 = formatValue(bvalue1, commonData).unit; // Unit of value + String svalue1 = formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit1 = formatValue(bvalue1, *commonData).unit; // Unit of value // Get boat values #2 GwApi::BoatValue *bvalue2 = pageData.values[1]; // Second element in list (only one value by PageOneValue) @@ -52,8 +52,8 @@ class PageTwoValues : public Page name2 = name2.substring(0, 6); // String length limit for value name double value2 = bvalue2->value; // Value as double in SI unit bool valid2 = bvalue2->valid; // Valid information - String svalue2 = formatValue(bvalue2, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit2 = formatValue(bvalue2, commonData).unit; // Unit of value + String svalue2 = formatValue(bvalue2, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit2 = formatValue(bvalue2, *commonData).unit; // Unit of value // Optical warning by limit violation (unused) if(String(flashLED) == "Limit Violation"){ @@ -74,7 +74,7 @@ class PageTwoValues : public Page // ############### Value 1 ################ // Show name - getdisplay().setTextColor(commonData.fgcolor); + getdisplay().setTextColor(commonData->fgcolor); getdisplay().setFont(&Ubuntu_Bold20pt7b); getdisplay().setCursor(20, 80); getdisplay().print(name1); // Page name @@ -118,7 +118,7 @@ class PageTwoValues : public Page // ############### Horizontal Line ################ // Horizontal line 3 pix - getdisplay().fillRect(0, 145, 400, 3, commonData.fgcolor); + getdisplay().fillRect(0, 145, 400, 3, commonData->fgcolor); // ############### Value 2 ################ @@ -168,9 +168,7 @@ class PageTwoValues : public Page // Key Layout getdisplay().setFont(&Ubuntu_Bold8pt7b); - if(keylock == false){ - getdisplay().setCursor(130, 290); - getdisplay().print("[ <<<< " + String(commonData.data.actpage) + "/" + String(commonData.data.maxpage) + " >>>> ]"); + if(commonData->keylock == false){ if(String(backlightMode) == "Control by Key"){ // Key for illumination getdisplay().setCursor(343, 290); getdisplay().print("[ILUM]"); diff --git a/lib/obp60task/PageVoltage.cpp b/lib/obp60task/PageVoltage.cpp index cdee817..76d67e2 100644 --- a/lib/obp60task/PageVoltage.cpp +++ b/lib/obp60task/PageVoltage.cpp @@ -7,7 +7,6 @@ class PageVoltage : public Page { bool init = false; // Marker for init done -bool keylock = false; // Keylock uint8_t average = 0; // Average type [0...3], 0=off, 1=10s, 2=60s, 3=300s bool trend = true; // Trend indicator [0|1], 0=off, 1=on double raw = 0; @@ -15,6 +14,7 @@ char mode = 'D'; // display mode (A)nalog | (D)igital public: PageVoltage(CommonData &common){ + commonData = &common; common.logger->logDebug(GwLog::LOG,"Instantiate PageVoltage"); if (hasFRAM) { average = fram.read(FRAM_VOLTAGE_AVG); @@ -51,7 +51,7 @@ public: // Code for keylock if(key == 11){ - keylock = !keylock; // Toggle keylock + commonData->keylock = !commonData->keylock; return 0; // Commit the key } return key; @@ -92,10 +92,9 @@ public: getdisplay().fillRect(x + 16, y + 11, 6, 3, color); } - virtual void displayPage(CommonData &commonData, PageData &pageData) - { - GwConfigHandler *config = commonData.config; - GwLog *logger=commonData.logger; + virtual void displayPage(PageData &pageData){ + GwConfigHandler *config = commonData->config; + GwLog *logger = commonData->logger; // Get config data bool simulation = config->getBool(config->useSimuData); @@ -113,32 +112,32 @@ public: // Create trend value if(init == false){ // Load start values for first page run - valueTrend = commonData.data.batteryVoltage10; + valueTrend = commonData->data.batteryVoltage10; init = true; } else{ // Reading trend value - valueTrend = commonData.data.batteryVoltage10; + valueTrend = commonData->data.batteryVoltage10; } // Get raw value for trend indicator - raw = commonData.data.batteryVoltage; // Live data + raw = commonData->data.batteryVoltage; // Live data // Switch average values switch (average) { case 0: - value1 = commonData.data.batteryVoltage; // Live data + value1 = commonData->data.batteryVoltage; // Live data break; case 1: - value1 = commonData.data.batteryVoltage10; // Average 10s + value1 = commonData->data.batteryVoltage10; // Average 10s break; case 2: - value1 = commonData.data.batteryVoltage60; // Average 60s + value1 = commonData->data.batteryVoltage60; // Average 60s break; case 3: - value1 = commonData.data.batteryVoltage300; // Average 300s + value1 = commonData->data.batteryVoltage300; // Average 300s break; default: - value1 = commonData.data.batteryVoltage; // Default + value1 = commonData->data.batteryVoltage; // Default break; } bool valid1 = true; @@ -193,7 +192,7 @@ public: // Display mode digital // Show name - getdisplay().setTextColor(commonData.fgcolor); + getdisplay().setTextColor(commonData->fgcolor); getdisplay().setFont(&Ubuntu_Bold32pt7b); getdisplay().setCursor(20, 100); getdisplay().print(name1); // Value name @@ -246,18 +245,18 @@ public: // Trend indicator // Show trend indicator if(trend == true){ - getdisplay().fillRect(310, 240, 40, 120, commonData.bgcolor); // Clear area - getdisplay().fillRect(315, 183, 35, 4, commonData.fgcolor); // Draw separator + getdisplay().fillRect(310, 240, 40, 120, commonData->bgcolor); // Clear area + getdisplay().fillRect(315, 183, 35, 4, commonData->fgcolor); // Draw separator if(int(raw * 10) > int(valueTrend * 10)){ - displayTrendHigh(320, 174, 11, commonData.fgcolor); // Show high indicator + displayTrendHigh(320, 174, 11, commonData->fgcolor); // Show high indicator } if(int(raw * 10) < int(valueTrend * 10)){ - displayTrendLow(320, 195, 11, commonData.fgcolor); // Show low indicator + displayTrendLow(320, 195, 11, commonData->fgcolor); // Show low indicator } } // No trend indicator else{ - getdisplay().fillRect(310, 240, 40, 120, commonData.bgcolor); // Clear area + getdisplay().fillRect(310, 240, 40, 120, commonData->bgcolor); // Clear area } } @@ -272,9 +271,9 @@ public: std::vector pts; // Instrument - getdisplay().drawCircleHelper(c.x, c.y, r + 2, 0x01, commonData.fgcolor); - getdisplay().drawCircleHelper(c.x, c.y, r + 1, 0x01, commonData.fgcolor); - getdisplay().drawCircleHelper(c.x, c.y, r , 0x01, commonData.fgcolor); + getdisplay().drawCircleHelper(c.x, c.y, r + 2, 0x01, commonData->fgcolor); + getdisplay().drawCircleHelper(c.x, c.y, r + 1, 0x01, commonData->fgcolor); + getdisplay().drawCircleHelper(c.x, c.y, r , 0x01, commonData->fgcolor); // Scale // angle to voltage scale mapping @@ -290,14 +289,14 @@ public: getdisplay().setFont(&Ubuntu_Bold10pt7b); for (int angle = 3; angle < 90; angle += 3) { if (angle % 15 == 0) { - fillPoly4(rotatePoints(c, pts, angle), commonData.fgcolor); + fillPoly4(rotatePoints(c, pts, angle), commonData->fgcolor); p1 = rotatePoint(c, {c.x - r + 30, c.y}, angle); drawTextCenter(p1.x, p1.y, mapping[angle]); } else { p1 = rotatePoint(c, {c.x - r, c.y}, angle); p2 = rotatePoint(c, {c.x - r + 6, c.y}, angle); - getdisplay().drawLine(p1.x, p1.y, p2.x, p2.y, commonData.fgcolor); + getdisplay().drawLine(p1.x, p1.y, p2.x, p2.y, commonData->fgcolor); } } @@ -326,7 +325,7 @@ public: {c.x - r + 38, c.y - 2}, {c.x - 2, c.y - 3} }; - fillPoly4(rotatePoints(c, pts, angle), commonData.fgcolor); + fillPoly4(rotatePoints(c, pts, angle), commonData->fgcolor); // thin part pts = { {c.x - r + 40, c.y + 1}, @@ -334,14 +333,14 @@ public: {c.x - r + 5, c.y -1}, {c.x - r + 40, c.y - 1}, }; - fillPoly4(rotatePoints(c, pts, angle), commonData.fgcolor); + fillPoly4(rotatePoints(c, pts, angle), commonData->fgcolor); // base - getdisplay().fillCircle(c.x, c.y, 7, commonData.fgcolor); - getdisplay().fillCircle(c.x, c.y, 4, commonData.bgcolor); + getdisplay().fillCircle(c.x, c.y, 7, commonData->fgcolor); + getdisplay().fillCircle(c.x, c.y, 4, commonData->bgcolor); // Symbol - printVoltageSymbol(40, 60, commonData.fgcolor); + printVoltageSymbol(40, 60, commonData->fgcolor); // Additional information at right side getdisplay().setFont(&Ubuntu_Bold8pt7b); @@ -361,32 +360,26 @@ public: // FRAM indicator if (hasFRAM) { - getdisplay().drawXBitmap(300, 240, fram_bits, fram_width, fram_height, commonData.fgcolor); + getdisplay().drawXBitmap(300, 240, fram_bits, fram_width, fram_height, commonData->fgcolor); } } // Key Layout - getdisplay().setTextColor(commonData.fgcolor); + getdisplay().setTextColor(commonData->fgcolor); getdisplay().setFont(&Ubuntu_Bold8pt7b); - if(keylock == false){ + if(commonData->keylock == false){ getdisplay().setCursor(10, 290); getdisplay().print("[AVG]"); getdisplay().setCursor(62, 290); getdisplay().print("[MODE]"); - getdisplay().setCursor(130, 290); - getdisplay().print("[ <<<< " + String(commonData.data.actpage) + "/" + String(commonData.data.maxpage) + " >>>> ]"); getdisplay().setCursor(293, 290); - getdisplay().print("[TRD]"); + getdisplay().print("[TRD]"); if(String(backlightMode) == "Control by Key"){ // Key for illumination getdisplay().setCursor(343, 290); getdisplay().print("[ILUM]"); } } - else{ - getdisplay().setCursor(130, 290); - getdisplay().print(" [ Keylock active ]"); - } // Update display getdisplay().nextPage(); // Partial update (fast) diff --git a/lib/obp60task/PageWhite.cpp b/lib/obp60task/PageWhite.cpp index e941732..4c9d0c7 100644 --- a/lib/obp60task/PageWhite.cpp +++ b/lib/obp60task/PageWhite.cpp @@ -3,17 +3,17 @@ #include "Pagedata.h" #include "OBP60Extensions.h" -class PageWhite : public Page{ - bool keylock = false; // Keylock - +class PageWhite : public Page +{ public: PageWhite(CommonData &common){ - common.logger->logDebug(GwLog::LOG,"Show PageWhite"); + commonData = &common; + common.logger->logDebug(GwLog::LOG,"Instantiate PageWhite"); } - virtual void displayPage(CommonData &commonData, PageData &pageData){ - GwConfigHandler *config = commonData.config; - GwLog *logger=commonData.logger; + virtual void displayPage(PageData &pageData){ + GwConfigHandler *config = commonData->config; + GwLog *logger = commonData->logger; // Get config data String flashLED = config->getString(config->flashLED); @@ -60,4 +60,4 @@ PageDescription registerPageWhite( false // Show display header on/off ); -#endif \ No newline at end of file +#endif diff --git a/lib/obp60task/PageWindRose.cpp b/lib/obp60task/PageWindRose.cpp index 82700f3..be3d468 100644 --- a/lib/obp60task/PageWindRose.cpp +++ b/lib/obp60task/PageWindRose.cpp @@ -5,28 +5,27 @@ class PageWindRose : public Page { -bool keylock = false; // Keylock int16_t lp = 80; // Pointer length public: PageWindRose(CommonData &common){ + commonData = &common; common.logger->logDebug(GwLog::LOG,"Show PageWindRose"); } // Key functions virtual int handleKey(int key){ - // Keylock function - if(key == 11){ // Code for keylock - keylock = !keylock; // Toggle keylock + // Code for keylock + if(key == 11){ + commonData->keylock = !commonData->keylock; return 0; // Commit the key } return key; } - virtual void displayPage(CommonData &commonData, PageData &pageData) - { - GwConfigHandler *config = commonData.config; - GwLog *logger=commonData.logger; + virtual void displayPage(PageData &pageData){ + GwConfigHandler *config = commonData->config; + GwLog *logger = commonData->logger; static String svalue1old = ""; static String unit1old = ""; @@ -54,9 +53,9 @@ public: name1 = name1.substring(0, 6); // String length limit for value name double value1 = bvalue1->value; // Value as double in SI unit bool valid1 = bvalue1->valid; // Valid information - value1 = formatValue(bvalue1, commonData).value;// Format only nesaccery for simulation data for pointer - String svalue1 = formatValue(bvalue1, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit1 = formatValue(bvalue1, commonData).unit; // Unit of value + value1 = formatValue(bvalue1, *commonData).value;// Format only nesaccery for simulation data for pointer + String svalue1 = formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit1 = formatValue(bvalue1, *commonData).unit; // Unit of value if(valid1 == true){ svalue1old = svalue1; // Save old value unit1old = unit1; // Save old unit @@ -68,8 +67,8 @@ public: name2 = name2.substring(0, 6); // String length limit for value name double value2 = bvalue2->value; // Value as double in SI unit bool valid2 = bvalue2->valid; // Valid information - String svalue2 = formatValue(bvalue2, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit2 = formatValue(bvalue2, commonData).unit; // Unit of value + String svalue2 = formatValue(bvalue2, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit2 = formatValue(bvalue2, *commonData).unit; // Unit of value if(valid2 == true){ svalue2old = svalue2; // Save old value unit2old = unit2; // Save old unit @@ -81,8 +80,8 @@ public: name3 = name3.substring(0, 6); // String length limit for value name double value3 = bvalue3->value; // Value as double in SI unit bool valid3 = bvalue3->valid; // Valid information - String svalue3 = formatValue(bvalue3, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit3 = formatValue(bvalue3, commonData).unit; // Unit of value + String svalue3 = formatValue(bvalue3, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit3 = formatValue(bvalue3, *commonData).unit; // Unit of value if(valid3 == true){ svalue3old = svalue3; // Save old value unit3old = unit3; // Save old unit @@ -94,8 +93,8 @@ public: name4 = name4.substring(0, 6); // String length limit for value name double value4 = bvalue4->value; // Value as double in SI unit bool valid4 = bvalue4->valid; // Valid information - String svalue4 = formatValue(bvalue4, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit4 = formatValue(bvalue4, commonData).unit; // Unit of value + String svalue4 = formatValue(bvalue4, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit4 = formatValue(bvalue4, *commonData).unit; // Unit of value if(valid4 == true){ svalue4old = svalue4; // Save old value unit4old = unit4; // Save old unit @@ -107,8 +106,8 @@ public: name5 = name5.substring(0, 6); // String length limit for value name double value5 = bvalue5->value; // Value as double in SI unit bool valid5 = bvalue5->valid; // Valid information - String svalue5 = formatValue(bvalue5, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit5 = formatValue(bvalue5, commonData).unit; // Unit of value + String svalue5 = formatValue(bvalue5, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit5 = formatValue(bvalue5, *commonData).unit; // Unit of value if(valid5 == true){ svalue5old = svalue5; // Save old value unit5old = unit5; // Save old unit @@ -120,8 +119,8 @@ public: name6 = name6.substring(0, 6); // String length limit for value name double value6 = bvalue6->value; // Value as double in SI unit bool valid6 = bvalue6->valid; // Valid information - String svalue6 = formatValue(bvalue6, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit6 = formatValue(bvalue6, commonData).unit; // Unit of value + String svalue6 = formatValue(bvalue6, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit6 = formatValue(bvalue6, *commonData).unit; // Unit of value if(valid6 == true){ svalue6old = svalue6; // Save old value unit6old = unit6; // Save old unit @@ -143,7 +142,7 @@ public: // Set display in partial refresh mode getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update - getdisplay().setTextColor(commonData.fgcolor); + getdisplay().setTextColor(commonData->fgcolor); // Show values AWA getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b); @@ -163,7 +162,7 @@ public: } // Horizintal separator left - getdisplay().fillRect(0, 149, 60, 3, commonData.fgcolor); + getdisplay().fillRect(0, 149, 60, 3, commonData->fgcolor); // Show values AWS getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b); @@ -205,7 +204,7 @@ public: } // Horizintal separator right - getdisplay().fillRect(340, 149, 80, 3, commonData.fgcolor); + getdisplay().fillRect(340, 149, 80, 3, commonData->fgcolor); // Show values TWS getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b); @@ -230,10 +229,10 @@ public: int rInstrument = 110; // Radius of grafic instrument float pi = 3.141592; - getdisplay().fillCircle(200, 150, rInstrument + 10, commonData.fgcolor); // Outer circle - getdisplay().fillCircle(200, 150, rInstrument + 7, commonData.bgcolor); // Outer circle - getdisplay().fillCircle(200, 150, rInstrument - 10, commonData.fgcolor); // Inner circle - getdisplay().fillCircle(200, 150, rInstrument - 13, commonData.bgcolor); // Inner circle + getdisplay().fillCircle(200, 150, rInstrument + 10, commonData->fgcolor); // Outer circle + getdisplay().fillCircle(200, 150, rInstrument + 7, commonData->bgcolor); // Outer circle + getdisplay().fillCircle(200, 150, rInstrument - 10, commonData->fgcolor); // Inner circle + getdisplay().fillCircle(200, 150, rInstrument - 13, commonData->bgcolor); // Inner circle for(int i=0; i<360; i=i+10) { @@ -271,7 +270,7 @@ public: // Draw sub scale with dots 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, commonData.fgcolor); + getdisplay().fillCircle((int)x1c, (int)y1c, 2, commonData->fgcolor); float sinx=sin(i/180.0*pi); float cosx=cos(i/180.0*pi); @@ -284,10 +283,10 @@ 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),commonData.fgcolor); + 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),commonData.fgcolor); + 200+(int)(cosx*xx2-sinx*yy2),150+(int)(sinx*xx2+cosx*yy2),commonData->fgcolor); } } @@ -304,7 +303,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),commonData.fgcolor); + 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 @@ -314,12 +313,12 @@ 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),commonData.fgcolor); + 200+(int)(cosx*0-sinx*iy2),150+(int)(sinx*0+cosx*iy2),commonData->fgcolor); } // Center circle - getdisplay().fillCircle(200, 150, startwidth + 6, commonData.bgcolor); - getdisplay().fillCircle(200, 150, startwidth + 4, commonData.fgcolor); + getdisplay().fillCircle(200, 150, startwidth + 6, commonData->bgcolor); + getdisplay().fillCircle(200, 150, startwidth + 4, commonData->fgcolor); //******************************************************************************************* @@ -353,18 +352,12 @@ public: // Key Layout getdisplay().setFont(&Ubuntu_Bold8pt7b); - if(keylock == false){ - getdisplay().setCursor(130, 290); - getdisplay().print("[ <<<< " + String(commonData.data.actpage) + "/" + String(commonData.data.maxpage) + " >>>> ]"); + if(commonData->keylock == false){ if(String(backlightMode) == "Control by Key"){ // Key for illumination getdisplay().setCursor(343, 290); getdisplay().print("[ILUM]"); } } - else{ - getdisplay().setCursor(130, 290); - getdisplay().print(" [ Keylock active ]"); - } // Update display getdisplay().nextPage(); // Partial update (fast) diff --git a/lib/obp60task/PageWindRoseFlex.cpp b/lib/obp60task/PageWindRoseFlex.cpp index e33b869..ad5cfde 100644 --- a/lib/obp60task/PageWindRoseFlex.cpp +++ b/lib/obp60task/PageWindRoseFlex.cpp @@ -5,28 +5,27 @@ class PageWindRoseFlex : public Page { -bool keylock = false; // Keylock int16_t lp = 80; // Pointer length public: PageWindRoseFlex(CommonData &common){ + commonData = &common; common.logger->logDebug(GwLog::LOG,"Show PageWindRoseFlex"); } // Key functions virtual int handleKey(int key){ - // Keylock function - if(key == 11){ // Code for keylock - keylock = !keylock; // Toggle keylock + // Code for keylock + if(key == 11){ + commonData->keylock = !commonData->keylock; return 0; // Commit the key } return key; } - virtual void displayPage(CommonData &commonData, PageData &pageData) - { - GwConfigHandler *config = commonData.config; - GwLog *logger=commonData.logger; + virtual void displayPage(PageData &pageData){ + GwConfigHandler *config = commonData->config; + GwLog *logger = commonData->logger; static String svalue1old = ""; static String unit1old = ""; @@ -54,9 +53,9 @@ public: name1 = name1.substring(0, 6); // String length limit for value name double value1 = bvalue1->value; // Value as double in SI unit bool valid1 = bvalue1->valid; // Valid information - value1 = formatValue(bvalue1, commonData).value;// Format only nesaccery for simulation data for pointer - String svalue1 = formatValue(bvalue1, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit1 = formatValue(bvalue1, commonData).unit; // Unit of value + value1 = formatValue(bvalue1, *commonData).value;// Format only nesaccery for simulation data for pointer + String svalue1 = formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit1 = formatValue(bvalue1, *commonData).unit; // Unit of value if(valid1 == true){ svalue1old = svalue1; // Save old value unit1old = unit1; // Save old unit @@ -68,8 +67,8 @@ public: name2 = name2.substring(0, 6); // String length limit for value name double value2 = bvalue2->value; // Value as double in SI unit bool valid2 = bvalue2->valid; // Valid information - String svalue2 = formatValue(bvalue2, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit2 = formatValue(bvalue2, commonData).unit; // Unit of value + String svalue2 = formatValue(bvalue2, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit2 = formatValue(bvalue2, *commonData).unit; // Unit of value if(valid2 == true){ svalue2old = svalue2; // Save old value unit2old = unit2; // Save old unit @@ -81,8 +80,8 @@ public: name3 = name3.substring(0, 6); // String length limit for value name double value3 = bvalue3->value; // Value as double in SI unit bool valid3 = bvalue3->valid; // Valid information - String svalue3 = formatValue(bvalue3, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit3 = formatValue(bvalue3, commonData).unit; // Unit of value + String svalue3 = formatValue(bvalue3, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit3 = formatValue(bvalue3, *commonData).unit; // Unit of value if(valid3 == true){ svalue3old = svalue3; // Save old value unit3old = unit3; // Save old unit @@ -94,8 +93,8 @@ public: name4 = name4.substring(0, 6); // String length limit for value name double value4 = bvalue4->value; // Value as double in SI unit bool valid4 = bvalue4->valid; // Valid information - String svalue4 = formatValue(bvalue4, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit4 = formatValue(bvalue4, commonData).unit; // Unit of value + String svalue4 = formatValue(bvalue4, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit4 = formatValue(bvalue4, *commonData).unit; // Unit of value if(valid4 == true){ svalue4old = svalue4; // Save old value unit4old = unit4; // Save old unit @@ -107,8 +106,8 @@ public: name5 = name5.substring(0, 6); // String length limit for value name double value5 = bvalue5->value; // Value as double in SI unit bool valid5 = bvalue5->valid; // Valid information - String svalue5 = formatValue(bvalue5, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit5 = formatValue(bvalue5, commonData).unit; // Unit of value + String svalue5 = formatValue(bvalue5, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit5 = formatValue(bvalue5, *commonData).unit; // Unit of value if(valid5 == true){ svalue5old = svalue5; // Save old value unit5old = unit5; // Save old unit @@ -120,8 +119,8 @@ public: name6 = name6.substring(0, 6); // String length limit for value name double value6 = bvalue6->value; // Value as double in SI unit bool valid6 = bvalue6->valid; // Valid information - String svalue6 = formatValue(bvalue6, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit6 = formatValue(bvalue6, commonData).unit; // Unit of value + String svalue6 = formatValue(bvalue6, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit6 = formatValue(bvalue6, *commonData).unit; // Unit of value if(valid6 == true){ svalue6old = svalue6; // Save old value unit6old = unit6; // Save old unit @@ -143,7 +142,7 @@ public: // Set display in partial refresh mode getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update - getdisplay().setTextColor(commonData.fgcolor); + getdisplay().setTextColor(commonData->fgcolor); // Show values AWA getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b); @@ -163,7 +162,7 @@ public: } // Horizintal separator left - getdisplay().fillRect(0, 149, 60, 3, commonData.fgcolor); + getdisplay().fillRect(0, 149, 60, 3, commonData->fgcolor); // Show values AWS getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b); @@ -205,7 +204,7 @@ public: } // Horizintal separator right - getdisplay().fillRect(340, 149, 80, 3, commonData.fgcolor); + getdisplay().fillRect(340, 149, 80, 3, commonData->fgcolor); // Show values TWS getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b); @@ -230,10 +229,10 @@ public: int rInstrument = 110; // Radius of grafic instrument float pi = 3.141592; - getdisplay().fillCircle(200, 150, rInstrument + 10, commonData.fgcolor); // Outer circle - getdisplay().fillCircle(200, 150, rInstrument + 7, commonData.bgcolor); // Outer circle - getdisplay().fillCircle(200, 150, rInstrument - 10, commonData.fgcolor); // Inner circle - getdisplay().fillCircle(200, 150, rInstrument - 13, commonData.bgcolor); // Inner circle + getdisplay().fillCircle(200, 150, rInstrument + 10, commonData->fgcolor); // Outer circle + getdisplay().fillCircle(200, 150, rInstrument + 7, commonData->bgcolor); // Outer circle + getdisplay().fillCircle(200, 150, rInstrument - 10, commonData->fgcolor); // Inner circle + getdisplay().fillCircle(200, 150, rInstrument - 13, commonData->bgcolor); // Inner circle for(int i=0; i<360; i=i+10) { @@ -271,7 +270,7 @@ public: // Draw sub scale with dots 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, commonData.fgcolor); + getdisplay().fillCircle((int)x1c, (int)y1c, 2, commonData->fgcolor); float sinx=sin(i/180.0*pi); float cosx=cos(i/180.0*pi); @@ -284,10 +283,10 @@ 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),commonData.fgcolor); + 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),commonData.fgcolor); + 200+(int)(cosx*xx2-sinx*yy2),150+(int)(sinx*xx2+cosx*yy2),commonData->fgcolor); } } @@ -304,7 +303,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),commonData.fgcolor); + 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 @@ -314,12 +313,12 @@ 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),commonData.fgcolor); + 200+(int)(cosx*0-sinx*iy2),150+(int)(sinx*0+cosx*iy2),commonData->fgcolor); } // Center circle - getdisplay().fillCircle(200, 150, startwidth + 6, commonData.bgcolor); - getdisplay().fillCircle(200, 150, startwidth + 4, commonData.fgcolor); + getdisplay().fillCircle(200, 150, startwidth + 6, commonData->bgcolor); + getdisplay().fillCircle(200, 150, startwidth + 4, commonData->fgcolor); //******************************************************************************************* @@ -353,18 +352,12 @@ public: // Key Layout getdisplay().setFont(&Ubuntu_Bold8pt7b); - if(keylock == false){ - getdisplay().setCursor(130, 290); - getdisplay().print("[ <<<< " + String(commonData.data.actpage) + "/" + String(commonData.data.maxpage) + " >>>> ]"); + if(commonData->keylock == false){ if(String(backlightMode) == "Control by Key"){ // Key for illumination getdisplay().setCursor(343, 290); getdisplay().print("[ILUM]"); } } - else{ - getdisplay().setCursor(130, 290); - getdisplay().print(" [ Keylock active ]"); - } // Update display getdisplay().nextPage(); // Partial update (fast) diff --git a/lib/obp60task/PageXTETrack.cpp b/lib/obp60task/PageXTETrack.cpp index 91afff1..d16a8b7 100644 --- a/lib/obp60task/PageXTETrack.cpp +++ b/lib/obp60task/PageXTETrack.cpp @@ -26,12 +26,12 @@ static unsigned char ship_bits[] PROGMEM = { 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00 }; -class PageXTETrack : public Page{ - bool keylock = false; // Keylock - +class PageXTETrack : public Page +{ public: PageXTETrack(CommonData &common){ - common.logger->logDebug(GwLog::LOG,"Show PageXTETrack"); + commonData = &common; + common.logger->logDebug(GwLog::LOG,"Instantiate PageXTETrack"); } void drawSegment(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, @@ -52,16 +52,17 @@ class PageXTETrack : public Page{ } virtual int handleKey(int key){ - if(key == 11){ // Code for keylock - keylock = !keylock; // Toggle keylock + // Code for keylock + if(key == 11){ + commonData->keylock = !commonData->keylock; return 0; // Commit the key } return key; } - virtual void displayPage(CommonData &commonData, PageData &pageData){ - GwConfigHandler *config = commonData.config; - GwLog *logger=commonData.logger; + virtual void displayPage(PageData &pageData){ + GwConfigHandler *config = commonData->config; + GwLog *logger = commonData->logger; // Get config data String flashLED = config->getString(config->flashLED); @@ -85,7 +86,7 @@ class PageXTETrack : public Page{ // Set display in partial refresh mode getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update - getdisplay().setTextColor(commonData.fgcolor); + getdisplay().setTextColor(commonData->fgcolor); // descriptions getdisplay().setFont(&Ubuntu_Bold8pt7b); @@ -105,25 +106,25 @@ class PageXTETrack : public Page{ uint16_t w, h; GwApi::BoatValue *bv_xte = pageData.values[0]; // XTE - String sval_xte = formatValue(bv_xte, commonData).svalue; + String sval_xte = formatValue(bv_xte, *commonData).svalue; getdisplay().getTextBounds(sval_xte, 0, 0, &x, &y, &w, &h); getdisplay().setCursor(160-w, 170); getdisplay().print(sval_xte); GwApi::BoatValue *bv_cog = pageData.values[1]; // COG - String sval_cog = formatValue(bv_cog, commonData).svalue; + String sval_cog = formatValue(bv_cog, *commonData).svalue; getdisplay().getTextBounds(sval_cog, 0, 0, &x, &y, &w, &h); getdisplay().setCursor(360-w, 170); getdisplay().print(sval_cog); GwApi::BoatValue *bv_dtw = pageData.values[2]; // DTW - String sval_dtw = formatValue(bv_dtw, commonData).svalue; + String sval_dtw = formatValue(bv_dtw, *commonData).svalue; getdisplay().getTextBounds(sval_dtw, 0, 0, &x, &y, &w, &h); getdisplay().setCursor(160-w, 257); getdisplay().print(sval_dtw); GwApi::BoatValue *bv_btw = pageData.values[3]; // BTW - String sval_btw = formatValue(bv_btw, commonData).svalue; + String sval_btw = formatValue(bv_btw, *commonData).svalue; getdisplay().getTextBounds(sval_btw, 0, 0, &x, &y, &w, &h); getdisplay().setCursor(360-w, 257); getdisplay().print(sval_btw); @@ -133,7 +134,7 @@ class PageXTETrack : public Page{ // XTETrack view // draw ship symbol (as bitmap) - getdisplay().drawXBitmap(184, 68, ship_bits, ship_width, ship_height, commonData.fgcolor); + getdisplay().drawXBitmap(184, 68, ship_bits, ship_width, ship_height, commonData->fgcolor); // draw next waypoint name String sval_wpname = "no data"; @@ -188,28 +189,22 @@ class PageXTETrack : public Page{ } // left segments - drawSegment(0, 54, 46, 24, 75, 24, 0, 90, commonData.fgcolor, seg[2]); - drawSegment(0, 100, 82, 24, 112, 24, 50, 100, commonData.fgcolor, seg[1]); - drawSegment(60, 100, 117, 24, 147, 24, 110, 100, commonData.fgcolor,seg[0]); + drawSegment(0, 54, 46, 24, 75, 24, 0, 90, commonData->fgcolor, seg[2]); + drawSegment(0, 100, 82, 24, 112, 24, 50, 100, commonData->fgcolor, seg[1]); + drawSegment(60, 100, 117, 24, 147, 24, 110, 100, commonData->fgcolor,seg[0]); // right segments - drawSegment(340, 100, 283, 24, 253, 24, 290, 100, commonData.fgcolor, seg[3]); - drawSegment(399, 100, 318, 24, 289, 24, 350, 100, commonData.fgcolor, seg[4]); - drawSegment(399, 54, 354, 24, 325, 24, 399, 90, commonData.fgcolor, seg[5]); + drawSegment(340, 100, 283, 24, 253, 24, 290, 100, commonData->fgcolor, seg[3]); + drawSegment(399, 100, 318, 24, 289, 24, 350, 100, commonData->fgcolor, seg[4]); + drawSegment(399, 54, 354, 24, 325, 24, 399, 90, commonData->fgcolor, seg[5]); // Key Layout getdisplay().setFont(&Ubuntu_Bold8pt7b); - if(keylock == false){ - getdisplay().setCursor(130, 296); - getdisplay().print("[ <<<< " + String(commonData.data.actpage) + "/" + String(commonData.data.maxpage) + " >>>> ]"); + if(commonData->keylock == false){ if(String(backlightMode) == "Control by Key"){ // Key for illumination getdisplay().setCursor(343, 296); getdisplay().print("[ILUM]"); } } - else{ - getdisplay().setCursor(130, 296); - getdisplay().print(" [ Keylock active ]"); - } // Update display getdisplay().nextPage(); // Partial update (fast) diff --git a/lib/obp60task/Pagedata.h b/lib/obp60task/Pagedata.h index d18452f..9f9764c 100644 --- a/lib/obp60task/Pagedata.h +++ b/lib/obp60task/Pagedata.h @@ -73,13 +73,16 @@ typedef struct{ GwApi::BoatValue *date=NULL; uint16_t fgcolor; uint16_t bgcolor; + bool keylock = false; } CommonData; //a base class that all pages must inherit from class Page{ + protected: + CommonData *commonData; public: - virtual void displayPage(CommonData &commonData, PageData &pageData)=0; - virtual void displayNew(CommonData &commonData, PageData &pageData){} + virtual void displayPage(PageData &pageData)=0; + virtual void displayNew(PageData &pageData){} //return -1 if handled by the page virtual int handleKey(int key){return key;} }; diff --git a/lib/obp60task/obp60task.cpp b/lib/obp60task/obp60task.cpp index 73bd9fe..f85e746 100644 --- a/lib/obp60task/obp60task.cpp +++ b/lib/obp60task/obp60task.cpp @@ -629,12 +629,13 @@ void OBP60Task(GwApi *api){ } else{ if (lastPage != pageNumber){ - currentPage->displayNew(commonData,pages[pageNumber].parameters); + if (hasFRAM) fram.write(FRAM_PAGE_NO, pageNumber); // remember page for device restart + currentPage->displayNew(pages[pageNumber].parameters); lastPage=pageNumber; } //call the page code LOG_DEBUG(GwLog::DEBUG,"calling page %d",pageNumber); - currentPage->displayPage(commonData,pages[pageNumber].parameters); + currentPage->displayPage(pages[pageNumber].parameters); } } }