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,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"
|
||||
|
||||
@@ -24,9 +28,9 @@ public:
|
||||
|
||||
int handleKey(int key){
|
||||
// Code for keylock
|
||||
if(key == 11){
|
||||
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,24 +110,23 @@ 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{
|
||||
if (holdvalues == false) {
|
||||
epd->print(unit1);
|
||||
} else {
|
||||
epd->print(unit1old);
|
||||
}
|
||||
|
||||
// Switch font if format for any values
|
||||
if(bvalue1->getFormat() == "formatLatitude" || bvalue1->getFormat() == "formatLongitude"){
|
||||
if (bvalue1->getFormat() == "formatLatitude" || bvalue1->getFormat() == "formatLongitude") {
|
||||
epd->setFont(&Ubuntu_Bold12pt8b);
|
||||
epd->setCursor(120, 55);
|
||||
}
|
||||
else if(bvalue1->getFormat() == "formatTime" || bvalue1->getFormat() == "formatDate"){
|
||||
else if (bvalue1->getFormat() == "formatTime" || bvalue1->getFormat() == "formatDate") {
|
||||
epd->setFont(&Ubuntu_Bold12pt8b);
|
||||
epd->setCursor(150, 58);
|
||||
}
|
||||
@@ -145,13 +136,12 @@ public:
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
@@ -166,24 +156,23 @@ 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{
|
||||
if (holdvalues == false){
|
||||
epd->print(unit2);
|
||||
} else {
|
||||
epd->print(unit2old);
|
||||
}
|
||||
|
||||
// Switch font if format for any values
|
||||
if(bvalue2->getFormat() == "formatLatitude" || bvalue2->getFormat() == "formatLongitude"){
|
||||
if (bvalue2->getFormat() == "formatLatitude" || bvalue2->getFormat() == "formatLongitude") {
|
||||
epd->setFont(&Ubuntu_Bold12pt8b);
|
||||
epd->setCursor(120, 123);
|
||||
}
|
||||
else if(bvalue2->getFormat() == "formatTime" || bvalue2->getFormat() == "formatDate"){
|
||||
else if (bvalue2->getFormat() == "formatTime" || bvalue2->getFormat() == "formatDate") {
|
||||
epd->setFont(&Ubuntu_Bold12pt8b);
|
||||
epd->setCursor(150, 123);
|
||||
}
|
||||
@@ -193,13 +182,12 @@ public:
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
@@ -214,40 +202,39 @@ 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);
|
||||
}
|
||||
|
||||
// Switch font if format for any values
|
||||
if(bvalue3->getFormat() == "formatLatitude" || bvalue3->getFormat() == "formatLongitude"){
|
||||
if (bvalue3->getFormat() == "formatLatitude" || bvalue3->getFormat() == "formatLongitude") {
|
||||
epd->setFont(&Ubuntu_Bold12pt8b);
|
||||
epd->setCursor(120, 191);
|
||||
}
|
||||
else if(bvalue3->getFormat() == "formatTime" || bvalue3->getFormat() == "formatDate"){
|
||||
else if (bvalue3->getFormat() == "formatTime" || bvalue3->getFormat() == "formatDate") {
|
||||
epd->setFont(&Ubuntu_Bold12pt8b);
|
||||
epd->setCursor(150, 191);
|
||||
}
|
||||
else{
|
||||
else {
|
||||
epd->setFont(&DSEG7Classic_BoldItalic20pt7b);
|
||||
epd->setCursor(180, 201);
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
@@ -275,11 +262,11 @@ public:
|
||||
}
|
||||
|
||||
// Switch font if format for any values
|
||||
if(bvalue4->getFormat() == "formatLatitude" || bvalue4->getFormat() == "formatLongitude"){
|
||||
if (bvalue4->getFormat() == "formatLatitude" || bvalue4->getFormat() == "formatLongitude") {
|
||||
epd->setFont(&Ubuntu_Bold12pt8b);
|
||||
epd->setCursor(120, 259);
|
||||
}
|
||||
else if(bvalue4->getFormat() == "formatTime" || bvalue4->getFormat() == "formatDate"){
|
||||
else if (bvalue4->getFormat() == "formatTime" || bvalue4->getFormat() == "formatDate") {
|
||||
epd->setFont(&Ubuntu_Bold12pt8b);
|
||||
epd->setCursor(150, 259);
|
||||
}
|
||||
@@ -289,13 +276,12 @@ public:
|
||||
}
|
||||
|
||||
// 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