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