diff --git a/extra_script.py b/extra_script.py index b185a93..dd9a90b 100644 --- a/extra_script.py +++ b/extra_script.py @@ -526,3 +526,17 @@ env.Append( ) #script does not run on clean yet - maybe in the future env.AddPostAction("clean",cleangenerated) + +#look for extra task scripts and include them here +for taskdir in userTaskDirs: + script = os.path.join(taskdir, "extra_task.py") + if os.path.isfile(script): + taskname = os.path.basename(os.path.normpath(taskdir)) + print("#extra task script for '{}'".format(taskname)) + with open(script) as fh: + try: + code = compile(fh.read(), taskname, 'exec') + except SyntaxError: + print("#ERROR: script does not compile") + continue + exec(code) diff --git a/extra_script.py.new b/extra_script.py.new index 31ae608..dd9a90b 100644 --- a/extra_script.py.new +++ b/extra_script.py.new @@ -520,19 +520,23 @@ prebuild(env) board="PLATFORM_BOARD_%s"%env["BOARD"].replace("-","_").upper() print("Board=#%s#"%board) print("BuildFlags=%s"%(" ".join(env["BUILD_FLAGS"]))) - -epdtype = "unknown" -pcbvers = "unknown" -for x in env["BUILD_FLAGS"]: - if x.startswith("-D HARDWARE_"): - pcbvers = x.split('_')[1] - if x.startswith("-D DISPLAY_"): - epdtype = x.split('_')[1] - env.Append( LINKFLAGS=[ "-u", "custom_app_desc" ], - CPPDEFINES=[(board,"1"), ("BOARD", env["BOARD"]), ("EPDTYPE", epdtype), - ("PCBVERS", pcbvers)] + CPPDEFINES=[(board,"1")] ) #script does not run on clean yet - maybe in the future env.AddPostAction("clean",cleangenerated) + +#look for extra task scripts and include them here +for taskdir in userTaskDirs: + script = os.path.join(taskdir, "extra_task.py") + if os.path.isfile(script): + taskname = os.path.basename(os.path.normpath(taskdir)) + print("#extra task script for '{}'".format(taskname)) + with open(script) as fh: + try: + code = compile(fh.read(), taskname, 'exec') + except SyntaxError: + print("#ERROR: script does not compile") + continue + exec(code) diff --git a/lib/obp60task/OBP60Extensions.cpp b/lib/obp60task/OBP60Extensions.cpp index 9b86292..70348e7 100644 --- a/lib/obp60task/OBP60Extensions.cpp +++ b/lib/obp60task/OBP60Extensions.cpp @@ -300,6 +300,49 @@ void fillPoly4(const std::vector& p4, uint16_t color) { getdisplay().fillTriangle(p4[0].x, p4[0].y, p4[2].x, p4[2].y, p4[3].x, p4[3].y, color); } +// Split string into words, whitespace separated +std::vector split(const String &s) { + std::vector words; + String word = ""; + for (size_t i = 0; i < s.length(); i++) { + if (s[i] == ' ' || s[i] == '\t' || s[i] == '\r' || s[i] == '\n') { + if (word.length() > 0) { + words.push_back(word); + word = ""; + } + } else { + word += s[i]; + } + } + if (word.length() > 0) { + words.push_back(word); + } + return words; +} + +// Wordwrap single line, monospaced font +std::vector wordwrap(String &line, uint16_t maxwidth) { + std::vector lines; + std::vector words = split(line); + String currentLine = ""; + for (const auto& word : words) { + if (currentLine.length() + word.length() + 1 > maxwidth) { + if (currentLine.length() > 0) { + lines.push_back(currentLine); + currentLine = ""; + } + } + if (currentLine.length() > 0) { + currentLine += " "; + } + currentLine += word; + } + if (currentLine.length() > 0) { + lines.push_back(currentLine); + } + return lines; +} + // Draw centered text void drawTextCenter(int16_t cx, int16_t cy, String text) { int16_t x1, y1; @@ -545,6 +588,47 @@ void displayFooter(CommonData &commonData) { #endif } +// Alarm overlay, to be drawn as very last draw operation +void displayAlarm(CommonData &commonData) { + + const uint16_t x = 50; // overlay area + const uint16_t y = 100; + const uint16_t w = 300; + const uint16_t h = 150; + + getdisplay().setFont(&Atari16px); + getdisplay().setTextColor(commonData.fgcolor); + + // overlay + getdisplay().drawRect(x, y, w, h, commonData.fgcolor); + getdisplay().fillRect(x + 1, y + 1, w - 1, h - 1, commonData.bgcolor); + getdisplay().drawRect(x + 3, y + 3, w - 5, h - 5, commonData.fgcolor); + + // exclamation icon in left top corner + getdisplay().drawXBitmap(x + 16, y + 16, exclamation_bits, exclamation_width, exclamation_height, commonData.fgcolor); + + // title + getdisplay().setCursor(x + 64, y + 30); + getdisplay().print("A L A R M"); + getdisplay().setCursor(x + 64, y + 48); + getdisplay().print("#" + commonData.alarm.id); + getdisplay().print(" from "); + getdisplay().print(commonData.alarm.source); + + // message, but maximum 4 lines + std::vector lines = wordwrap (commonData.alarm.message, w - 16 - 8 / 8); + int n = 0; + for (const auto& l : lines) { + getdisplay().setCursor(x + 16, y + 80 + n); + getdisplay().print(l); + n += 16; + if (n > 64) { + break; + } + } + drawTextCenter(x + w / 2, y + h - 16, "Press button 1 to dismiss alarm"); +} + // Sunset und sunrise calculation SunData calcSunsetSunrise(double time, double date, double latitude, double longitude, float timezone){ SunData returnset; diff --git a/lib/obp60task/OBP60Extensions.h b/lib/obp60task/OBP60Extensions.h index 94e7935..ed67716 100644 --- a/lib/obp60task/OBP60Extensions.h +++ b/lib/obp60task/OBP60Extensions.h @@ -57,6 +57,11 @@ GxEPD2_BW & getdisplay(); GxEPD2_BW & getdisplay(); #endif +// Page display return values +#define PAGE_OK 0 // all ok, do nothing +#define PAGE_UPDATE 1 // page wants display to update +#define PAGE_HIBERNATE 2 // page wants displey to hibernate + struct Point { double x; double y; @@ -97,6 +102,7 @@ void displayTrendLow(int16_t x, int16_t y, uint16_t size, uint16_t color); void displayHeader(CommonData &commonData, GwApi::BoatValue *date, GwApi::BoatValue *time, GwApi::BoatValue *hdop); // Draw display header void displayFooter(CommonData &commonData); +void displayAlarm(CommonData &commonData); SunData calcSunsetSunrise(double time, double date, double latitude, double longitude, float timezone); // Calulate sunset and sunrise SunData calcSunsetSunriseRTC(struct tm *rtctime, double latitude, double longitude, float timezone); @@ -142,12 +148,12 @@ static unsigned char fram_bits[] PROGMEM = { 0xff, 0xff, 0xf8, 0x1f, 0xf8, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x1f, 0xf8, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x1f }; -static unsigned char ap_bits[] = { +static unsigned char ap_bits[] PROGMEM = { 0xe0, 0x03, 0x18, 0x0c, 0x04, 0x10, 0xc2, 0x21, 0x30, 0x06, 0x08, 0x08, 0xc0, 0x01, 0x20, 0x02, 0x00, 0x00, 0x80, 0x00, 0xc0, 0x01, 0xc0, 0x01, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00 }; -static unsigned char dish_bits[] PROGMEM= { +static unsigned char dish_bits[] PROGMEM = { 0x3c, 0x00, 0x42, 0x18, 0xfa, 0x1b, 0x02, 0x04, 0x02, 0x0a, 0x02, 0x09, 0x82, 0x08, 0x06, 0x0a, 0x0e, 0x1b, 0x9c, 0x2b, 0x38, 0x2b, 0x74, 0x20, 0xec, 0x1f, 0x1c, 0x00, 0xf4, 0x00, 0xfe, 0x03 }; diff --git a/lib/obp60task/OBP60Formater.cpp b/lib/obp60task/OBP60Formater.cpp index 6ac51a8..3fb5cff 100644 --- a/lib/obp60task/OBP60Formater.cpp +++ b/lib/obp60task/OBP60Formater.cpp @@ -37,6 +37,18 @@ String formatTime(char fmttype, uint8_t hour, uint8_t minute, uint8_t second) { return String(buffer); } +String formatLatitude(double lat) { + float degree = abs(int(lat)); + float minute = abs((lat - int(lat)) * 60); + return String(degree, 0) + "\x90 " + String(minute, 4) + "' " + ((lat > 0) ? "N" : "S"); +} + +String formatLongitude(double lon) { + float degree = abs(int(lon)); + float minute = abs((lon - int(lon)) * 60); + return String(degree, 0) + "\x90 " + String(minute, 4) + "' " + ((lon > 0) ? "E" : "W"); +} + FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){ GwLog *logger = commondata.logger; FormatedData result; diff --git a/lib/obp60task/OBPSensorTask.cpp b/lib/obp60task/OBPSensorTask.cpp index 311da1c..31c754c 100644 --- a/lib/obp60task/OBPSensorTask.cpp +++ b/lib/obp60task/OBPSensorTask.cpp @@ -498,14 +498,18 @@ void sensorTask(void *param){ // Send supply voltage value all 1s if(millis() > starttime5 + 1000 && String(powsensor1) == "off"){ starttime5 = millis(); - float rawVoltage = 0; - #if defined(BOARD_OBP40S3) && defined(VOLTAGE_SENSOR) + float rawVoltage = 0; // Default value + #ifdef BOARD_OBP40S3 + sensors.batteryVoltage = 0; // If no sensor then zero voltage + #endif + #if defined(BOARD_OBP40S3) && defined(VOLTAGE_SENSOR) rawVoltage = (float(analogRead(OBP_ANALOG0)) * 3.3 / 4096 + 0.53) * 2; // Vin = 1/2 for OBP40 + sensors.batteryVoltage = rawVoltage * vslope + voffset; // Calibration #endif #ifdef BOARD_OBP60S3 - rawVoltage = (float(analogRead(OBP_ANALOG0)) * 3.3 / 4096 + 0.17) * 20; // Vin = 1/20 for OBP60 + rawVoltage = (float(analogRead(OBP_ANALOG0)) * 3.3 / 4096 + 0.17) * 20; // Vin = 1/20 for OBP60 + sensors.batteryVoltage = rawVoltage * vslope + voffset; // Calibration #endif - sensors.batteryVoltage = rawVoltage * vslope + voffset; // Calibration // Save new data in average array batV.reading(int(sensors.batteryVoltage * 100)); // Calculate the average values for different time lines from integer values diff --git a/lib/obp60task/PageBME280.cpp b/lib/obp60task/PageBME280.cpp index 84fa030..540d5c5 100644 --- a/lib/obp60task/PageBME280.cpp +++ b/lib/obp60task/PageBME280.cpp @@ -20,7 +20,7 @@ class PageBME280 : public Page return key; } - virtual void displayPage(PageData &pageData){ + int displayPage(PageData &pageData){ GwConfigHandler *config = commonData->config; GwLog *logger = commonData->logger; @@ -176,9 +176,7 @@ class PageBME280 : public Page // Show bus data getdisplay().print(svalue3); // Real value as formated string - // Update display - getdisplay().nextPage(); // Partial update (fast) - + return PAGE_UPDATE; }; }; diff --git a/lib/obp60task/PageBattery.cpp b/lib/obp60task/PageBattery.cpp index e3304b5..0938b13 100644 --- a/lib/obp60task/PageBattery.cpp +++ b/lib/obp60task/PageBattery.cpp @@ -34,7 +34,7 @@ class PageBattery : public Page return key; } - virtual void displayPage(PageData &pageData){ + int displayPage(PageData &pageData){ GwConfigHandler *config = commonData->config; GwLog *logger = commonData->logger; @@ -288,9 +288,7 @@ class PageBattery : public Page getdisplay().print("---"); // No sensor data (sensor is off) } - // Update display - getdisplay().nextPage(); // Partial update (fast) - + return PAGE_UPDATE; }; }; diff --git a/lib/obp60task/PageBattery2.cpp b/lib/obp60task/PageBattery2.cpp index c4497ef..b0b712b 100644 --- a/lib/obp60task/PageBattery2.cpp +++ b/lib/obp60task/PageBattery2.cpp @@ -44,7 +44,7 @@ public: return key; } - virtual void displayPage(PageData &pageData) + int displayPage(PageData &pageData) { GwConfigHandler *config = commonData->config; GwLog *logger = commonData->logger; @@ -334,8 +334,7 @@ public: getdisplay().setFont(&Ubuntu_Bold16pt8b); getdisplay().print("W"); - // Update display - getdisplay().nextPage(); // Partial update (fast) + return PAGE_UPDATE; }; }; diff --git a/lib/obp60task/PageClock.cpp b/lib/obp60task/PageClock.cpp index 7a293b2..b567d1d 100644 --- a/lib/obp60task/PageClock.cpp +++ b/lib/obp60task/PageClock.cpp @@ -85,7 +85,7 @@ bool homevalid = false; // homelat and homelon are valid return key; } - virtual void displayPage(PageData &pageData) + int displayPage(PageData &pageData) { GwConfigHandler *config = commonData->config; GwLog *logger = commonData->logger; @@ -162,7 +162,7 @@ bool homevalid = false; // homelat and homelon are valid } // Logging boat values - if (bvalue1 == NULL) return; + if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement? LOG_DEBUG(GwLog::LOG,"Drawing at PageClock, %s:%f, %s:%f", name1.c_str(), value1, name2.c_str(), value2); // Draw page @@ -438,9 +438,7 @@ bool homevalid = false; // homelat and homelon are valid getdisplay().fillCircle(200, 150, startwidth + 6, commonData->bgcolor); getdisplay().fillCircle(200, 150, startwidth + 4, commonData->fgcolor); - // Update display - getdisplay().nextPage(); // Partial update (fast) - + return PAGE_UPDATE; }; }; diff --git a/lib/obp60task/PageCompass.cpp b/lib/obp60task/PageCompass.cpp index 202d8d9..783e8cd 100644 --- a/lib/obp60task/PageCompass.cpp +++ b/lib/obp60task/PageCompass.cpp @@ -61,7 +61,7 @@ class PageCompass : public Page return key; } - virtual void displayPage(PageData &pageData){ + int displayPage(PageData &pageData){ GwConfigHandler *config = commonData->config; GwLog *logger = commonData->logger; @@ -104,7 +104,7 @@ class PageCompass : public Page setFlashLED(false); } - if (bvalue == NULL) return; + if (bvalue == NULL) return PAGE_OK; // WTF why this statement? //*********************************************************** @@ -235,12 +235,11 @@ class PageCompass : public Page // if ( x_test > 390) // x_test = 320; - // Update display - getdisplay().nextPage(); // Partial update (fast) - - }; - + return PAGE_UPDATE; }; + +}; + static Page *createPage(CommonData &common){ return new PageCompass(common); }/** diff --git a/lib/obp60task/PageDST810.cpp b/lib/obp60task/PageDST810.cpp index 5eb1452..2ac7494 100644 --- a/lib/obp60task/PageDST810.cpp +++ b/lib/obp60task/PageDST810.cpp @@ -20,7 +20,7 @@ public: return key; } - virtual void displayPage(PageData &pageData){ + int displayPage(PageData &pageData){ GwConfigHandler *config = commonData->config; GwLog *logger = commonData->logger; @@ -84,7 +84,7 @@ public: } // Logging boat values - if (bvalue1 == NULL) return; + if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement? LOG_DEBUG(GwLog::LOG,"Drawing at PageDST810, %s: %f, %s: %f, %s: %f, %s: %f", name1.c_str(), value1, name2.c_str(), value2, name3.c_str(), value3, name4.c_str(), value4); // Draw page @@ -242,9 +242,7 @@ public: unit4old = unit4; // Save the old unit } - // Update display - getdisplay().nextPage(); // Partial update (fast) - + return PAGE_UPDATE; }; }; diff --git a/lib/obp60task/PageFluid.cpp b/lib/obp60task/PageFluid.cpp index 51ce120..f844d87 100644 --- a/lib/obp60task/PageFluid.cpp +++ b/lib/obp60task/PageFluid.cpp @@ -98,7 +98,7 @@ class PageFluid : public Page commonData->logger->logDebug(GwLog::LOG,"New PageFluid: fluidtype=%d", fluidtype); } - virtual void displayPage(PageData &pageData){ + int displayPage(PageData &pageData){ GwConfigHandler *config = commonData->config; GwLog *logger = commonData->logger; @@ -252,9 +252,7 @@ class PageFluid : public Page getdisplay().fillCircle(c.x, c.y, 6, commonData->bgcolor); } - // Update display - getdisplay().nextPage(); // Partial update (fast) - + return PAGE_UPDATE; }; }; diff --git a/lib/obp60task/PageFourValues.cpp b/lib/obp60task/PageFourValues.cpp index d931f20..53120cc 100644 --- a/lib/obp60task/PageFourValues.cpp +++ b/lib/obp60task/PageFourValues.cpp @@ -21,7 +21,7 @@ class PageFourValues : public Page return key; } - virtual void displayPage(PageData &pageData){ + int displayPage(PageData &pageData){ GwConfigHandler *config = commonData->config; GwLog *logger = commonData->logger; @@ -89,7 +89,7 @@ class PageFourValues : public Page } // Logging boat values - if (bvalue1 == NULL) return; + if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement? LOG_DEBUG(GwLog::LOG,"Drawing at PageFourValues, %s: %f, %s: %f, %s: %f, %s: %f", name1.c_str(), value1, name2.c_str(), value2, name3.c_str(), value3, name4.c_str(), value4); // Draw page @@ -287,9 +287,7 @@ class PageFourValues : public Page unit4old = unit4; // Save the old unit } - // Update display - getdisplay().nextPage(); // Partial update (fast) - + return PAGE_UPDATE; }; }; diff --git a/lib/obp60task/PageFourValues2.cpp b/lib/obp60task/PageFourValues2.cpp index db1fba0..e608409 100644 --- a/lib/obp60task/PageFourValues2.cpp +++ b/lib/obp60task/PageFourValues2.cpp @@ -21,7 +21,7 @@ class PageFourValues2 : public Page return key; } - virtual void displayPage(PageData &pageData){ + int displayPage(PageData &pageData){ GwConfigHandler *config = commonData->config; GwLog *logger = commonData->logger; @@ -89,7 +89,7 @@ class PageFourValues2 : public Page } // Logging boat values - if (bvalue1 == NULL) return; + if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement? LOG_DEBUG(GwLog::LOG,"Drawing at PageFourValues2, %s: %f, %s: %f, %s: %f, %s: %f", name1.c_str(), value1, name2.c_str(), value2, name3.c_str(), value3, name4.c_str(), value4); // Draw page @@ -287,9 +287,7 @@ class PageFourValues2 : public Page unit4old = unit4; // Save the old unit } - // Update display - getdisplay().nextPage(); // Partial update (fast) - + return PAGE_UPDATE; }; }; diff --git a/lib/obp60task/PageGenerator.cpp b/lib/obp60task/PageGenerator.cpp index 276e4b0..201b647 100644 --- a/lib/obp60task/PageGenerator.cpp +++ b/lib/obp60task/PageGenerator.cpp @@ -20,7 +20,7 @@ public: return key; } - virtual void displayPage(PageData &pageData) + int displayPage(PageData &pageData) { GwConfigHandler *config = commonData->config; GwLog *logger = commonData->logger; @@ -203,8 +203,7 @@ public: getdisplay().setFont(&Ubuntu_Bold16pt8b); getdisplay().print("W"); - // Update display - getdisplay().nextPage(); // Partial update (fast) + return PAGE_UPDATE; }; }; diff --git a/lib/obp60task/PageKeelPosition.cpp b/lib/obp60task/PageKeelPosition.cpp index 5a25866..48e5018 100644 --- a/lib/obp60task/PageKeelPosition.cpp +++ b/lib/obp60task/PageKeelPosition.cpp @@ -21,7 +21,7 @@ public: return key; } - virtual void displayPage(PageData &pageData) + int displayPage(PageData &pageData) { GwConfigHandler *config = commonData->config; GwLog *logger = commonData->logger; @@ -206,9 +206,7 @@ public: getdisplay().print("No sensor data"); // Info missing sensor } - // Update display - getdisplay().nextPage(); // Partial update (fast) - + return PAGE_UPDATE; }; }; diff --git a/lib/obp60task/PageOneValue.cpp b/lib/obp60task/PageOneValue.cpp index ebdb96e..6f33597 100644 --- a/lib/obp60task/PageOneValue.cpp +++ b/lib/obp60task/PageOneValue.cpp @@ -21,7 +21,7 @@ class PageOneValue : public Page return key; } - virtual void displayPage(PageData &pageData){ + int displayPage(PageData &pageData){ GwConfigHandler *config = commonData->config; GwLog *logger = commonData->logger; @@ -53,7 +53,7 @@ class PageOneValue : public Page } // Logging boat values - if (bvalue1 == NULL) return; + if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement? LOG_DEBUG(GwLog::LOG,"Drawing at PageOneValue, %s: %f", name1.c_str(), value1); // Draw page @@ -104,9 +104,7 @@ class PageOneValue : public Page unit1old = unit1; // Save the old unit } - // Update display - getdisplay().nextPage(); // Partial update (fast) - + return PAGE_UPDATE; }; }; diff --git a/lib/obp60task/PageRollPitch.cpp b/lib/obp60task/PageRollPitch.cpp index 488056d..db3d27f 100644 --- a/lib/obp60task/PageRollPitch.cpp +++ b/lib/obp60task/PageRollPitch.cpp @@ -21,7 +21,7 @@ public: return key; } - virtual void displayPage(PageData &pageData){ + int displayPage(PageData &pageData){ GwConfigHandler *config = commonData->config; GwLog *logger = commonData->logger; @@ -109,7 +109,7 @@ public: } // Logging boat values - if (bvalue1 == NULL) return; + if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement? LOG_DEBUG(GwLog::LOG,"Drawing at PageRollPitch, %s:%f, %s:%f", name1.c_str(), value1, name2.c_str(), value2); // Draw page @@ -305,9 +305,7 @@ public: getdisplay().print("No sensor data"); // Info missing sensor } - // Update display - getdisplay().nextPage(); // Partial update (fast) - + return PAGE_UPDATE; }; }; diff --git a/lib/obp60task/PageRudderPosition.cpp b/lib/obp60task/PageRudderPosition.cpp index a11f917..22b5f91 100644 --- a/lib/obp60task/PageRudderPosition.cpp +++ b/lib/obp60task/PageRudderPosition.cpp @@ -22,7 +22,7 @@ public: return key; } - virtual void displayPage(PageData &pageData){ + int displayPage(PageData &pageData){ GwConfigHandler *config = commonData->config; GwLog *logger = commonData->logger; @@ -67,7 +67,7 @@ public: } // Logging boat values - if (bvalue1 == NULL) return; + if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement? LOG_DEBUG(GwLog::LOG,"Drawing at PageRudderPosition, %s:%f", name1.c_str(), value1); // Draw page @@ -207,8 +207,7 @@ public: getdisplay().fillCircle(200, 150, startwidth + 6, commonData->bgcolor); getdisplay().fillCircle(200, 150, startwidth + 4, commonData->fgcolor); - // Update display - getdisplay().nextPage(); // Partial update (fast) + return PAGE_UPDATE; }; }; diff --git a/lib/obp60task/PageSixValues.cpp b/lib/obp60task/PageSixValues.cpp index fc42ad9..af735f2 100644 --- a/lib/obp60task/PageSixValues.cpp +++ b/lib/obp60task/PageSixValues.cpp @@ -29,7 +29,7 @@ class PageSixValues : public Page return key; } - virtual void displayPage(PageData &pageData){ + int displayPage(PageData &pageData){ GwConfigHandler *config = commonData->config; GwLog *logger = commonData->logger; @@ -71,7 +71,7 @@ class PageSixValues : public Page setFlashLED(false); } - if (bvalue == NULL) return; + if (bvalue == NULL) return PAGE_OK; // WTF why this statement? // Draw page //*********************************************************** @@ -149,9 +149,7 @@ class PageSixValues : public Page getdisplay().fillRect(SixValues_x1+SixValues_DeltaX-8, SixValues_y1+i*SixValues_DeltaY, 3, SixValues_DeltaY, commonData->fgcolor); } - // Update display - getdisplay().nextPage(); // Partial update (fast) - + return PAGE_UPDATE; }; }; diff --git a/lib/obp60task/PageSolar.cpp b/lib/obp60task/PageSolar.cpp index 1962b66..2a19bb9 100644 --- a/lib/obp60task/PageSolar.cpp +++ b/lib/obp60task/PageSolar.cpp @@ -20,7 +20,7 @@ public: return key; } - virtual void displayPage(PageData &pageData){ + int displayPage(PageData &pageData){ GwConfigHandler *config = commonData->config; GwLog *logger = commonData->logger; @@ -199,8 +199,7 @@ public: getdisplay().setFont(&Ubuntu_Bold16pt8b); getdisplay().print("W"); - // Update display - getdisplay().nextPage(); // Partial update (fast) + return PAGE_UPDATE; }; }; diff --git a/lib/obp60task/PageSystem.cpp b/lib/obp60task/PageSystem.cpp index 18852cb..ddff3d4 100644 --- a/lib/obp60task/PageSystem.cpp +++ b/lib/obp60task/PageSystem.cpp @@ -17,6 +17,7 @@ #define BOARDINFO STRINGIZE(BOARD) #define PCBINFO STRINGIZE(PCBVERS) #define DISPLAYINFO STRINGIZE(EPDTYPE) +#define GXEPD2INFO STRINGIZE(GXEPD2VERS) /* * Special system page, called directly with fast key sequence 5,4 @@ -43,6 +44,8 @@ String batt_sensor; String solar_sensor; String gen_sensor; String rot_sensor; +double homelat; +double homelon; char mode = 'N'; // (N)ormal, (S)ettings, (D)evice list, (C)ard @@ -69,6 +72,8 @@ public: solar_sensor = common.config->getString(common.config->usePowSensor2); gen_sensor = common.config->getString(common.config->usePowSensor3); rot_sensor = common.config->getString(common.config->useRotSensor); + homelat = common.config->getString(common.config->homeLAT).toDouble(); + homelon = common.config->getString(common.config->homeLON).toDouble(); } virtual void setupKeys(){ @@ -159,7 +164,7 @@ public: } } - virtual void displayPage(PageData &pageData){ + int displayPage(PageData &pageData){ GwConfigHandler *config = commonData->config; GwLog *logger = commonData->logger; @@ -203,19 +208,21 @@ public: getdisplay().setCursor(8, 95); getdisplay().print("Firmware version: "); - getdisplay().setCursor(160, 95); + getdisplay().setCursor(150, 95); getdisplay().print(VERSINFO); getdisplay().setCursor(8, 113); getdisplay().print("Board version: "); - getdisplay().setCursor(160, 113); + getdisplay().setCursor(150, 113); getdisplay().print(BOARDINFO); getdisplay().print(String(" HW ") + String(PCBINFO)); getdisplay().setCursor(8, 131); getdisplay().print("Display version: "); - getdisplay().setCursor(160, 131); + getdisplay().setCursor(150, 131); getdisplay().print(DISPLAYINFO); + getdisplay().print("; GxEPD2 v"); + getdisplay().print(GXEPD2INFO); getdisplay().setCursor(8, 265); #ifdef BOARD_OBP60S3 @@ -295,34 +302,44 @@ public: // left column getdisplay().setCursor(x0, y0); getdisplay().print("Simulation:"); - getdisplay().setCursor(140, y0); + getdisplay().setCursor(120, y0); getdisplay().print(simulation ? "on" : "off"); getdisplay().setCursor(x0, y0 + 16); getdisplay().print("Environment:"); - getdisplay().setCursor(140, y0 + 16); + getdisplay().setCursor(120, y0 + 16); getdisplay().print(env_module); getdisplay().setCursor(x0, y0 + 32); getdisplay().print("Buzzer:"); - getdisplay().setCursor(140, y0 + 32); + getdisplay().setCursor(120, y0 + 32); getdisplay().print(buzzer_mode); getdisplay().setCursor(x0, y0 + 64); getdisplay().print("GPS:"); - getdisplay().setCursor(140, y0 + 64); + getdisplay().setCursor(120, y0 + 64); getdisplay().print(gps_module); getdisplay().setCursor(x0, y0 + 80); getdisplay().print("RTC:"); - getdisplay().setCursor(140, y0 + 80); + getdisplay().setCursor(120, y0 + 80); getdisplay().print(rtc_module); getdisplay().setCursor(x0, y0 + 96); getdisplay().print("Wifi:"); - getdisplay().setCursor(140, y0 + 96); + getdisplay().setCursor(120, y0 + 96); getdisplay().print(commonData->status.wifiApOn ? "on" : "off"); + // Home location + getdisplay().setCursor(x0, y0 + 128); + getdisplay().print("Home Lat.:"); + getdisplay().setCursor(120, y0 + 128); + getdisplay().print(formatLatitude(homelat)); + getdisplay().setCursor(x0, y0 + 144); + getdisplay().print("Home Lon.:"); + getdisplay().setCursor(120, y0 + 144); + getdisplay().print(formatLongitude(homelon)); + // right column getdisplay().setCursor(202, y0); getdisplay().print("Batt. sensor:"); @@ -374,7 +391,7 @@ public: // Update display getdisplay().nextPage(); // Partial update (fast) - + return PAGE_OK; }; }; diff --git a/lib/obp60task/PageThreeValues.cpp b/lib/obp60task/PageThreeValues.cpp index d2131b7..3bd2d0b 100644 --- a/lib/obp60task/PageThreeValues.cpp +++ b/lib/obp60task/PageThreeValues.cpp @@ -21,7 +21,7 @@ class PageThreeValues : public Page return key; } - virtual void displayPage(PageData &pageData){ + int displayPage(PageData &pageData){ GwConfigHandler *config = commonData->config; GwLog *logger = commonData->logger; @@ -77,7 +77,7 @@ class PageThreeValues : public Page } // Logging boat values - if (bvalue1 == NULL) return; + if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement? LOG_DEBUG(GwLog::LOG,"Drawing at PageThreeValues, %s: %f, %s: %f, %s: %f", name1.c_str(), value1, name2.c_str(), value2, name3.c_str(), value3); // Draw page @@ -226,8 +226,7 @@ class PageThreeValues : public Page unit3old = unit3; // Save the old unit } - // Update display - getdisplay().nextPage(); // Partial update (fast) + return PAGE_UPDATE; }; }; diff --git a/lib/obp60task/PageTwoValues.cpp b/lib/obp60task/PageTwoValues.cpp index 2859fd2..8b27e7b 100644 --- a/lib/obp60task/PageTwoValues.cpp +++ b/lib/obp60task/PageTwoValues.cpp @@ -21,7 +21,7 @@ class PageTwoValues : public Page return key; } - virtual void displayPage(PageData &pageData){ + int displayPage(PageData &pageData){ GwConfigHandler *config = commonData->config; GwLog *logger = commonData->logger; @@ -65,7 +65,7 @@ class PageTwoValues : public Page } // Logging boat values - if (bvalue1 == NULL) return; + if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement? LOG_DEBUG(GwLog::LOG,"Drawing at PageTwoValues, %s: %f, %s: %f", name1.c_str(), value1, name2.c_str(), value2); // Draw page @@ -166,8 +166,7 @@ class PageTwoValues : public Page unit2old = unit2; // Save the old unit } - // Update display - getdisplay().nextPage(); // Partial update (fast) + return PAGE_UPDATE; }; }; diff --git a/lib/obp60task/PageVoltage.cpp b/lib/obp60task/PageVoltage.cpp index 2aab416..3c2693b 100644 --- a/lib/obp60task/PageVoltage.cpp +++ b/lib/obp60task/PageVoltage.cpp @@ -100,7 +100,7 @@ public: getdisplay().fillRect(x + 16, y + 11, 6, 3, color); } - virtual void displayPage(PageData &pageData){ + int displayPage(PageData &pageData){ GwConfigHandler *config = commonData->config; GwLog *logger = commonData->logger; @@ -187,7 +187,6 @@ public: } // Logging voltage value - if (raw == 0) return; LOG_DEBUG(GwLog::LOG,"Drawing at PageVoltage, Type:%s %s:=%f", batType, name1.c_str(), raw); // Draw page @@ -384,8 +383,7 @@ public: } - // Update display - getdisplay().nextPage(); // Partial update (fast) + return PAGE_UPDATE; }; }; diff --git a/lib/obp60task/PageWhite.cpp b/lib/obp60task/PageWhite.cpp index e40a3ac..ada2616 100644 --- a/lib/obp60task/PageWhite.cpp +++ b/lib/obp60task/PageWhite.cpp @@ -31,7 +31,7 @@ public: return key; } - virtual void displayPage(PageData &pageData){ + int displayPage(PageData &pageData){ GwConfigHandler *config = commonData->config; GwLog *logger = commonData->logger; @@ -67,10 +67,13 @@ public: } // Update display - getdisplay().nextPage(); + // getdisplay().nextPage(); + int ret = PAGE_UPDATE; if (mode == 'W') { - getdisplay().hibernate(); + //getdisplay().hibernate(); + ret |= PAGE_HIBERNATE; } + return ret; }; }; diff --git a/lib/obp60task/PageWind.cpp b/lib/obp60task/PageWind.cpp index 0a94857..0b11461 100644 --- a/lib/obp60task/PageWind.cpp +++ b/lib/obp60task/PageWind.cpp @@ -296,7 +296,7 @@ public: return key; } - virtual void displayPage(PageData &pageData) + int displayPage(PageData &pageData) { GwConfigHandler *config = commonData->config; GwLog *logger = commonData->logger; @@ -354,7 +354,7 @@ public: } // Logging boat values - if (bvalue1 == NULL) return; + if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement? LOG_DEBUG(GwLog::LOG,"Drawing at PageWind, %s:%f, %s:%f", name1.c_str(), value1, name2.c_str(), value2); // Draw page @@ -618,9 +618,7 @@ public: } - // Update display - getdisplay().nextPage(); // Partial update (fast) - + return PAGE_UPDATE; }; }; diff --git a/lib/obp60task/PageWindRose.cpp b/lib/obp60task/PageWindRose.cpp index 9b1c203..45c62ce 100644 --- a/lib/obp60task/PageWindRose.cpp +++ b/lib/obp60task/PageWindRose.cpp @@ -24,7 +24,7 @@ public: return key; } - virtual void displayPage(PageData &pageData){ + int displayPage(PageData &pageData){ GwConfigHandler *config = commonData->config; GwLog *logger = commonData->logger; @@ -140,7 +140,7 @@ public: } // Logging boat values - if (bvalue1 == NULL) return; + if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement? LOG_DEBUG(GwLog::LOG,"Drawing at PageWindRose, %s:%f, %s:%f, %s:%f, %s:%f, %s:%f, %s:%f", name1.c_str(), value1, name2.c_str(), value2, name3.c_str(), value3, name4.c_str(), value4, name5.c_str(), value5, name6.c_str(), value6); // Draw page @@ -357,8 +357,7 @@ public: getdisplay().print(unit6old); // Unit } - // Update display - getdisplay().nextPage(); // Partial update (fast) + return PAGE_UPDATE; }; }; diff --git a/lib/obp60task/PageWindRoseFlex.cpp b/lib/obp60task/PageWindRoseFlex.cpp index bee86fe..f0e21ab 100644 --- a/lib/obp60task/PageWindRoseFlex.cpp +++ b/lib/obp60task/PageWindRoseFlex.cpp @@ -24,7 +24,7 @@ public: return key; } - virtual void displayPage(PageData &pageData){ + int displayPage(PageData &pageData){ GwConfigHandler *config = commonData->config; GwLog *logger = commonData->logger; @@ -140,7 +140,7 @@ public: } // Logging boat values - if (bvalue1 == NULL) return; + if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement? LOG_DEBUG(GwLog::LOG,"Drawing at PageWindRoseFlex, %s:%f, %s:%f, %s:%f, %s:%f, %s:%f, %s:%f", name1.c_str(), value1, name2.c_str(), value2, name3.c_str(), value3, name4.c_str(), value4, name5.c_str(), value5, name6.c_str(), value6); // Draw page @@ -362,8 +362,7 @@ if ( cos(value1) > 0){ } - // Update display - getdisplay().nextPage(); // Partial update (fast) + return PAGE_UPDATE; }; }; diff --git a/lib/obp60task/PageXTETrack.cpp b/lib/obp60task/PageXTETrack.cpp index 5b0bdbb..cbb0af5 100644 --- a/lib/obp60task/PageXTETrack.cpp +++ b/lib/obp60task/PageXTETrack.cpp @@ -65,7 +65,7 @@ class PageXTETrack : public Page return key; } - virtual void displayPage(PageData &pageData){ + int displayPage(PageData &pageData){ GwConfigHandler *config = commonData->config; GwLog *logger = commonData->logger; @@ -207,9 +207,7 @@ class PageXTETrack : public Page 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]); - // Update display - getdisplay().nextPage(); // Partial update (fast) - + return PAGE_UPDATE; }; }; diff --git a/lib/obp60task/Pagedata.h b/lib/obp60task/Pagedata.h index ad252ea..75a4b8c 100644 --- a/lib/obp60task/Pagedata.h +++ b/lib/obp60task/Pagedata.h @@ -82,6 +82,22 @@ typedef struct{ bool on; // fast on/off detector } BacklightData; +enum AlarmSource { + Alarm_Generic, + Alarm_Local, + Alarm_NMEA0183, + Alarm_NMEA2000 +}; + +typedef struct{ + uint8_t id; // alarm-id e.g. 01..99 from NMEA0183 + AlarmSource source; + String message; // single line of plain text + bool active = false; + uint8_t signal; // how to signal MESSAGE | LED | BUZZER + uint8_t length_sec; // seconds until alarm disappeares without user interaction +} AlarmData; + typedef struct{ GwApi::Status status; GwLog *logger=NULL; @@ -90,6 +106,7 @@ typedef struct{ SunData sundata; TouchKeyData keydata[6]; BacklightData backlight; + AlarmData alarm; GwApi::BoatValue *time=NULL; GwApi::BoatValue *date=NULL; uint16_t fgcolor; @@ -104,7 +121,7 @@ class Page{ CommonData *commonData; public: int refreshtime = 1000; - virtual void displayPage(PageData &pageData)=0; + virtual int displayPage(PageData &pageData)=0; virtual void displayNew(PageData &pageData){} virtual void setupKeys() { #ifdef HARDWARE_V21 @@ -172,6 +189,8 @@ class PageStruct{ // Standard format functions without overhead String formatDate(String fmttype, uint16_t year, uint8_t month, uint8_t day); String formatTime(char fmttype, uint8_t hour, uint8_t minute, uint8_t second); +String formatLatitude(double lat); +String formatLongitude(double lon); // Structure for formatted boat values typedef struct{ diff --git a/lib/obp60task/config.json b/lib/obp60task/config.json index c1f9ab8..eed7ba2 100644 --- a/lib/obp60task/config.json +++ b/lib/obp60task/config.json @@ -737,7 +737,7 @@ "condition": [ { "calInstance1": "AWA" }, { "calInstance1": "AWS" }, - { "calInstance2": "COG" }, + { "calInstance1": "COG" }, { "calInstance1": "DBT" }, { "calInstance1": "HDM" }, { "calInstance1": "PRPOS" }, @@ -762,7 +762,7 @@ "condition": [ { "calInstance1": "AWA" }, { "calInstance1": "AWS" }, - { "calInstance2": "COG" }, + { "calInstance1": "COG" }, { "calInstance1": "DBT" }, { "calInstance1": "HDM" }, { "calInstance1": "PRPOS" }, @@ -790,7 +790,7 @@ "condition": [ { "calInstance1": "AWA" }, { "calInstance1": "AWS" }, - { "calInstance2": "COG" }, + { "calInstance1": "COG" }, { "calInstance1": "DBT" }, { "calInstance1": "HDM" }, { "calInstance1": "PRPOS" }, @@ -1296,8 +1296,6 @@ "obp60":"true" } }, - - { "name": "page1type", "label": "Type", diff --git a/lib/obp60task/config_obp40.json b/lib/obp60task/config_obp40.json index 8747e4e..92cb0f6 100644 --- a/lib/obp60task/config_obp40.json +++ b/lib/obp60task/config_obp40.json @@ -718,10 +718,12 @@ "---", "AWA", "AWS", + "COG", "DBT", "HDM", "PRPOS", "RPOS", + "SOG", "STW", "TWA", "TWS", @@ -741,8 +743,22 @@ "description": "Offset for data instance 1", "category": "OBP40 Calibrations", "capabilities": { - "obp40": "true" - } + "obp40":"true" + }, + "condition": [ + { "calInstance1": "AWA" }, + { "calInstance1": "AWS" }, + { "calInstance1": "COG" }, + { "calInstance1": "DBT" }, + { "calInstance1": "HDM" }, + { "calInstance1": "PRPOS" }, + { "calInstance1": "RPOS" }, + { "calInstance1": "SOG" }, + { "calInstance1": "STW" }, + { "calInstance1": "TWA" }, + { "calInstance1": "TWS" }, + { "calInstance1": "TWD" }, + { "calInstance1": "WTemp" } ] }, { "name": "calSlope1", @@ -752,8 +768,22 @@ "description": "Slope for data instance 1", "category": "OBP40 Calibrations", "capabilities": { - "obp40": "true" - } + "obp40":"true" + }, + "condition": [ + { "calInstance1": "AWA" }, + { "calInstance1": "AWS" }, + { "calInstance1": "COG" }, + { "calInstance1": "DBT" }, + { "calInstance1": "HDM" }, + { "calInstance1": "PRPOS" }, + { "calInstance1": "RPOS" }, + { "calInstance1": "SOG" }, + { "calInstance1": "STW" }, + { "calInstance1": "TWA" }, + { "calInstance1": "TWS" }, + { "calInstance1": "TWD" }, + { "calInstance1": "WTemp" } ] }, { "name": "calSmooth1", @@ -763,11 +793,25 @@ "check": "checkMinMax", "min": 0, "max": 10, - "description": "Smoothing factor for data instance 1", + "description": "Smoothing factor [0..10]; 0 = no smoothing", "category": "OBP40 Calibrations", "capabilities": { - "obp40": "true" - } + "obp40":"true" + }, + "condition": [ + { "calInstance1": "AWA" }, + { "calInstance1": "AWS" }, + { "calInstance1": "COG" }, + { "calInstance1": "DBT" }, + { "calInstance1": "HDM" }, + { "calInstance1": "PRPOS" }, + { "calInstance1": "RPOS" }, + { "calInstance1": "SOG" }, + { "calInstance1": "STW" }, + { "calInstance1": "TWA" }, + { "calInstance1": "TWS" }, + { "calInstance1": "TWD" }, + { "calInstance1": "WTemp" } ] }, { "name": "calInstance2", @@ -779,10 +823,12 @@ "---", "AWA", "AWS", + "COG", "DBT", "HDM", "PRPOS", "RPOS", + "SOG", "STW", "TWA", "TWS", @@ -802,8 +848,22 @@ "description": "Offset for data instance 2", "category": "OBP40 Calibrations", "capabilities": { - "obp40": "true" - } + "obp40":"true" + }, + "condition": [ + { "calInstance2": "AWA" }, + { "calInstance2": "AWS" }, + { "calInstance2": "COG" }, + { "calInstance2": "DBT" }, + { "calInstance2": "HDM" }, + { "calInstance2": "PRPOS" }, + { "calInstance2": "RPOS" }, + { "calInstance2": "SOG" }, + { "calInstance2": "STW" }, + { "calInstance2": "TWA" }, + { "calInstance2": "TWS" }, + { "calInstance2": "TWD" }, + { "calInstance2": "WTemp" } ] }, { "name": "calSlope2", @@ -813,8 +873,22 @@ "description": "Slope for data instance 2", "category": "OBP40 Calibrations", "capabilities": { - "obp40": "true" - } + "obp40":"true" + }, + "condition": [ + { "calInstance2": "AWA" }, + { "calInstance2": "AWS" }, + { "calInstance2": "COG" }, + { "calInstance2": "DBT" }, + { "calInstance2": "HDM" }, + { "calInstance2": "PRPOS" }, + { "calInstance2": "RPOS" }, + { "calInstance2": "SOG" }, + { "calInstance2": "STW" }, + { "calInstance2": "TWA" }, + { "calInstance2": "TWS" }, + { "calInstance2": "TWD" }, + { "calInstance2": "WTemp" } ] }, { "name": "calSmooth2", @@ -824,11 +898,25 @@ "check": "checkMinMax", "min": 0, "max": 10, - "description": "Smoothing factor for data instance 2", + "description": "Smoothing factor [0..10]; 0 = no smoothing", "category": "OBP40 Calibrations", "capabilities": { - "obp40": "true" - } + "obp40":"true" + }, + "condition": [ + { "calInstance2": "AWA" }, + { "calInstance2": "AWS" }, + { "calInstance2": "COG" }, + { "calInstance2": "DBT" }, + { "calInstance2": "HDM" }, + { "calInstance2": "PRPOS" }, + { "calInstance2": "RPOS" }, + { "calInstance2": "SOG" }, + { "calInstance2": "STW" }, + { "calInstance2": "TWA" }, + { "calInstance2": "TWS" }, + { "calInstance2": "TWD" }, + { "calInstance2": "WTemp" } ] }, { "name": "calInstance3", @@ -840,10 +928,12 @@ "---", "AWA", "AWS", + "COG", "DBT", "HDM", "PRPOS", "RPOS", + "SOG", "STW", "TWA", "TWS", @@ -863,8 +953,22 @@ "description": "Offset for data instance 3", "category": "OBP40 Calibrations", "capabilities": { - "obp40": "true" - } + "obp40":"true" + }, + "condition": [ + { "calInstance3": "AWA" }, + { "calInstance3": "AWS" }, + { "calInstance3": "COG" }, + { "calInstance3": "DBT" }, + { "calInstance3": "HDM" }, + { "calInstance3": "PRPOS" }, + { "calInstance3": "RPOS" }, + { "calInstance3": "SOG" }, + { "calInstance3": "STW" }, + { "calInstance3": "TWA" }, + { "calInstance3": "TWS" }, + { "calInstance3": "TWD" }, + { "calInstance3": "WTemp" } ] }, { "name": "calSlope3", @@ -874,8 +978,22 @@ "description": "Slope for data instance 3", "category": "OBP40 Calibrations", "capabilities": { - "obp40": "true" - } + "obp40":"true" + }, + "condition": [ + { "calInstance3": "AWA" }, + { "calInstance3": "AWS" }, + { "calInstance3": "COG" }, + { "calInstance3": "DBT" }, + { "calInstance3": "HDM" }, + { "calInstance3": "PRPOS" }, + { "calInstance3": "RPOS" }, + { "calInstance3": "SOG" }, + { "calInstance3": "STW" }, + { "calInstance3": "TWA" }, + { "calInstance3": "TWS" }, + { "calInstance3": "TWD" }, + { "calInstance3": "WTemp" } ] }, { "name": "calSmooth3", @@ -885,11 +1003,25 @@ "check": "checkMinMax", "min": 0, "max": 10, - "description": "Smoothing factor for data instance 3", + "description": "Smoothing factor [0..10]; 0 = no smoothing", "category": "OBP40 Calibrations", "capabilities": { - "obp40": "true" - } + "obp40":"true" + }, + "condition": [ + { "calInstance3": "AWA" }, + { "calInstance3": "AWS" }, + { "calInstance3": "COG" }, + { "calInstance3": "DBT" }, + { "calInstance3": "HDM" }, + { "calInstance3": "PRPOS" }, + { "calInstance3": "RPOS" }, + { "calInstance3": "SOG" }, + { "calInstance3": "STW" }, + { "calInstance3": "TWA" }, + { "calInstance3": "TWS" }, + { "calInstance3": "TWD" }, + { "calInstance3": "WTemp" } ] }, { "name": "display", @@ -3863,3 +3995,4 @@ ] } ] + diff --git a/lib/obp60task/extra_task.py b/lib/obp60task/extra_task.py new file mode 100644 index 0000000..28e9980 --- /dev/null +++ b/lib/obp60task/extra_task.py @@ -0,0 +1,30 @@ +# PlatformIO extra script for obp60task + +epdtype = "unknown" +pcbvers = "unknown" +for x in env["BUILD_FLAGS"]: + if x.startswith("-D HARDWARE_"): + pcbvers = x.split('_')[1] + if x.startswith("-D DISPLAY_"): + epdtype = x.split('_')[1] + +propfilename = os.path.join(env["PROJECT_LIBDEPS_DIR"], env["PIOENV"], "GxEPD2/library.properties") +properties = {} +with open(propfilename, 'r') as file: + for line in file: + match = re.match(r'^([^=]+)=(.*)$', line) + if match: + key = match.group(1).strip() + value = match.group(2).strip() + properties[key] = value + +gxepd2vers = "unknown" +try: + if properties["name"] == "GxEPD2": + gxepd2vers = properties["version"] +except: + pass + +env["CPPDEFINES"].extend([("BOARD", env["BOARD"]), ("EPDTYPE", epdtype), ("PCBVERS", pcbvers), ("GXEPD2VERS", gxepd2vers)]) + +print("added hardware info to CPPDEFINES") diff --git a/lib/obp60task/obp60task.cpp b/lib/obp60task/obp60task.cpp index 505d89c..48ce978 100644 --- a/lib/obp60task/obp60task.cpp +++ b/lib/obp60task/obp60task.cpp @@ -531,7 +531,7 @@ void OBP60Task(GwApi *api){ #endif #ifdef DISPLAY_GDEY042T81 - getdisplay().init(115200, true, 2, false); // Use this for Waveshare boards with "clever" reset circuit, 2ms reset pulse + getdisplay().init(115200, true, 2, false); // Init for Waveshare boards with "clever" reset circuit, 2ms reset pulse #else getdisplay().init(115200); // Init for normal displays #endif @@ -837,7 +837,7 @@ void OBP60Task(GwApi *api){ } // #9 or #10 Refresh display after a new page after 4s waiting time and if refresh is disabled - if(refreshmode == true && (keyboardMessage == 9 || keyboardMessage == 10)){ + if(refreshmode == true && (keyboardMessage == 9 || keyboardMessage == 10 || keyboardMessage == 4 || keyboardMessage == 3)){ starttime4 = millis(); starttime2 = millis(); // Reset the timer for full display update delayedDisplayUpdate = true; @@ -873,12 +873,22 @@ void OBP60Task(GwApi *api){ starttime1 = millis(); starttime2 = millis(); getdisplay().setFullWindow(); // Set full update - getdisplay().nextPage(); - if(fastrefresh == "false"){ + if(fastrefresh == "true"){ + getdisplay().nextPage(); // Full update + } + else{ getdisplay().fillScreen(commonData.fgcolor); // Clear display + #ifdef DISPLAY_GDEY042T81 + getdisplay().init(115200, true, 2, false); // Init for Waveshare boards with "clever" reset circuit, 2ms reset pulse + #else + getdisplay().init(115200); // Init for normal displays + #endif + getdisplay().firstPage(); // Full update getdisplay().nextPage(); // Full update - getdisplay().fillScreen(commonData.bgcolor); // Clear display - getdisplay().nextPage(); // Full update +// getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update +// getdisplay().fillScreen(commonData.bgcolor); // Clear display +// getdisplay().nextPage(); // Partial update +// getdisplay().nextPage(); // Partial update } delayedDisplayUpdate = false; } @@ -890,12 +900,22 @@ void OBP60Task(GwApi *api){ starttime2 = millis(); LOG_DEBUG(GwLog::DEBUG,"E-Ink full refresh first 5 min"); getdisplay().setFullWindow(); // Set full update - getdisplay().nextPage(); - if(fastrefresh == "false"){ + if(fastrefresh == "true"){ + getdisplay().nextPage(); // Full update + } + else{ getdisplay().fillScreen(commonData.fgcolor); // Clear display + #ifdef DISPLAY_GDEY042T81 + getdisplay().init(115200, true, 2, false); // Init for Waveshare boards with "clever" reset circuit, 2ms reset pulse + #else + getdisplay().init(115200); // Init for normal displays + #endif + getdisplay().firstPage(); // Full update getdisplay().nextPage(); // Full update - getdisplay().fillScreen(commonData.bgcolor); // Clear display - getdisplay().nextPage(); // Full update +// getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update +// getdisplay().fillScreen(commonData.bgcolor); // Clear display +// getdisplay().nextPage(); // Partial update +// getdisplay().nextPage(); // Partial update } } @@ -904,12 +924,22 @@ void OBP60Task(GwApi *api){ starttime2 = millis(); LOG_DEBUG(GwLog::DEBUG,"E-Ink full refresh"); getdisplay().setFullWindow(); // Set full update - getdisplay().nextPage(); - if(fastrefresh == "false"){ + if(fastrefresh == "true"){ + getdisplay().nextPage(); // Full update + } + else{ getdisplay().fillScreen(commonData.fgcolor); // Clear display + #ifdef DISPLAY_GDEY042T81 + getdisplay().init(115200, true, 2, false); // Init for Waveshare boards with "clever" reset circuit, 2ms reset pulse + #else + getdisplay().init(115200); // Init for normal displays + #endif + getdisplay().firstPage(); // Full update getdisplay().nextPage(); // Full update - getdisplay().fillScreen(commonData.bgcolor); // Clear display - getdisplay().nextPage(); // Full update +// getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update +// getdisplay().fillScreen(commonData.bgcolor); // Clear display +// getdisplay().nextPage(); // Partial update +// getdisplay().nextPage(); // Partial update } } @@ -975,7 +1005,16 @@ void OBP60Task(GwApi *api){ if (pages[pageNumber].description && pages[pageNumber].description->header){ displayFooter(commonData); } - currentPage->displayPage(pages[pageNumber].parameters); + int ret = currentPage->displayPage(pages[pageNumber].parameters); + if (commonData.alarm.active) { + displayAlarm(commonData); + } + if (ret & PAGE_UPDATE) { + getdisplay().nextPage(); // Partial update (fast) + } + if (ret & PAGE_HIBERNATE) { + getdisplay().hibernate(); + } } } diff --git a/lib/obp60task/platformio.ini b/lib/obp60task/platformio.ini index 21d56a5..074c140 100644 --- a/lib/obp60task/platformio.ini +++ b/lib/obp60task/platformio.ini @@ -40,7 +40,7 @@ lib_deps = paulstoffregen/OneWire@2.3.8 milesburton/DallasTemperature@3.11.0 signetica/SunRise@2.0.2 - adafruit/Adafruit FRAM I2C@^2.0.3 + adafruit/Adafruit FRAM I2C@2.0.3 build_flags= #https://thingpulse.com/usb-settings-for-logging-with-the-esp32-s3-in-platformio/?srsltid=AfmBOopGskbkr4GoeVkNlFaZXe_zXkLceKF6Rn-tmoXABCeAR2vWsdHL # -D CORE_DEBUG_LEVEL=1 #Debug level for CPU core via CDC (seral device) @@ -91,7 +91,7 @@ lib_deps = paulstoffregen/OneWire@2.3.8 milesburton/DallasTemperature@3.11.0 signetica/SunRise@2.0.2 - adafruit/Adafruit FRAM I2C@^2.0.3 + adafruit/Adafruit FRAM I2C@2.0.3 build_flags= -D DISABLE_DIAGNOSTIC_OUTPUT #Disable diagnostic output for GxEPD2 lib -D BOARD_OBP40S3 #Board OBP40 with ESP32S3