Adapt barograph page to current code
This commit is contained in:
parent
4513f9d7b0
commit
c6df6eac56
|
@ -1,10 +1,18 @@
|
||||||
#ifdef BOARD_OBP60S3
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
#if defined BOARD_OBP60S3 || defined BOARD_OBP40S3
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Barograph WIP
|
||||||
|
* - Zoom feature
|
||||||
|
* - Saves data in FRAM if available
|
||||||
|
*/
|
||||||
|
|
||||||
#include "Pagedata.h"
|
#include "Pagedata.h"
|
||||||
#include "OBP60Extensions.h"
|
#include "OBP60Extensions.h"
|
||||||
|
|
||||||
class PageBarograph : public Page{
|
class PageBarograph : public Page
|
||||||
|
{
|
||||||
|
private:
|
||||||
bool keylock = false;
|
bool keylock = false;
|
||||||
bool has_fram = false;
|
bool has_fram = false;
|
||||||
String flashLED;
|
String flashLED;
|
||||||
|
@ -61,11 +69,12 @@ class PageBarograph : public Page{
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PageBarograph(CommonData &common){
|
PageBarograph(CommonData &common): Page(common)
|
||||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageBarograph");
|
{
|
||||||
|
logger->logDebug(GwLog::LOG, "Instantiate PageBarograph");
|
||||||
|
|
||||||
// Get config data
|
// Get config data
|
||||||
flashLED = common.config->getString(common.config->flashLED);
|
useenvsensor = config->getString(common.config->useEnvSensor);
|
||||||
useenvsensor = common.config->getString(common.config->useEnvSensor);
|
|
||||||
// possible values for internal sensor
|
// possible values for internal sensor
|
||||||
static std::vector<String> sensorList = {
|
static std::vector<String> sensorList = {
|
||||||
"BME280", "BMP280", "BMP180", "BMP085", "HTU21", "SHT21"
|
"BME280", "BMP280", "BMP180", "BMP085", "HTU21", "SHT21"
|
||||||
|
@ -80,7 +89,7 @@ class PageBarograph : public Page{
|
||||||
loadData(); // initial load
|
loadData(); // initial load
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int handleKey(int key) {
|
int handleKey(int key) {
|
||||||
if (key == 1) {
|
if (key == 1) {
|
||||||
// zoom in
|
// zoom in
|
||||||
if (zoomindex > 0) {
|
if (zoomindex > 0) {
|
||||||
|
@ -102,33 +111,36 @@ class PageBarograph : public Page{
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void displayPage(CommonData &commonData, PageData &pageData){
|
void displayNew(PageData &pageData) {
|
||||||
GwLog *logger=commonData.logger;
|
#ifdef BOARD_OBP60S3
|
||||||
|
// Clear optical warning
|
||||||
// Optical warning by limit violation (unused)
|
if (flashLED == "Limit Violation") {
|
||||||
if (String(flashLED) == "Limit Violation") {
|
|
||||||
setBlinkingLED(false);
|
setBlinkingLED(false);
|
||||||
setFlashLED(false);
|
setFlashLED(false);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
int displayPage(PageData &pageData) {
|
||||||
|
|
||||||
// Logging boat values
|
// Logging boat values
|
||||||
LOG_DEBUG(GwLog::LOG,"Drawing at PageBarograph");
|
logger->logDebug(GwLog::LOG, "Drawing at PageBarograph");
|
||||||
|
|
||||||
// Draw page
|
// Draw page
|
||||||
//***********************************************************
|
//***********************************************************
|
||||||
|
|
||||||
// Set display in partial refresh mode
|
// Set display in partial refresh mode
|
||||||
getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update
|
epd->setPartialWindow(0, 0, epd->width(), epd->height()); // Set partial update
|
||||||
|
|
||||||
// Frames
|
// Frames
|
||||||
getdisplay().fillRect(0, 75, 400, 2, commonData.fgcolor); // fillRect: x, y, w, h
|
epd->fillRect(0, 75, 400, 2, commonData->fgcolor); // fillRect: x, y, w, h
|
||||||
getdisplay().fillRect(130, 20, 2, 55, commonData.fgcolor);
|
epd->fillRect(130, 20, 2, 55, commonData->fgcolor);
|
||||||
getdisplay().fillRect(270, 20, 2, 55, commonData.fgcolor);
|
epd->fillRect(270, 20, 2, 55, commonData->fgcolor);
|
||||||
getdisplay().fillRect(325, 20, 2, 55, commonData.fgcolor);
|
epd->fillRect(325, 20, 2, 55, commonData->fgcolor);
|
||||||
|
|
||||||
getdisplay().setTextColor(commonData.fgcolor);
|
epd->setTextColor(commonData->fgcolor);
|
||||||
|
|
||||||
getdisplay().setFont(&Ubuntu_Bold8pt7b);
|
epd->setFont(&Ubuntu_Bold8pt8b);
|
||||||
if (source == 'I') {
|
if (source == 'I') {
|
||||||
drawTextCenter(360, 40, useenvsensor);
|
drawTextCenter(360, 40, useenvsensor);
|
||||||
} else {
|
} else {
|
||||||
|
@ -156,9 +168,9 @@ class PageBarograph : public Page{
|
||||||
drawTextCenter(360, 62, fmt);
|
drawTextCenter(360, 62, fmt);
|
||||||
|
|
||||||
// Current measurement
|
// Current measurement
|
||||||
getdisplay().setFont(&Ubuntu_Bold16pt7b);
|
epd->setFont(&Ubuntu_Bold16pt8b);
|
||||||
drawTextCenter(200, 40, String(commonData.data.airPressure / 100, 1));
|
drawTextCenter(200, 40, String(commonData->data.airPressure / 100, 1));
|
||||||
getdisplay().setFont(&Ubuntu_Bold8pt7b);
|
epd->setFont(&Ubuntu_Bold8pt8b);
|
||||||
drawTextCenter(200, 62, "hPa"); // Unit
|
drawTextCenter(200, 62, "hPa"); // Unit
|
||||||
|
|
||||||
// Diagram
|
// Diagram
|
||||||
|
@ -168,20 +180,20 @@ class PageBarograph : public Page{
|
||||||
const int w = 7 * 48;
|
const int w = 7 * 48;
|
||||||
const int h = 180;
|
const int h = 180;
|
||||||
|
|
||||||
// getdisplay().drawRect(x0 - w, y0 - h, w, h, commonData.fgcolor);
|
// epd->drawRect(x0 - w, y0 - h, w, h, commonData->fgcolor);
|
||||||
|
|
||||||
// x-axis are hours
|
// x-axis are hours
|
||||||
for (int i = 1; i <= 6; i++) {
|
for (int i = 1; i <= 6; i++) {
|
||||||
String label = String(-1 * zoom[zoomindex] * i);
|
String label = String(-1 * zoom[zoomindex] * i);
|
||||||
getdisplay().drawLine(x0 - i * xstep, y0, x0 - i * xstep, y0 - h, commonData.fgcolor);
|
epd->drawLine(x0 - i * xstep, y0, x0 - i * xstep, y0 - h, commonData->fgcolor);
|
||||||
drawTextCenter(x0 - i * xstep, y0 - 10, label);
|
drawTextCenter(x0 - i * xstep, y0 - 10, label);
|
||||||
}
|
}
|
||||||
|
|
||||||
// y-axis
|
// y-axis
|
||||||
getdisplay().drawLine(x0 + 5, y0, x0 + 5, y0 - h, commonData.fgcolor); // drawLine: x1, y1, x2, y2
|
epd->drawLine(x0 + 5, y0, x0 + 5, y0 - h, commonData->fgcolor); // drawLine: x1, y1, x2, y2
|
||||||
getdisplay().drawLine(x0 - w, y0, x0 - w, y0 - h, commonData.fgcolor);
|
epd->drawLine(x0 - w, y0, x0 - w, y0 - h, commonData->fgcolor);
|
||||||
getdisplay().drawLine(x0 - w - 5, y0, x0 - w - 5, y0 - h, commonData.fgcolor);
|
epd->drawLine(x0 - w - 5, y0, x0 - w - 5, y0 - h, commonData->fgcolor);
|
||||||
getdisplay().drawLine(x0, y0, x0, y0 - h, commonData.fgcolor);
|
epd->drawLine(x0, y0, x0, y0 - h, commonData->fgcolor);
|
||||||
|
|
||||||
int16_t dy = 9; // px for one hPa
|
int16_t dy = 9; // px for one hPa
|
||||||
int16_t y = y0;
|
int16_t y = y0;
|
||||||
|
@ -189,21 +201,19 @@ class PageBarograph : public Page{
|
||||||
while (y >= y0 - h) {
|
while (y >= y0 - h) {
|
||||||
if (y % scalestep == 0) {
|
if (y % scalestep == 0) {
|
||||||
// big step, show label and long line
|
// big step, show label and long line
|
||||||
getdisplay().setCursor(x0 + 10, y + 5);
|
epd->setCursor(x0 + 10, y + 5);
|
||||||
getdisplay().print(String(ys));
|
epd->print(String(ys));
|
||||||
getdisplay().drawLine(x0 + 5, y, x0 - w - 5, y, commonData.fgcolor);
|
epd->drawLine(x0 + 5, y, x0 - w - 5, y, commonData->fgcolor);
|
||||||
} else {
|
} else {
|
||||||
// small step, only short lines left and right
|
// small step, only short lines left and right
|
||||||
getdisplay().drawLine(x0 + 5, y, x0, y, commonData.fgcolor);
|
epd->drawLine(x0 + 5, y, x0, y, commonData->fgcolor);
|
||||||
getdisplay().drawLine(x0 - w - 5, y, x0 - w, y, commonData.fgcolor);
|
epd->drawLine(x0 - w - 5, y, x0 - w, y, commonData->fgcolor);
|
||||||
}
|
}
|
||||||
y -= dy;
|
y -= dy;
|
||||||
ys += 1;
|
ys += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update display
|
return PAGE_UPDATE;
|
||||||
getdisplay().nextPage(); // Partial update (fast)
|
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,10 @@ Compile result for OBP40 (CrowPanel 4.2):
|
||||||
|
|
||||||
/workspace/esp32-nmea2000-obp60/.pio/build/obp40_s3/obp40_s3-all.bin, ready to flash to offset 0x0000
|
/workspace/esp32-nmea2000-obp60/.pio/build/obp40_s3/obp40_s3-all.bin, ready to flash to offset 0x0000
|
||||||
|
|
||||||
|
Compilation issues
|
||||||
|
------------------
|
||||||
|
? Error while linking: "undefined reference to `registerPageXXX'"
|
||||||
|
: Check if the required page is enabled for current board/environment: #if defined ...
|
||||||
|
|
||||||
Debugging tool
|
Debugging tool
|
||||||
--------------
|
--------------
|
||||||
|
|
|
@ -1372,6 +1372,7 @@
|
||||||
"list": [
|
"list": [
|
||||||
"AIS",
|
"AIS",
|
||||||
"Anchor",
|
"Anchor",
|
||||||
|
"Barograph",
|
||||||
"BME280",
|
"BME280",
|
||||||
"Battery",
|
"Battery",
|
||||||
"Battery2",
|
"Battery2",
|
||||||
|
@ -1682,6 +1683,7 @@
|
||||||
"list": [
|
"list": [
|
||||||
"AIS",
|
"AIS",
|
||||||
"Anchor",
|
"Anchor",
|
||||||
|
"Barograph",
|
||||||
"BME280",
|
"BME280",
|
||||||
"Battery",
|
"Battery",
|
||||||
"Battery2",
|
"Battery2",
|
||||||
|
@ -1983,6 +1985,7 @@
|
||||||
"list": [
|
"list": [
|
||||||
"AIS",
|
"AIS",
|
||||||
"Anchor",
|
"Anchor",
|
||||||
|
"Barograph",
|
||||||
"BME280",
|
"BME280",
|
||||||
"Battery",
|
"Battery",
|
||||||
"Battery2",
|
"Battery2",
|
||||||
|
@ -2275,6 +2278,7 @@
|
||||||
"list": [
|
"list": [
|
||||||
"AIS",
|
"AIS",
|
||||||
"Anchor",
|
"Anchor",
|
||||||
|
"Barograph",
|
||||||
"BME280",
|
"BME280",
|
||||||
"Battery",
|
"Battery",
|
||||||
"Battery2",
|
"Battery2",
|
||||||
|
@ -2558,6 +2562,7 @@
|
||||||
"list": [
|
"list": [
|
||||||
"AIS",
|
"AIS",
|
||||||
"Anchor",
|
"Anchor",
|
||||||
|
"Barograph",
|
||||||
"BME280",
|
"BME280",
|
||||||
"Battery",
|
"Battery",
|
||||||
"Battery2",
|
"Battery2",
|
||||||
|
@ -2832,6 +2837,7 @@
|
||||||
"list": [
|
"list": [
|
||||||
"AIS",
|
"AIS",
|
||||||
"Anchor",
|
"Anchor",
|
||||||
|
"Barograph",
|
||||||
"BME280",
|
"BME280",
|
||||||
"Battery",
|
"Battery",
|
||||||
"Battery2",
|
"Battery2",
|
||||||
|
@ -3097,6 +3103,7 @@
|
||||||
"list": [
|
"list": [
|
||||||
"AIS",
|
"AIS",
|
||||||
"Anchor",
|
"Anchor",
|
||||||
|
"Barograph",
|
||||||
"BME280",
|
"BME280",
|
||||||
"Battery",
|
"Battery",
|
||||||
"Battery2",
|
"Battery2",
|
||||||
|
@ -3353,6 +3360,7 @@
|
||||||
"list": [
|
"list": [
|
||||||
"AIS",
|
"AIS",
|
||||||
"Anchor",
|
"Anchor",
|
||||||
|
"Barograph",
|
||||||
"BME280",
|
"BME280",
|
||||||
"Battery",
|
"Battery",
|
||||||
"Battery2",
|
"Battery2",
|
||||||
|
@ -3600,6 +3608,7 @@
|
||||||
"list": [
|
"list": [
|
||||||
"AIS",
|
"AIS",
|
||||||
"Anchor",
|
"Anchor",
|
||||||
|
"Barograph",
|
||||||
"BME280",
|
"BME280",
|
||||||
"Battery",
|
"Battery",
|
||||||
"Battery2",
|
"Battery2",
|
||||||
|
@ -3838,6 +3847,7 @@
|
||||||
"list": [
|
"list": [
|
||||||
"AIS",
|
"AIS",
|
||||||
"Anchor",
|
"Anchor",
|
||||||
|
"Barograph",
|
||||||
"BME280",
|
"BME280",
|
||||||
"Battery",
|
"Battery",
|
||||||
"Battery2",
|
"Battery2",
|
||||||
|
|
Loading…
Reference in New Issue