Skip to content

Commit

Permalink
Add DBT and STW in WindRose page
Browse files Browse the repository at this point in the history
  • Loading branch information
norbert-walter committed Aug 18, 2023
1 parent 333018c commit e5f945f
Showing 1 changed file with 67 additions and 6 deletions.
73 changes: 67 additions & 6 deletions lib/obp60task/PageWindRose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ int16_t lp = 80; // Pointer length
static String unit3old = "";
static String svalue4old = "";
static String unit4old = "";
static String svalue5old = "";
static String unit5old = "";
static String svalue6old = "";
static String unit6old = "";

// Get config data
String lengthformat = config->getString(config->lengthFormat);
Expand All @@ -45,7 +49,7 @@ int16_t lp = 80; // Pointer length
String flashLED = config->getString(config->flashLED);
String backlightMode = config->getString(config->backlight);

// Get boat values for AWS
// Get boat values for AWA
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
Expand All @@ -58,7 +62,7 @@ int16_t lp = 80; // Pointer length
unit1old = unit1; // Save old unit
}

// Get boat values for AWD
// Get boat values for AWS
GwApi::BoatValue *bvalue2 = pageData.values[1]; // First element in list (only one value by PageOneValue)
String name2 = xdrDelete(bvalue2->getName()); // Value name
name2 = name2.substring(0, 6); // String length limit for value name
Expand All @@ -71,7 +75,7 @@ int16_t lp = 80; // Pointer length
unit2old = unit2; // Save old unit
}

// Get boat values #3
// Get boat values TWD
GwApi::BoatValue *bvalue3 = pageData.values[2]; // Second element in list (only one value by PageOneValue)
String name3 = xdrDelete(bvalue3->getName()); // Value name
name3 = name3.substring(0, 6); // String length limit for value name
Expand All @@ -84,7 +88,7 @@ int16_t lp = 80; // Pointer length
unit3old = unit3; // Save old unit
}

// Get boat values #4
// Get boat values TWS
GwApi::BoatValue *bvalue4 = pageData.values[3]; // Second element in list (only one value by PageOneValue)
String name4 = xdrDelete(bvalue4->getName()); // Value name
name4 = name4.substring(0, 6); // String length limit for value name
Expand All @@ -97,6 +101,32 @@ int16_t lp = 80; // Pointer length
unit4old = unit4; // Save old unit
}

// Get boat values DBT
GwApi::BoatValue *bvalue5 = pageData.values[4]; // Second element in list (only one value by PageOneValue)
String name5 = xdrDelete(bvalue5->getName()); // Value name
name5 = name5.substring(0, 6); // String length limit for value name
double value5 = bvalue5->value; // Value as double in SI unit
bool valid5 = bvalue5->valid; // Valid information
String svalue5 = formatValue(bvalue5, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
String unit5 = formatValue(bvalue5, commonData).unit; // Unit of value
if(valid5 == true){
svalue5old = svalue5; // Save old value
unit5old = unit5; // Save old unit
}

// Get boat values STW
GwApi::BoatValue *bvalue6 = pageData.values[5]; // Second element in list (only one value by PageOneValue)
String name6 = xdrDelete(bvalue6->getName()); // Value name
name6 = name6.substring(0, 6); // String length limit for value name
double value6 = bvalue6->value; // Value as double in SI unit
bool valid6 = bvalue6->valid; // Valid information
String svalue6 = formatValue(bvalue6, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
String unit6 = formatValue(bvalue6, commonData).unit; // Unit of value
if(valid6 == true){
svalue6old = svalue6; // Save old value
unit6old = unit6; // Save old unit
}

// Optical warning by limit violation (unused)
if(String(flashLED) == "Limit Violation"){
setBlinkingLED(false);
Expand All @@ -105,7 +135,7 @@ int16_t lp = 80; // Pointer length

// Logging boat values
if (bvalue1 == NULL) return;
LOG_DEBUG(GwLog::LOG,"Drawing at PageWindRose, %s:%f, %s:%f, %s:%f, %s:%f", name1, value1, name2, value2, name3, value3, name4, value4);
LOG_DEBUG(GwLog::LOG,"Drawing at PageWindRose, %s:%f, %s:%f, %s:%f, %s:%f, %s:%f, %s:%f", name1, value1, name2, value2, name3, value3, name4, value4, name5, value5, name6, value6);

// Draw page
//***********************************************************
Expand Down Expand Up @@ -307,6 +337,37 @@ int16_t lp = 80; // Pointer length
display.fillCircle(200, 150, startwidth + 4, pixelcolor);

//*******************************************************************************************

// Show values DBT
display.setTextColor(textcolor);
display.setFont(&DSEG7Classic_BoldItalic16pt7b);
display.setCursor(160, 200);
display.print(svalue5); // Value
display.setFont(&Ubuntu_Bold8pt7b);
display.setCursor(190, 215);
display.print(" ");
if(holdvalues == false){
display.print(unit5); // Unit
}
else{
display.print(unit5old); // Unit
}

// Show values STW
display.setTextColor(textcolor);
display.setFont(&DSEG7Classic_BoldItalic16pt7b);
display.setCursor(160, 130);
display.print(svalue6); // Value
display.setFont(&Ubuntu_Bold8pt7b);
display.setCursor(190, 90);
display.print(" ");
if(holdvalues == false){
display.print(unit6); // Unit
}
else{
display.print(unit6old); // Unit
}

// Key Layout
display.setTextColor(textcolor);
display.setFont(&Ubuntu_Bold8pt7b);
Expand Down Expand Up @@ -343,7 +404,7 @@ PageDescription registerPageWindRose(
"WindRose", // Page name
createPage, // Action
0, // Number of bus values depends on selection in Web configuration
{"AWA", "AWS", "TWD", "TWS"}, // Bus values we need in the page
{"AWA", "AWS", "TWD", "TWS", "DBT", "STW"}, // Bus values we need in the page
true // Show display header on/off
);

Expand Down

0 comments on commit e5f945f

Please sign in to comment.