From 726b1abf2db5339579ff0fe34330bdfc5da68809 Mon Sep 17 00:00:00 2001 From: norbert-walter Date: Sun, 24 Mar 2024 14:10:26 +0100 Subject: [PATCH] First Alpha Version V0.80 --- lib/obp60task/OBP60Extensions.cpp | 66 ++++++++++++++-------------- lib/obp60task/PageApparentWind.cpp | 1 - lib/obp60task/PageBME280.cpp | 1 - lib/obp60task/PageBattery.cpp | 1 - lib/obp60task/PageBattery2.cpp | 1 - lib/obp60task/PageClock.cpp | 1 - lib/obp60task/PageDST810.cpp | 1 - lib/obp60task/PageFourValues.cpp | 1 - lib/obp60task/PageFourValues2.cpp | 1 - lib/obp60task/PageGenerator.cpp | 1 - lib/obp60task/PageKeelPosition.cpp | 2 - lib/obp60task/PageOneValue.cpp | 1 - lib/obp60task/PageRollPitch.cpp | 1 - lib/obp60task/PageRudderPosition.cpp | 2 - lib/obp60task/PageSolar.cpp | 1 - lib/obp60task/PageThreeValues.cpp | 1 - lib/obp60task/PageTwoValues.cpp | 1 - lib/obp60task/PageVoltage.cpp | 1 - lib/obp60task/PageWhite.cpp | 1 - lib/obp60task/PageWindRose.cpp | 1 - lib/obp60task/config.json | 9 ++++ lib/obp60task/obp60task.cpp | 14 ++++-- lib/obp60task/obp60task.h | 3 +- 23 files changed, 54 insertions(+), 59 deletions(-) diff --git a/lib/obp60task/OBP60Extensions.cpp b/lib/obp60task/OBP60Extensions.cpp index b4c191f..c565c6c 100644 --- a/lib/obp60task/OBP60Extensions.cpp +++ b/lib/obp60task/OBP60Extensions.cpp @@ -77,7 +77,7 @@ void hardwareInit() setPortPin(OBP_POWER_50, true); // Init E-Ink display - //display.init(115200, true, 2, false); // Use this for Waveshare boards with "clever" reset circuit, 2ms reset pulse + //getdisplay().init(115200, true, 2, false); // Use this for Waveshare boards with "clever" reset circuit, 2ms reset pulse // Init RGB LEDs @@ -225,12 +225,12 @@ String xdrDelete(String input){ // Show a triangle for trend direction high (x, y is the left edge) void displayTrendHigh(int16_t x, int16_t y, uint16_t size, uint16_t color){ - display.fillTriangle(x, y, x+size*2, y, x+size, y-size*2, color); + getdisplay().fillTriangle(x, y, x+size*2, y, x+size, y-size*2, color); } // Show a triangle for trend direction low (x, y is the left edge) void displayTrendLow(int16_t x, int16_t y, uint16_t size, uint16_t color){ - display.fillTriangle(x, y, x+size*2, y, x+size, y+size*2, color); + getdisplay().fillTriangle(x, y, x+size*2, y, x+size, y+size*2, color); } // Show header informations @@ -259,27 +259,27 @@ void displayHeader(CommonData &commonData, GwApi::BoatValue *date, GwApi::BoatVa } // Show status info - display.setTextColor(textcolor); - display.setFont(&Ubuntu_Bold8pt7b); - display.setCursor(0, 15); + getdisplay().setTextColor(textcolor); + getdisplay().setFont(&Ubuntu_Bold8pt7b); + getdisplay().setCursor(0, 15); if(commonData.status.wifiApOn){ - display.print(" AP "); + getdisplay().print(" AP "); } // If receive new telegram data then display bus name if(commonData.status.tcpClRx != tcpClRxOld || commonData.status.tcpClTx != tcpClTxOld || commonData.status.tcpSerRx != tcpSerRxOld || commonData.status.tcpSerTx != tcpSerTxOld){ - display.print("TCP "); + getdisplay().print("TCP "); } if(commonData.status.n2kRx != n2kRxOld || commonData.status.n2kTx != n2kTxOld){ - display.print("N2K "); + getdisplay().print("N2K "); } if(commonData.status.serRx != serRxOld || commonData.status.serTx != serTxOld){ - display.print("183 "); + getdisplay().print("183 "); } if(commonData.status.usbRx != usbRxOld || commonData.status.usbTx != usbTxOld){ - display.print("USB "); + getdisplay().print("USB "); } if(commonData.config->getBool(commonData.config->useGPS) == true && date->valid == true){ - display.print("GPS"); + getdisplay().print("GPS"); } // Save old telegram counter tcpClRxOld = commonData.status.tcpClRx; @@ -294,38 +294,38 @@ void displayHeader(CommonData &commonData, GwApi::BoatValue *date, GwApi::BoatVa usbTxOld = commonData.status.usbTx; // Heartbeat as dot - display.setTextColor(textcolor); - display.setFont(&Ubuntu_Bold32pt7b); - display.setCursor(205, 14); + getdisplay().setTextColor(textcolor); + getdisplay().setFont(&Ubuntu_Bold32pt7b); + getdisplay().setCursor(205, 14); if(heartbeat == true){ - display.print("."); + getdisplay().print("."); } else{ - display.print(" "); + getdisplay().print(" "); } heartbeat = !heartbeat; // Date and time - display.setTextColor(textcolor); - display.setFont(&Ubuntu_Bold8pt7b); - display.setCursor(230, 15); + getdisplay().setTextColor(textcolor); + getdisplay().setFont(&Ubuntu_Bold8pt7b); + getdisplay().setCursor(230, 15); if(date->valid == true){ String acttime = formatValue(time, commonData).svalue; acttime = acttime.substring(0, 5); String actdate = formatValue(date, commonData).svalue; - display.print(acttime); - display.print(" "); - display.print(actdate); - display.print(" "); + getdisplay().print(acttime); + getdisplay().print(" "); + getdisplay().print(actdate); + getdisplay().print(" "); if(commonData.config->getInt(commonData.config->timeZone) == 0){ - display.print("UTC"); + getdisplay().print("UTC"); } else{ - display.print("LOT"); + getdisplay().print("LOT"); } } else{ - display.print("No GPS data"); + getdisplay().print("No GPS data"); } } } @@ -385,20 +385,20 @@ void batteryGraphic(uint x, uint y, float percent, int pcolor, int bcolor){ } // Battery corpus 100x80 with fill level int level = int((100.0 - percent) * (80-(2*t)) / 100.0); - display.fillRect(xb, yb, 100, 80, pcolor); + getdisplay().fillRect(xb, yb, 100, 80, pcolor); if(percent < 99){ - display.fillRect(xb+t, yb+t, 100-(2*t), level, bcolor); + getdisplay().fillRect(xb+t, yb+t, 100-(2*t), level, bcolor); } // Plus pol 20x15 int xp = xb + 20; int yp = yb - 15 + t; - display.fillRect(xp, yp, 20, 15, pcolor); - display.fillRect(xp+t, yp+t, 20-(2*t), 15-(2*t), bcolor); + getdisplay().fillRect(xp, yp, 20, 15, pcolor); + getdisplay().fillRect(xp+t, yp+t, 20-(2*t), 15-(2*t), bcolor); // Minus pol 20x15 int xm = xb + 60; int ym = yb -15 + t; - display.fillRect(xm, ym, 20, 15, pcolor); - display.fillRect(xm+t, ym+t, 20-(2*t), 15-(2*t), bcolor); + getdisplay().fillRect(xm, ym, 20, 15, pcolor); + getdisplay().fillRect(xm+t, ym+t, 20-(2*t), 15-(2*t), bcolor); } #endif \ No newline at end of file diff --git a/lib/obp60task/PageApparentWind.cpp b/lib/obp60task/PageApparentWind.cpp index 77e4fa6..41be004 100644 --- a/lib/obp60task/PageApparentWind.cpp +++ b/lib/obp60task/PageApparentWind.cpp @@ -106,7 +106,6 @@ public: } // Set display in partial refresh mode getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update - getdisplay().fillScreen(bgcolor); // Clear display // Show values AWS getdisplay().setTextColor(textcolor); diff --git a/lib/obp60task/PageBME280.cpp b/lib/obp60task/PageBME280.cpp index 496ea83..a46f243 100644 --- a/lib/obp60task/PageBME280.cpp +++ b/lib/obp60task/PageBME280.cpp @@ -121,7 +121,6 @@ class PageBME280 : public Page } // Set display in partial refresh mode getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update - getdisplay().fillScreen(bgcolor); // Clear display // ############### Value 1 ################ diff --git a/lib/obp60task/PageBattery.cpp b/lib/obp60task/PageBattery.cpp index ba570db..e0758d2 100644 --- a/lib/obp60task/PageBattery.cpp +++ b/lib/obp60task/PageBattery.cpp @@ -169,7 +169,6 @@ class PageBattery : public Page } // Set display in partial refresh mode getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update - getdisplay().fillScreen(bgcolor); // Clear display // Show average settings getdisplay().setTextColor(textcolor); diff --git a/lib/obp60task/PageBattery2.cpp b/lib/obp60task/PageBattery2.cpp index 7ec911b..a88ad40 100644 --- a/lib/obp60task/PageBattery2.cpp +++ b/lib/obp60task/PageBattery2.cpp @@ -195,7 +195,6 @@ public: } // Set display in partial refresh mode getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update - getdisplay().fillScreen(bgcolor); // Clear display // Show name getdisplay().setTextColor(textcolor); diff --git a/lib/obp60task/PageClock.cpp b/lib/obp60task/PageClock.cpp index c7b341d..e14d3e7 100644 --- a/lib/obp60task/PageClock.cpp +++ b/lib/obp60task/PageClock.cpp @@ -107,7 +107,6 @@ public: } // Set display in partial refresh mode getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update - getdisplay().fillScreen(bgcolor); // Clear display // Show values GPS date getdisplay().setTextColor(textcolor); diff --git a/lib/obp60task/PageDST810.cpp b/lib/obp60task/PageDST810.cpp index 759e5f6..3ee57ad 100644 --- a/lib/obp60task/PageDST810.cpp +++ b/lib/obp60task/PageDST810.cpp @@ -107,7 +107,6 @@ class PageDST810 : public Page } // Set display in partial refresh mode getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update - getdisplay().fillScreen(bgcolor); // Clear display // ############### Value 1 ################ diff --git a/lib/obp60task/PageFourValues.cpp b/lib/obp60task/PageFourValues.cpp index 307d1ec..e9106b8 100644 --- a/lib/obp60task/PageFourValues.cpp +++ b/lib/obp60task/PageFourValues.cpp @@ -107,7 +107,6 @@ class PageFourValues : public Page } // Set display in partial refresh mode getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update - getdisplay().fillScreen(bgcolor); // Clear display // ############### Value 1 ################ diff --git a/lib/obp60task/PageFourValues2.cpp b/lib/obp60task/PageFourValues2.cpp index db0168b..9dd9a21 100644 --- a/lib/obp60task/PageFourValues2.cpp +++ b/lib/obp60task/PageFourValues2.cpp @@ -107,7 +107,6 @@ class PageFourValues2 : public Page } // Set display in partial refresh mode getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update - getdisplay().fillScreen(bgcolor); // Clear display // ############### Value 1 ################ diff --git a/lib/obp60task/PageGenerator.cpp b/lib/obp60task/PageGenerator.cpp index 8220721..432ae47 100644 --- a/lib/obp60task/PageGenerator.cpp +++ b/lib/obp60task/PageGenerator.cpp @@ -83,7 +83,6 @@ public: } /// Set display in partial refresh mode getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update - getdisplay().fillScreen(bgcolor); // Clear display // Show name getdisplay().setTextColor(textcolor); diff --git a/lib/obp60task/PageKeelPosition.cpp b/lib/obp60task/PageKeelPosition.cpp index 37a799d..d7eaaf2 100644 --- a/lib/obp60task/PageKeelPosition.cpp +++ b/lib/obp60task/PageKeelPosition.cpp @@ -85,8 +85,6 @@ public: } // Set display in partial refresh mode getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update - getdisplay().fillScreen(bgcolor); // Clear display - //******************************************************************************************* diff --git a/lib/obp60task/PageOneValue.cpp b/lib/obp60task/PageOneValue.cpp index 7d1caae..7998dd6 100644 --- a/lib/obp60task/PageOneValue.cpp +++ b/lib/obp60task/PageOneValue.cpp @@ -73,7 +73,6 @@ class PageOneValue : public Page{ } /// Set display in partial refresh mode getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update - getdisplay().fillScreen(bgcolor); // Clear display // Show name getdisplay().setTextColor(textcolor); diff --git a/lib/obp60task/PageRollPitch.cpp b/lib/obp60task/PageRollPitch.cpp index 23d65e6..2667e10 100644 --- a/lib/obp60task/PageRollPitch.cpp +++ b/lib/obp60task/PageRollPitch.cpp @@ -145,7 +145,6 @@ public: } // Set display in partial refresh mode getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update - getdisplay().fillScreen(bgcolor); // Clear display // Horizintal separator left getdisplay().fillRect(0, 149, 60, 3, pixelcolor); diff --git a/lib/obp60task/PageRudderPosition.cpp b/lib/obp60task/PageRudderPosition.cpp index 7369b0b..675e301 100644 --- a/lib/obp60task/PageRudderPosition.cpp +++ b/lib/obp60task/PageRudderPosition.cpp @@ -81,8 +81,6 @@ public: } // Set display in partial refresh mode getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update - getdisplay().fillScreen(bgcolor); // Clear display - //******************************************************************************************* diff --git a/lib/obp60task/PageSolar.cpp b/lib/obp60task/PageSolar.cpp index 323ac95..75631d4 100644 --- a/lib/obp60task/PageSolar.cpp +++ b/lib/obp60task/PageSolar.cpp @@ -83,7 +83,6 @@ public: } // Set display in partial refresh mode getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update - getdisplay().fillScreen(bgcolor); // Clear display // Show name getdisplay().setTextColor(textcolor); diff --git a/lib/obp60task/PageThreeValues.cpp b/lib/obp60task/PageThreeValues.cpp index 6e8042e..fef7b80 100644 --- a/lib/obp60task/PageThreeValues.cpp +++ b/lib/obp60task/PageThreeValues.cpp @@ -96,7 +96,6 @@ class PageThreeValues : public Page } /// Set display in partial refresh mode getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update - getdisplay().fillScreen(bgcolor); // Clear display // ############### Value 1 ################ diff --git a/lib/obp60task/PageTwoValues.cpp b/lib/obp60task/PageTwoValues.cpp index 47dabec..2bcb80a 100644 --- a/lib/obp60task/PageTwoValues.cpp +++ b/lib/obp60task/PageTwoValues.cpp @@ -85,7 +85,6 @@ class PageTwoValues : public Page } // Set display in partial refresh mode getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update - getdisplay().fillScreen(bgcolor); // Clear display // ############### Value 1 ################ diff --git a/lib/obp60task/PageVoltage.cpp b/lib/obp60task/PageVoltage.cpp index c8cc6e3..36cba5b 100644 --- a/lib/obp60task/PageVoltage.cpp +++ b/lib/obp60task/PageVoltage.cpp @@ -149,7 +149,6 @@ public: } // Set display in partial refresh mode getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update - getdisplay().fillScreen(bgcolor); // Clear display // Show name getdisplay().setTextColor(textcolor); diff --git a/lib/obp60task/PageWhite.cpp b/lib/obp60task/PageWhite.cpp index 366c6c6..e941732 100644 --- a/lib/obp60task/PageWhite.cpp +++ b/lib/obp60task/PageWhite.cpp @@ -35,7 +35,6 @@ class PageWhite : public Page{ // Set display in partial refresh mode getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update - getdisplay().fillScreen(bgcolor); // Clear display // Update display getdisplay().nextPage(); // Partial update (fast) diff --git a/lib/obp60task/PageWindRose.cpp b/lib/obp60task/PageWindRose.cpp index a74ac6d..e5fe969 100644 --- a/lib/obp60task/PageWindRose.cpp +++ b/lib/obp60task/PageWindRose.cpp @@ -156,7 +156,6 @@ public: } // Set display in partial refresh mode getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update - getdisplay().fillScreen(bgcolor); // Clear display // Show values AWA getdisplay().setTextColor(textcolor); diff --git a/lib/obp60task/config.json b/lib/obp60task/config.json index 82da582..93452e9 100644 --- a/lib/obp60task/config.json +++ b/lib/obp60task/config.json @@ -1,4 +1,13 @@ [ + { + "name": "deviceName", + "label": "system name", + "type": "string", + "default": "OBP60V2", + "check": "checkSystemName", + "description": "system name, used for the access point and for services", + "category": "system" + }, { "name": "timeZone", "label": "Time Zone", diff --git a/lib/obp60task/obp60task.cpp b/lib/obp60task/obp60task.cpp index 530ddb1..c7749f0 100644 --- a/lib/obp60task/obp60task.cpp +++ b/lib/obp60task/obp60task.cpp @@ -30,6 +30,11 @@ int taskRunCounter = 0; // Task couter for loop section // Hardware initialization before start all services //#################################################################################### void OBP60Init(GwApi *api){ + + // Set a new device name and hidden the original name in the main config + String devicename = api->getConfig()->getConfigItem(api->getConfig()->deviceName,true)->asString(); + api->getConfig()->setValue(GwConfigDefinitions::systemName, devicename, GwConfigInterface::ConfigType::HIDDEN); + api->getLogger()->logDebug(GwLog::LOG,"obp60init running"); // Check I2C devices @@ -477,7 +482,7 @@ void OBP60Task(GwApi *api){ // Full display update afer a new selected page and 4s wait time if(millis() > starttime4 + 4000 && delayedDisplayUpdate == true){ getdisplay().setFullWindow(); // Set full update - getdisplay().nextPage(); // Full Update + getdisplay().nextPage(); // Full update delayedDisplayUpdate = false; } @@ -487,7 +492,7 @@ void OBP60Task(GwApi *api){ starttime1 = millis(); LOG_DEBUG(GwLog::DEBUG,"E-Ink full refresh first 5 min"); getdisplay().setFullWindow(); // Set full update - getdisplay().nextPage(); // Full Update + getdisplay().nextPage(); // Full update } // Subtask E-Ink full refresh @@ -495,7 +500,7 @@ void OBP60Task(GwApi *api){ starttime2 = millis(); LOG_DEBUG(GwLog::DEBUG,"E-Ink full refresh"); getdisplay().setFullWindow(); // Set full update - getdisplay().nextPage(); // Full Update + getdisplay().nextPage(); // Full update } // Refresh display data all 1s @@ -509,7 +514,8 @@ void OBP60Task(GwApi *api){ getdisplay().fillRect(0, 0, getdisplay().width(), getdisplay().height(), bgcolor); // Clear display if (pages[pageNumber].description && pages[pageNumber].description->header){ //build some header and footer using commonData - displayHeader(commonData, date, time); + getdisplay().fillScreen(bgcolor); // Clear display + displayHeader(commonData, date, time); // Sown header } // Call the particular page diff --git a/lib/obp60task/obp60task.h b/lib/obp60task/obp60task.h index c81e68f..e184220 100644 --- a/lib/obp60task/obp60task.h +++ b/lib/obp60task/obp60task.h @@ -21,6 +21,7 @@ // OBP60 Task void OBP60Task(GwApi *param); - DECLARE_USERTASK_PARAM(OBP60Task, 10000) // Need 8k RAM as stack size + DECLARE_USERTASK_PARAM(OBP60Task, 10000); // Need 8k RAM as stack size DECLARE_CAPABILITY(obp60,true); + DECLARE_STRING_CAPABILITY(HELP_URL, "https://obp60-v2-docu.readthedocs.io/de/latest/"); // Link to help pages #endif \ No newline at end of file