Enable pages OneValue, TwoValue, ThreeValue,

FourValue, FourValue2 for small decimals
This commit is contained in:
Ulrich Meine
2026-08-31 23:54:02 +02:00
parent 33768440b1
commit 0f98331eb4
5 changed files with 166 additions and 81 deletions
+46 -15
View File
@@ -5,6 +5,11 @@
class PageFourValues : public Page class PageFourValues : public Page
{ {
private:
static constexpr int8_t LEFT = 0;
static constexpr int8_t CENTER = 1;
static constexpr int8_t RIGHT = 2;
public: public:
PageFourValues(CommonData &common){ PageFourValues(CommonData &common){
commonData = &common; commonData = &common;
@@ -24,6 +29,9 @@ class PageFourValues : public Page
GwConfigHandler *config = commonData->config; GwConfigHandler *config = commonData->config;
GwLog *logger = commonData->logger; GwLog *logger = commonData->logger;
int valueX, valueY;
int DsegFontSize;
// Old values for hold function // Old values for hold function
static String svalue1old = ""; static String svalue1old = "";
static String unit1old = ""; static String unit1old = "";
@@ -35,11 +43,9 @@ class PageFourValues : public Page
static String unit4old = ""; static String unit4old = "";
// Get config data // Get config data
String lengthformat = config->getString(config->lengthFormat);
// bool simulation = config->getBool(config->useSimuData);
bool holdvalues = config->getBool(config->holdvalues); bool holdvalues = config->getBool(config->holdvalues);
String flashLED = config->getString(config->flashLED); String flashLED = config->getString(config->flashLED);
String backlightMode = config->getString(config->backlight); bool smallDecimals = config->getBool(config->smallDecimals);
// Get boat values #1 // Get boat values #1
GwApi::BoatValue *bvalue1 = pageData.values[0]; // First element in list (only one value by PageOneValue) GwApi::BoatValue *bvalue1 = pageData.values[0]; // First element in list (only one value by PageOneValue)
@@ -104,7 +110,7 @@ class PageFourValues : public Page
// Show unit // Show unit
getdisplay().setFont(&Ubuntu_Bold8pt8b); getdisplay().setFont(&Ubuntu_Bold8pt8b);
getdisplay().setCursor(20, 65); getdisplay().setCursor(20, 67);
if(holdvalues == false){ if(holdvalues == false){
getdisplay().print(unit1); // Unit getdisplay().print(unit1); // Unit
} }
@@ -113,25 +119,32 @@ class PageFourValues : public Page
} }
// Switch font if format for any values // Switch font if format for any values
valueX = 380;
if(bvalue1->getFormat() == "formatLatitude" || bvalue1->getFormat() == "formatLongitude"){ if(bvalue1->getFormat() == "formatLatitude" || bvalue1->getFormat() == "formatLongitude"){
valueY = 55;
DsegFontSize = 12;
getdisplay().setFont(&Ubuntu_Bold12pt8b); getdisplay().setFont(&Ubuntu_Bold12pt8b);
getdisplay().setCursor(120, 55); getdisplay().setCursor(120, 55);
} }
else if(bvalue1->getFormat() == "formatTime" || bvalue1->getFormat() == "formatDate"){ else if(bvalue1->getFormat() == "formatTime" || bvalue1->getFormat() == "formatDate"){
valueY = 67;
DsegFontSize = 20;
getdisplay().setFont(&Ubuntu_Bold12pt8b); getdisplay().setFont(&Ubuntu_Bold12pt8b);
getdisplay().setCursor(150, 58); getdisplay().setCursor(150, 58);
} }
else{ else{
valueY = 67;
DsegFontSize = 20;
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b); getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
getdisplay().setCursor(180, 65); getdisplay().setCursor(180, 65);
} }
// Show bus data // Show bus data
if(holdvalues == false){ if(holdvalues == false){
getdisplay().print(svalue1); // Real value as formated string printBoatValue(svalue1, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string
} }
else{ else{
getdisplay().print(svalue1old); // Old value as formated string printBoatValue(svalue1old, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string
} }
if(valid1 == true){ if(valid1 == true){
svalue1old = svalue1; // Save the old value svalue1old = svalue1; // Save the old value
@@ -152,7 +165,7 @@ class PageFourValues : public Page
// Show unit // Show unit
getdisplay().setFont(&Ubuntu_Bold8pt8b); getdisplay().setFont(&Ubuntu_Bold8pt8b);
getdisplay().setCursor(20, 133); getdisplay().setCursor(20, 135);
if(holdvalues == false){ if(holdvalues == false){
getdisplay().print(unit2); // Unit getdisplay().print(unit2); // Unit
} }
@@ -162,24 +175,30 @@ class PageFourValues : public Page
// Switch font if format for any values // Switch font if format for any values
if(bvalue2->getFormat() == "formatLatitude" || bvalue2->getFormat() == "formatLongitude"){ if(bvalue2->getFormat() == "formatLatitude" || bvalue2->getFormat() == "formatLongitude"){
valueY = 123;
DsegFontSize = 12;
getdisplay().setFont(&Ubuntu_Bold12pt8b); getdisplay().setFont(&Ubuntu_Bold12pt8b);
getdisplay().setCursor(120, 123); getdisplay().setCursor(120, 123);
} }
else if(bvalue2->getFormat() == "formatTime" || bvalue2->getFormat() == "formatDate"){ else if(bvalue2->getFormat() == "formatTime" || bvalue2->getFormat() == "formatDate"){
valueY = 135;
DsegFontSize = 20;
getdisplay().setFont(&Ubuntu_Bold12pt8b); getdisplay().setFont(&Ubuntu_Bold12pt8b);
getdisplay().setCursor(150, 123); getdisplay().setCursor(150, 123);
} }
else{ else{
valueY = 135;
DsegFontSize = 20;
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b); getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
getdisplay().setCursor(180, 133); getdisplay().setCursor(180, 133);
} }
// Show bus data // Show bus data
if(holdvalues == false){ if(holdvalues == false){
getdisplay().print(svalue2); // Real value as formated string printBoatValue(svalue2, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string
} }
else{ else{
getdisplay().print(svalue2old); // Old value as formated string printBoatValue(svalue2old, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string
} }
if(valid2 == true){ if(valid2 == true){
svalue2old = svalue2; // Save the old value svalue2old = svalue2; // Save the old value
@@ -200,7 +219,7 @@ class PageFourValues : public Page
// Show unit // Show unit
getdisplay().setFont(&Ubuntu_Bold8pt8b); getdisplay().setFont(&Ubuntu_Bold8pt8b);
getdisplay().setCursor(20, 201); getdisplay().setCursor(20, 203);
if(holdvalues == false){ if(holdvalues == false){
getdisplay().print(unit3); // Unit getdisplay().print(unit3); // Unit
} }
@@ -210,24 +229,30 @@ class PageFourValues : public Page
// Switch font if format for any values // Switch font if format for any values
if(bvalue3->getFormat() == "formatLatitude" || bvalue3->getFormat() == "formatLongitude"){ if(bvalue3->getFormat() == "formatLatitude" || bvalue3->getFormat() == "formatLongitude"){
valueY = 191;
DsegFontSize = 16;
getdisplay().setFont(&Ubuntu_Bold12pt8b); getdisplay().setFont(&Ubuntu_Bold12pt8b);
getdisplay().setCursor(120, 191); getdisplay().setCursor(120, 191);
} }
else if(bvalue3->getFormat() == "formatTime" || bvalue3->getFormat() == "formatDate"){ else if(bvalue3->getFormat() == "formatTime" || bvalue3->getFormat() == "formatDate"){
valueY = 203;
DsegFontSize = 20;
getdisplay().setFont(&Ubuntu_Bold12pt8b); getdisplay().setFont(&Ubuntu_Bold12pt8b);
getdisplay().setCursor(150, 191); getdisplay().setCursor(150, 191);
} }
else{ else{
valueY = 203;
DsegFontSize = 20;
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b); getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
getdisplay().setCursor(180, 201); getdisplay().setCursor(180, 201);
} }
// Show bus data // Show bus data
if(holdvalues == false){ if(holdvalues == false){
getdisplay().print(svalue3); // Real value as formated string printBoatValue(svalue3, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string
} }
else{ else{
getdisplay().print(svalue3old); // Old value as formated string printBoatValue(svalue3old, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string
} }
if(valid3 == true){ if(valid3 == true){
svalue3old = svalue3; // Save the old value svalue3old = svalue3; // Save the old value
@@ -248,7 +273,7 @@ class PageFourValues : public Page
// Show unit // Show unit
getdisplay().setFont(&Ubuntu_Bold8pt8b); getdisplay().setFont(&Ubuntu_Bold8pt8b);
getdisplay().setCursor(20, 269); getdisplay().setCursor(20, 271);
if(holdvalues == false){ if(holdvalues == false){
getdisplay().print(unit4); // Unit getdisplay().print(unit4); // Unit
} }
@@ -258,24 +283,30 @@ class PageFourValues : public Page
// Switch font if format for any values // Switch font if format for any values
if(bvalue4->getFormat() == "formatLatitude" || bvalue4->getFormat() == "formatLongitude"){ if(bvalue4->getFormat() == "formatLatitude" || bvalue4->getFormat() == "formatLongitude"){
valueY = 271;
DsegFontSize = 16;
getdisplay().setFont(&Ubuntu_Bold12pt8b); getdisplay().setFont(&Ubuntu_Bold12pt8b);
getdisplay().setCursor(120, 259); getdisplay().setCursor(120, 259);
} }
else if(bvalue4->getFormat() == "formatTime" || bvalue4->getFormat() == "formatDate"){ else if(bvalue4->getFormat() == "formatTime" || bvalue4->getFormat() == "formatDate"){
valueY = 271;
DsegFontSize = 20;
getdisplay().setFont(&Ubuntu_Bold12pt8b); getdisplay().setFont(&Ubuntu_Bold12pt8b);
getdisplay().setCursor(150, 259); getdisplay().setCursor(150, 259);
} }
else{ else{
valueY = 271;
DsegFontSize = 20;
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b); getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
getdisplay().setCursor(180, 269); getdisplay().setCursor(180, 269);
} }
// Show bus data // Show bus data
if(holdvalues == false){ if(holdvalues == false){
getdisplay().print(svalue4); // Real value as formated string printBoatValue(svalue4, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string
} }
else{ else{
getdisplay().print(svalue4old); // Old value as formated string printBoatValue(svalue4old, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string
} }
if(valid4 == true){ if(valid4 == true){
svalue4old = svalue4; // Save the old value svalue4old = svalue4; // Save the old value
+52 -19
View File
@@ -5,6 +5,11 @@
class PageFourValues2 : public Page class PageFourValues2 : public Page
{ {
private:
static constexpr int8_t LEFT = 0;
static constexpr int8_t CENTER = 1;
static constexpr int8_t RIGHT = 2;
public: public:
PageFourValues2(CommonData &common){ PageFourValues2(CommonData &common){
commonData = &common; commonData = &common;
@@ -24,6 +29,9 @@ class PageFourValues2 : public Page
GwConfigHandler *config = commonData->config; GwConfigHandler *config = commonData->config;
GwLog *logger = commonData->logger; GwLog *logger = commonData->logger;
int valueX, valueY;
int DsegFontSize;
// Old values for hold function // Old values for hold function
static String svalue1old = ""; static String svalue1old = "";
static String unit1old = ""; static String unit1old = "";
@@ -35,11 +43,9 @@ class PageFourValues2 : public Page
static String unit4old = ""; static String unit4old = "";
// Get config data // Get config data
String lengthformat = config->getString(config->lengthFormat);
// bool simulation = config->getBool(config->useSimuData);
bool holdvalues = config->getBool(config->holdvalues); bool holdvalues = config->getBool(config->holdvalues);
String flashLED = config->getString(config->flashLED); String flashLED = config->getString(config->flashLED);
String backlightMode = config->getString(config->backlight); bool smallDecimals = config->getBool(config->smallDecimals);
// Get boat values #1 // Get boat values #1
GwApi::BoatValue *bvalue1 = pageData.values[0]; // First element in list (only one value by PageOneValue) GwApi::BoatValue *bvalue1 = pageData.values[0]; // First element in list (only one value by PageOneValue)
@@ -113,25 +119,32 @@ class PageFourValues2 : public Page
} }
// Switch font if format for any values // Switch font if format for any values
valueX = 380;
if(bvalue1->getFormat() == "formatLatitude" || bvalue1->getFormat() == "formatLongitude"){ if(bvalue1->getFormat() == "formatLatitude" || bvalue1->getFormat() == "formatLongitude"){
valueY = 90;
DsegFontSize = 20;
getdisplay().setFont(&Ubuntu_Bold12pt8b); getdisplay().setFont(&Ubuntu_Bold12pt8b);
getdisplay().setCursor(100, 90); getdisplay().setCursor(100, 90);
} }
else if(bvalue1->getFormat() == "formatTime" || bvalue1->getFormat() == "formatDate"){ else if(bvalue1->getFormat() == "formatTime" || bvalue1->getFormat() == "formatDate"){
valueY = 80;
DsegFontSize = 20;
getdisplay().setFont(&Ubuntu_Bold12pt8b); getdisplay().setFont(&Ubuntu_Bold12pt8b);
getdisplay().setCursor(180, 77); getdisplay().setCursor(180, 77);
} }
else{ else{
valueY = 90;
DsegFontSize = 30;
getdisplay().setFont(&DSEG7Classic_BoldItalic30pt7b); getdisplay().setFont(&DSEG7Classic_BoldItalic30pt7b);
getdisplay().setCursor(180, 90); getdisplay().setCursor(180, 90);
} }
// Show bus data // Show bus data
if(holdvalues == false){ if(holdvalues == false){
getdisplay().print(svalue1); // Real value as formated string printBoatValue(svalue1, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string
} }
else{ else{
getdisplay().print(svalue1old); // Old value as formated string printBoatValue(svalue1old, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string
} }
if(valid1 == true){ if(valid1 == true){
svalue1old = svalue1; // Save the old value svalue1old = svalue1; // Save the old value
@@ -162,24 +175,30 @@ class PageFourValues2 : public Page
// Switch font if format for any values // Switch font if format for any values
if(bvalue2->getFormat() == "formatLatitude" || bvalue2->getFormat() == "formatLongitude"){ if(bvalue2->getFormat() == "formatLatitude" || bvalue2->getFormat() == "formatLongitude"){
valueY = 180;
DsegFontSize = 20;
getdisplay().setFont(&Ubuntu_Bold12pt8b); getdisplay().setFont(&Ubuntu_Bold12pt8b);
getdisplay().setCursor(100, 180); getdisplay().setCursor(100, 180);
} }
else if(bvalue2->getFormat() == "formatTime" || bvalue2->getFormat() == "formatDate"){ else if(bvalue2->getFormat() == "formatTime" || bvalue2->getFormat() == "formatDate"){
valueY = 170;
DsegFontSize = 20;
getdisplay().setFont(&Ubuntu_Bold12pt8b); getdisplay().setFont(&Ubuntu_Bold12pt8b);
getdisplay().setCursor(180, 158); getdisplay().setCursor(180, 158);
} }
else{ else{
valueY = 180;
DsegFontSize = 30;
getdisplay().setFont(&DSEG7Classic_BoldItalic30pt7b); getdisplay().setFont(&DSEG7Classic_BoldItalic30pt7b);
getdisplay().setCursor(180, 180); getdisplay().setCursor(180, 180);
} }
// Show bus data // Show bus data
if(holdvalues == false){ if(holdvalues == false){
getdisplay().print(svalue2); // Real value as formated string printBoatValue(svalue2, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string
} }
else{ else{
getdisplay().print(svalue2old); // Old value as formated string printBoatValue(svalue2old, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string
} }
if(valid2 == true){ if(valid2 == true){
svalue2old = svalue2; // Save the old value svalue2old = svalue2; // Save the old value
@@ -194,13 +213,13 @@ class PageFourValues2 : public Page
// ############### Value 3 ################ // ############### Value 3 ################
// Show name // Show name
getdisplay().setFont(&Ubuntu_Bold12pt8b); getdisplay().setFont(&Ubuntu_Bold16pt8b);
getdisplay().setCursor(20, 220); getdisplay().setCursor(20, 223);
getdisplay().print(name3); // Page name getdisplay().print(name3); // Page name
// Show unit // Show unit
getdisplay().setFont(&Ubuntu_Bold8pt8b); getdisplay().setFont(&Ubuntu_Bold10pt8b);
getdisplay().setCursor(20, 240); getdisplay().setCursor(20, 270);
if(holdvalues == false){ if(holdvalues == false){
getdisplay().print(unit3); // Unit getdisplay().print(unit3); // Unit
} }
@@ -209,25 +228,32 @@ class PageFourValues2 : public Page
} }
// Switch font if format for any values // Switch font if format for any values
valueX = 190;
if(bvalue3->getFormat() == "formatLatitude" || bvalue3->getFormat() == "formatLongitude"){ if(bvalue3->getFormat() == "formatLatitude" || bvalue3->getFormat() == "formatLongitude"){
valueY = 250;
DsegFontSize = 10;
getdisplay().setFont(&Ubuntu_Bold8pt8b); getdisplay().setFont(&Ubuntu_Bold8pt8b);
getdisplay().setCursor(50, 240); getdisplay().setCursor(50, 240);
} }
else if(bvalue3->getFormat() == "formatTime" || bvalue3->getFormat() == "formatDate"){ else if(bvalue3->getFormat() == "formatTime" || bvalue3->getFormat() == "formatDate"){
valueY = 253;
DsegFontSize = 10;
getdisplay().setFont(&Ubuntu_Bold8pt8b); getdisplay().setFont(&Ubuntu_Bold8pt8b);
getdisplay().setCursor(100, 240); getdisplay().setCursor(100, 240);
} }
else{ else{
valueY = 270;
DsegFontSize = 20;
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b); getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
getdisplay().setCursor(80, 270); getdisplay().setCursor(80, 270);
} }
// Show bus data // Show bus data
if(holdvalues == false){ if(holdvalues == false){
getdisplay().print(svalue3); // Real value as formated string printBoatValue(svalue3, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string
} }
else{ else{
getdisplay().print(svalue3old); // Old value as formated string printBoatValue(svalue3old, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string
} }
if(valid3 == true){ if(valid3 == true){
svalue3old = svalue3; // Save the old value svalue3old = svalue3; // Save the old value
@@ -242,13 +268,13 @@ class PageFourValues2 : public Page
// ############### Value 4 ################ // ############### Value 4 ################
// Show name // Show name
getdisplay().setFont(&Ubuntu_Bold12pt8b); getdisplay().setFont(&Ubuntu_Bold16pt8b);
getdisplay().setCursor(220, 220); getdisplay().setCursor(220, 223);
getdisplay().print(name4); // Page name getdisplay().print(name4); // Page name
// Show unit // Show unit
getdisplay().setFont(&Ubuntu_Bold8pt8b); getdisplay().setFont(&Ubuntu_Bold10pt8b);
getdisplay().setCursor(220, 240); getdisplay().setCursor(220, 270);
if(holdvalues == false){ if(holdvalues == false){
getdisplay().print(unit4); // Unit getdisplay().print(unit4); // Unit
} }
@@ -257,25 +283,32 @@ class PageFourValues2 : public Page
} }
// Switch font if format for any values // Switch font if format for any values
valueX = 390;
if(bvalue4->getFormat() == "formatLatitude" || bvalue4->getFormat() == "formatLongitude"){ if(bvalue4->getFormat() == "formatLatitude" || bvalue4->getFormat() == "formatLongitude"){
valueY = 250;
DsegFontSize = 10;
getdisplay().setFont(&Ubuntu_Bold8pt8b); getdisplay().setFont(&Ubuntu_Bold8pt8b);
getdisplay().setCursor(250, 240); getdisplay().setCursor(250, 240);
} }
else if(bvalue4->getFormat() == "formatTime" || bvalue4->getFormat() == "formatDate"){ else if(bvalue4->getFormat() == "formatTime" || bvalue4->getFormat() == "formatDate"){
valueY = 253;
DsegFontSize = 10;
getdisplay().setFont(&Ubuntu_Bold8pt8b); getdisplay().setFont(&Ubuntu_Bold8pt8b);
getdisplay().setCursor(300, 240); getdisplay().setCursor(300, 240);
} }
else{ else{
valueY = 270;
DsegFontSize = 20;
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b); getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
getdisplay().setCursor(280, 270); getdisplay().setCursor(280, 270);
} }
// Show bus data // Show bus data
if(holdvalues == false){ if(holdvalues == false){
getdisplay().print(svalue4); // Real value as formated string printBoatValue(svalue4, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string
} }
else{ else{
getdisplay().print(svalue4old); // Old value as formated string printBoatValue(svalue4old, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string
} }
if(valid4 == true){ if(valid4 == true){
svalue4old = svalue4; // Save the old value svalue4old = svalue4; // Save the old value
+7 -8
View File
@@ -72,11 +72,7 @@ private:
nameFnt = &Ubuntu_Bold20pt8b; nameFnt = &Ubuntu_Bold20pt8b;
unitX = 10; unitX = 10;
unitY = 121; unitY = 121;
// unitXoff = -295;
//unitXoff = -280;
//unitYoff = 21;
unitFnt = &Ubuntu_Bold12pt8b; unitFnt = &Ubuntu_Bold12pt8b;
// value1Xoff = 111;
valueXoff = 0; valueXoff = 0;
valueYoff = -119; valueYoff = -119;
valueFontSize1 = 12; valueFontSize1 = 12;
@@ -143,6 +139,8 @@ public:
{ {
commonData = &common; commonData = &common;
logger = commonData->logger; logger = commonData->logger;
GwConfigHandler *config = commonData->config;
LOG_DEBUG(GwLog::LOG, "Instantiate PageOneValue"); LOG_DEBUG(GwLog::LOG, "Instantiate PageOneValue");
width = getdisplay().width(); // Screen width width = getdisplay().width(); // Screen width
@@ -150,7 +148,7 @@ public:
getdisplay().setTextWrap(false); getdisplay().setTextWrap(false);
// Get config data // Get config data
useSimuData = commonData->config->getBool(commonData->config->useSimuData); useSimuData = config->getBool(config->useSimuData);
holdValues = commonData->config->getBool(commonData->config->holdvalues); holdValues = commonData->config->getBool(commonData->config->holdvalues);
flashLED = commonData->config->getString(commonData->config->flashLED); flashLED = commonData->config->getString(commonData->config->flashLED);
smallDecimals = commonData->config->getBool(commonData->config->smallDecimals); smallDecimals = commonData->config->getBool(commonData->config->smallDecimals);
@@ -264,12 +262,13 @@ public:
// Get boat value for page // Get boat value for page
GwApi::BoatValue* bValue1 = pageData.values[0]; // Page boat data element GwApi::BoatValue* bValue1 = pageData.values[0]; // Page boat data element
#ifdef BOARD_OBP60S3
// Optical warning by limit violation (unused) // Optical warning by limit violation (unused)
if (String(flashLED) == "Limit Violation") { if (String(flashLED) == "Limit Violation") {
setBlinkingLED(false); setBlinkingLED(false);
setFlashLED(false); setFlashLED(false);
} }
#endif
if (bValue1 == NULL) if (bValue1 == NULL)
return PAGE_OK; // no data, no page to display return PAGE_OK; // no data, no page to display
@@ -280,13 +279,13 @@ public:
displaySetPartialWindow(0, 0, width, height); // Set partial update displaySetPartialWindow(0, 0, width, height); // Set partial update
if (dataChart) { // Check only if dataChart object exist^s at all if (dataChart) { // Check only if dataChart object exists at all
if (!dataChart->isValid()) { if (!dataChart->isValid()) {
dataChart->init(); // try late initialization if chart object could not be properly initialized earlier due to missing boat data dataChart->init(); // try late initialization if chart object could not be properly initialized earlier due to missing boat data
} }
} }
if (pageMode == VALUE || dataHstryBuf == nullptr) { if (pageMode == VALUE || dataChart == nullptr) {
// show only data value; ignore other pageMode options if no chart supported boat data history buffer is available // show only data value; ignore other pageMode options if no chart supported boat data history buffer is available
showData(bValue1, FULL); showData(bValue1, FULL);
+34 -20
View File
@@ -5,6 +5,11 @@
class PageThreeValues : public Page class PageThreeValues : public Page
{ {
private:
static constexpr int8_t LEFT = 0;
static constexpr int8_t CENTER = 1;
static constexpr int8_t RIGHT = 2;
public: public:
PageThreeValues(CommonData &common){ PageThreeValues(CommonData &common){
commonData = &common; commonData = &common;
@@ -24,6 +29,9 @@ class PageThreeValues : public Page
GwConfigHandler *config = commonData->config; GwConfigHandler *config = commonData->config;
GwLog *logger = commonData->logger; GwLog *logger = commonData->logger;
int valueX, valueY;
int DsegFontSize;
// Old values for hold function // Old values for hold function
static String svalue1old = ""; static String svalue1old = "";
static String unit1old = ""; static String unit1old = "";
@@ -33,11 +41,10 @@ class PageThreeValues : public Page
static String unit3old = ""; static String unit3old = "";
// Get config data // Get config data
String lengthformat = config->getString(config->lengthFormat);
// bool simulation = config->getBool(config->useSimuData); // bool simulation = config->getBool(config->useSimuData);
bool holdvalues = config->getBool(config->holdvalues); bool holdvalues = config->getBool(config->holdvalues);
String flashLED = config->getString(config->flashLED); String flashLED = config->getString(config->flashLED);
String backlightMode = config->getString(config->backlight); bool smallDecimals = config->getBool(config->smallDecimals);
// Get boat values #1 // Get boat values #1
GwApi::BoatValue *bvalue1 = pageData.values[0]; // First element in list (only one value by PageOneValue) GwApi::BoatValue *bvalue1 = pageData.values[0]; // First element in list (only one value by PageOneValue)
@@ -101,25 +108,26 @@ class PageThreeValues : public Page
} }
// Switch font if format for any values // Switch font if format for any values
valueX = 380;
if(bvalue1->getFormat() == "formatLatitude" || bvalue1->getFormat() == "formatLongitude"){ if(bvalue1->getFormat() == "formatLatitude" || bvalue1->getFormat() == "formatLongitude"){
getdisplay().setFont(&Ubuntu_Bold20pt8b); valueY = 90;
getdisplay().setCursor(50, 90); DsegFontSize = 20;
} }
else if(bvalue1->getFormat() == "formatTime" || bvalue1->getFormat() == "formatDate"){ else if(bvalue1->getFormat() == "formatTime" || bvalue1->getFormat() == "formatDate"){
getdisplay().setFont(&Ubuntu_Bold20pt8b); valueY = 80;
getdisplay().setCursor(170, 68); DsegFontSize = 20;
} }
else{ else{
getdisplay().setFont(&DSEG7Classic_BoldItalic30pt7b); valueY = 90;
getdisplay().setCursor(180, 90); DsegFontSize = 30;
} }
// Show bus data // Show bus data
if(holdvalues == false){ if(holdvalues == false){
getdisplay().print(svalue1); // Real value as formated string printBoatValue(svalue1, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string
} }
else{ else{
getdisplay().print(svalue1old); // Old value as formated string printBoatValue(svalue1old, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Old value as formated string
} }
if(valid1 == true){ if(valid1 == true){
svalue1old = svalue1; // Save the old value svalue1old = svalue1; // Save the old value
@@ -150,24 +158,30 @@ class PageThreeValues : public Page
// Switch font if format for any values // Switch font if format for any values
if(bvalue2->getFormat() == "formatLatitude" || bvalue2->getFormat() == "formatLongitude"){ if(bvalue2->getFormat() == "formatLatitude" || bvalue2->getFormat() == "formatLongitude"){
valueY = 180;
DsegFontSize = 20;
getdisplay().setFont(&Ubuntu_Bold20pt8b); getdisplay().setFont(&Ubuntu_Bold20pt8b);
getdisplay().setCursor(50, 180); getdisplay().setCursor(50, 180);
} }
else if(bvalue2->getFormat() == "formatTime" || bvalue2->getFormat() == "formatDate"){ else if(bvalue2->getFormat() == "formatTime" || bvalue2->getFormat() == "formatDate"){
valueY = 170;
DsegFontSize = 20;
getdisplay().setFont(&Ubuntu_Bold20pt8b); getdisplay().setFont(&Ubuntu_Bold20pt8b);
getdisplay().setCursor(170, 158); getdisplay().setCursor(170, 158);
} }
else{ else{
valueY = 180;
DsegFontSize = 30;
getdisplay().setFont(&DSEG7Classic_BoldItalic30pt7b); getdisplay().setFont(&DSEG7Classic_BoldItalic30pt7b);
getdisplay().setCursor(180, 180); getdisplay().setCursor(180, 180);
} }
// Show bus data // Show bus data
if(holdvalues == false){ if(holdvalues == false){
getdisplay().print(svalue2); // Real value as formated string printBoatValue(svalue2, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string
} }
else{ else{
getdisplay().print(svalue2old); // Old value as formated string printBoatValue(svalue2old, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string
} }
if(valid2 == true){ if(valid2 == true){
svalue2old = svalue2; // Save the old value svalue2old = svalue2; // Save the old value
@@ -198,24 +212,24 @@ class PageThreeValues : public Page
// Switch font if format for any values // Switch font if format for any values
if(bvalue3->getFormat() == "formatLatitude" || bvalue3->getFormat() == "formatLongitude"){ if(bvalue3->getFormat() == "formatLatitude" || bvalue3->getFormat() == "formatLongitude"){
getdisplay().setFont(&Ubuntu_Bold20pt8b); valueY = 270;
getdisplay().setCursor(50, 270); DsegFontSize = 20;
} }
else if(bvalue3->getFormat() == "formatTime" || bvalue3->getFormat() == "formatDate"){ else if(bvalue3->getFormat() == "formatTime" || bvalue3->getFormat() == "formatDate"){
getdisplay().setFont(&Ubuntu_Bold20pt8b); valueY = 260;
getdisplay().setCursor(170, 248); DsegFontSize = 20;
} }
else{ else{
getdisplay().setFont(&DSEG7Classic_BoldItalic30pt7b); valueY = 270;
getdisplay().setCursor(180, 270); DsegFontSize = 30;
} }
// Show bus data // Show bus data
if(holdvalues == false){ if(holdvalues == false){
getdisplay().print(svalue3); // Real value as formated string printBoatValue(svalue3, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string
} }
else{ else{
getdisplay().print(svalue3old); // Old value as formated string printBoatValue(svalue3old, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string
} }
if(valid3 == true){ if(valid3 == true){
svalue3old = svalue3; // Save the old value svalue3old = svalue3; // Save the old value
+24 -16
View File
@@ -34,8 +34,11 @@ private:
bool useSimuData; bool useSimuData;
bool holdValues; bool holdValues;
String flashLED; String flashLED;
String backlightMode; bool smallDecimals;
String tempFormat;
static constexpr int8_t LEFT = 0;
static constexpr int8_t CENTER = 1;
static constexpr int8_t RIGHT = 2;
// Data buffer pointer (owned by HstryBuffers) // Data buffer pointer (owned by HstryBuffers)
static constexpr int NUMVALUES = 2; // two data values in this page static constexpr int NUMVALUES = 2; // two data values in this page
@@ -49,8 +52,10 @@ private:
// display data values in display <mode> [FULL|HALF] // display data values in display <mode> [FULL|HALF]
void showData(const std::vector<GwApi::BoatValue*>& bValue, DisplayMode mode) void showData(const std::vector<GwApi::BoatValue*>& bValue, DisplayMode mode)
{ {
getdisplay().setTextColor(commonData->fgcolor); int valueX, valueY;
int DsegFontSize;
getdisplay().setTextColor(commonData->fgcolor);
int numValues = bValue.size(); // do we have to handle 1 or 2 values? int numValues = bValue.size(); // do we have to handle 1 or 2 values?
for (int i = 0; i < numValues; i++) { for (int i = 0; i < numValues; i++) {
@@ -78,22 +83,23 @@ private:
} }
// Switch font depending on value format and adjust position // Switch font depending on value format and adjust position
valueX = 380;
if (bValue[i]->getFormat() == "formatLatitude" || bValue[i]->getFormat() == "formatLongitude") { if (bValue[i]->getFormat() == "formatLatitude" || bValue[i]->getFormat() == "formatLongitude") {
getdisplay().setFont(&Ubuntu_Bold20pt8b); valueY = 125 + yOffset;
getdisplay().setCursor(50, 125 + yOffset); DsegFontSize = 20;
} else if (bValue[i]->getFormat() == "formatTime" || bValue[i]->getFormat() == "formatDate") { } else if (bValue[i]->getFormat() == "formatTime" || bValue[i]->getFormat() == "formatDate") {
getdisplay().setFont(&Ubuntu_Bold20pt8b); valueY = 105 + yOffset;
getdisplay().setCursor(170, 105 + yOffset); DsegFontSize = 20;
} else { // Default font for other formats } else { // Default font for other formats
getdisplay().setFont(&DSEG7Classic_BoldItalic42pt7b); valueY = 125 + yOffset;
getdisplay().setCursor(180, 125 + yOffset); DsegFontSize = 42;
} }
// Show bus data // Show bus data
if (!holdValues || useSimuData) { if (!holdValues || useSimuData) {
getdisplay().print(sValue); // Real value as formated string printBoatValue(sValue, valueX, valueY, RIGHT, DsegFontSize, smallDecimals);
} else { } else {
getdisplay().print(sValueOld[i]); // Old value as formated string printBoatValue(sValueOld[i], valueX, valueY, RIGHT, DsegFontSize, smallDecimals);
} }
if (valid == true) { if (valid == true) {
@@ -116,14 +122,13 @@ public:
width = getdisplay().width(); // Screen width width = getdisplay().width(); // Screen width
height = getdisplay().height(); // Screen height height = getdisplay().height(); // Screen height
getdisplay().setTextWrap(false);
// Get config data // Get config data
// lengthformat = commonData->config->getString(commonData->config->lengthFormat);
useSimuData = commonData->config->getBool(commonData->config->useSimuData); useSimuData = commonData->config->getBool(commonData->config->useSimuData);
holdValues = commonData->config->getBool(commonData->config->holdvalues); holdValues = commonData->config->getBool(commonData->config->holdvalues);
flashLED = commonData->config->getString(commonData->config->flashLED); flashLED = commonData->config->getString(commonData->config->flashLED);
backlightMode = commonData->config->getString(commonData->config->backlight); smallDecimals = commonData->config->getBool(commonData->config->smallDecimals);
tempFormat = commonData->config->getString(commonData->config->tempFormat); // [K|°C|°F]
} }
virtual void setupKeys() virtual void setupKeys()
@@ -255,12 +260,13 @@ public:
bValue.push_back(pageData.values[0]); // Page boat data element 1 bValue.push_back(pageData.values[0]); // Page boat data element 1
bValue.push_back(pageData.values[1]); // Page boat data element 2 bValue.push_back(pageData.values[1]); // Page boat data element 2
#ifdef BOARD_OBP60S3
// Optical warning by limit violation (unused) // Optical warning by limit violation (unused)
if (String(flashLED) == "Limit Violation") { if (String(flashLED) == "Limit Violation") {
setBlinkingLED(false); setBlinkingLED(false);
setFlashLED(false); setFlashLED(false);
} }
#endif
if (bValue[0] == NULL && bValue[1] == NULL) if (bValue[0] == NULL && bValue[1] == NULL)
return PAGE_OK; // no data, no page to display return PAGE_OK; // no data, no page to display
@@ -273,12 +279,14 @@ public:
displaySetPartialWindow(0, 0, width, height); // Set partial update displaySetPartialWindow(0, 0, width, height); // Set partial update
for (int i = 0; i < NUMVALUES; i++) { for (int i = 0; i < NUMVALUES; i++) {
if (dataChart[i]) { // Check only if dataChart object exists at all
if (!dataChart[i]->isValid()) { if (!dataChart[i]->isValid()) {
dataChart[i]->init(); // try late initialization if chart object could not be properly initialized earlier due to missing boat data dataChart[i]->init(); // try late initialization if chart object could not be properly initialized earlier due to missing boat data
} }
} }
}
if (pageMode == VALUES || (dataHstryBuf[0] == nullptr && dataHstryBuf[1] == nullptr)) { if (pageMode == VALUES || (dataChart[0] == nullptr && dataChart[1] == nullptr)) {
// show only data value; ignore other pageMode options if no chart supported boat data history buffer is available // show only data value; ignore other pageMode options if no chart supported boat data history buffer is available
showData(bValue, FULL); showData(bValue, FULL);