Preparation for upcoming alarm functionality
This commit is contained in:
parent
58adea1da7
commit
e43199b05d
|
@ -350,6 +350,49 @@ void fillPoly4(const std::vector<Point>& p4, uint16_t color) {
|
|||
getdisplay().fillTriangle(p4[0].x, p4[0].y, p4[2].x, p4[2].y, p4[3].x, p4[3].y, color);
|
||||
}
|
||||
|
||||
// Split string into words, whitespace separated
|
||||
std::vector<String> split(const String &s) {
|
||||
std::vector<String> words;
|
||||
String word = "";
|
||||
for (size_t i = 0; i < s.length(); i++) {
|
||||
if (s[i] == ' ' || s[i] == '\t' || s[i] == '\r' || s[i] == '\n') {
|
||||
if (word.length() > 0) {
|
||||
words.push_back(word);
|
||||
word = "";
|
||||
}
|
||||
} else {
|
||||
word += s[i];
|
||||
}
|
||||
}
|
||||
if (word.length() > 0) {
|
||||
words.push_back(word);
|
||||
}
|
||||
return words;
|
||||
}
|
||||
|
||||
// Wordwrap single line, monospaced font
|
||||
std::vector<String> wordwrap(String &line, uint16_t maxwidth) {
|
||||
std::vector<String> lines;
|
||||
std::vector<String> words = split(line);
|
||||
String currentLine = "";
|
||||
for (const auto& word : words) {
|
||||
if (currentLine.length() + word.length() + 1 > maxwidth) {
|
||||
if (currentLine.length() > 0) {
|
||||
lines.push_back(currentLine);
|
||||
currentLine = "";
|
||||
}
|
||||
}
|
||||
if (currentLine.length() > 0) {
|
||||
currentLine += " ";
|
||||
}
|
||||
currentLine += word;
|
||||
}
|
||||
if (currentLine.length() > 0) {
|
||||
lines.push_back(currentLine);
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
// Draw centered text
|
||||
void drawTextCenter(int16_t cx, int16_t cy, String text) {
|
||||
int16_t x1, y1;
|
||||
|
@ -595,6 +638,47 @@ void displayFooter(CommonData &commonData) {
|
|||
#endif
|
||||
}
|
||||
|
||||
// Alarm overlay, to be drawn as very last draw operation
|
||||
void displayAlarm(CommonData &commonData) {
|
||||
|
||||
const uint16_t x = 50; // overlay area
|
||||
const uint16_t y = 100;
|
||||
const uint16_t w = 300;
|
||||
const uint16_t h = 150;
|
||||
|
||||
getdisplay().setFont(&Atari16px);
|
||||
getdisplay().setTextColor(commonData.fgcolor);
|
||||
|
||||
// overlay
|
||||
getdisplay().drawRect(x, y, w, h, commonData.fgcolor);
|
||||
getdisplay().fillRect(x + 1, y + 1, w - 1, h - 1, commonData.bgcolor);
|
||||
getdisplay().drawRect(x + 3, y + 3, w - 5, h - 5, commonData.fgcolor);
|
||||
|
||||
// exclamation icon in left top corner
|
||||
getdisplay().drawXBitmap(x + 16, y + 16, exclamation_bits, exclamation_width, exclamation_height, commonData.fgcolor);
|
||||
|
||||
// title
|
||||
getdisplay().setCursor(x + 64, y + 30);
|
||||
getdisplay().print("A L A R M");
|
||||
getdisplay().setCursor(x + 64, y + 48);
|
||||
getdisplay().print("#" + commonData.alarm.id);
|
||||
getdisplay().print(" from ");
|
||||
getdisplay().print(commonData.alarm.source);
|
||||
|
||||
// message, but maximum 4 lines
|
||||
std::vector<String> lines = wordwrap (commonData.alarm.message, w - 16 - 8 / 8);
|
||||
int n = 0;
|
||||
for (const auto& l : lines) {
|
||||
getdisplay().setCursor(x + 16, y + 80 + n);
|
||||
getdisplay().print(l);
|
||||
n += 16;
|
||||
if (n > 64) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
drawTextCenter(x + w / 2, y + h - 16, "Press button 1 to dismiss alarm");
|
||||
}
|
||||
|
||||
// Sunset und sunrise calculation
|
||||
SunData calcSunsetSunrise(double time, double date, double latitude, double longitude, float timezone){
|
||||
SunData returnset;
|
||||
|
|
|
@ -67,6 +67,11 @@ GxEPD2_BW<GxEPD2_420_GYE042A87, GxEPD2_420_GYE042A87::HEIGHT> & getdisplay();
|
|||
GxEPD2_BW<GxEPD2_420_SE0420NQ04, GxEPD2_420_SE0420NQ04::HEIGHT> & getdisplay();
|
||||
#endif
|
||||
|
||||
// Page display return values
|
||||
#define PAGE_OK 0 // all ok, do nothing
|
||||
#define PAGE_UPDATE 1 // page wants display to update
|
||||
#define PAGE_HIBERNATE 2 // page wants displey to hibernate
|
||||
|
||||
struct Point {
|
||||
double x;
|
||||
double y;
|
||||
|
@ -107,6 +112,7 @@ void displayTrendLow(int16_t x, int16_t y, uint16_t size, uint16_t color);
|
|||
|
||||
void displayHeader(CommonData &commonData, GwApi::BoatValue *date, GwApi::BoatValue *time, GwApi::BoatValue *hdop); // Draw display header
|
||||
void displayFooter(CommonData &commonData);
|
||||
void displayAlarm(CommonData &commonData);
|
||||
|
||||
SunData calcSunsetSunrise(double time, double date, double latitude, double longitude, float timezone); // Calulate sunset and sunrise
|
||||
SunData calcSunsetSunriseRTC(struct tm *rtctime, double latitude, double longitude, float timezone);
|
||||
|
@ -152,12 +158,12 @@ static unsigned char fram_bits[] PROGMEM = {
|
|||
0xff, 0xff, 0xf8, 0x1f, 0xf8, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x1f,
|
||||
0xf8, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x1f };
|
||||
|
||||
static unsigned char ap_bits[] = {
|
||||
static unsigned char ap_bits[] PROGMEM = {
|
||||
0xe0, 0x03, 0x18, 0x0c, 0x04, 0x10, 0xc2, 0x21, 0x30, 0x06, 0x08, 0x08,
|
||||
0xc0, 0x01, 0x20, 0x02, 0x00, 0x00, 0x80, 0x00, 0xc0, 0x01, 0xc0, 0x01,
|
||||
0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00 };
|
||||
|
||||
static unsigned char dish_bits[] PROGMEM= {
|
||||
static unsigned char dish_bits[] PROGMEM = {
|
||||
0x3c, 0x00, 0x42, 0x18, 0xfa, 0x1b, 0x02, 0x04, 0x02, 0x0a, 0x02, 0x09,
|
||||
0x82, 0x08, 0x06, 0x0a, 0x0e, 0x1b, 0x9c, 0x2b, 0x38, 0x2b, 0x74, 0x20,
|
||||
0xec, 0x1f, 0x1c, 0x00, 0xf4, 0x00, 0xfe, 0x03 };
|
||||
|
|
|
@ -20,7 +20,7 @@ class PageBME280 : public Page
|
|||
return key;
|
||||
}
|
||||
|
||||
virtual void displayPage(PageData &pageData){
|
||||
int displayPage(PageData &pageData){
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
|
@ -176,9 +176,7 @@ class PageBME280 : public Page
|
|||
// Show bus data
|
||||
getdisplay().print(svalue3); // Real value as formated string
|
||||
|
||||
// Update display
|
||||
getdisplay().nextPage(); // Partial update (fast)
|
||||
|
||||
return PAGE_UPDATE;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ class PageBattery : public Page
|
|||
return key;
|
||||
}
|
||||
|
||||
virtual void displayPage(PageData &pageData){
|
||||
int displayPage(PageData &pageData){
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
|
@ -288,9 +288,7 @@ class PageBattery : public Page
|
|||
getdisplay().print("---"); // No sensor data (sensor is off)
|
||||
}
|
||||
|
||||
// Update display
|
||||
getdisplay().nextPage(); // Partial update (fast)
|
||||
|
||||
return PAGE_UPDATE;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ public:
|
|||
return key;
|
||||
}
|
||||
|
||||
virtual void displayPage(PageData &pageData)
|
||||
int displayPage(PageData &pageData)
|
||||
{
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
@ -334,8 +334,7 @@ public:
|
|||
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
||||
getdisplay().print("W");
|
||||
|
||||
// Update display
|
||||
getdisplay().nextPage(); // Partial update (fast)
|
||||
return PAGE_UPDATE;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ bool homevalid = false; // homelat and homelon are valid
|
|||
return key;
|
||||
}
|
||||
|
||||
virtual void displayPage(PageData &pageData)
|
||||
int displayPage(PageData &pageData)
|
||||
{
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
@ -162,7 +162,7 @@ bool homevalid = false; // homelat and homelon are valid
|
|||
}
|
||||
|
||||
// Logging boat values
|
||||
if (bvalue1 == NULL) return;
|
||||
if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement?
|
||||
LOG_DEBUG(GwLog::LOG,"Drawing at PageClock, %s:%f, %s:%f", name1.c_str(), value1, name2.c_str(), value2);
|
||||
|
||||
// Draw page
|
||||
|
@ -438,9 +438,7 @@ bool homevalid = false; // homelat and homelon are valid
|
|||
getdisplay().fillCircle(200, 150, startwidth + 6, commonData->bgcolor);
|
||||
getdisplay().fillCircle(200, 150, startwidth + 4, commonData->fgcolor);
|
||||
|
||||
// Update display
|
||||
getdisplay().nextPage(); // Partial update (fast)
|
||||
|
||||
return PAGE_UPDATE;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ class PageCompass : public Page
|
|||
return key;
|
||||
}
|
||||
|
||||
virtual void displayPage(PageData &pageData){
|
||||
int displayPage(PageData &pageData){
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
|
@ -104,7 +104,7 @@ class PageCompass : public Page
|
|||
setFlashLED(false);
|
||||
}
|
||||
|
||||
if (bvalue == NULL) return;
|
||||
if (bvalue == NULL) return PAGE_OK; // WTF why this statement?
|
||||
|
||||
//***********************************************************
|
||||
|
||||
|
@ -235,12 +235,11 @@ class PageCompass : public Page
|
|||
// if ( x_test > 390)
|
||||
// x_test = 320;
|
||||
|
||||
// Update display
|
||||
getdisplay().nextPage(); // Partial update (fast)
|
||||
|
||||
};
|
||||
|
||||
return PAGE_UPDATE;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
static Page *createPage(CommonData &common){
|
||||
return new PageCompass(common);
|
||||
}/**
|
||||
|
|
|
@ -20,7 +20,7 @@ public:
|
|||
return key;
|
||||
}
|
||||
|
||||
virtual void displayPage(PageData &pageData){
|
||||
int displayPage(PageData &pageData){
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
|
@ -84,7 +84,7 @@ public:
|
|||
}
|
||||
|
||||
// Logging boat values
|
||||
if (bvalue1 == NULL) return;
|
||||
if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement?
|
||||
LOG_DEBUG(GwLog::LOG,"Drawing at PageDST810, %s: %f, %s: %f, %s: %f, %s: %f", name1.c_str(), value1, name2.c_str(), value2, name3.c_str(), value3, name4.c_str(), value4);
|
||||
|
||||
// Draw page
|
||||
|
@ -242,9 +242,7 @@ public:
|
|||
unit4old = unit4; // Save the old unit
|
||||
}
|
||||
|
||||
// Update display
|
||||
getdisplay().nextPage(); // Partial update (fast)
|
||||
|
||||
return PAGE_UPDATE;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ class PageFluid : public Page
|
|||
commonData->logger->logDebug(GwLog::LOG,"New PageFluid: fluidtype=%d", fluidtype);
|
||||
}
|
||||
|
||||
virtual void displayPage(PageData &pageData){
|
||||
int displayPage(PageData &pageData){
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
|
@ -252,9 +252,7 @@ class PageFluid : public Page
|
|||
getdisplay().fillCircle(c.x, c.y, 6, commonData->bgcolor);
|
||||
}
|
||||
|
||||
// Update display
|
||||
getdisplay().nextPage(); // Partial update (fast)
|
||||
|
||||
return PAGE_UPDATE;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ class PageFourValues : public Page
|
|||
return key;
|
||||
}
|
||||
|
||||
virtual void displayPage(PageData &pageData){
|
||||
int displayPage(PageData &pageData){
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
|
@ -89,7 +89,7 @@ class PageFourValues : public Page
|
|||
}
|
||||
|
||||
// Logging boat values
|
||||
if (bvalue1 == NULL) return;
|
||||
if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement?
|
||||
LOG_DEBUG(GwLog::LOG,"Drawing at PageFourValues, %s: %f, %s: %f, %s: %f, %s: %f", name1.c_str(), value1, name2.c_str(), value2, name3.c_str(), value3, name4.c_str(), value4);
|
||||
|
||||
// Draw page
|
||||
|
@ -287,9 +287,7 @@ class PageFourValues : public Page
|
|||
unit4old = unit4; // Save the old unit
|
||||
}
|
||||
|
||||
// Update display
|
||||
getdisplay().nextPage(); // Partial update (fast)
|
||||
|
||||
return PAGE_UPDATE;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ class PageFourValues2 : public Page
|
|||
return key;
|
||||
}
|
||||
|
||||
virtual void displayPage(PageData &pageData){
|
||||
int displayPage(PageData &pageData){
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
|
@ -89,7 +89,7 @@ class PageFourValues2 : public Page
|
|||
}
|
||||
|
||||
// Logging boat values
|
||||
if (bvalue1 == NULL) return;
|
||||
if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement?
|
||||
LOG_DEBUG(GwLog::LOG,"Drawing at PageFourValues2, %s: %f, %s: %f, %s: %f, %s: %f", name1.c_str(), value1, name2.c_str(), value2, name3.c_str(), value3, name4.c_str(), value4);
|
||||
|
||||
// Draw page
|
||||
|
@ -287,9 +287,7 @@ class PageFourValues2 : public Page
|
|||
unit4old = unit4; // Save the old unit
|
||||
}
|
||||
|
||||
// Update display
|
||||
getdisplay().nextPage(); // Partial update (fast)
|
||||
|
||||
return PAGE_UPDATE;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ public:
|
|||
return key;
|
||||
}
|
||||
|
||||
virtual void displayPage(PageData &pageData)
|
||||
int displayPage(PageData &pageData)
|
||||
{
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
@ -203,8 +203,7 @@ public:
|
|||
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
||||
getdisplay().print("W");
|
||||
|
||||
// Update display
|
||||
getdisplay().nextPage(); // Partial update (fast)
|
||||
return PAGE_UPDATE;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ public:
|
|||
return key;
|
||||
}
|
||||
|
||||
virtual void displayPage(PageData &pageData)
|
||||
int displayPage(PageData &pageData)
|
||||
{
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
@ -206,9 +206,7 @@ public:
|
|||
getdisplay().print("No sensor data"); // Info missing sensor
|
||||
}
|
||||
|
||||
// Update display
|
||||
getdisplay().nextPage(); // Partial update (fast)
|
||||
|
||||
return PAGE_UPDATE;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ class PageOneValue : public Page
|
|||
return key;
|
||||
}
|
||||
|
||||
virtual void displayPage(PageData &pageData){
|
||||
int displayPage(PageData &pageData){
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
|
@ -53,7 +53,7 @@ class PageOneValue : public Page
|
|||
}
|
||||
|
||||
// Logging boat values
|
||||
if (bvalue1 == NULL) return;
|
||||
if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement?
|
||||
LOG_DEBUG(GwLog::LOG,"Drawing at PageOneValue, %s: %f", name1.c_str(), value1);
|
||||
|
||||
// Draw page
|
||||
|
@ -104,9 +104,7 @@ class PageOneValue : public Page
|
|||
unit1old = unit1; // Save the old unit
|
||||
}
|
||||
|
||||
// Update display
|
||||
getdisplay().nextPage(); // Partial update (fast)
|
||||
|
||||
return PAGE_UPDATE;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ public:
|
|||
return key;
|
||||
}
|
||||
|
||||
virtual void displayPage(PageData &pageData){
|
||||
int displayPage(PageData &pageData){
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
|
@ -109,7 +109,7 @@ public:
|
|||
}
|
||||
|
||||
// Logging boat values
|
||||
if (bvalue1 == NULL) return;
|
||||
if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement?
|
||||
LOG_DEBUG(GwLog::LOG,"Drawing at PageRollPitch, %s:%f, %s:%f", name1.c_str(), value1, name2.c_str(), value2);
|
||||
|
||||
// Draw page
|
||||
|
@ -305,9 +305,7 @@ public:
|
|||
getdisplay().print("No sensor data"); // Info missing sensor
|
||||
}
|
||||
|
||||
// Update display
|
||||
getdisplay().nextPage(); // Partial update (fast)
|
||||
|
||||
return PAGE_UPDATE;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ public:
|
|||
return key;
|
||||
}
|
||||
|
||||
virtual void displayPage(PageData &pageData){
|
||||
int displayPage(PageData &pageData){
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
|
@ -67,7 +67,7 @@ public:
|
|||
}
|
||||
|
||||
// Logging boat values
|
||||
if (bvalue1 == NULL) return;
|
||||
if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement?
|
||||
LOG_DEBUG(GwLog::LOG,"Drawing at PageRudderPosition, %s:%f", name1.c_str(), value1);
|
||||
|
||||
// Draw page
|
||||
|
@ -207,8 +207,7 @@ public:
|
|||
getdisplay().fillCircle(200, 150, startwidth + 6, commonData->bgcolor);
|
||||
getdisplay().fillCircle(200, 150, startwidth + 4, commonData->fgcolor);
|
||||
|
||||
// Update display
|
||||
getdisplay().nextPage(); // Partial update (fast)
|
||||
return PAGE_UPDATE;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ class PageSixValues : public Page
|
|||
return key;
|
||||
}
|
||||
|
||||
virtual void displayPage(PageData &pageData){
|
||||
int displayPage(PageData &pageData){
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
|
@ -71,7 +71,7 @@ class PageSixValues : public Page
|
|||
setFlashLED(false);
|
||||
}
|
||||
|
||||
if (bvalue == NULL) return;
|
||||
if (bvalue == NULL) return PAGE_OK; // WTF why this statement?
|
||||
|
||||
// Draw page
|
||||
//***********************************************************
|
||||
|
@ -149,9 +149,7 @@ class PageSixValues : public Page
|
|||
getdisplay().fillRect(SixValues_x1+SixValues_DeltaX-8, SixValues_y1+i*SixValues_DeltaY, 3, SixValues_DeltaY, commonData->fgcolor);
|
||||
}
|
||||
|
||||
// Update display
|
||||
getdisplay().nextPage(); // Partial update (fast)
|
||||
|
||||
return PAGE_UPDATE;
|
||||
};
|
||||
|
||||
};
|
||||
|
|
|
@ -20,7 +20,7 @@ public:
|
|||
return key;
|
||||
}
|
||||
|
||||
virtual void displayPage(PageData &pageData){
|
||||
int displayPage(PageData &pageData){
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
|
@ -199,8 +199,7 @@ public:
|
|||
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
||||
getdisplay().print("W");
|
||||
|
||||
// Update display
|
||||
getdisplay().nextPage(); // Partial update (fast)
|
||||
return PAGE_UPDATE;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -159,7 +159,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
virtual void displayPage(PageData &pageData){
|
||||
int displayPage(PageData &pageData){
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
|
@ -380,7 +380,7 @@ public:
|
|||
|
||||
// Update display
|
||||
getdisplay().nextPage(); // Partial update (fast)
|
||||
|
||||
return PAGE_OK;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ class PageThreeValues : public Page
|
|||
return key;
|
||||
}
|
||||
|
||||
virtual void displayPage(PageData &pageData){
|
||||
int displayPage(PageData &pageData){
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
|
@ -77,7 +77,7 @@ class PageThreeValues : public Page
|
|||
}
|
||||
|
||||
// Logging boat values
|
||||
if (bvalue1 == NULL) return;
|
||||
if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement?
|
||||
LOG_DEBUG(GwLog::LOG,"Drawing at PageThreeValues, %s: %f, %s: %f, %s: %f", name1.c_str(), value1, name2.c_str(), value2, name3.c_str(), value3);
|
||||
|
||||
// Draw page
|
||||
|
@ -226,8 +226,7 @@ class PageThreeValues : public Page
|
|||
unit3old = unit3; // Save the old unit
|
||||
}
|
||||
|
||||
// Update display
|
||||
getdisplay().nextPage(); // Partial update (fast)
|
||||
return PAGE_UPDATE;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ class PageTwoValues : public Page
|
|||
return key;
|
||||
}
|
||||
|
||||
virtual void displayPage(PageData &pageData){
|
||||
int displayPage(PageData &pageData){
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
|
@ -65,7 +65,7 @@ class PageTwoValues : public Page
|
|||
}
|
||||
|
||||
// Logging boat values
|
||||
if (bvalue1 == NULL) return;
|
||||
if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement?
|
||||
LOG_DEBUG(GwLog::LOG,"Drawing at PageTwoValues, %s: %f, %s: %f", name1.c_str(), value1, name2.c_str(), value2);
|
||||
|
||||
// Draw page
|
||||
|
@ -166,8 +166,7 @@ class PageTwoValues : public Page
|
|||
unit2old = unit2; // Save the old unit
|
||||
}
|
||||
|
||||
// Update display
|
||||
getdisplay().nextPage(); // Partial update (fast)
|
||||
return PAGE_UPDATE;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ public:
|
|||
getdisplay().fillRect(x + 16, y + 11, 6, 3, color);
|
||||
}
|
||||
|
||||
virtual void displayPage(PageData &pageData){
|
||||
int displayPage(PageData &pageData){
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
|
@ -383,8 +383,7 @@ public:
|
|||
|
||||
}
|
||||
|
||||
// Update display
|
||||
getdisplay().nextPage(); // Partial update (fast)
|
||||
return PAGE_UPDATE;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
return key;
|
||||
}
|
||||
|
||||
virtual void displayPage(PageData &pageData){
|
||||
int displayPage(PageData &pageData){
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
|
@ -67,10 +67,13 @@ public:
|
|||
}
|
||||
|
||||
// Update display
|
||||
getdisplay().nextPage();
|
||||
// getdisplay().nextPage();
|
||||
int ret = PAGE_UPDATE;
|
||||
if (mode == 'W') {
|
||||
getdisplay().hibernate();
|
||||
//getdisplay().hibernate();
|
||||
ret |= PAGE_HIBERNATE;
|
||||
}
|
||||
return ret;
|
||||
|
||||
};
|
||||
};
|
||||
|
|
|
@ -296,7 +296,7 @@ public:
|
|||
return key;
|
||||
}
|
||||
|
||||
virtual void displayPage(PageData &pageData)
|
||||
int displayPage(PageData &pageData)
|
||||
{
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
@ -354,7 +354,7 @@ public:
|
|||
}
|
||||
|
||||
// Logging boat values
|
||||
if (bvalue1 == NULL) return;
|
||||
if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement?
|
||||
LOG_DEBUG(GwLog::LOG,"Drawing at PageWind, %s:%f, %s:%f", name1.c_str(), value1, name2.c_str(), value2);
|
||||
|
||||
// Draw page
|
||||
|
@ -618,9 +618,7 @@ public:
|
|||
|
||||
}
|
||||
|
||||
// Update display
|
||||
getdisplay().nextPage(); // Partial update (fast)
|
||||
|
||||
return PAGE_UPDATE;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ public:
|
|||
return key;
|
||||
}
|
||||
|
||||
virtual void displayPage(PageData &pageData){
|
||||
int displayPage(PageData &pageData){
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
|
@ -140,7 +140,7 @@ public:
|
|||
}
|
||||
|
||||
// Logging boat values
|
||||
if (bvalue1 == NULL) return;
|
||||
if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement?
|
||||
LOG_DEBUG(GwLog::LOG,"Drawing at PageWindRose, %s:%f, %s:%f, %s:%f, %s:%f, %s:%f, %s:%f", name1.c_str(), value1, name2.c_str(), value2, name3.c_str(), value3, name4.c_str(), value4, name5.c_str(), value5, name6.c_str(), value6);
|
||||
|
||||
// Draw page
|
||||
|
@ -357,8 +357,7 @@ public:
|
|||
getdisplay().print(unit6old); // Unit
|
||||
}
|
||||
|
||||
// Update display
|
||||
getdisplay().nextPage(); // Partial update (fast)
|
||||
return PAGE_UPDATE;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ public:
|
|||
return key;
|
||||
}
|
||||
|
||||
virtual void displayPage(PageData &pageData){
|
||||
int displayPage(PageData &pageData){
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
|
@ -140,7 +140,7 @@ public:
|
|||
}
|
||||
|
||||
// Logging boat values
|
||||
if (bvalue1 == NULL) return;
|
||||
if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement?
|
||||
LOG_DEBUG(GwLog::LOG,"Drawing at PageWindRoseFlex, %s:%f, %s:%f, %s:%f, %s:%f, %s:%f, %s:%f", name1.c_str(), value1, name2.c_str(), value2, name3.c_str(), value3, name4.c_str(), value4, name5.c_str(), value5, name6.c_str(), value6);
|
||||
|
||||
// Draw page
|
||||
|
@ -362,8 +362,7 @@ if ( cos(value1) > 0){
|
|||
}
|
||||
|
||||
|
||||
// Update display
|
||||
getdisplay().nextPage(); // Partial update (fast)
|
||||
return PAGE_UPDATE;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ class PageXTETrack : public Page
|
|||
return key;
|
||||
}
|
||||
|
||||
virtual void displayPage(PageData &pageData){
|
||||
int displayPage(PageData &pageData){
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
|
@ -207,9 +207,7 @@ class PageXTETrack : public Page
|
|||
drawSegment(399, 100, 318, 24, 289, 24, 350, 100, commonData->fgcolor, seg[4]);
|
||||
drawSegment(399, 54, 354, 24, 325, 24, 399, 90, commonData->fgcolor, seg[5]);
|
||||
|
||||
// Update display
|
||||
getdisplay().nextPage(); // Partial update (fast)
|
||||
|
||||
return PAGE_UPDATE;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -78,6 +78,22 @@ typedef struct{
|
|||
bool on; // fast on/off detector
|
||||
} BacklightData;
|
||||
|
||||
enum AlarmSource {
|
||||
Alarm_Generic,
|
||||
Alarm_Local,
|
||||
Alarm_NMEA0183,
|
||||
Alarm_NMEA2000
|
||||
};
|
||||
|
||||
typedef struct{
|
||||
uint8_t id; // alarm-id e.g. 01..99 from NMEA0183
|
||||
AlarmSource source;
|
||||
String message; // single line of plain text
|
||||
bool active = false;
|
||||
uint8_t signal; // how to signal MESSAGE | LED | BUZZER
|
||||
uint8_t length_sec; // seconds until alarm disappeares without user interaction
|
||||
} AlarmData;
|
||||
|
||||
typedef struct{
|
||||
GwApi::Status status;
|
||||
GwLog *logger=NULL;
|
||||
|
@ -86,6 +102,7 @@ typedef struct{
|
|||
SunData sundata;
|
||||
TouchKeyData keydata[6];
|
||||
BacklightData backlight;
|
||||
AlarmData alarm;
|
||||
GwApi::BoatValue *time=NULL;
|
||||
GwApi::BoatValue *date=NULL;
|
||||
uint16_t fgcolor;
|
||||
|
@ -100,7 +117,7 @@ class Page{
|
|||
CommonData *commonData;
|
||||
public:
|
||||
int refreshtime = 1000;
|
||||
virtual void displayPage(PageData &pageData)=0;
|
||||
virtual int displayPage(PageData &pageData)=0;
|
||||
virtual void displayNew(PageData &pageData){}
|
||||
virtual void setupKeys() {
|
||||
#ifdef HARDWARE_V21
|
||||
|
|
|
@ -845,7 +845,16 @@ void OBP60Task(GwApi *api){
|
|||
if (pages[pageNumber].description && pages[pageNumber].description->header){
|
||||
displayFooter(commonData);
|
||||
}
|
||||
currentPage->displayPage(pages[pageNumber].parameters);
|
||||
int ret = currentPage->displayPage(pages[pageNumber].parameters);
|
||||
if (commonData.alarm.active) {
|
||||
displayAlarm(commonData);
|
||||
}
|
||||
if (ret & PAGE_UPDATE) {
|
||||
getdisplay().nextPage(); // Partial update (fast)
|
||||
}
|
||||
if (ret & PAGE_HIBERNATE) {
|
||||
getdisplay().hibernate();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue