Enable pages Weather, Wind, XTETrack + charts function for small decimals

This commit is contained in:
Ulrich Meine
2026-09-01 16:55:34 +02:00
parent d44dc94ec7
commit 0202c5d82a
4 changed files with 55 additions and 53 deletions
+11 -5
View File
@@ -581,6 +581,11 @@ void Chart::drawChrtValAxis(const ChrtDir chrtDir, const ChrtSize chrtSz, const
// Print current data value
void Chart::prntCurrValue(const ChrtDir chrtDir, GwApi::BoatValue& currValue)
{
static constexpr int8_t LEFT = 0;
static constexpr int8_t CENTER = 1;
static constexpr int8_t RIGHT = 2;
static constexpr bool smallDecimals = true; // print data value always with small decimals
const int xPosVal = (chrtDir == HORIZONTAL) ? cRoot.x + (timAxis / 2) - 74 : cRoot.x + 31;
const int yPosVal = (chrtDir == HORIZONTAL) ? cRoot.y + valAxis : cRoot.y + timAxis;
@@ -593,19 +598,20 @@ void Chart::prntCurrValue(const ChrtDir chrtDir, GwApi::BoatValue& currValue)
getdisplay().drawRect(xPosVal, yPosVal - 39, 146, 37, fgColor); // Draw box for value
// value
getdisplay().setFont(&DSEG7Classic_BoldItalic16pt7b);
getdisplay().setCursor(xPosVal + 1, yPosVal - 6);
getdisplay().print(sdbValue);
printBoatValue(sdbValue, xPosVal + 93, yPosVal - 6, RIGHT, 16, smallDecimals);
// getdisplay().setFont(&DSEG7Classic_BoldItalic16pt7b);
// getdisplay().setCursor(xPosVal + 1, yPosVal - 6);
// getdisplay().print(sdbValue);
// name
getdisplay().setFont(&Ubuntu_Bold10pt8b);
getdisplay().setCursor(xPosVal + 100, yPosVal - 23);
getdisplay().setCursor(xPosVal + 97, yPosVal - 23);
String name = xdrDelete(dbName);
getdisplay().print(name.substring(0, 3)); // Name, limited to 3 characters
// unit
getdisplay().setFont(&Ubuntu_Bold8pt8b);
getdisplay().setCursor(xPosVal + 101, yPosVal - 8);
getdisplay().setCursor(xPosVal + 98, yPosVal - 8);
getdisplay().print(dbUnit);
}
+13 -12
View File
@@ -14,6 +14,10 @@ private:
CHART
};
static constexpr int8_t LEFT = 0;
static constexpr int8_t CENTER = 1;
static constexpr int8_t RIGHT = 2;
static constexpr int XOFFSET = 133; // x offset for display of boat values
int width; // Screen width
@@ -28,8 +32,7 @@ private:
bool useSimuData;
bool holdValues;
String flashLED;
String backlightMode;
String tempFormat;
bool smallDecimals;
static constexpr int NUMVALUES = 4; // number of boat values used on this page
static constexpr int NUMCHARTS = 1; // one data buffer used on this page
@@ -74,16 +77,13 @@ private:
}
// Print value
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
if (bValue[i]->getFormat() == "formatXdr:P:P" || bValue[i]->getFormat() == "formatXdr:P:B") {
getdisplay().setCursor(6 + xOffset, 275); // pressure format is always 4 digits when all other boat data has 3 digit format
} else {
getdisplay().setCursor(37 + xOffset, 275);
}
int valueX = XOFFSET * i - 5;
int valueY = 275;
int DsegFontSize = 20;
if (!holdValues || useSimuData) {
getdisplay().print(sValue); // Real value as formated string
printBoatValue(sValue, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string
} else {
getdisplay().print(sValueOld[i]); // Old value as formated string
printBoatValue(sValueOld[i], valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Old value as formated string
}
if (valid) { // Save value for hold function
@@ -112,8 +112,7 @@ public:
useSimuData = commonData->config->getBool(commonData->config->useSimuData);
holdValues = commonData->config->getBool(commonData->config->holdvalues);
flashLED = commonData->config->getString(commonData->config->flashLED);
backlightMode = commonData->config->getString(commonData->config->backlight);
tempFormat = commonData->config->getString(commonData->config->tempFormat); // [K|°C|°F]
smallDecimals = commonData->config->getBool(commonData->config->smallDecimals);
}
virtual void setupKeys()
@@ -239,9 +238,11 @@ public:
displaySetPartialWindow(0, 0, width, height); // Set partial update
if (dataChart[0]) { // Check only if dataChart object exists at all
if (!dataChart[0]->isValid()) {
dataChart[0]->init(); // try late initialization if chart object could not be properly initialized earlier due to missing boat data
}
}
if (pageMode == VAL_CHART) {
if (dataChart[0]) {
+11 -14
View File
@@ -213,6 +213,10 @@ static unsigned char front_bits[] PROGMEM = {
class PageWind : public Page
{
static constexpr int8_t LEFT = 0;
static constexpr int8_t CENTER = 1;
static constexpr int8_t RIGHT = 2;
bool keylock = false; // Keylock
int8_t lp = 80; // Pointer length
char mode = 'N'; // page mode (N)ormal | (L)ens | e(X)ample
@@ -306,11 +310,10 @@ public:
static String unit2old = "";
// Get config data
String lengthformat = config->getString(config->lengthFormat);
bool simulation = config->getBool(config->useSimuData);
bool holdvalues = config->getBool(config->holdvalues);
String flashLED = config->getString(config->flashLED);
String backlightMode = config->getString(config->backlight);
bool smallDecimals = config->getBool(config->smallDecimals);
GwApi::BoatValue *bvalue1; // Value 1 for speed on top
GwApi::BoatValue *bvalue2; // Value 2 for angle on bottom
@@ -512,17 +515,14 @@ public:
}
// Wind speed as decimal number
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
getdisplay().setCursor(150, 250);
if (holdvalues == false) {
getdisplay().print(svalue1);
printBoatValue(svalue1, 260, 250, RIGHT, 26, smallDecimals);
} else {
getdisplay().print(svalue1old);
printBoatValue(svalue1old, 260, 250, RIGHT, 26, smallDecimals);
}
// unit
getdisplay().setFont(&Ubuntu_Bold8pt8b);
getdisplay().setCursor(220, 265);
getdisplay().print("kts");
drawTextRalign(260, 265, unit1);
}
else {
// Normal mode
@@ -584,17 +584,14 @@ public:
}
// Wind speed as decimal number
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
getdisplay().setCursor(150, 250);
if (holdvalues == false) {
getdisplay().print(svalue1);
printBoatValue(svalue1, 260, 250, RIGHT, 26, smallDecimals);
} else {
getdisplay().print(svalue1old);
printBoatValue(svalue1old, 260, 250, RIGHT, 26, smallDecimals);
}
// unit
getdisplay().setFont(&Ubuntu_Bold8pt8b);
getdisplay().setCursor(220, 265);
getdisplay().print("kts");
drawTextRalign(260, 265, unit1);
// Wind pointer (angle)
if (bvalue2->valid or simulation) {
+18 -20
View File
@@ -28,8 +28,13 @@ static unsigned char ship_bits[] PROGMEM = {
class PageXTETrack : public Page
{
static constexpr int8_t LEFT = 0;
static constexpr int8_t CENTER = 1;
static constexpr int8_t RIGHT = 2;
bool simulation = false;
bool holdvalues = false;
bool smallDecimals = false;
public:
PageXTETrack(CommonData &common){
@@ -37,6 +42,7 @@ class PageXTETrack : public Page
common.logger->logDebug(GwLog::LOG,"Instantiate PageXTETrack");
simulation = common.config->getBool(common.config->useSimuData);
holdvalues = common.config->getBool(common.config->holdvalues);
smallDecimals = common.config->getBool(common.config->smallDecimals);
}
void drawSegment(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1,
@@ -95,44 +101,33 @@ class PageXTETrack : public Page
// descriptions
getdisplay().setFont(&Ubuntu_Bold8pt8b);
getdisplay().setCursor(50, 188);
getdisplay().setCursor(30, 188);
getdisplay().print("Cross-track error");
getdisplay().setCursor(270, 188);
getdisplay().setCursor(290, 188);
getdisplay().print("Track");
getdisplay().setCursor(45, 275);
getdisplay().setCursor(25, 275);
getdisplay().print("Distance to waypoint");
getdisplay().setCursor(260, 275);
getdisplay().print("Bearing");
// values
getdisplay().setFont(&DSEG7Classic_BoldItalic30pt7b);
int16_t x, y;
uint16_t w, h;
GwApi::BoatValue *bv_xte = pageData.values[0]; // XTE
String sval_xte = formatValue(bv_xte, *commonData).svalue;
displayGetTextBounds(sval_xte, 0, 0, &x, &y, &w, &h);
getdisplay().setCursor(160-w, 170);
getdisplay().print(sval_xte);
// printBoatValue(sval_xte, 160, 170, RIGHT, 30, smallDecimals);
printBoatValue(sval_xte, 20, 170, LEFT, 30, smallDecimals);
GwApi::BoatValue *bv_cog = pageData.values[1]; // COG
String sval_cog = formatValue(bv_cog, *commonData).svalue;
displayGetTextBounds(sval_cog, 0, 0, &x, &y, &w, &h);
getdisplay().setCursor(360-w, 170);
getdisplay().print(sval_cog);
printBoatValue(sval_cog, 380, 170, RIGHT, 30, smallDecimals);
GwApi::BoatValue *bv_dtw = pageData.values[2]; // DTW
String sval_dtw = formatValue(bv_dtw, *commonData).svalue;
displayGetTextBounds(sval_dtw, 0, 0, &x, &y, &w, &h);
getdisplay().setCursor(160-w, 257);
getdisplay().print(sval_dtw);
// printBoatValue(sval_dtw, 160, 257, RIGHT, 30, smallDecimals);
printBoatValue(sval_dtw, 40, 257, LEFT, 30, smallDecimals);
GwApi::BoatValue *bv_btw = pageData.values[3]; // BTW
String sval_btw = formatValue(bv_btw, *commonData).svalue;
displayGetTextBounds(sval_btw, 0, 0, &x, &y, &w, &h);
getdisplay().setCursor(360-w, 257);
getdisplay().print(sval_btw);
printBoatValue(sval_btw, 360, 257, RIGHT, 30, smallDecimals);
bool valid = bv_cog->valid && bv_btw->valid;
@@ -148,6 +143,9 @@ class PageXTETrack : public Page
sval_wpname = "Tonne 122";
}
int16_t x, y;
uint16_t w, h;
getdisplay().setFont(&Ubuntu_Bold10pt8b);
displayGetTextBounds(sval_wpname, 0, 150, &x, &y, &w, &h);
// TODO if text don't fix use smaller font size.