mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2026-03-28 18:06:37 +01:00
Some code cleanup
This commit is contained in:
@@ -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{
|
||||
if (holdvalues == false){
|
||||
epd->print(unit1);
|
||||
} else {
|
||||
epd->print(unit1old);
|
||||
}
|
||||
|
||||
@@ -115,13 +125,12 @@ public:
|
||||
epd->setCursor(180, 90);
|
||||
|
||||
// Show bus data
|
||||
if(holdvalues == false){
|
||||
if (holdvalues == false) {
|
||||
epd->print(svalue1); // Real value as formated string
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
epd->print(svalue1old); // Old value as formated string
|
||||
}
|
||||
if(valid1 == true){
|
||||
if (valid1 == true) {
|
||||
svalue1old = svalue1; // Save the old value
|
||||
unit1old = unit1; // Save the old unit
|
||||
}
|
||||
@@ -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{
|
||||
if (holdvalues == false) {
|
||||
epd->print(unit2);
|
||||
} else {
|
||||
epd->print(unit2old);
|
||||
}
|
||||
|
||||
@@ -153,13 +161,12 @@ public:
|
||||
epd->setCursor(180, 180);
|
||||
|
||||
// Show bus data
|
||||
if(holdvalues == false){
|
||||
if (holdvalues == false) {
|
||||
epd->print(svalue2); // Real value as formated string
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
epd->print(svalue2old); // Old value as formated string
|
||||
}
|
||||
if(valid2 == true){
|
||||
if (valid2 == true) {
|
||||
svalue2old = svalue2; // Save the old value
|
||||
unit2old = unit2; // Save the old unit
|
||||
}
|
||||
@@ -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{
|
||||
if (holdvalues == false) {
|
||||
epd->print(unit3);
|
||||
} else {
|
||||
epd->print(unit3old);
|
||||
}
|
||||
|
||||
@@ -191,13 +197,12 @@ public:
|
||||
epd->setCursor(80, 270);
|
||||
|
||||
// Show bus data
|
||||
if(holdvalues == false){
|
||||
if (holdvalues == false) {
|
||||
epd->print(svalue3); // Real value as formated string
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
epd->print(svalue3old); // Old value as formated string
|
||||
}
|
||||
if(valid3 == true){
|
||||
if (valid3 == true) {
|
||||
svalue3old = svalue3; // Save the old value
|
||||
unit3old = unit3; // Save the old unit
|
||||
}
|
||||
@@ -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{
|
||||
if (holdvalues == false) {
|
||||
epd->print(unit4);
|
||||
} else {
|
||||
epd->print(unit4old);
|
||||
}
|
||||
|
||||
@@ -229,13 +233,12 @@ public:
|
||||
epd->setCursor(280, 270);
|
||||
|
||||
// Show bus data
|
||||
if(holdvalues == false){
|
||||
if (holdvalues == false) {
|
||||
epd->print(svalue4); // Real value as formated string
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
epd->print(svalue4old); // Old value as formated string
|
||||
}
|
||||
if(valid4 == true){
|
||||
if (valid4 == true) {
|
||||
svalue4old = svalue4; // Save the old value
|
||||
unit4old = unit4; // Save the old unit
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user