diff --git a/lib/obp60task/OBP60Extensions.cpp b/lib/obp60task/OBP60Extensions.cpp index 6c4f1c3..a4d652b 100644 --- a/lib/obp60task/OBP60Extensions.cpp +++ b/lib/obp60task/OBP60Extensions.cpp @@ -302,8 +302,8 @@ void toggleBacklightLED(uint brightness, const Color &color) { void setFlashLED(bool status) { if (ledTaskData == nullptr) return; - Color c = status?COLOR_RED:COLOR_BLACK; - LedInterface current=ledTaskData->getLedData(); + Color c = status ? COLOR_RED : COLOR_BLACK; + LedInterface current = ledTaskData->getLedData(); current.setFlash(c); ledTaskData->setLedData(current); } diff --git a/lib/obp60task/OBPSensorTask.cpp b/lib/obp60task/OBPSensorTask.cpp index 31c754c..6b3114d 100644 --- a/lib/obp60task/OBPSensorTask.cpp +++ b/lib/obp60task/OBPSensorTask.cpp @@ -90,16 +90,16 @@ void sensorTask(void *param){ double voffset = (api->getConfig()->getConfigItem(api->getConfig()->vOffset,true)->asString()).toFloat(); double vslope = (api->getConfig()->getConfigItem(api->getConfig()->vSlope,true)->asString()).toFloat(); if(String(powsensor1) == "off"){ - #ifdef VOLTAGE_SENSOR +#ifdef VOLTAGE_SENSOR float rawVoltage = (float(analogRead(OBP_ANALOG0)) * 3.3 / 4096 + 0.53) * 2; // Vin = 1/2 for OBP40 - #else +#else float rawVoltage = (float(analogRead(OBP_ANALOG0)) * 3.3 / 4096 + 0.17) * 20; // Vin = 1/20 for OBP60 - #endif +#endif sensors.batteryVoltage = rawVoltage * vslope + voffset; // Calibration - #ifdef LIPO_ACCU_1200 +#ifdef LIPO_ACCU_1200 sensors.BatteryChargeStatus = 0; // Set to discharging sensors.batteryLevelLiPo = 0; // Level 0...100% - #endif +#endif sensors.batteryCurrent = 0; sensors.batteryPower = 0; // Fill average arrays with start values @@ -499,24 +499,24 @@ void sensorTask(void *param){ if(millis() > starttime5 + 1000 && String(powsensor1) == "off"){ starttime5 = millis(); float rawVoltage = 0; // Default value - #ifdef BOARD_OBP40S3 +#ifdef BOARD_OBP40S3 sensors.batteryVoltage = 0; // If no sensor then zero voltage - #endif - #if defined(BOARD_OBP40S3) && defined(VOLTAGE_SENSOR) +#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 +#endif +#ifdef BOARD_OBP60S3 rawVoltage = (float(analogRead(OBP_ANALOG0)) * 3.3 / 4096 + 0.17) * 20; // Vin = 1/20 for OBP60 sensors.batteryVoltage = rawVoltage * vslope + voffset; // Calibration - #endif +#endif // Save new data in average array batV.reading(int(sensors.batteryVoltage * 100)); // Calculate the average values for different time lines from integer values sensors.batteryVoltage10 = batV.getAvg(10) / 100.0; sensors.batteryVoltage60 = batV.getAvg(60) / 100.0; sensors.batteryVoltage300 = batV.getAvg(300) / 100.0; - #if BOARD_OBP40S3 && defined LIPO_ACCU_1200 && defined VOLTAGE_SENSOR +#if BOARD_OBP40S3 && defined LIPO_ACCU_1200 && defined VOLTAGE_SENSOR // Polynomfit for LiPo capacity calculation for 3,7V LiPo accus, 0...100% sensors.batteryLevelLiPo = sensors.batteryVoltage60 * 203.8312 -738.1635; // Limiter @@ -555,14 +555,14 @@ void sensorTask(void *param){ SetN2kDCBatStatus(N2kMsg, 10, sensors.batteryVoltage, N2kDoubleNA, N2kDoubleNA, 0); api->sendN2kMessage(N2kMsg); } - #endif - #ifdef BOARD_OBP60S3 +#endif +#ifdef BOARD_OBP60S3 // Send to NMEA200 bus if(!isnan(sensors.batteryVoltage)){ SetN2kDCBatStatus(N2kMsg, 0, sensors.batteryVoltage, N2kDoubleNA, N2kDoubleNA, 1); api->sendN2kMessage(N2kMsg); } - #endif +#endif } // Send data from environment sensor all 2s diff --git a/lib/obp60task/PageAIS.cpp b/lib/obp60task/PageAIS.cpp index df090ef..2ca5420 100644 --- a/lib/obp60task/PageAIS.cpp +++ b/lib/obp60task/PageAIS.cpp @@ -125,7 +125,14 @@ public: } #endif - void displayNew(PageData &pageData){ + void displayNew(PageData &pageData) { +#ifdef BOARD_OBP60S3 + // Clear optical warning + if (flashLED == "Limit Violation") { + setBlinkingLED(false); + setFlashLED(false); + } +#endif }; int displayPage(PageData &pageData){ diff --git a/lib/obp60task/PageAnchor.cpp b/lib/obp60task/PageAnchor.cpp index 2625706..0f49365 100644 --- a/lib/obp60task/PageAnchor.cpp +++ b/lib/obp60task/PageAnchor.cpp @@ -379,7 +379,14 @@ public: #endif void displayNew(PageData &pageData){ - }; + #ifdef BOARD_OBP60S3 + // Clear optical warning + if (flashLED == "Limit Violation") { + setBlinkingLED(false); + setFlashLED(false); + } +#endif + }; int displayPage(PageData &pageData){ diff --git a/lib/obp60task/PageAutopilot.cpp b/lib/obp60task/PageAutopilot.cpp index 7b5ebdc..430f34d 100644 --- a/lib/obp60task/PageAutopilot.cpp +++ b/lib/obp60task/PageAutopilot.cpp @@ -89,6 +89,13 @@ public: #endif void displayNew(PageData &pageData){ +#ifdef BOARD_OBP60S3 + // Clear optical warning + if (flashLED == "Limit Violation") { + setBlinkingLED(false); + setFlashLED(false); + } +#endif }; int displayPage(PageData &pageData){ diff --git a/lib/obp60task/PageBattery.cpp b/lib/obp60task/PageBattery.cpp index a79bccb..37f7368 100644 --- a/lib/obp60task/PageBattery.cpp +++ b/lib/obp60task/PageBattery.cpp @@ -40,6 +40,16 @@ public: return key; } + void displayNew(PageData &pageData) { +#ifdef BOARD_OBP60S3 + // Clear optical warning + if (flashLED == "Limit Violation") { + setBlinkingLED(false); + setFlashLED(false); + } +#endif + }; + int displayPage(PageData &pageData){ // Old values for hold function @@ -141,12 +151,6 @@ public: String svalue3 = String(value3); // Formatted value as string including unit conversion and switching decimal places String unit3 = "W"; // Unit of value - // Optical warning by limit violation (unused) - if(String(flashLED) == "Limit Violation"){ - setBlinkingLED(false); - setFlashLED(false); - } - // Logging boat values logger->logDebug(GwLog::LOG, "Drawing at PageBattery, %s: %f, %s: %f, %s: %f, Avg: %d", name1.c_str(), value1, name2.c_str(), value2, name3.c_str(), value3, average); diff --git a/lib/obp60task/PageBattery2.cpp b/lib/obp60task/PageBattery2.cpp index e238d4f..e79cddb 100644 --- a/lib/obp60task/PageBattery2.cpp +++ b/lib/obp60task/PageBattery2.cpp @@ -140,36 +140,20 @@ public: if(batRange > 99) batRange = 99; // Optical warning by limit violation - if(String(flashLED) == "Limit Violation"){ - // Limits for Pb battery - if(String(batType) == "Pb" && (raw < 11.8 || raw > 14.8)){ + if (flashLED == "Limit Violation") { + bool violation = false; + if (batType == "Pb") { + violation = (raw < 11.8 || raw > 14.8); + } else if (batType == "Gel") { + violation = (raw < 11.8 || raw > 14.4); + } else if (batType == "AGM") { + violation = (raw < 11.8 || raw > 14.7); + } else if (batType == "LiFePo4") { + violation = (raw < 12.0 || raw > 14.6); + } + if (violation) { setBlinkingLED(true); - } - if(String(batType) == "Pb" && (raw >= 11.8 && raw <= 14.8)){ - setBlinkingLED(false); - setFlashLED(false); - } - // Limits for Gel battery - if(String(batType) == "Gel" && (raw < 11.8 || raw > 14.4)){ - setBlinkingLED(true); - } - if(String(batType) == "Gel" && (raw >= 11.8 && raw <= 14.4)){ - setBlinkingLED(false); - setFlashLED(false); - } - // Limits for AGM battery - if(String(batType) == "AGM" && (raw < 11.8 || raw > 14.7)){ - setBlinkingLED(true); - } - if(String(batType) == "AGM" && (raw >= 11.8 && raw <= 14.7)){ - setBlinkingLED(false); - setFlashLED(false); - } - // Limits for LiFePo4 battery - if(String(batType) == "LiFePo4" && (raw < 12.0 || raw > 14.6)){ - setBlinkingLED(true); - } - if(String(batType) == "LiFePo4" && (raw >= 12.0 && raw <= 14.6)){ + } else { setBlinkingLED(false); setFlashLED(false); } diff --git a/lib/obp60task/PageClock.cpp b/lib/obp60task/PageClock.cpp index 2e50468..7353b83 100644 --- a/lib/obp60task/PageClock.cpp +++ b/lib/obp60task/PageClock.cpp @@ -97,8 +97,18 @@ public: return key; } - int displayPage(PageData &pageData) - { + void displayNew(PageData &pageData) { +#ifdef BOARD_OBP60S3 + // Clear optical warning + if (flashLED == "Limit Violation") { + setBlinkingLED(false); + setFlashLED(false); + } +#endif + }; + + int displayPage(PageData &pageData) { + static String svalue1old = ""; static String unit1old = ""; static String svalue2old = ""; diff --git a/lib/obp60task/PageCompass.cpp b/lib/obp60task/PageCompass.cpp index 9063ff4..658e8ad 100644 --- a/lib/obp60task/PageCompass.cpp +++ b/lib/obp60task/PageCompass.cpp @@ -61,6 +61,16 @@ public: return key; } + void displayNew(PageData &pageData) { +#ifdef BOARD_OBP60S3 + // Clear optical warning + if (flashLED == "Limit Violation") { + setBlinkingLED(false); + setFlashLED(false); + } +#endif + }; + int displayPage(PageData &pageData) { // Old values for hold function @@ -89,12 +99,6 @@ public: logger->logDebug(GwLog::LOG, "Drawing at PageCompass: %d %s %f %s %s", i, DataName[i], DataValue[i], DataFormat[i], DataText[i] ); } - // Optical warning by limit violation (unused) - if(String(flashLED) == "Limit Violation"){ - setBlinkingLED(false); - setFlashLED(false); - } - if (bvalue == NULL) return PAGE_OK; // WTF why this statement? //*********************************************************** diff --git a/lib/obp60task/PageEPropulsion.cpp b/lib/obp60task/PageEPropulsion.cpp index c99f2ee..4f537dd 100644 --- a/lib/obp60task/PageEPropulsion.cpp +++ b/lib/obp60task/PageEPropulsion.cpp @@ -88,6 +88,13 @@ public: #endif void displayNew(PageData &pageData){ +#ifdef BOARD_OBP60S3 + // Clear optical warning + if (flashLED == "Limit Violation") { + setBlinkingLED(false); + setFlashLED(false); + } +#endif }; int displayPage(PageData &pageData){ diff --git a/lib/obp60task/PageFluid.cpp b/lib/obp60task/PageFluid.cpp index 11b16e4..ff0f39b 100644 --- a/lib/obp60task/PageFluid.cpp +++ b/lib/obp60task/PageFluid.cpp @@ -94,6 +94,13 @@ public: void displayNew(PageData &pageData) { fluidtype = config->getInt("page" + String(pageData.pageNumber) + "fluid", 0); logger->logDebug(GwLog::LOG, "New PageFluid: fluidtype=%d", fluidtype); +#ifdef BOARD_OBP60S3 + // Clear optical warning + if (flashLED == "Limit Violation") { + setBlinkingLED(false); + setFlashLED(false); + } +#endif } int displayPage(PageData &pageData) { @@ -101,16 +108,6 @@ public: // Old values for hold function static double value1old; - // Get config data - String flashLED = config->getString(config->flashLED); - String backlightMode = config->getString(config->backlight); - - // Optical warning by limit violation (unused) - if(String(flashLED) == "Limit Violation"){ - setBlinkingLED(false); - setFlashLED(false); - } - GwApi::BoatValue *bvalue1 = pageData.values[0]; String name1 = bvalue1->getName(); double fluidlevel = bvalue1->value; diff --git a/lib/obp60task/PageFourValues.cpp b/lib/obp60task/PageFourValues.cpp index e5c64fe..8eea92d 100644 --- a/lib/obp60task/PageFourValues.cpp +++ b/lib/obp60task/PageFourValues.cpp @@ -9,6 +9,7 @@ class PageFourValues : public Page { private: String lengthformat; + public: PageFourValues(CommonData &common) : Page(common) { @@ -27,6 +28,16 @@ public: return key; } + void displayNew(PageData &pageData) { +#ifdef BOARD_OBP60S3 + // Clear optical warning + if (flashLED == "Limit Violation") { + setBlinkingLED(false); + setFlashLED(false); + } +#endif + }; + int displayPage(PageData &pageData){ // Old values for hold function @@ -79,12 +90,6 @@ public: 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"){ - setBlinkingLED(false); - setFlashLED(false); - } - // Logging boat values if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement? logger->logDebug(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); diff --git a/lib/obp60task/PageFourValues2.cpp b/lib/obp60task/PageFourValues2.cpp index a583c2e..99f1f3b 100644 --- a/lib/obp60task/PageFourValues2.cpp +++ b/lib/obp60task/PageFourValues2.cpp @@ -9,6 +9,7 @@ class PageFourValues2 : public Page { private: String lengthformat; + public: PageFourValues2(CommonData &common) : Page(common) { @@ -27,6 +28,16 @@ public: return key; } + void displayNew(PageData &pageData) { +#ifdef BOARD_OBP60S3 + // Clear optical warning + if (flashLED == "Limit Violation") { + setBlinkingLED(false); + setFlashLED(false); + } +#endif + }; + int displayPage(PageData &pageData) { // Old values for hold function @@ -79,12 +90,6 @@ public: 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"){ - setBlinkingLED(false); - setFlashLED(false); - } - // Logging boat values if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement? logger->logDebug(GwLog::LOG, "Drawing at PageFourValues2, %s: %f, %s: %f, %s: %f, %s: %f", name1.c_str(), value1, name2.c_str(), value2, name3.c_str(), value3, name4.c_str(), value4); diff --git a/lib/obp60task/PageGenerator.cpp b/lib/obp60task/PageGenerator.cpp index 4569690..b26c87f 100644 --- a/lib/obp60task/PageGenerator.cpp +++ b/lib/obp60task/PageGenerator.cpp @@ -60,22 +60,17 @@ public: bool valid1 = true; // Optical warning by limit violation - if(String(flashLED) == "Limit Violation"){ - // Over voltage - if(value1 > 14.8 && batVoltage == "12V"){ - setBlinkingLED(true); - } - if(value1 <= 14.8 && batVoltage == "12V"){ + if (flashLED == "Limit Violation") { + // Over voltage? + if (batVoltage == "12V") { + setBlinkingLED(value1 > 14.8); + } else if (batVoltage == "24V") { + setBlinkingLED(value1 > 29.6); + } else { setBlinkingLED(false); } - if(value1 > 29.6 && batVoltage == "24V"){ - setBlinkingLED(true); - } - if(value1 <= 29.6 && batVoltage == "24V"){ - setBlinkingLED(false); - } } - + // Logging voltage value logger->logDebug(GwLog::LOG, "Drawing at PageGenerator, Type:%iW %s:=%f", genPower, name1.c_str(), value1); diff --git a/lib/obp60task/PageKeelPosition.cpp b/lib/obp60task/PageKeelPosition.cpp index 7f302c8..2381b89 100644 --- a/lib/obp60task/PageKeelPosition.cpp +++ b/lib/obp60task/PageKeelPosition.cpp @@ -32,6 +32,16 @@ public: return key; } + void displayNew(PageData &pageData) { +#ifdef BOARD_OBP60S3 + // Clear optical warning + if (flashLED == "Limit Violation") { + setBlinkingLED(false); + setFlashLED(false); + } +#endif + }; + int displayPage(PageData &pageData) { double value1 = 0; @@ -54,12 +64,6 @@ public: value1old = value1; // Save old value } - // Optical warning by limit violation (unused) - if(String(flashLED) == "Limit Violation"){ - setBlinkingLED(false); - setFlashLED(false); - } - // Logging boat values logger->logDebug(GwLog::LOG, "Drawing at PageKeelPosition, Keel:%f", value1); diff --git a/lib/obp60task/PageOneValue.cpp b/lib/obp60task/PageOneValue.cpp index 708cc32..b90fefe 100644 --- a/lib/obp60task/PageOneValue.cpp +++ b/lib/obp60task/PageOneValue.cpp @@ -9,6 +9,7 @@ class PageOneValue : public Page { private: String lengthformat; + public: PageOneValue(CommonData &common) : Page(common) { @@ -27,6 +28,16 @@ public: return key; } + void displayNew(PageData &pageData) { +#ifdef BOARD_OBP60S3 + // Clear optical warning + if (flashLED == "Limit Violation") { + setBlinkingLED(false); + setFlashLED(false); + } +#endif + }; + int displayPage(PageData &pageData) { // Old values for hold function @@ -44,12 +55,6 @@ public: 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"){ - setBlinkingLED(false); - setFlashLED(false); - } - // Logging boat values if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement? logger->logDebug(GwLog::LOG, "Drawing at PageOneValue, %s: %f", name1.c_str(), value1); diff --git a/lib/obp60task/PageRollPitch.cpp b/lib/obp60task/PageRollPitch.cpp index 013ea69..9f25518 100644 --- a/lib/obp60task/PageRollPitch.cpp +++ b/lib/obp60task/PageRollPitch.cpp @@ -99,13 +99,12 @@ public: } // Optical warning by limit violation - if(String(flashLED) == "Limit Violation"){ + if (flashLED == "Limit Violation") { // Limits for roll - if(value1*360/(2*M_PI) >= -1*rolllimit && value1*360/(2*M_PI) <= rolllimit){ + if (value1*360/(2*M_PI) >= -1*rolllimit && value1*360/(2*M_PI) <= rolllimit) { setBlinkingLED(false); setFlashLED(false); - } - else{ + } else { setBlinkingLED(true); } } diff --git a/lib/obp60task/PageRudderPosition.cpp b/lib/obp60task/PageRudderPosition.cpp index 9d151ca..7573fff 100644 --- a/lib/obp60task/PageRudderPosition.cpp +++ b/lib/obp60task/PageRudderPosition.cpp @@ -29,6 +29,16 @@ public: return key; } + void displayNew(PageData &pageData) { +#ifdef BOARD_OBP60S3 + // Clear optical warning + if (flashLED == "Limit Violation") { + setBlinkingLED(false); + setFlashLED(false); + } +#endif + }; + int displayPage(PageData &pageData) { static String unit1old = ""; @@ -57,12 +67,6 @@ public: } } - // Optical warning by limit violation (unused) - if(String(flashLED) == "Limit Violation"){ - setBlinkingLED(false); - setFlashLED(false); - } - // Logging boat values if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement? logger->logDebug(GwLog::LOG, "Drawing at PageRudderPosition, %s:%f", name1.c_str(), value1); @@ -89,21 +93,20 @@ public: float x = 200 + (rInstrument-30)*sin(i/180.0*pi); // x-coordinate dots float y = 150 - (rInstrument-30)*cos(i/180.0*pi); // y-coordinate cots const char *ii = " "; - switch (i) - { - case 0: ii=" "; break; // Use a blank for a empty scale value - case 30 : ii=" "; break; - case 60 : ii=" "; break; - case 90 : ii="45"; break; - case 120 : ii="30"; break; - case 150 : ii="15"; break; - case 180 : ii="0"; break; - case 210 : ii="15"; break; - case 240 : ii="30"; break; - case 270 : ii="45"; break; - case 300 : ii=" "; break; - case 330 : ii=" "; break; - default: break; + switch (i) { + case 0: ii=" "; break; // Use a blank for a empty scale value + case 30 : ii=" "; break; + case 60 : ii=" "; break; + case 90 : ii="45"; break; + case 120 : ii="30"; break; + case 150 : ii="15"; break; + case 180 : ii="0"; break; + case 210 : ii="15"; break; + case 240 : ii="30"; break; + case 270 : ii="45"; break; + case 300 : ii=" "; break; + case 330 : ii=" "; break; + default: break; } // Print text centered on position x, y diff --git a/lib/obp60task/PageSixValues.cpp b/lib/obp60task/PageSixValues.cpp index 4a6af30..d29fa32 100644 --- a/lib/obp60task/PageSixValues.cpp +++ b/lib/obp60task/PageSixValues.cpp @@ -30,6 +30,16 @@ public: return key; } + void displayNew(PageData &pageData) { +#ifdef BOARD_OBP60S3 + // Clear optical warning + if (flashLED == "Limit Violation") { + setBlinkingLED(false); + setFlashLED(false); + } +#endif + }; + int displayPage(PageData &pageData) { // Old values for hold function @@ -63,12 +73,6 @@ public: DataFormat[i] = bvalue->getFormat(); // Unit of value } - // Optical warning by limit violation (unused) - if(String(flashLED) == "Limit Violation"){ - setBlinkingLED(false); - setFlashLED(false); - } - if (bvalue == NULL) return PAGE_OK; // WTF why this statement? // Draw page diff --git a/lib/obp60task/PageSkyView.cpp b/lib/obp60task/PageSkyView.cpp index 7e33c0e..9c9d993 100644 --- a/lib/obp60task/PageSkyView.cpp +++ b/lib/obp60task/PageSkyView.cpp @@ -25,13 +25,17 @@ public: return key; } - int displayPage(PageData &pageData) { - - // Optical warning by limit violation (unused) - if(String(flashLED) == "Limit Violation"){ + void displayNew(PageData &pageData) { +#ifdef BOARD_OBP60S3 + // Clear optical warning + if (flashLED == "Limit Violation") { setBlinkingLED(false); - setFlashLED(false); + setFlashLED(false); } +#endif + }; + + int displayPage(PageData &pageData) { // Logging boat values logger->logDebug(GwLog::LOG, "Drawing at PageSkyView"); diff --git a/lib/obp60task/PageSolar.cpp b/lib/obp60task/PageSolar.cpp index 27d2751..cd0a1d1 100644 --- a/lib/obp60task/PageSolar.cpp +++ b/lib/obp60task/PageSolar.cpp @@ -59,21 +59,16 @@ public: bool valid1 = true; - // Optical warning by limit violation - if(String(flashLED) == "Limit Violation"){ - // Over voltage - if(value1 > 14.8 && batVoltage == "12V"){ - setBlinkingLED(true); - } - if(value1 <= 14.8 && batVoltage == "12V"){ + // Optical warning by limit violation + if (flashLED == "Limit Violation") { + // Over voltage? + if (batVoltage == "12V") { + setBlinkingLED(value1 > 14.8); + } else if (batVoltage == "24V") { + setBlinkingLED(value1 > 29.6); + } else { setBlinkingLED(false); } - if(value1 > 29.6 && batVoltage == "24V"){ - setBlinkingLED(true); - } - if(value1 <= 29.6 && batVoltage == "24V"){ - setBlinkingLED(false); - } } // Logging voltage value diff --git a/lib/obp60task/PageSystem.cpp b/lib/obp60task/PageSystem.cpp index 58f9807..5767ffa 100644 --- a/lib/obp60task/PageSystem.cpp +++ b/lib/obp60task/PageSystem.cpp @@ -391,7 +391,12 @@ private: epd->setFont(&Ubuntu_Bold8pt8b); epd->setCursor(x0, y0); epd->print("Work in progress..."); - +#ifdef BOARD_OBP60S3 + // This mode should not be callable by devices without card hardware + // In case of accidential reaching this, display a friendly message + epd->print("This mode is not indended to be reached!\n"); + epd->print("There's nothing to see here. Move on."); +#endif #ifdef BOARD_OBP40S3 /* TODO identify card as OBP-Card: magic.dat @@ -645,6 +650,13 @@ public: } void displayNew(PageData &pageData) { +#ifdef BOARD_OBP60S3 + // Clear optical warning + if (flashLED == "Limit Violation") { + setBlinkingLED(false); + setFlashLED(false); + } +#endif // Get references from API logger->logDebug(GwLog::LOG, "New page display: PageSystem"); NMEA2000 = pageData.api->getNMEA2000(); @@ -652,12 +664,6 @@ public: int displayPage(PageData &pageData) { - // Optical warning by limit violation (unused) - if(flashLED == "Limit Violation"){ - setBlinkingLED(false); - setFlashLED(false); - } - // Logging page information logger->logDebug(GwLog::LOG, "Drawing at PageSystem, Mode=%c", mode); diff --git a/lib/obp60task/PageThreeValues.cpp b/lib/obp60task/PageThreeValues.cpp index 7083337..9288370 100644 --- a/lib/obp60task/PageThreeValues.cpp +++ b/lib/obp60task/PageThreeValues.cpp @@ -9,6 +9,7 @@ class PageThreeValues : public Page { private: String lengthformat; + public: PageThreeValues(CommonData &common) : Page(common) { @@ -27,6 +28,16 @@ public: return key; } + void displayNew(PageData &pageData) { +#ifdef BOARD_OBP60S3 + // Clear optical warning + if (flashLED == "Limit Violation") { + setBlinkingLED(false); + setFlashLED(false); + } +#endif + }; + int displayPage(PageData &pageData) { // Old values for hold function @@ -67,12 +78,6 @@ public: 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"){ - setBlinkingLED(false); - setFlashLED(false); - } - // Logging boat values if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement? logger->logDebug(GwLog::LOG, "Drawing at PageThreeValues, %s: %f, %s: %f, %s: %f", name1.c_str(), value1, name2.c_str(), value2, name3.c_str(), value3); diff --git a/lib/obp60task/PageTwoValues.cpp b/lib/obp60task/PageTwoValues.cpp index 52d4946..23c1ffc 100644 --- a/lib/obp60task/PageTwoValues.cpp +++ b/lib/obp60task/PageTwoValues.cpp @@ -9,6 +9,7 @@ class PageTwoValues : public Page { private: String lengthformat; + public: PageTwoValues(CommonData &common) : Page(common) { @@ -27,6 +28,16 @@ public: return key; } + void displayNew(PageData &pageData) { +#ifdef BOARD_OBP60S3 + // Clear optical warning + if (flashLED == "Limit Violation") { + setBlinkingLED(false); + setFlashLED(false); + } +#endif + }; + int displayPage(PageData &pageData) { // Old values for hold function @@ -56,12 +67,6 @@ public: 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"){ - setBlinkingLED(false); - setFlashLED(false); - } - // Logging boat values if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement? logger->logDebug(GwLog::LOG, "Drawing at PageTwoValues, %s: %f, %s: %f", name1.c_str(), value1, name2.c_str(), value2); diff --git a/lib/obp60task/PageVoltage.cpp b/lib/obp60task/PageVoltage.cpp index 01acb87..7f1229a 100644 --- a/lib/obp60task/PageVoltage.cpp +++ b/lib/obp60task/PageVoltage.cpp @@ -154,41 +154,25 @@ public: bool valid1 = true; // Optical warning by limit violation - if(String(flashLED) == "Limit Violation"){ - // Limits for Pb battery - if(String(batType) == "Pb" && (raw < 11.8 || raw > 14.8)){ + if (flashLED == "Limit Violation") { + bool violation = false; + if (batType == "Pb") { + violation = (raw < 11.8 || raw > 14.8); + } else if (batType == "Gel") { + violation = (raw < 11.8 || raw > 14.4); + } else if (batType == "AGM") { + violation = (raw < 11.8 || raw > 14.7); + } else if (batType == "LiFePo4") { + violation = (raw < 12.0 || raw > 14.6); + } + if (violation) { setBlinkingLED(true); - } - if(String(batType) == "Pb" && (raw >= 11.8 && raw <= 14.8)){ - setBlinkingLED(false); - setFlashLED(false); - } - // Limits for Gel battery - if(String(batType) == "Gel" && (raw < 11.8 || raw > 14.4)){ - setBlinkingLED(true); - } - if(String(batType) == "Gel" && (raw >= 11.8 && raw <= 14.4)){ - setBlinkingLED(false); - setFlashLED(false); - } - // Limits for AGM battery - if(String(batType) == "AGM" && (raw < 11.8 || raw > 14.7)){ - setBlinkingLED(true); - } - if(String(batType) == "AGM" && (raw >= 11.8 && raw <= 14.7)){ - setBlinkingLED(false); - setFlashLED(false); - } - // Limits for LiFePo4 battery - if(String(batType) == "LiFePo4" && (raw < 12.0 || raw > 14.6)){ - setBlinkingLED(true); - } - if(String(batType) == "LiFePo4" && (raw >= 12.0 && raw <= 14.6)){ + } else { setBlinkingLED(false); setFlashLED(false); } } - + // Logging voltage value logger->logDebug(GwLog::LOG, "Drawing at PageVoltage, Type:%s %s:=%f", batType, name1.c_str(), raw); @@ -207,7 +191,7 @@ public: epd->setCursor(20, 100); epd->print(name1); // Value name - #if defined BOARD_OBP40S3 && defined LIPO_ACCU_1200 && defined VOLTAGE_SENSOR +#if defined BOARD_OBP40S3 && defined LIPO_ACCU_1200 && defined VOLTAGE_SENSOR // Show charge status epd->setFont(&Ubuntu_Bold8pt8b); epd->setCursor(185, 100); @@ -217,7 +201,7 @@ public: else{ epd->print("Discharge"); } - #endif +#endif // Show unit epd->setFont(&Ubuntu_Bold20pt8b); @@ -227,12 +211,12 @@ public: // Show battery type epd->setFont(&Ubuntu_Bold8pt8b); epd->setCursor(295, 100); - #ifdef BOARD_OBP60S3 +#ifdef BOARD_OBP60S3 epd->print(batType); - #endif - #if defined BOARD_OBP40S3 && defined LIPO_ACCU_1200 && defined VOLTAGE_SENSOR +#endif +#if defined BOARD_OBP40S3 && defined LIPO_ACCU_1200 && defined VOLTAGE_SENSOR epd->print("LiPo"); - #endif +#endif // Show average settings printAvg(average, 320, 84, true); diff --git a/lib/obp60task/PageWhite.cpp b/lib/obp60task/PageWhite.cpp index addd745..c41e38c 100644 --- a/lib/obp60task/PageWhite.cpp +++ b/lib/obp60task/PageWhite.cpp @@ -39,13 +39,17 @@ public: return key; } - int displayPage(PageData &pageData) { - - // Optical warning by limit violation (unused) - if(String(flashLED) == "Limit Violation"){ + void displayNew(PageData &pageData) { +#ifdef BOARD_OBP60S3 + // Clear optical warning + if (flashLED == "Limit Violation") { setBlinkingLED(false); - setFlashLED(false); + setFlashLED(false); } +#endif + }; + + int displayPage(PageData &pageData) { // Logging boat values logger->logDebug(GwLog::LOG, "Drawing at PageWhite"); diff --git a/lib/obp60task/PageWind.cpp b/lib/obp60task/PageWind.cpp index 9daa267..2a3f868 100644 --- a/lib/obp60task/PageWind.cpp +++ b/lib/obp60task/PageWind.cpp @@ -303,6 +303,16 @@ public: return key; } + void displayNew(PageData &pageData) { +#ifdef BOARD_OBP60S3 + // Clear optical warning + if (flashLED == "Limit Violation") { + setBlinkingLED(false); + setFlashLED(false); + } +#endif + }; + int displayPage(PageData &pageData) { static String svalue1old = ""; @@ -344,12 +354,6 @@ public: 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"){ - setBlinkingLED(false); - setFlashLED(false); - } - // Logging boat values if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement? logger->logDebug(GwLog::LOG, "Drawing at PageWind, %s:%f, %s:%f", name1.c_str(), value1, name2.c_str(), value2); diff --git a/lib/obp60task/PageWindPlot.cpp b/lib/obp60task/PageWindPlot.cpp index 0607713..94e3512 100644 --- a/lib/obp60task/PageWindPlot.cpp +++ b/lib/obp60task/PageWindPlot.cpp @@ -111,6 +111,16 @@ public: return key; } + void displayNew(PageData &pageData) { +#ifdef BOARD_OBP60S3 + // Clear optical warning + if (flashLED == "Limit Violation") { + setBlinkingLED(false); + setFlashLED(false); + } +#endif + }; + int displayPage(PageData& pageData) { float twsValue; // TWS value in chart area diff --git a/lib/obp60task/PageWindRose.cpp b/lib/obp60task/PageWindRose.cpp index cb8dbe2..6d5c183 100644 --- a/lib/obp60task/PageWindRose.cpp +++ b/lib/obp60task/PageWindRose.cpp @@ -30,6 +30,16 @@ public: return key; } + void displayNew(PageData &pageData) { +#ifdef BOARD_OBP60S3 + // Clear optical warning + if (flashLED == "Limit Violation") { + setBlinkingLED(false); + setFlashLED(false); + } +#endif + }; + int displayPage(PageData &pageData) { static String svalue1old = ""; @@ -130,12 +140,6 @@ public: unit6old = unit6; // Save old unit } - // Optical warning by limit violation (unused) - if(String(flashLED) == "Limit Violation"){ - setBlinkingLED(false); - setFlashLED(false); - } - // Logging boat values if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement? logger->logDebug(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); @@ -158,12 +162,7 @@ public: epd->setFont(&Ubuntu_Bold8pt8b); epd->setCursor(10, 115); epd->print(" "); - if(holdvalues == false){ - epd->print(unit1); // Unit - } - else{ - epd->print(unit1old); // Unit - } + epd->print(holdvalues ? unit1old : unit1); // Horizintal separator left epd->fillRect(0, 149, 60, 3, commonData->fgcolor); @@ -178,12 +177,7 @@ public: epd->setFont(&Ubuntu_Bold8pt8b); epd->setCursor(10, 190); epd->print(" "); - if(holdvalues == false){ - epd->print(unit2); // Unit - } - else{ - epd->print(unit2old); // Unit - } + epd->print(holdvalues ? unit2old : unit2); // Show values TWD epd->setFont(&DSEG7Classic_BoldItalic20pt7b); @@ -200,12 +194,7 @@ public: epd->setFont(&Ubuntu_Bold8pt8b); epd->setCursor(335, 115); epd->print(" "); - if(holdvalues == false){ - epd->print(unit3); // Unit - } - else{ - epd->print(unit3old); // Unit - } + epd->print(holdvalues ? unit3old : unit3); // Horizintal separator right epd->fillRect(340, 149, 80, 3, commonData->fgcolor); @@ -220,12 +209,7 @@ public: epd->setFont(&Ubuntu_Bold8pt8b); epd->setCursor(335, 190); epd->print(" "); - if(holdvalues == false){ - epd->print(unit4); // Unit - } - else{ - epd->print(unit4old); // Unit - } + epd->print(holdvalues ? unit4old : unit4); //******************************************************************************************* @@ -244,21 +228,20 @@ public: float x = 200 + (rInstrument-30)*sin(i/180.0*pi); // x-coordinate dots float y = 150 - (rInstrument-30)*cos(i/180.0*pi); // y-coordinate cots const char *ii = ""; - switch (i) -{ - case 0: ii="0"; break; - case 30 : ii="30"; break; - case 60 : ii="60"; break; - case 90 : ii="90"; break; - case 120 : ii="120"; break; - case 150 : ii="150"; break; - case 180 : ii="180"; break; - case 210 : ii="210"; break; - case 240 : ii="240"; break; - case 270 : ii="270"; break; - case 300 : ii="300"; break; - case 330 : ii="330"; break; - default: break; + switch (i) { + case 0: ii="0"; break; + case 30 : ii="30"; break; + case 60 : ii="60"; break; + case 90 : ii="90"; break; + case 120 : ii="120"; break; + case 150 : ii="150"; break; + case 180 : ii="180"; break; + case 210 : ii="210"; break; + case 240 : ii="240"; break; + case 270 : ii="270"; break; + case 300 : ii="300"; break; + case 330 : ii="330"; break; + default: break; } // Print text centered on position x, y @@ -266,7 +249,7 @@ public: uint16_t w, h; // Return values of getTextBounds epd->getTextBounds(ii, int(x), int(y), &x1, &y1, &w, &h); // Calc width of new string epd->setCursor(x-w/2, y+h/2); - if(i % 30 == 0){ + if (i % 30 == 0) { epd->setFont(&Ubuntu_Bold8pt8b); epd->print(ii); } @@ -333,12 +316,7 @@ public: epd->setFont(&Ubuntu_Bold8pt8b); epd->setCursor(190, 215); epd->print(" "); - if(holdvalues == false){ - epd->print(unit5); // Unit - } - else{ - epd->print(unit5old); // Unit - } + epd->print(holdvalues ? unit5old : unit5); // Show values STW epd->setFont(&DSEG7Classic_BoldItalic16pt7b); @@ -347,12 +325,7 @@ public: epd->setFont(&Ubuntu_Bold8pt8b); epd->setCursor(190, 90); epd->print(" "); - if(holdvalues == false){ - epd->print(unit6); // Unit - } - else{ - epd->print(unit6old); // Unit - } + epd->print(holdvalues ? unit6old : unit6); return PAGE_UPDATE; }; diff --git a/lib/obp60task/PageWindRoseFlex.cpp b/lib/obp60task/PageWindRoseFlex.cpp index 64585a3..85a4424 100644 --- a/lib/obp60task/PageWindRoseFlex.cpp +++ b/lib/obp60task/PageWindRoseFlex.cpp @@ -30,6 +30,16 @@ public: return key; } + void displayNew(PageData &pageData) { +#ifdef BOARD_OBP60S3 + // Clear optical warning + if (flashLED == "Limit Violation") { + setBlinkingLED(false); + setFlashLED(false); + } +#endif + }; + int displayPage(PageData &pageData) { static String svalue1old = ""; @@ -130,12 +140,6 @@ public: unit6old = unit6; // Save old unit } - // Optical warning by limit violation (unused) - if(String(flashLED) == "Limit Violation"){ - setBlinkingLED(false); - setFlashLED(false); - } - // Logging boat values if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement? logger->logDebug(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); @@ -158,12 +162,7 @@ public: epd->setFont(&Ubuntu_Bold8pt8b); epd->setCursor(10, 115); epd->print(" "); - if(holdvalues == false){ - epd->print(unit2); // Unit - } - else{ - epd->print(unit2old); // Unit - } + epd->print(holdvalues ? unit2old : unit2); // Horizintal separator left epd->fillRect(0, 149, 60, 3, commonData->fgcolor); @@ -178,12 +177,8 @@ public: epd->setFont(&Ubuntu_Bold8pt8b); epd->setCursor(10, 190); epd->print(" "); - if(holdvalues == false){ - epd->print(unit3); // Unit - } - else{ - epd->print(unit3old); // Unit - } + epd->print(holdvalues ? unit3old : unit3); + // Show value 4 at top right epd->setFont(&DSEG7Classic_BoldItalic20pt7b); @@ -201,12 +196,8 @@ public: epd->setFont(&Ubuntu_Bold8pt8b); epd->setCursor(335, 115); epd->print(" "); - if(holdvalues == false){ - epd->print(unit4); // Unit - } - else{ - epd->print(unit4old); // Unit - } + epd->print(holdvalues ? unit4old : unit4); + // Horizintal separator right epd->fillRect(340, 149, 80, 3, commonData->fgcolor); @@ -221,13 +212,7 @@ public: epd->setFont(&Ubuntu_Bold8pt8b); epd->setCursor(335, 190); epd->print(" "); - if(holdvalues == false){ - epd->print(unit5); // Unit - } - else{ - epd->print(unit5old); // Unit - } - + epd->print(holdvalues ? unit5old : unit5); //******************************************************************************************* @@ -340,12 +325,7 @@ public: epd->setCursor(190, 90); } epd->print(" "); - if(holdvalues == false){ - epd->print(unit6); // Unit - } - else{ - epd->print(unit6old); // Unit - } + epd->print(holdvalues ? unit6old : unit6); return PAGE_UPDATE; }; diff --git a/lib/obp60task/PageXTETrack.cpp b/lib/obp60task/PageXTETrack.cpp index 0b0412d..1952c16 100644 --- a/lib/obp60task/PageXTETrack.cpp +++ b/lib/obp60task/PageXTETrack.cpp @@ -69,13 +69,17 @@ public: return key; } - int displayPage(PageData &pageData) { - - // Optical warning by limit violation (unused) - if(String(flashLED) == "Limit Violation"){ + void displayNew(PageData &pageData) { +#ifdef BOARD_OBP60S3 + // Clear optical warning + if (flashLED == "Limit Violation") { setBlinkingLED(false); setFlashLED(false); } +#endif + }; + + int displayPage(PageData &pageData) { // Logging boat values logger->logDebug(GwLog::LOG, "Drawing at PageXTETrack"); diff --git a/lib/obp60task/Pagedata.h b/lib/obp60task/Pagedata.h index 690815b..cbf738d 100644 --- a/lib/obp60task/Pagedata.h +++ b/lib/obp60task/Pagedata.h @@ -147,6 +147,7 @@ public: int refreshtime = 1000; virtual int displayPage(PageData &pageData)=0; virtual void displayNew(PageData &pageData){} + virtual void leavePage(PageData &pageData){} virtual void setupKeys() { #ifdef HARDWARE_V21 commonData->keydata[0].label = ""; diff --git a/lib/obp60task/README b/lib/obp60task/README index 1e35f8c..3a368b2 100644 --- a/lib/obp60task/README +++ b/lib/obp60task/README @@ -4,6 +4,12 @@ Development information This file contains some hints concerning building the firmware as well as developing and debugging it. +Coding style +------------ +WIP +Please format your new code the same as already existing code. +Preprocessor directives go to column zero. + Git commands ------------ diff --git a/lib/obp60task/TODO b/lib/obp60task/TODO index ba56b3c..451a4b5 100644 --- a/lib/obp60task/TODO +++ b/lib/obp60task/TODO @@ -2,8 +2,6 @@ - page refresh after page change and not connected to key codes -- fix sd card code - - config: getFloat, getDouble - dseg7 font to new version diff --git a/lib/obp60task/obp60task.cpp b/lib/obp60task/obp60task.cpp index 781225a..4c25e6f 100644 --- a/lib/obp60task/obp60task.cpp +++ b/lib/obp60task/obp60task.cpp @@ -66,13 +66,13 @@ void OBP60Init(GwApi *api){ // Settings for e-paper display String fastrefresh = api->getConfig()->getConfigItem(api->getConfig()->fastRefresh,true)->asString(); logger->logDebug(GwLog::DEBUG,"Fast Refresh Mode is: %s", fastrefresh.c_str()); - #ifdef DISPLAY_GDEY042T81 +#ifdef DISPLAY_GDEY042T81 if(fastrefresh == "true"){ static const bool useFastFullUpdate = true; // Enable fast full display update only for GDEY042T81 } - #endif +#endif - #ifdef BOARD_OBP60S3 +#ifdef BOARD_OBP60S3 touchSleepWakeUpEnable(TP1, 45); // TODO sensitivity should be configurable via web interface touchSleepWakeUpEnable(TP2, 45); touchSleepWakeUpEnable(TP3, 45); @@ -80,7 +80,7 @@ void OBP60Init(GwApi *api){ touchSleepWakeUpEnable(TP5, 45); touchSleepWakeUpEnable(TP6, 45); esp_sleep_enable_touchpad_wakeup(); - #endif +#endif // Get CPU speed int freq = getCpuFrequencyMhz(); @@ -282,16 +282,16 @@ void underVoltageDetection(GwApi *api, CommonData &common){ double voffset = (api->getConfig()->getConfigItem(api->getConfig()->vOffset,true)->asString()).toFloat(); double vslope = (api->getConfig()->getConfigItem(api->getConfig()->vSlope,true)->asString()).toFloat(); // Read supply voltage - #if defined VOLTAGE_SENSOR && defined LIPO_ACCU_1200 +#if defined VOLTAGE_SENSOR && defined LIPO_ACCU_1200 float actVoltage = (float(analogRead(OBP_ANALOG0)) * 3.3 / 4096 + 0.53) * 2; // Vin = 1/2 for OBP40 float minVoltage = 3.65; // Absolut minimum volatge for 3,7V LiPo accu - #else +#else float actVoltage = (float(analogRead(OBP_ANALOG0)) * 3.3 / 4096 + 0.17) * 20; // Vin = 1/20 for OBP60 float minVoltage = MIN_VOLTAGE; - #endif +#endif double calVoltage = actVoltage * vslope + voffset; // Calibration if(calVoltage < minVoltage){ - #if defined VOLTAGE_SENSOR && defined LIPO_ACCU_1200 +#if defined VOLTAGE_SENSOR && defined LIPO_ACCU_1200 // Switch off all power lines setPortPin(OBP_BACKLIGHT_LED, false); // Backlight Off setFlashLED(false); // Flash LED Off @@ -311,7 +311,7 @@ void underVoltageDetection(GwApi *api, CommonData &common){ epd->powerOff(); // Display power off setPortPin(OBP_POWER_EPD, false); // Power off ePaper display setPortPin(OBP_POWER_SD, false); // Power off SD card - #else +#else // Switch off all power lines setPortPin(OBP_BACKLIGHT_LED, false); // Backlight Off setFlashLED(false); // Flash LED Off @@ -329,7 +329,7 @@ void underVoltageDetection(GwApi *api, CommonData &common){ epd->print("To wake up repower system"); epd->nextPage(); // Partial update epd->powerOff(); // Display power off - #endif +#endif // Stop system while(true){ esp_deep_sleep_start(); // Deep Sleep without weakup. Weakup only after power cycle (restart). @@ -500,15 +500,15 @@ void OBP60Task(GwApi *api){ bool symbolmode = (config->getString(config->headerFormat) == "ICON"); String fastrefresh = api->getConfig()->getConfigItem(api->getConfig()->fastRefresh,true)->asString(); uint fullrefreshtime = uint(api->getConfig()->getConfigItem(api->getConfig()->fullRefreshTime,true)->asInt()); - #ifdef BOARD_OBP40S3 +#ifdef BOARD_OBP40S3 bool syspage_enabled = config->getBool(config->systemPage); - #endif +#endif - #ifdef DISPLAY_GDEY042T81 +#ifdef DISPLAY_GDEY042T81 epd->init(115200, true, 2, false); // Init for Waveshare boards with "clever" reset circuit, 2ms reset pulse - #else +#else epd->init(115200); // Init for normal displays - #endif +#endif epd->setRotation(0); // Set display orientation (horizontal) epd->setFullWindow(); // Set full Refresh @@ -643,9 +643,9 @@ void OBP60Task(GwApi *api){ allParameters.page0=3; allParameters.queue=xQueueCreate(10,sizeof(int)); allParameters.sensitivity= api->getConfig()->getInt(GwConfigDefinitions::tSensitivity); - #ifdef BOARD_OBP40S3 +#ifdef BOARD_OBP40S3 allParameters.use_syspage = syspage_enabled; - #endif +#endif xTaskCreate(keyboardTask,"keyboard",2000,&allParameters,configMAX_PRIORITIES-1,NULL); SharedData *shared=new SharedData(api); createSensorTask(shared); @@ -785,12 +785,12 @@ void OBP60Task(GwApi *api){ toggleBacklightLED(commonData.backlight.brightness, commonData.backlight.color); } } - #ifdef BOARD_OBP40S3 +#ifdef BOARD_OBP40S3 // #3 Deep sleep mode for OBP40 if ((keyboardMessage == 3) and !syspage_enabled){ deepSleep(commonData); } - #endif +#endif // #9 Swipe right or #4 key right if ((keyboardMessage == 9) or (keyboardMessage == 4)) { @@ -854,11 +854,11 @@ void OBP60Task(GwApi *api){ } else{ epd->fillScreen(commonData.fgcolor); // Clear display - #ifdef DISPLAY_GDEY042T81 +#ifdef DISPLAY_GDEY042T81 epd->init(115200, true, 2, false); // Init for Waveshare boards with "clever" reset circuit, 2ms reset pulse - #else +#else epd->init(115200); // Init for normal displays - #endif +#endif epd->firstPage(); // Full update epd->nextPage(); // Full update // epd->setPartialWindow(0, 0, epd->width(), epd->height()); // Set partial update @@ -881,11 +881,11 @@ void OBP60Task(GwApi *api){ } else{ epd->fillScreen(commonData.fgcolor); // Clear display - #ifdef DISPLAY_GDEY042T81 +#ifdef DISPLAY_GDEY042T81 epd->init(115200, true, 2, false); // Init for Waveshare boards with "clever" reset circuit, 2ms reset pulse - #else +#else epd->init(115200); // Init for normal displays - #endif +#endif epd->firstPage(); // Full update epd->nextPage(); // Full update // epd->setPartialWindow(0, 0, epd->width(), epd->height()); // Set partial update @@ -905,11 +905,11 @@ void OBP60Task(GwApi *api){ } else{ epd->fillScreen(commonData.fgcolor); // Clear display - #ifdef DISPLAY_GDEY042T81 +#ifdef DISPLAY_GDEY042T81 epd->init(115200, true, 2, false); // Init for Waveshare boards with "clever" reset circuit, 2ms reset pulse - #else +#else epd->init(115200); // Init for normal displays - #endif +#endif epd->firstPage(); // Full update epd->nextPage(); // Full update // epd->setPartialWindow(0, 0, epd->width(), epd->height()); // Set partial update