1
0
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:
2026-03-19 15:34:51 +01:00
parent caf833e6ac
commit ce5d4e231f
7 changed files with 286 additions and 264 deletions

View File

@@ -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){
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){
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"){
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){
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);

View File

@@ -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
@@ -74,11 +88,11 @@ public:
String name1 = "VBat";
// Create trend value
if(init == false){ // Load start values for first page run
if (init == false) { // Load start values for first page run
valueTrend = commonData->data.batteryVoltage10;
init = true;
}
else{ // Reading trend value
else { // Reading trend value
valueTrend = commonData->data.batteryVoltage10;
}
@@ -116,28 +130,35 @@ public:
bool valid1 = true;
// Battery energy level calculation
if(String(batType) == "Pb"){
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);
@@ -240,11 +262,15 @@ public:
// Show time to full discharge
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 ((powerSensor == "INA219" || powerSensor == "INA226") && simulation == false) {
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) + ")";
}
@@ -267,25 +293,22 @@ public:
// Reading bus data or using simulation data
epd->setFont(&DSEG7Classic_BoldItalic20pt7b);
epd->setCursor(260, 140);
if(simulation == true){
if(batVoltage == "12V"){
value1 = 12.0;
}
if(batVoltage == "24V"){
value1 = 24.0;
}
if (simulation == true) {
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){
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);
}
else{
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 {
epd->print(commonData->fmt->placeholder); // Missing bus data
}
}
@@ -295,12 +318,15 @@ public:
// Show actual current in A
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);
}
else {
if ((powerSensor == "INA219" || powerSensor == "INA226") && simulation == false) {
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 {
epd->print(commonData->fmt->placeholder);
}
epd->setFont(&Ubuntu_Bold16pt8b);
@@ -309,12 +335,15 @@ public:
// Show actual consumption in W
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);
}
else {
if ((powerSensor == "INA219" || powerSensor == "INA226") && simulation == false) {
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 {
epd->print(commonData->fmt->placeholder);
}
epd->setFont(&Ubuntu_Bold16pt8b);

View File

@@ -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
}

View File

@@ -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:

View File

@@ -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[] = {

View File

@@ -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
}

View File

@@ -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"
@@ -20,9 +24,9 @@ public:
int handleKey(int key) {
// Code for keylock
if(key == 11){
commonData->keylock = !commonData->keylock; // Toggle keylock
return 0; // Commit the key
if (key == 11) {
commonData->keylock = !commonData->keylock; // Toggle keylock
return 0;
}
return key;
}
@@ -102,40 +106,38 @@ 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{
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(100, 90);
}
else if(bvalue1->getFormat() == "formatTime" || bvalue1->getFormat() == "formatDate"){
else if (bvalue1->getFormat() == "formatTime" || bvalue1->getFormat() == "formatDate") {
epd->setFont(&Ubuntu_Bold12pt8b);
epd->setCursor(180, 77);
}
else{
else {
epd->setFont(&DSEG7Classic_BoldItalic30pt7b);
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
}
@@ -150,40 +152,38 @@ 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{
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(100, 180);
}
else if(bvalue2->getFormat() == "formatTime" || bvalue2->getFormat() == "formatDate"){
else if (bvalue2->getFormat() == "formatTime" || bvalue2->getFormat() == "formatDate") {
epd->setFont(&Ubuntu_Bold12pt8b);
epd->setCursor(180, 158);
}
else{
else {
epd->setFont(&DSEG7Classic_BoldItalic30pt7b);
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
}
@@ -198,28 +198,28 @@ 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
if (holdvalues == false) {
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_Bold8pt8b);
epd->setCursor(50, 240);
}
else if(bvalue3->getFormat() == "formatTime" || bvalue3->getFormat() == "formatDate"){
else if (bvalue3->getFormat() == "formatTime" || bvalue3->getFormat() == "formatDate") {
epd->setFont(&Ubuntu_Bold8pt8b);
epd->setCursor(100, 240);
}
else{
else {
epd->setFont(&DSEG7Classic_BoldItalic20pt7b);
epd->setCursor(80, 270);
}
@@ -246,24 +246,23 @@ 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{
if (holdvalues == false) {
epd->print(unit4);
} else {
epd->print(unit4old);
}
// Switch font if format for any values
if(bvalue4->getFormat() == "formatLatitude" || bvalue4->getFormat() == "formatLongitude"){
if (bvalue4->getFormat() == "formatLatitude" || bvalue4->getFormat() == "formatLongitude") {
epd->setFont(&Ubuntu_Bold8pt8b);
epd->setCursor(250, 240);
}
else if(bvalue4->getFormat() == "formatTime" || bvalue4->getFormat() == "formatDate"){
else if (bvalue4->getFormat() == "formatTime" || bvalue4->getFormat() == "formatDate") {
epd->setFont(&Ubuntu_Bold8pt8b);
epd->setCursor(300, 240);
}
@@ -273,13 +272,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
}