diff --git a/lib/obp60task/OBP60Extensions.cpp b/lib/obp60task/OBP60Extensions.cpp index c565c6c..94d4714 100644 --- a/lib/obp60task/OBP60Extensions.cpp +++ b/lib/obp60task/OBP60Extensions.cpp @@ -325,7 +325,12 @@ void displayHeader(CommonData &commonData, GwApi::BoatValue *date, GwApi::BoatVa } } else{ - getdisplay().print("No GPS data"); + if(commonData.config->getBool(commonData.config->useSimuData) == true){ + getdisplay().print("12:00 01.01.2024 LOT"); + } + else{ + getdisplay().print("No GPS data"); + } } } } diff --git a/lib/obp60task/OBP60Formater.cpp b/lib/obp60task/OBP60Formater.cpp index 4695ff3..1ddbe76 100644 --- a/lib/obp60task/OBP60Formater.cpp +++ b/lib/obp60task/OBP60Formater.cpp @@ -12,6 +12,7 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){ GwLog *logger = commondata.logger; FormatedData result; static int dayoffset = 0; + double rawvalue = 0; // Load configuration values String stimeZone = commondata.config->getString(commondata.config->timeZone); // [UTC -14.00...+12.00] @@ -112,9 +113,11 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){ else if (value->getFormat() == "formatFixed0"){ if(usesimudata == false) { snprintf(buffer,bsize,"%3.0f",value->value); + rawvalue = value->value; } else{ - snprintf(buffer,bsize,"%3.0f", 8.0 + float(random(0, 10)) / 10.0); + rawvalue = 8.0 + float(random(0, 10)) / 10.0; + snprintf(buffer,bsize,"%3.0f", rawvalue); } result.unit = ""; } @@ -123,9 +126,11 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){ double course = 0; if(usesimudata == false) { course = value->value; + rawvalue = value->value; } else{ course = 2.53 + float(random(0, 10) / 100.0); + rawvalue = course; } course = course * 57.2958; // Unit conversion form rad to deg @@ -138,9 +143,11 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){ double speed = 0; if(usesimudata == false) { speed = value->value; + rawvalue = value->value; } else{ - speed = 4.0 + float(random(0, 40)); + rawvalue = 4.0 + float(random(0, 40)); + speed = rawvalue; } if(String(speedFormat) == "km/h"){ speed = speed * 3.6; // Unit conversion form m/s to km/h @@ -169,9 +176,11 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){ double speed = 0; if(usesimudata == false) { speed = value->value; + rawvalue = value->value; } else{ - speed = 4.0 + float(random(0, 40)); + rawvalue = 4.0 + float(random(0, 40)); + speed = rawvalue; } if(String(windspeedFormat) == "km/h"){ speed = speed * 3.6; // Unit conversion form m/s to km/h @@ -247,9 +256,11 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){ double rotation = 0; if(usesimudata == false) { rotation = value->value; + rawvalue = value->value; } else{ - rotation = 0.04 + float(random(0, 10)) / 100.0; + rawvalue = 0.04 + float(random(0, 10)) / 100.0; + rotation = rawvalue; } rotation = rotation * 57.2958; // Unit conversion form rad/s to deg/s result.unit = "Deg/s"; @@ -271,9 +282,11 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){ double dop = 0; if(usesimudata == false) { dop = value->value; + rawvalue = value->value; } else{ - dop = 2.0 + float(random(0, 40)) / 10.0; + rawvalue = 2.0 + float(random(0, 40)) / 10.0; + dop = rawvalue; } result.unit = "m"; if(dop > 99.9){ @@ -290,6 +303,7 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){ else if (value->getFormat() == "formatLatitude"){ if(usesimudata == false) { double lat = value->value; + rawvalue = value->value; String latitude = ""; String latdir = ""; float degree = abs(int(lat)); @@ -305,13 +319,15 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){ strcpy(buffer, latitude.c_str()); } else{ - snprintf(buffer,bsize," 51\" %2.4f' N", 35.0 + float(random(0, 10)) / 10000.0); + rawvalue = 35.0 + float(random(0, 10)) / 10000.0; + snprintf(buffer,bsize," 51\" %2.4f' N", rawvalue); } } //######################################################## else if (value->getFormat() == "formatLongitude"){ if(usesimudata == false) { double lon = value->value; + rawvalue = value->value; String longitude = ""; String londir = ""; float degree = abs(int(lon)); @@ -327,7 +343,8 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){ strcpy(buffer, longitude.c_str()); } else{ - snprintf(buffer,bsize," 15\" %2.4f'", 6.0 + float(random(0, 10)) / 100000.0); + rawvalue = 6.0 + float(random(0, 10)) / 100000.0; + snprintf(buffer,bsize," 15\" %2.4f'", rawvalue); } } //######################################################## @@ -335,9 +352,11 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){ double depth = 0; if(usesimudata == false) { depth = value->value; + rawvalue = value->value; } else{ - depth = 18.0 + float(random(0, 100)) / 10.0; + rawvalue = 18.0 + float(random(0, 100)) / 10.0; + depth = rawvalue; } if(String(lengthFormat) == "ft"){ depth = depth * 3.28084; @@ -361,9 +380,11 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){ double temp = 0; if(usesimudata == false) { temp = value->value; + rawvalue = value->value; } else{ - temp = 296.0 + float(random(0, 10)) / 10.0; + rawvalue = 296.0 + float(random(0, 10)) / 10.0; + temp = rawvalue; } if(String(tempFormat) == "C"){ temp = temp - 273.15; @@ -391,9 +412,11 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){ double distance = 0; if(usesimudata == false) { distance = value->value; + rawvalue = value->value; } else{ - distance = 2960.0 + float(random(0, 10)); + rawvalue = 2960.0 + float(random(0, 10)); + distance = rawvalue; } if(String(distanceFormat) == "km"){ distance = distance * 0.001; @@ -424,22 +447,26 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){ double pressure = 0; if(usesimudata == false) { pressure = value->value; - pressure = pressure; // Unit conversion form Pa to mBar + rawvalue = value->value; + pressure = pressure / 100.0; // Unit conversion form Pa to hPa } else{ - pressure = 968 + float(random(0, 10)); + rawvalue = 968 + float(random(0, 10)); + pressure = rawvalue; } snprintf(buffer,bsize,"%4.0f",pressure); - result.unit = "mBar"; + result.unit = "hPa"; } //######################################################## else if (value->getFormat() == "formatXdr:P:B"){ double pressure = 0; if(usesimudata == false) { pressure = value->value; + rawvalue = value->value; pressure = pressure / 100.0; // Unit conversion form Pa to mBar } else{ + rawvalue = value->value; pressure = 968 + float(random(0, 10)); } snprintf(buffer,bsize,"%4.0f",pressure); @@ -450,9 +477,11 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){ double voltage = 0; if(usesimudata == false) { voltage = value->value; + rawvalue = value->value; } else{ - voltage = 12 + float(random(0, 30)) / 10.0; + rawvalue = 12 + float(random(0, 30)) / 10.0; + voltage = rawvalue; } if(voltage < 10){ snprintf(buffer,bsize,"%3.2f",voltage); @@ -467,9 +496,11 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){ double current = 0; if(usesimudata == false) { current = value->value; + rawvalue = value->value; } else{ - current = 8.2 + float(random(0, 50)) / 10.0; + rawvalue = 8.2 + float(random(0, 50)) / 10.0; + current = rawvalue; } if(current < 10){ snprintf(buffer,bsize,"%3.2f",current); @@ -487,9 +518,11 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){ double temperature = 0; if(usesimudata == false) { temperature = value->value - 273.15; // Convert K to C + rawvalue = value->value - 273.15; } else{ - temperature = 21.8 + float(random(0, 50)) / 10.0; + rawvalue = 21.8 + float(random(0, 50)) / 10.0; + temperature = rawvalue; } if(temperature < 10){ snprintf(buffer,bsize,"%3.2f",temperature); @@ -507,9 +540,11 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){ double temperature = 0; if(usesimudata == false) { temperature = value->value; // Value in C + rawvalue = value->value; } else{ - temperature = 21.8 + float(random(0, 50)) / 10.0; + rawvalue = 21.8 + float(random(0, 50)) / 10.0; + temperature = rawvalue; } if(temperature < 10){ snprintf(buffer,bsize,"%3.2f",temperature); @@ -527,9 +562,11 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){ double humidity = 0; if(usesimudata == false) { humidity = value->value; // Value in % + rawvalue = value->value; } else{ - humidity = 41.3 + float(random(0, 50)) / 10.0; + rawvalue = 41.3 + float(random(0, 50)) / 10.0; + humidity = rawvalue; } if(humidity < 10){ snprintf(buffer,bsize,"%3.2f",humidity); @@ -547,9 +584,11 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){ double volume = 0; if(usesimudata == false) { volume = value->value; // Value in % + rawvalue = value->value; } else{ - volume = 85.8 + float(random(0, 50)) / 10.0; + rawvalue = 85.8 + float(random(0, 50)) / 10.0; + volume = rawvalue; } if(volume < 10){ snprintf(buffer,bsize,"%3.2f",volume); @@ -567,9 +606,11 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){ double volume = 0; if(usesimudata == false) { volume = value->value; // Value in l + rawvalue = value->value; } else{ - volume = 75.2 + float(random(0, 50)) / 10.0; + rawvalue = 75.2 + float(random(0, 50)) / 10.0; + volume = rawvalue; } if(volume < 10){ snprintf(buffer,bsize,"%3.2f",volume); @@ -587,9 +628,11 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){ double flow = 0; if(usesimudata == false) { flow = value->value; // Value in l/min + rawvalue = value->value; } else{ - flow = 7.5 + float(random(0, 20)) / 10.0; + rawvalue = 7.5 + float(random(0, 20)) / 10.0; + flow = rawvalue; } if(flow < 10){ snprintf(buffer,bsize,"%3.2f",flow); @@ -607,9 +650,11 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){ double generic = 0; if(usesimudata == false) { generic = value->value; // Value in l/min + rawvalue = value->value; } else{ - generic = 18.5 + float(random(0, 20)) / 10.0; + rawvalue = 18.5 + float(random(0, 20)) / 10.0; + generic = rawvalue; } if(generic < 10){ snprintf(buffer,bsize,"%3.2f",generic); @@ -627,9 +672,11 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){ double dplace = 0; if(usesimudata == false) { dplace = value->value; // Value in % + rawvalue = value->value; } else{ - dplace = 55.3 + float(random(0, 20)) / 10.0; + rawvalue = 55.3 + float(random(0, 20)) / 10.0; + dplace = rawvalue; } if(dplace < 10){ snprintf(buffer,bsize,"%3.2f",dplace); @@ -648,9 +695,11 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){ if(usesimudata == false) { angle = value->value; angle = angle * 57.2958; // Unit conversion form rad to deg + rawvalue = value->value; } else{ - angle = 20 + random(-5, 5); + rawvalue = PI / 100 + (random(-5, 5) / 360 * 2* PI); + angle = rawvalue * 57.2958; } if(angle > -10 && angle < 10){ snprintf(buffer,bsize,"%3.1f",angle); @@ -665,9 +714,11 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){ double rpm = 0; if(usesimudata == false) { rpm = value->value; // Value in rpm + rawvalue = value->value; } else{ - rpm = 2505 + random(0, 20); + rawvalue = 2505 + random(0, 20); + rpm = rawvalue; } if(rpm < 10){ snprintf(buffer,bsize,"%3.2f",rpm); @@ -696,6 +747,7 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){ result.unit = ""; } buffer[bsize]=0; + result.value = rawvalue; // Return value is only necessary in case of simulation of graphic pointer result.svalue = String(buffer); return result; } diff --git a/lib/obp60task/PageKeelPosition.cpp b/lib/obp60task/PageKeelPosition.cpp index d7eaaf2..ecdb11e 100644 --- a/lib/obp60task/PageKeelPosition.cpp +++ b/lib/obp60task/PageKeelPosition.cpp @@ -171,7 +171,7 @@ public: // Draw keel position pointer float startwidth = 8; // Start width of pointer - if(rotsensor == "AS5600" && rotfunction == "Keel" && (valid1 == true || holdvalues == true || simulation == true)){ + if((rotsensor == "AS5600" && rotfunction == "Keel" && (valid1 == true || holdvalues == true)) || simulation == true){ float sinx=sin(value1); float cosx=cos(value1); // Normal pointer @@ -210,7 +210,7 @@ public: getdisplay().setCursor(100, 70); getdisplay().print("Keel Position"); // Label - if(rotsensor == "AS5600" && rotfunction == "Keel" && (valid1 == true || holdvalues == true || simulation == true)){ + if((rotsensor == "AS5600" && rotfunction == "Keel" && (valid1 == true || holdvalues == true)) || simulation == true){ // Print Unit of keel position getdisplay().setFont(&Ubuntu_Bold12pt7b); getdisplay().setCursor(175, 110); diff --git a/lib/obp60task/PageRollPitch.cpp b/lib/obp60task/PageRollPitch.cpp index 2667e10..1119044 100644 --- a/lib/obp60task/PageRollPitch.cpp +++ b/lib/obp60task/PageRollPitch.cpp @@ -27,17 +27,13 @@ public: GwConfigHandler *config = commonData.config; GwLog *logger=commonData.logger; - static String svalue1old = ""; - static String unit1old = ""; - static String svalue2old = ""; - static String unit2old = ""; - double value1 = 0; double value2 = 0; String svalue1 = ""; - String unit1 = ""; + String svalue1old = ""; String svalue2 = ""; - String unit2 = ""; + String svalue2old = ""; + // Get config data String lengthformat = config->getString(config->lengthFormat); @@ -63,7 +59,6 @@ public: else{ if(simulation == true){ value1 = (20 + float(random(0, 50)) / 10.0)/360*2*PI; - unit1 = "Deg"; } else{ value1 = 0; @@ -75,11 +70,6 @@ public: else{ svalue1 = String(value1/(2*PI)*360,0); } - unit1 = formatValue(bvalue1, commonData).unit; // Unit of value - if(valid1 == true){ - svalue1old = svalue1; // Save old value - unit1old = unit1; // Save old unit - } // Get boat values for pitch GwApi::BoatValue *bvalue2 = pageData.values[1]; // Second element in list (xdrPitch) @@ -92,7 +82,6 @@ public: else{ if(simulation == true){ value2 = (float(random(-5, 5)))/360*2*PI; - unit2 = "Deg"; } else{ value2 = 0; @@ -104,16 +93,11 @@ public: else{ svalue2 = String(value2/(2*PI)*360,0); } - unit2 = formatValue(bvalue2, commonData).unit; // Unit of value - if(valid2 == true){ - svalue2old = svalue2; // Save old value - unit2old = unit2; // Save old unit - } // Optical warning by limit violation if(String(flashLED) == "Limit Violation"){ // Limits for roll - if(value1*360/(2*PI) > -1*rolllimit && value1*360/(2*PI) < rolllimit){ + if(value1*360/(2*PI) >= -1*rolllimit && value1*360/(2*PI) <= rolllimit){ setBlinkingLED(false); setFlashLED(false); } @@ -146,6 +130,18 @@ public: // Set display in partial refresh mode getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update + // Show roll limit + getdisplay().setTextColor(textcolor); + getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b); + getdisplay().setCursor(10, 65); + getdisplay().print(rolllimit); // Value + getdisplay().setFont(&Ubuntu_Bold12pt7b); + getdisplay().setCursor(10, 95); + getdisplay().print("Limit"); // Name + getdisplay().setFont(&Ubuntu_Bold8pt7b); + getdisplay().setCursor(10, 115); + getdisplay().print("DEG"); + // Horizintal separator left getdisplay().fillRect(0, 149, 60, 3, pixelcolor); @@ -160,9 +156,7 @@ public: getdisplay().print(name1); // Name getdisplay().setFont(&Ubuntu_Bold8pt7b); getdisplay().setCursor(10, 190); - getdisplay().print(" "); - if(holdvalues == false) getdisplay().print(unit1); // Unit - else getdisplay().print(unit1old); + getdisplay().print("Deg"); // Horizintal separator right getdisplay().fillRect(340, 149, 80, 3, pixelcolor); @@ -178,9 +172,7 @@ public: getdisplay().print(name2); // Name getdisplay().setFont(&Ubuntu_Bold8pt7b); getdisplay().setCursor(335, 190); - getdisplay().print(" "); - if(holdvalues == false) getdisplay().print(unit1); // Unit - else getdisplay().print(unit1old); + getdisplay().print("Deg"); //******************************************************************************************* diff --git a/lib/obp60task/PageRudderPosition.cpp b/lib/obp60task/PageRudderPosition.cpp index 675e301..5495a3b 100644 --- a/lib/obp60task/PageRudderPosition.cpp +++ b/lib/obp60task/PageRudderPosition.cpp @@ -52,6 +52,15 @@ public: unit1old = unit1; // Save old unit } + if(simulation == true){ + value1 = (3 + float(random(0, 50)) / 10.0)/360*2*PI; + unit1 = "Deg"; + } + else{ + value1 = 0; + } + + // Optical warning by limit violation (unused) if(String(flashLED) == "Limit Violation"){ setBlinkingLED(false); diff --git a/lib/obp60task/PageWindRose.cpp b/lib/obp60task/PageWindRose.cpp index e5fe969..df546f5 100644 --- a/lib/obp60task/PageWindRose.cpp +++ b/lib/obp60task/PageWindRose.cpp @@ -43,7 +43,7 @@ public: // Get config data String lengthformat = config->getString(config->lengthFormat); - // bool simulation = config->getBool(config->useSimuData); + bool simulation = config->getBool(config->useSimuData); String displaycolor = config->getString(config->displaycolor); bool holdvalues = config->getBool(config->holdvalues); String flashLED = config->getString(config->flashLED); @@ -54,7 +54,8 @@ public: String name1 = xdrDelete(bvalue1->getName()); // Value name name1 = name1.substring(0, 6); // String length limit for value name double value1 = bvalue1->value; // Value as double in SI unit - bool valid1 = bvalue1->valid; // Valid information + bool valid1 = bvalue1->valid; // Valid information + value1 = formatValue(bvalue1, commonData).value;// Format only nesaccery for simulation data for pointer String svalue1 = formatValue(bvalue1, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places String unit1 = formatValue(bvalue1, commonData).unit; // Unit of value if(valid1 == true){ @@ -309,7 +310,7 @@ public: // Draw wind pointer float startwidth = 8; // Start width of pointer - if(valid2 == true || holdvalues == true){ + if(valid2 == true || holdvalues == true || simulation == true){ float sinx=sin(value1); // Wind direction float cosx=cos(value1); // Normal pointer diff --git a/lib/obp60task/Pagedata.h b/lib/obp60task/Pagedata.h index a814172..54deb1f 100644 --- a/lib/obp60task/Pagedata.h +++ b/lib/obp60task/Pagedata.h @@ -11,19 +11,20 @@ typedef struct{ ValueList values; } PageData; +// Sensor data structure (only for extended sensors, not for NMEA bus sensors) typedef struct{ int actpage = 0; int maxpage = 0; double batteryVoltage = 0; double batteryCurrent = 0; double batteryPower = 0; - double batteryVoltage10 = 0; + double batteryVoltage10 = 0; // Sliding average over 10 values double batteryCurrent10 = 0; double batteryPower10 = 0; - double batteryVoltage60 = 0; + double batteryVoltage60 = 0; // Sliding average over 60 values double batteryCurrent60 = 0; double batteryPower60 = 0; - double batteryVoltage300 = 0; + double batteryVoltage300 = 0; // Sliding average over 300 values double batteryCurrent300 = 0; double batteryPower300 = 0; double solarVoltage = 0; @@ -42,7 +43,7 @@ typedef struct{ double onewireTemp5 = 0; double onewireTemp6 = 0; double rotationAngle = 0; // Rotation angle in radiant - bool validRotAngle = false; // Valid flag for magnet present + bool validRotAngle = false; // Valid flag magnet present for potation sensor int sunsetHour = 0; int sunsetMinute = 0; int sunriseHour = 0; @@ -112,6 +113,7 @@ class PageDescription{ // Structure for formated boat values typedef struct{ + double value; String svalue; String unit; } FormatedData; diff --git a/lib/obp60task/config.json b/lib/obp60task/config.json index 93452e9..dafb69c 100644 --- a/lib/obp60task/config.json +++ b/lib/obp60task/config.json @@ -460,7 +460,7 @@ "name": "rollLimit", "label": "Roll Limit", "type": "number", - "default": "40", + "default": "25", "check": "checkMinMax", "min": -90, "max": 90, @@ -622,7 +622,7 @@ "label": "Refresh", "type": "boolean", "default": "true", - "description": "Refresh E-Ink display after each new page request to reduce shadows [on|off]", + "description": "Refresh E-Ink display after each new page request to reduce ghost effects [on|off]", "category": "OBP60 Display", "capabilities": { "obp60":"true" diff --git a/lib/obp60task/platformio.ini b/lib/obp60task/platformio.ini index fcc6cbf..b903618 100644 --- a/lib/obp60task/platformio.ini +++ b/lib/obp60task/platformio.ini @@ -6,9 +6,9 @@ default_envs = obp60_s3 [env:obp60_s3] platform = espressif32@6.3.2 #board = obp60_s3_n8 #8MB flash, no PSRAM -board = obp60_s3_n16 #16MB flash, no PSRAM, zero series +#board = obp60_s3_n16 #16MB flash, no PSRAM, zero series #board = obp60_s3_n8r8 #8MB flash, 8MB PSRAM -#board = obp60_s3_n16r8 #16MB flash, 8MB PSRAM, production series +board = obp60_s3_n16r8 #16MB flash, 8MB PSRAM, production series board_build.variants_dir = variants framework = arduino lib_deps = @@ -22,7 +22,8 @@ lib_deps = blemasle/MCP23017@2.0.0 adafruit/Adafruit BusIO@1.5.0 adafruit/Adafruit GFX Library@1.11.9 - zinggjm/GxEPD2@1.5.6 + #zinggjm/GxEPD2@1.5.6 + https://github.com/ZinggJM/GxEPD2 sstaub/Ticker@4.4.0 adafruit/Adafruit BMP280 Library@2.6.2 adafruit/Adafruit BME280 Library@2.2.2