mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2026-03-28 09:56:37 +01:00
Some code cleanup
This commit is contained in:
@@ -1,6 +1,16 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
#if defined BOARD_OBP60S3 || defined BOARD_OBP40S3
|
||||
|
||||
/***************************************************************************
|
||||
* Page to display internal environment data
|
||||
* - Internal device temperature
|
||||
* - Athmospheric pressure
|
||||
* - Humidity
|
||||
*
|
||||
* Supportet Sensors: BME280, BMP280, BMP180
|
||||
*
|
||||
*/
|
||||
|
||||
#include "Pagedata.h"
|
||||
#include "OBP60Extensions.h"
|
||||
|
||||
@@ -29,6 +39,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;
|
||||
@@ -40,64 +60,53 @@ public:
|
||||
|
||||
// Get sensor values #1
|
||||
String name1 = "Temp"; // Value name
|
||||
name1 = name1.substring(0, 6); // String length limit for value name
|
||||
if (simulation == false) {
|
||||
value1 = commonData->data.airTemperature; // Value as double in SI unit
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
value1 = 23.0 + float(random(0, 10)) / 10.0;
|
||||
}
|
||||
// Display data when sensor activated
|
||||
if((useenvsensor == "BME280") or (useenvsensor == "BMP280") or (useenvsensor == "BMP180")){
|
||||
if ((useenvsensor == "BME280") or (useenvsensor == "BMP280")
|
||||
or (useenvsensor == "BMP180"))
|
||||
{
|
||||
svalue1 = String(value1, 1); // Formatted value as string including unit conversion and switching decimal places
|
||||
}
|
||||
else{
|
||||
svalue1 = "---";
|
||||
} else {
|
||||
svalue1 = commonData->fmt->placeholder;
|
||||
}
|
||||
String unit1 = "Deg C"; // Unit of value
|
||||
|
||||
// Get sensor values #2
|
||||
String name2 = "Humid"; // Value name
|
||||
name2 = name2.substring(0, 6); // String length limit for value name
|
||||
if (simulation == false) {
|
||||
value2 = commonData->data.airHumidity; // Value as double in SI unit
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
value2 = 43 + float(random(0, 4));
|
||||
}
|
||||
// Display data when sensor activated
|
||||
if (useenvsensor == "BME280") {
|
||||
svalue2 = String(value2, 0); // Formatted value as string including unit conversion and switching decimal places
|
||||
}
|
||||
else{
|
||||
svalue2 = "---";
|
||||
} else {
|
||||
svalue2 = commonData->fmt->placeholder;
|
||||
}
|
||||
String unit2 = "%"; // Unit of value
|
||||
|
||||
// Get sensor values #3
|
||||
String name3 = "Press"; // Value name
|
||||
name3 = name3.substring(0, 6); // String length limit for value name
|
||||
if (simulation == false) {
|
||||
value3 = commonData->data.airPressure; // Value as double in SI unit
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
value3 = 1006 + float(random(0, 5));
|
||||
}
|
||||
// Display data when sensor activated
|
||||
if((useenvsensor == "BME280") or (useenvsensor == "BMP280") or (useenvsensor == "BMP180")){
|
||||
if ((useenvsensor == "BME280") or (useenvsensor == "BMP280")
|
||||
or (useenvsensor == "BMP180"))
|
||||
{
|
||||
svalue3 = String(value3 / 100, 1); // Formatted value as string including unit conversion and switching decimal places
|
||||
}
|
||||
else{
|
||||
svalue3 = "---";
|
||||
} else {
|
||||
svalue3 = commonData->fmt->placeholder;
|
||||
}
|
||||
String unit3 = "hPa"; // 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 PageBME280, %s: %f, %s: %f, %s: %f", name1.c_str(), value1, name2.c_str(), value2, name3.c_str(), value3);
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
#if defined BOARD_OBP60S3 || defined BOARD_OBP40S3
|
||||
|
||||
/***************************************************************************
|
||||
* External battery sensors
|
||||
*/
|
||||
|
||||
#include "Pagedata.h"
|
||||
#include "OBP60Extensions.h"
|
||||
#include "movingAvg.h" // Lib for moving average building
|
||||
@@ -56,6 +60,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) {
|
||||
// Polynominal coefficients second order for battery energy level calculation
|
||||
// index 0 = Pb, 1 = Gel, 2 = AGM, 3 = LiFePo4
|
||||
@@ -118,26 +132,33 @@ public:
|
||||
// Battery energy level calculation
|
||||
if (String(batType) == "Pb") {
|
||||
batPercentage = (value1 * value1 * x2[0]) + (value1 * x1[0]) + x0[0];
|
||||
}
|
||||
if(String(batType) == "Gel"){
|
||||
} else if (String(batType) == "Gel") {
|
||||
batPercentage = (value1 * value1 * x2[1]) + (value1 * x1[1]) + x0[1];
|
||||
}
|
||||
if(String(batType) == "AGM"){
|
||||
} else if (String(batType) == "AGM") {
|
||||
batPercentage = (value1 * value1 * x2[2]) + (value1 * x1[2]) + x0[2];
|
||||
}
|
||||
if(String(batType) == "LiFePo4"){
|
||||
} else if (String(batType) == "LiFePo4") {
|
||||
batPercentage = (value1 * value1 * x2[3]) + (value1 * x1[3]) + x0[3];
|
||||
}
|
||||
|
||||
// Limits for battery level
|
||||
if(batPercentage < 0) batPercentage = 0;
|
||||
if(batPercentage > 99) batPercentage = 99;
|
||||
if (batPercentage < 0) {
|
||||
batPercentage = 0;
|
||||
} else if (batPercentage > 99) {
|
||||
batPercentage = 99;
|
||||
}
|
||||
|
||||
// Battery range calculation
|
||||
if(value2 <= 0) value2 = 0.0000001; // Limiting current
|
||||
if (value2 <= 0) {
|
||||
value2 = 0.0000001; // Limiting current
|
||||
}
|
||||
batRange = batCapacity * batPercentage / 100 / value2;
|
||||
|
||||
// Limits for battery range
|
||||
if(batRange < 0) batRange = 0;
|
||||
if(batRange > 99) batRange = 99;
|
||||
if (batRange < 0) {
|
||||
batRange = 0;
|
||||
} else if (batRange > 99) {
|
||||
batRange = 99;
|
||||
}
|
||||
|
||||
// Optical warning by limit violation
|
||||
if (flashLED == "Limit Violation") {
|
||||
@@ -183,21 +204,22 @@ public:
|
||||
// Show voltage type
|
||||
epd->setFont(&DSEG7Classic_BoldItalic20pt7b);
|
||||
epd->setCursor(10, 140);
|
||||
int bvoltage = 0;
|
||||
if(String(batVoltage) == "12V") bvoltage = 12;
|
||||
else bvoltage = 24;
|
||||
epd->print(bvoltage);
|
||||
epd->print(batVoltage == "12V" ? "12" : "24");
|
||||
epd->setFont(&Ubuntu_Bold16pt8b);
|
||||
epd->print("V");
|
||||
|
||||
// Show battery capacity
|
||||
epd->setFont(&DSEG7Classic_BoldItalic20pt7b);
|
||||
epd->setCursor(10, 200);
|
||||
if(batCapacity <= 999) epd->print(batCapacity, 0);
|
||||
if(batCapacity > 999) epd->print(float(batCapacity/1000.0), 1);
|
||||
String unit = "Ah";
|
||||
if (batCapacity <= 999) {
|
||||
epd->print(batCapacity, 0);
|
||||
} else if (batCapacity > 999) {
|
||||
epd->print(float(batCapacity/1000.0), 1);
|
||||
unit = "kAh";
|
||||
}
|
||||
epd->setFont(&Ubuntu_Bold16pt8b);
|
||||
if(batCapacity <= 999) epd->print("Ah");
|
||||
if(batCapacity > 999) epd->print("kAh");
|
||||
epd->print(unit);
|
||||
|
||||
// Show info
|
||||
epd->setFont(&Ubuntu_Bold8pt8b);
|
||||
@@ -241,10 +263,14 @@ public:
|
||||
epd->setFont(&DSEG7Classic_BoldItalic20pt7b);
|
||||
epd->setCursor(150, 260);
|
||||
if ((powerSensor == "INA219" || powerSensor == "INA226") && simulation == false) {
|
||||
if(batRange < 9.9) epd->print(batRange, 1);
|
||||
else epd->print(batRange, 0);
|
||||
if (batRange < 9.9) {
|
||||
epd->print(batRange, 1);
|
||||
} else {
|
||||
epd->print(batRange, 0);
|
||||
}
|
||||
} else {
|
||||
epd->print("--");
|
||||
}
|
||||
else epd->print("--");
|
||||
epd->setFont(&Ubuntu_Bold16pt8b);
|
||||
epd->print("h");
|
||||
|
||||
@@ -252,11 +278,11 @@ public:
|
||||
String i2cAddr = "";
|
||||
epd->setFont(&Ubuntu_Bold8pt8b);
|
||||
epd->setCursor(270, 60);
|
||||
if(powerSensor == "off") epd->print("Internal");
|
||||
if(powerSensor == "INA219"){
|
||||
if (powerSensor == "off") {
|
||||
epd->print("Internal");
|
||||
} else if (powerSensor == "INA219") {
|
||||
epd->print("INA219");
|
||||
}
|
||||
if(powerSensor == "INA226"){
|
||||
} else if(powerSensor == "INA226") {
|
||||
epd->print("INA226");
|
||||
i2cAddr = " (0x" + String(INA226_I2C_ADDR1, HEX) + ")";
|
||||
}
|
||||
@@ -268,24 +294,21 @@ public:
|
||||
epd->setFont(&DSEG7Classic_BoldItalic20pt7b);
|
||||
epd->setCursor(260, 140);
|
||||
if (simulation == true) {
|
||||
if(batVoltage == "12V"){
|
||||
value1 = 12.0;
|
||||
}
|
||||
if(batVoltage == "24V"){
|
||||
value1 = 24.0;
|
||||
}
|
||||
value1 = batVoltage == "12V" ? 12.0 : 24.0;
|
||||
value1 += float(random(0, 5)) / 10; // Simulation data
|
||||
epd->print(value1,1);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
// Check for valid real data, display also if hold values activated
|
||||
if (valid1 == true || holdvalues == true) {
|
||||
// Resolution switching
|
||||
if(value1 <= 9.9) epd->print(value1, 2);
|
||||
if(value1 > 9.9 && value1 <= 99.9)epd->print(value1, 1);
|
||||
if(value1 > 99.9) epd->print(value1, 0);
|
||||
if (value1 <= 9.9) {
|
||||
epd->print(value1, 2);
|
||||
} else if (value1 > 9.9 && value1 <= 99.9) {
|
||||
epd->print(value1, 1);
|
||||
} else if (value1 > 99.9) {
|
||||
epd->print(value1, 0);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
epd->print(commonData->fmt->placeholder); // Missing bus data
|
||||
}
|
||||
}
|
||||
@@ -296,11 +319,14 @@ public:
|
||||
epd->setFont(&DSEG7Classic_BoldItalic20pt7b);
|
||||
epd->setCursor(260, 200);
|
||||
if ((powerSensor == "INA219" || powerSensor == "INA226") && simulation == false) {
|
||||
if(value2 <= 9.9) epd->print(value2, 2);
|
||||
if(value2 > 9.9 && value2 <= 99.9)epd->print(value2, 1);
|
||||
if(value2 > 99.9) epd->print(value2, 0);
|
||||
if (value2 <= 9.9) {
|
||||
epd->print(value2, 2);
|
||||
} else if (value2 > 9.9 && value2 <= 99.9) {
|
||||
epd->print(value2, 1);
|
||||
} else if (value2 > 99.9) {
|
||||
epd->print(value2, 0);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
epd->print(commonData->fmt->placeholder);
|
||||
}
|
||||
epd->setFont(&Ubuntu_Bold16pt8b);
|
||||
@@ -310,11 +336,14 @@ public:
|
||||
epd->setFont(&DSEG7Classic_BoldItalic20pt7b);
|
||||
epd->setCursor(260, 260);
|
||||
if ((powerSensor == "INA219" || powerSensor == "INA226") && simulation == false) {
|
||||
if(value3 <= 9.9) epd->print(value3, 2);
|
||||
if(value3 > 9.9 && value3 <= 99.9)epd->print(value3, 1);
|
||||
if(value3 > 99.9) epd->print(value3, 0);
|
||||
if(value3 <= 9.9) {
|
||||
epd->print(value3, 2);
|
||||
} else if (value3 > 9.9 && value3 <= 99.9) {
|
||||
epd->print(value3, 1);
|
||||
} else if (value3 > 99.9) {
|
||||
epd->print(value3, 0);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
epd->print(commonData->fmt->placeholder);
|
||||
}
|
||||
epd->setFont(&Ubuntu_Bold16pt8b);
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
#if defined BOARD_OBP60S3 || defined BOARD_OBP40S3
|
||||
|
||||
/***************************************************************************
|
||||
* Page similar to Raymarine DST810 smart transducer
|
||||
* - Depth
|
||||
* - Speed
|
||||
* - Temperature
|
||||
*/
|
||||
|
||||
#include "Pagedata.h"
|
||||
#include "OBP60Extensions.h"
|
||||
|
||||
@@ -27,6 +34,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
|
||||
@@ -39,8 +56,8 @@ public:
|
||||
static String svalue4old = "";
|
||||
static String unit4old = "";
|
||||
|
||||
// Get boat values #1
|
||||
GwApi::BoatValue *bvalue1 = pageData.values[0]; // First element in list (only one value by PageOneValue)
|
||||
// Get boat values #1 DBT
|
||||
GwApi::BoatValue *bvalue1 = pageData.values[0];
|
||||
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
|
||||
@@ -48,8 +65,8 @@ public:
|
||||
String svalue1 = commonData->fmt->formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
||||
String unit1 = commonData->fmt->formatValue(bvalue1, *commonData).unit; // Unit of value
|
||||
|
||||
// Get boat values #2
|
||||
GwApi::BoatValue *bvalue2 = pageData.values[1]; // Second element in list (only one value by PageOneValue)
|
||||
// Get boat values #2 STW
|
||||
GwApi::BoatValue *bvalue2 = pageData.values[1];
|
||||
String name2 = xdrDelete(bvalue2->getName()); // Value name
|
||||
name2 = name2.substring(0, 6); // String length limit for value name
|
||||
double value2 = bvalue2->value; // Value as double in SI unit
|
||||
@@ -57,8 +74,8 @@ public:
|
||||
String svalue2 = commonData->fmt->formatValue(bvalue2, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
||||
String unit2 = commonData->fmt->formatValue(bvalue2, *commonData).unit; // Unit of value
|
||||
|
||||
// Get boat values #3
|
||||
GwApi::BoatValue *bvalue3 = pageData.values[2]; // Second element in list (only one value by PageOneValue)
|
||||
// Get boat values #3 Log
|
||||
GwApi::BoatValue *bvalue3 = pageData.values[2];
|
||||
String name3 = xdrDelete(bvalue3->getName()); // Value name
|
||||
name3 = name3.substring(0, 6); // String length limit for value name
|
||||
double value3 = bvalue3->value; // Value as double in SI unit
|
||||
@@ -66,8 +83,8 @@ public:
|
||||
String svalue3 = commonData->fmt->formatValue(bvalue3, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
||||
String unit3 = commonData->fmt->formatValue(bvalue3, *commonData).unit; // Unit of value
|
||||
|
||||
// Get boat values #4
|
||||
GwApi::BoatValue *bvalue4 = pageData.values[3]; // Second element in list (only one value by PageOneValue)
|
||||
// Get boat values #4 WTemp
|
||||
GwApi::BoatValue *bvalue4 = pageData.values[3];
|
||||
String name4 = xdrDelete(bvalue4->getName()); // Value name
|
||||
name4 = name4.substring(0, 6); // String length limit for value name
|
||||
double value4 = bvalue4->value; // Value as double in SI unit
|
||||
@@ -75,12 +92,6 @@ public:
|
||||
String svalue4 = commonData->fmt->formatValue(bvalue4, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
||||
String unit4 = commonData->fmt->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 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);
|
||||
@@ -98,15 +109,14 @@ public:
|
||||
// Show name
|
||||
epd->setFont(&Ubuntu_Bold20pt8b);
|
||||
epd->setCursor(20, 55);
|
||||
epd->print("Depth"); // Page name
|
||||
epd->print("Depth");
|
||||
|
||||
// Show unit
|
||||
epd->setFont(&Ubuntu_Bold12pt8b);
|
||||
epd->setCursor(20, 90);
|
||||
if (holdvalues == false){
|
||||
epd->print(unit1); // Unit
|
||||
}
|
||||
else{
|
||||
epd->print(unit1);
|
||||
} else {
|
||||
epd->print(unit1old);
|
||||
}
|
||||
|
||||
@@ -117,8 +127,7 @@ public:
|
||||
// Show bus data
|
||||
if (holdvalues == false) {
|
||||
epd->print(svalue1); // Real value as formated string
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
epd->print(svalue1old); // Old value as formated string
|
||||
}
|
||||
if (valid1 == true) {
|
||||
@@ -136,15 +145,14 @@ public:
|
||||
// Show name
|
||||
epd->setFont(&Ubuntu_Bold20pt8b);
|
||||
epd->setCursor(20, 145);
|
||||
epd->print("Speed"); // Page name
|
||||
epd->print("Speed");
|
||||
|
||||
// Show unit
|
||||
epd->setFont(&Ubuntu_Bold12pt8b);
|
||||
epd->setCursor(20, 180);
|
||||
if (holdvalues == false) {
|
||||
epd->print(unit2); // Unit
|
||||
}
|
||||
else{
|
||||
epd->print(unit2);
|
||||
} else {
|
||||
epd->print(unit2old);
|
||||
}
|
||||
|
||||
@@ -155,8 +163,7 @@ public:
|
||||
// Show bus data
|
||||
if (holdvalues == false) {
|
||||
epd->print(svalue2); // Real value as formated string
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
epd->print(svalue2old); // Old value as formated string
|
||||
}
|
||||
if (valid2 == true) {
|
||||
@@ -174,15 +181,14 @@ public:
|
||||
// Show name
|
||||
epd->setFont(&Ubuntu_Bold12pt8b);
|
||||
epd->setCursor(20, 220);
|
||||
epd->print("Log"); // Page name
|
||||
epd->print("Log");
|
||||
|
||||
// Show unit
|
||||
epd->setFont(&Ubuntu_Bold8pt8b);
|
||||
epd->setCursor(20, 240);
|
||||
if (holdvalues == false) {
|
||||
epd->print(unit3); // Unit
|
||||
}
|
||||
else{
|
||||
epd->print(unit3);
|
||||
} else {
|
||||
epd->print(unit3old);
|
||||
}
|
||||
|
||||
@@ -193,8 +199,7 @@ public:
|
||||
// Show bus data
|
||||
if (holdvalues == false) {
|
||||
epd->print(svalue3); // Real value as formated string
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
epd->print(svalue3old); // Old value as formated string
|
||||
}
|
||||
if (valid3 == true) {
|
||||
@@ -212,15 +217,14 @@ public:
|
||||
// Show name
|
||||
epd->setFont(&Ubuntu_Bold12pt8b);
|
||||
epd->setCursor(220, 220);
|
||||
epd->print("Temp"); // Page name
|
||||
epd->print("Temp");
|
||||
|
||||
// Show unit
|
||||
epd->setFont(&Ubuntu_Bold8pt8b);
|
||||
epd->setCursor(220, 240);
|
||||
if (holdvalues == false) {
|
||||
epd->print(unit4); // Unit
|
||||
}
|
||||
else{
|
||||
epd->print(unit4);
|
||||
} else {
|
||||
epd->print(unit4old);
|
||||
}
|
||||
|
||||
@@ -231,8 +235,7 @@ public:
|
||||
// Show bus data
|
||||
if (holdvalues == false) {
|
||||
epd->print(svalue4); // Real value as formated string
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
epd->print(svalue4old); // Old value as formated string
|
||||
}
|
||||
if (valid4 == true) {
|
||||
|
||||
@@ -1,22 +1,21 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
#if defined BOARD_OBP60S3 || defined BOARD_OBP40S3
|
||||
|
||||
/***************************************************************************
|
||||
* Electric propulsion (WIP)
|
||||
*
|
||||
* - Current, voltage, power
|
||||
* - 12, 24, 48 etc. Voltage
|
||||
* - rpm
|
||||
* - throttle position
|
||||
* - controller state
|
||||
* - error codes
|
||||
* - temperature engine, controller, batteries
|
||||
*/
|
||||
|
||||
#include "Pagedata.h"
|
||||
#include "OBP60Extensions.h"
|
||||
|
||||
/*
|
||||
Electric propulsion
|
||||
|
||||
- Current, voltage, power
|
||||
- 12, 24, 48 etc. Voltage
|
||||
- rpm
|
||||
- throttle position
|
||||
- controller state
|
||||
- error codes
|
||||
- temperature engine, controller, batteries
|
||||
|
||||
*/
|
||||
|
||||
class PageEPropulsion : public Page
|
||||
{
|
||||
private:
|
||||
|
||||
@@ -1,28 +1,26 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
#if defined BOARD_OBP60S3 || defined BOARD_OBP40S3
|
||||
|
||||
/***************************************************************************
|
||||
* Analog fluid display for different types
|
||||
* 0: Fuel
|
||||
* 1: Water
|
||||
* 2: Gray Water
|
||||
* 3: Live Well
|
||||
* 4: Oil
|
||||
* 5: Black Water
|
||||
* 6: Fuel Gasoline
|
||||
* 14: Error
|
||||
* 15: Unavailable
|
||||
*
|
||||
* TODO
|
||||
* - Check fluid type against connected XDR-value
|
||||
*/
|
||||
|
||||
#include "Pagedata.h"
|
||||
#include "OBP60Extensions.h"
|
||||
#include "GwXDRMappings.h"
|
||||
|
||||
/*
|
||||
Fluid level view
|
||||
|
||||
0: "Fuel",
|
||||
1: "Water",
|
||||
2: "Gray Water",
|
||||
3: "Live Well",
|
||||
4: "Oil",
|
||||
5: "Black Water",
|
||||
6: "Fuel Gasoline",
|
||||
14: "Error",
|
||||
15: "Unavailable"
|
||||
|
||||
TODO
|
||||
- Check fluid type against connected XDR-value
|
||||
|
||||
*/
|
||||
|
||||
#define fuel_width 16
|
||||
#define fuel_height 16
|
||||
static unsigned char fuel_bits[] = {
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
#if defined BOARD_OBP60S3 || defined BOARD_OBP40S3
|
||||
|
||||
/***************************************************************************
|
||||
* Display four values vertical stacked
|
||||
*/
|
||||
|
||||
#include "Pagedata.h"
|
||||
#include "OBP60Extensions.h"
|
||||
|
||||
@@ -26,7 +30,7 @@ public:
|
||||
// Code for keylock
|
||||
if(key == 11) {
|
||||
commonData->keylock = !commonData->keylock;
|
||||
return 0; // Commit the key
|
||||
return 0;
|
||||
}
|
||||
return key;
|
||||
}
|
||||
@@ -57,9 +61,6 @@ public:
|
||||
GwApi::BoatValue *bvalue1 = pageData.values[0]; // First element in list (only one value by PageOneValue)
|
||||
String name1 = xdrDelete(bvalue1->getName()); // Value name
|
||||
name1 = name1.substring(0, 6); // String length limit for value name
|
||||
#ifdef ENABLE_CALIBRATION
|
||||
calibrationData.calibrateInstance(bvalue1, logger); // Check if boat data value is to be calibrated
|
||||
#endif
|
||||
double value1 = bvalue1->value; // Value as double in SI unit
|
||||
bool valid1 = bvalue1->valid; // Valid information
|
||||
String svalue1 = commonData->fmt->formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
||||
@@ -69,9 +70,6 @@ public:
|
||||
GwApi::BoatValue *bvalue2 = pageData.values[1]; // Second element in list
|
||||
String name2 = xdrDelete(bvalue2->getName()); // Value name
|
||||
name2 = name2.substring(0, 6); // String length limit for value name
|
||||
#ifdef ENABLE_CALIBRATION
|
||||
calibrationData.calibrateInstance(bvalue2, logger); // Check if boat data value is to be calibrated
|
||||
#endif
|
||||
double value2 = bvalue2->value; // Value as double in SI unit
|
||||
bool valid2 = bvalue2->valid; // Valid information
|
||||
String svalue2 = commonData->fmt->formatValue(bvalue2, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
||||
@@ -81,9 +79,6 @@ public:
|
||||
GwApi::BoatValue *bvalue3 = pageData.values[2]; // Third element in list
|
||||
String name3 = xdrDelete(bvalue3->getName()); // Value name
|
||||
name3 = name3.substring(0, 6); // String length limit for value name
|
||||
#ifdef ENABLE_CALIBRATION
|
||||
calibrationData.calibrateInstance(bvalue3, logger); // Check if boat data value is to be calibrated
|
||||
#endif
|
||||
double value3 = bvalue3->value; // Value as double in SI unit
|
||||
bool valid3 = bvalue3->valid; // Valid information
|
||||
String svalue3 = commonData->fmt->formatValue(bvalue3, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
||||
@@ -93,9 +88,6 @@ public:
|
||||
GwApi::BoatValue *bvalue4 = pageData.values[3]; // Fourth element in list
|
||||
String name4 = xdrDelete(bvalue4->getName()); // Value name
|
||||
name4 = name4.substring(0, 6); // String length limit for value name
|
||||
#ifdef ENABLE_CALIBRATION
|
||||
calibrationData.calibrateInstance(bvalue4, logger); // Check if boat data value is to be calibrated
|
||||
#endif
|
||||
double value4 = bvalue4->value; // Value as double in SI unit
|
||||
bool valid4 = bvalue4->valid; // Valid information
|
||||
String svalue4 = commonData->fmt->formatValue(bvalue4, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
||||
@@ -118,15 +110,14 @@ public:
|
||||
// Show name
|
||||
epd->setFont(&Ubuntu_Bold16pt8b);
|
||||
epd->setCursor(20, 45);
|
||||
epd->print(name1); // Page name
|
||||
epd->print(name1);
|
||||
|
||||
// Show unit
|
||||
epd->setFont(&Ubuntu_Bold8pt8b);
|
||||
epd->setCursor(20, 65);
|
||||
if (holdvalues == false) {
|
||||
epd->print(unit1); // Unit
|
||||
}
|
||||
else{
|
||||
epd->print(unit1);
|
||||
} else {
|
||||
epd->print(unit1old);
|
||||
}
|
||||
|
||||
@@ -147,8 +138,7 @@ public:
|
||||
// Show bus data
|
||||
if (holdvalues == false) {
|
||||
epd->print(svalue1); // Real value as formated string
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
epd->print(svalue1old); // Old value as formated string
|
||||
}
|
||||
if (valid1 == true) {
|
||||
@@ -166,15 +156,14 @@ public:
|
||||
// Show name
|
||||
epd->setFont(&Ubuntu_Bold16pt8b);
|
||||
epd->setCursor(20, 113);
|
||||
epd->print(name2); // Page name
|
||||
epd->print(name2);
|
||||
|
||||
// Show unit
|
||||
epd->setFont(&Ubuntu_Bold8pt8b);
|
||||
epd->setCursor(20, 133);
|
||||
if (holdvalues == false){
|
||||
epd->print(unit2); // Unit
|
||||
}
|
||||
else{
|
||||
epd->print(unit2);
|
||||
} else {
|
||||
epd->print(unit2old);
|
||||
}
|
||||
|
||||
@@ -195,8 +184,7 @@ public:
|
||||
// Show bus data
|
||||
if (holdvalues == false) {
|
||||
epd->print(svalue2); // Real value as formated string
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
epd->print(svalue2old); // Old value as formated string
|
||||
}
|
||||
if (valid2 == true) {
|
||||
@@ -214,13 +202,13 @@ public:
|
||||
// Show name
|
||||
epd->setFont(&Ubuntu_Bold16pt8b);
|
||||
epd->setCursor(20, 181);
|
||||
epd->print(name3); // Page name
|
||||
epd->print(name3);
|
||||
|
||||
// Show unit
|
||||
epd->setFont(&Ubuntu_Bold8pt8b);
|
||||
epd->setCursor(20, 201);
|
||||
if(holdvalues == false){
|
||||
epd->print(unit3); // Unit
|
||||
epd->print(unit3);
|
||||
}
|
||||
else{
|
||||
epd->print(unit3old);
|
||||
@@ -243,8 +231,7 @@ public:
|
||||
// Show bus data
|
||||
if (holdvalues == false) {
|
||||
epd->print(svalue3); // Real value as formated string
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
epd->print(svalue3old); // Old value as formated string
|
||||
}
|
||||
if (valid3 == true) {
|
||||
@@ -291,8 +278,7 @@ public:
|
||||
// Show bus data
|
||||
if (holdvalues == false) {
|
||||
epd->print(svalue4); // Real value as formated string
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
epd->print(svalue4old); // Old value as formated string
|
||||
}
|
||||
if (valid4 == true) {
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
#if defined BOARD_OBP60S3 || defined BOARD_OBP40S3
|
||||
|
||||
/***************************************************************************
|
||||
* Display four values in alternative format
|
||||
*/
|
||||
|
||||
#include "Pagedata.h"
|
||||
#include "OBP60Extensions.h"
|
||||
|
||||
@@ -22,7 +26,7 @@ public:
|
||||
// Code for keylock
|
||||
if (key == 11) {
|
||||
commonData->keylock = !commonData->keylock; // Toggle keylock
|
||||
return 0; // Commit the key
|
||||
return 0;
|
||||
}
|
||||
return key;
|
||||
}
|
||||
@@ -102,15 +106,14 @@ public:
|
||||
// Show name
|
||||
epd->setFont(&Ubuntu_Bold20pt8b);
|
||||
epd->setCursor(20, 55);
|
||||
epd->print(name1); // Page name
|
||||
epd->print(name1);
|
||||
|
||||
// Show unit
|
||||
epd->setFont(&Ubuntu_Bold12pt8b);
|
||||
epd->setCursor(20, 90);
|
||||
if (holdvalues == false) {
|
||||
epd->print(unit1); // Unit
|
||||
}
|
||||
else{
|
||||
epd->print(unit1);
|
||||
} else {
|
||||
epd->print(unit1old);
|
||||
}
|
||||
|
||||
@@ -131,8 +134,7 @@ public:
|
||||
// Show bus data
|
||||
if (holdvalues == false) {
|
||||
epd->print(svalue1); // Real value as formated string
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
epd->print(svalue1old); // Old value as formated string
|
||||
}
|
||||
if (valid1 == true) {
|
||||
@@ -150,15 +152,14 @@ public:
|
||||
// Show name
|
||||
epd->setFont(&Ubuntu_Bold20pt8b);
|
||||
epd->setCursor(20, 145);
|
||||
epd->print(name2); // Page name
|
||||
epd->print(name2);
|
||||
|
||||
// Show unit
|
||||
epd->setFont(&Ubuntu_Bold12pt8b);
|
||||
epd->setCursor(20, 180);
|
||||
if (holdvalues == false) {
|
||||
epd->print(unit2); // Unit
|
||||
}
|
||||
else{
|
||||
epd->print(unit2);
|
||||
} else{
|
||||
epd->print(unit2old);
|
||||
}
|
||||
|
||||
@@ -179,8 +180,7 @@ public:
|
||||
// Show bus data
|
||||
if (holdvalues == false) {
|
||||
epd->print(svalue2); // Real value as formated string
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
epd->print(svalue2old); // Old value as formated string
|
||||
}
|
||||
if (valid2 == true) {
|
||||
@@ -198,13 +198,13 @@ public:
|
||||
// Show name
|
||||
epd->setFont(&Ubuntu_Bold12pt8b);
|
||||
epd->setCursor(20, 220);
|
||||
epd->print(name3); // Page name
|
||||
epd->print(name3);
|
||||
|
||||
// Show unit
|
||||
epd->setFont(&Ubuntu_Bold8pt8b);
|
||||
epd->setCursor(20, 240);
|
||||
if (holdvalues == false) {
|
||||
epd->print(unit3); // Unit
|
||||
epd->print(unit3);
|
||||
}
|
||||
else{
|
||||
epd->print(unit3old);
|
||||
@@ -246,15 +246,14 @@ public:
|
||||
// Show name
|
||||
epd->setFont(&Ubuntu_Bold12pt8b);
|
||||
epd->setCursor(220, 220);
|
||||
epd->print(name4); // Page name
|
||||
epd->print(name4);
|
||||
|
||||
// Show unit
|
||||
epd->setFont(&Ubuntu_Bold8pt8b);
|
||||
epd->setCursor(220, 240);
|
||||
if (holdvalues == false) {
|
||||
epd->print(unit4); // Unit
|
||||
}
|
||||
else{
|
||||
epd->print(unit4);
|
||||
} else {
|
||||
epd->print(unit4old);
|
||||
}
|
||||
|
||||
@@ -275,8 +274,7 @@ public:
|
||||
// Show bus data
|
||||
if (holdvalues == false) {
|
||||
epd->print(svalue4); // Real value as formated string
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
epd->print(svalue4old); // Old value as formated string
|
||||
}
|
||||
if (valid4 == true) {
|
||||
|
||||
Reference in New Issue
Block a user