From be48929c40888d85795372378c5b2ab4f1d5b4d0 Mon Sep 17 00:00:00 2001 From: Thomas Hooge Date: Wed, 8 Jan 2025 14:26:52 +0100 Subject: [PATCH] Changed ApparentWind to Wind with modes and lens function --- lib/obp60task/OBP60Extensions.h | 3 + lib/obp60task/PageApparentWind.cpp | 192 --------- lib/obp60task/PageWind.cpp | 650 +++++++++++++++++++++++++++++ lib/obp60task/config.json | 20 +- lib/obp60task/obp60task.cpp | 4 +- 5 files changed, 665 insertions(+), 204 deletions(-) delete mode 100644 lib/obp60task/PageApparentWind.cpp create mode 100644 lib/obp60task/PageWind.cpp diff --git a/lib/obp60task/OBP60Extensions.h b/lib/obp60task/OBP60Extensions.h index 5ab4caa..fcb1f29 100644 --- a/lib/obp60task/OBP60Extensions.h +++ b/lib/obp60task/OBP60Extensions.h @@ -12,6 +12,9 @@ #define FRAM_VOLTAGE_AVG 0x000A #define FRAM_VOLTAGE_TREND 0x000B #define FRAM_VOLTAGE_MODE 0x000C +#define FRAM_WIND_SIZE 0x000D +#define FRAM_WIND_SRC 0x000E +#define FRAM_WIND_MODE 0x000F // Barograph history data #define FRAM_BAROGRAPH_START 0x0400 #define FRAM_BAROGRAPH_END 0x13FF diff --git a/lib/obp60task/PageApparentWind.cpp b/lib/obp60task/PageApparentWind.cpp deleted file mode 100644 index 50be31c..0000000 --- a/lib/obp60task/PageApparentWind.cpp +++ /dev/null @@ -1,192 +0,0 @@ -#ifdef BOARD_OBP60S3 - -#include "Pagedata.h" -#include "OBP60Extensions.h" - -class PageApparentWind : public Page -{ -bool keylock = false; // Keylock -int16_t lp = 80; // Pointer length - -public: - PageApparentWind(CommonData &common){ - common.logger->logDebug(GwLog::LOG,"Show PageApparentWind"); - } - - // Key functions - virtual int handleKey(int key){ - // Reduce instrument size - if(key == 2){ // Code for reduce - lp = lp - 10; - if(lp < 10){ - lp = 10; - } - return 0; // Commit the key - } - - // Enlarge instrument size - if(key == 5){ // Code for enlarge - lp = lp + 10; - if(lp > 80){ - lp = 80; - } - return 0; // Commit the key - } - - // Keylock function - if(key == 11){ // Code for keylock - keylock = !keylock; // Toggle keylock - return 0; // Commit the key - } - return key; - } - - virtual void displayPage(CommonData &commonData, PageData &pageData) - { - GwConfigHandler *config = commonData.config; - GwLog *logger=commonData.logger; - - static String svalue1old = ""; - static String unit1old = ""; - static String svalue2old = ""; - 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); - - // Get boat values for AWS - GwApi::BoatValue *bvalue1 = pageData.values[0]; // First element in list (only one value by PageOneValue) - String name1 = bvalue1->getName().c_str(); // Value name - name1 = name1.substring(0, 6); // String length limit for value name - double value1 = bvalue1->value; // Value as double in SI unit - // bool valid1 = bvalue1->valid; // Valid information - String svalue1 = formatValue(bvalue1, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit1 = formatValue(bvalue1, commonData).unit; // Unit of value - - // Get boat values for AWD - GwApi::BoatValue *bvalue2 = pageData.values[1]; // First element in list (only one value by PageOneValue) - String name2 = bvalue2->getName().c_str(); // Value name - name2 = name2.substring(0, 6); // String length limit for value name - double value2 = bvalue2->value; // Value as double in SI unit - // bool valid2 = bvalue2->valid; // Valid information - String svalue2 = formatValue(bvalue2, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit2 = formatValue(bvalue2, commonData).unit; // Unit of value - - // Optical warning by limit violation (unused) - if(String(flashLED) == "Limit Violation"){ - setBlinkingLED(false); - setFlashLED(false); - } - - // Logging boat values - if (bvalue1 == NULL) return; - LOG_DEBUG(GwLog::LOG,"Drawing at PageApparentWind, %s:%f, %s:%f", name1.c_str(), value1, name2.c_str(), value2); - - // Draw page - //*********************************************************** - - // Set display in partial refresh mode - getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update - - getdisplay().setTextColor(commonData.fgcolor); - - // Show values AWS - getdisplay().setFont(&Ubuntu_Bold20pt7b); - getdisplay().setCursor(20, 50); - if(holdvalues == false){ - getdisplay().print(name1); // Value name - getdisplay().print(": "); - getdisplay().print(svalue1); // Value - getdisplay().print(" "); - getdisplay().print(unit1); // Unit - } - else{ - getdisplay().print(name1); // Value name - getdisplay().print(": "); - getdisplay().print(svalue1old); // Value old - getdisplay().print(" "); - getdisplay().print(unit1old); // Unit old - } - - // Show values AWD - getdisplay().setFont(&Ubuntu_Bold20pt7b); - getdisplay().setCursor(20, 260); - if(holdvalues == false){ - getdisplay().print(name2); // Value name - getdisplay().print(": "); - getdisplay().print(svalue2); // Value - getdisplay().print(" "); - getdisplay().print(unit2); // Unit - } - else{ - getdisplay().print(name2); // Value name - getdisplay().print(": "); - getdisplay().print(svalue2old); // Value old - getdisplay().print(" "); - getdisplay().print(unit2old); // Unit old - } - - // Draw wind pointer - static int16_t x0 = 200; // Center point - static int16_t y0 = 145; - static int16_t x1 = x0; // Start point for pointer - static int16_t y1 = y0; - static int16_t x2 = x0; // End point for pointer - static int16_t y2 = y0; - - //Draw instrument - getdisplay().fillCircle(x0, y0, lp + 5, commonData.fgcolor); - getdisplay().fillCircle(x0, y0, lp + 1, commonData.bgcolor); - - // Calculation end point of pointer - value2 = value2 - 3.14 / 2; - x1 = x0 + cos(value2) * lp * 0.6; - y1 = y0 + sin(value2) * lp * 0.6; - x2 = x0 + cos(value2) * lp; - y2 = y0 + sin(value2) * lp; - getdisplay().drawLine(x1, y1, x2, y2, commonData.fgcolor); - - // Key Layout - getdisplay().setFont(&Ubuntu_Bold8pt7b); - if(keylock == false){ - getdisplay().setCursor(130, 290); - getdisplay().print("[ <<<< " + String(commonData.data.actpage) + "/" + String(commonData.data.maxpage) + " >>>> ]"); - if(String(backlightMode) == "Control by Key"){ // Key for illumination - getdisplay().setCursor(343, 290); - getdisplay().print("[ILUM]"); - } - } - else{ - getdisplay().setCursor(130, 290); - getdisplay().print(" [ Keylock active ]"); - } - - // Update display - getdisplay().nextPage(); // Partial update (fast) - - }; -}; - -static Page *createPage(CommonData &common){ - return new PageApparentWind(common); -} -/** - * with the code below we make this page known to the PageTask - * we give it a type (name) that can be selected in the config - * we define which function is to be called - * and we provide the number of user parameters we expect (0 here) - * and will will provide the names of the fixed values we need - */ -PageDescription registerPageApparentWind( - "ApparentWind", // Page name - createPage, // Action - 0, // Number of bus values depends on selection in Web configuration - {"AWS","AWA"}, // Bus values we need in the page - true // Show display header on/off -); - -#endif diff --git a/lib/obp60task/PageWind.cpp b/lib/obp60task/PageWind.cpp new file mode 100644 index 0000000..c28caa9 --- /dev/null +++ b/lib/obp60task/PageWind.cpp @@ -0,0 +1,650 @@ +#ifdef BOARD_OBP60S3 + +#include "Pagedata.h" +#include "OBP60Extensions.h" +#include "N2kMessages.h" + +#define front_width 120 +#define front_height 162 +static unsigned char front_bits[] PROGMEM = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x80, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xc0, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xf0, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xf0, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x0f, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x1f, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xfc, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xfe, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf7, 0x7f, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, + 0xff, 0xf3, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xc0, 0xff, 0xe1, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xc1, 0xff, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0x80, 0xff, + 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, + 0x7f, 0x80, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xf0, 0x7f, 0x00, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0xfe, 0x0f, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0xfe, + 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, + 0x1f, 0x00, 0xfc, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xfc, 0x0f, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x0f, 0x00, 0xf8, 0x3f, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x07, 0x00, 0xf0, + 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0x03, 0x00, 0xe0, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x80, 0xff, 0x03, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x01, 0x00, 0xc0, 0xff, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x00, 0x00, 0x80, + 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, + 0x00, 0x00, 0x80, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xe0, 0x7f, 0x00, 0x00, 0x00, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xf0, 0x7f, 0x00, 0x00, 0x00, 0xfe, 0x07, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x3f, 0x00, 0x00, 0x00, + 0xfe, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x1f, + 0x00, 0x00, 0x00, 0xfc, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xf8, 0x1f, 0x00, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xfc, 0x0f, 0x00, 0x00, 0x00, 0xf8, 0x1f, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x07, 0x00, 0x00, 0x00, + 0xf0, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x07, + 0x00, 0x00, 0x00, 0xe0, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xfe, 0x03, 0x00, 0x00, 0x00, 0xe0, 0x7f, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xff, 0x03, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x01, 0x00, 0x00, 0x00, + 0xc0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x00, + 0x00, 0x00, 0x00, 0x80, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xc0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x7f, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xfe, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x3f, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xfe, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xf0, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x07, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x0f, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x0f, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xf8, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x0f, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xf8, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xfc, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x3f, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xc0, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xfe, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x7f, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x7f, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x80, + 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x01, 0x00, 0x00, + 0x00, 0x00, 0xc0, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, + 0x03, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xfc, 0x03, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x1f, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x07, 0x00, 0x00, 0x00, 0x00, 0xe0, + 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x07, 0x00, 0x00, + 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, + 0x07, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xf0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xf0, + 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x1f, 0x00, 0x00, + 0x00, 0x00, 0xf8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, + 0x1f, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xc0, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xfc, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, + 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x3f, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, + 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xfc, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xfc, 0x01, 0x00, 0x00, 0x80, 0x1f, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0x00, 0x00, 0x80, 0x0f, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0x00, + 0x00, 0x80, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xf0, 0x03, 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xf0, 0x03, 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x07, 0x00, + 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00, 0xe0, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x0f, 0x00, 0x00, 0xf0, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x0f, 0x00, + 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x80, 0x0f, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x78, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, + 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x3e, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x3c, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, + 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x7c, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x0e, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, + 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xf8, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x07, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x01, + 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xe0, 0x01, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xe0, 0x01, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x01, 0x80, 0x03, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, + 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xc0, 0x03, 0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0xc0, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, + 0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x80, 0x07, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0xe0, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, + 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x0f, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x70, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, + 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x0e, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x30, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, + 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x1c, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x18, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, + 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x1c, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, + 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x38, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0c, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, + 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x70, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x0e, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, + 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x60, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x06, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, + 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x60, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x06, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, + 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, + 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, + 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0 }; + +class PageWind : public Page +{ +bool keylock = false; // Keylock +int8_t lp = 80; // Pointer length +char mode = 'N'; // page mode (N)ormal | (L)ens | e(X)ample +char source = 'A'; // data source (A)pparent | (T)rue + +public: + PageWind(CommonData &common){ + common.logger->logDebug(GwLog::LOG,"Instantiate PageWind"); + if (hasFRAM) { + lp = fram.read(FRAM_WIND_SIZE); + source = fram.read(FRAM_WIND_SRC); + mode = fram.read(FRAM_WIND_MODE); + } + } + + // Key functions + virtual int handleKey(int key){ + + if(key == 1){ // Mode switch + if(mode == 'N'){ + mode = 'L'; + } else if (mode == 'L') { + mode = 'X'; + } else { + mode = 'N'; + } + if (hasFRAM) fram.write(FRAM_WIND_MODE, mode); + return 0; // Commit the key + } + + if(key == 3){ // Source switch + if(source == 'A'){ + source = 'T'; + } else { + source = 'A'; + } + if (hasFRAM) fram.write(FRAM_WIND_SRC, source); + return 0; // Commit the key + } + + // Reduce instrument size + if(key == 2 && mode == 'N'){ // Code for reduce + lp = lp - 10; + if(lp < 10){ + lp = 10; + } + if (hasFRAM) fram.write(FRAM_WIND_SIZE, lp); + return 0; // Commit the key + } + + // Enlarge instrument size + if(key == 5 && mode == 'N'){ // Code for enlarge + lp = lp + 10; + if(lp > 80){ + lp = 80; + } + if (hasFRAM) fram.write(FRAM_WIND_SIZE, lp); + return 0; // Commit the key + } + + // Keylock function + if(key == 11){ // Code for keylock + keylock = !keylock; // Toggle keylock + return 0; // Commit the key + } + return key; + } + + virtual void displayPage(CommonData &commonData, PageData &pageData) + { + GwConfigHandler *config = commonData.config; + GwLog *logger=commonData.logger; + + static String svalue1old = ""; + static String unit1old = ""; + static String svalue2old = ""; + 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); + + GwApi::BoatValue *bvalue1; // Value 1 for speed on top + GwApi::BoatValue *bvalue2; // Value 2 for angle on bottom + + // Get boat values for speed (AWS/TWS) + if (source == 'A') { + bvalue1 = pageData.values[0]; + } else { + bvalue1 = pageData.values[2]; + } + String name1 = bvalue1->getName().c_str(); // Value name + name1 = name1.substring(0, 6); // String length limit for value name + double value1 = bvalue1->value; // Value as double in SI unit + // bool valid1 = bvalue1->valid; // Valid information + String svalue1 = formatValue(bvalue1, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit1 = formatValue(bvalue1, commonData).unit; // Unit of value + + // Get boat values for angle (AWD/TWD) + if (source == 'A') { + bvalue2 = pageData.values[1]; + } else { + bvalue2 = pageData.values[3]; + } + String name2 = bvalue2->getName().c_str(); // Value name + name2 = name2.substring(0, 6); // String length limit for value name + double value2 = bvalue2->value; // Value as double in SI unit + // bool valid2 = bvalue2->valid; // Valid information + String svalue2 = formatValue(bvalue2, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit2 = formatValue(bvalue2, commonData).unit; // Unit of value + + // Optical warning by limit violation (unused) + if(String(flashLED) == "Limit Violation"){ + setBlinkingLED(false); + setFlashLED(false); + } + + // Logging boat values + if (bvalue1 == NULL) return; + LOG_DEBUG(GwLog::LOG,"Drawing at PageWind, %s:%f, %s:%f", name1.c_str(), value1, name2.c_str(), value2); + + // Draw page + //*********************************************************** + + // Set display in partial refresh mode + getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update + + getdisplay().setTextColor(commonData.fgcolor); + + + if (mode == 'X') { + // Original example code with scaling circle + + // Show values AWS/TWS + getdisplay().setFont(&Ubuntu_Bold20pt7b); + getdisplay().setCursor(20, 50); + getdisplay().print(name1); // Value name + getdisplay().print(": "); + if(holdvalues == false){ + getdisplay().print(svalue1); // Value + getdisplay().print(" "); + getdisplay().print(unit1); // Unit + } + else{ + getdisplay().print(svalue1old); // Value old + getdisplay().print(" "); + getdisplay().print(unit1old); // Unit old + } + + // Show values AWD/TWD + getdisplay().setFont(&Ubuntu_Bold20pt7b); + getdisplay().setCursor(20, 260); + getdisplay().print(name2); // Value name + getdisplay().print(": "); + if(holdvalues == false){ + getdisplay().print(svalue2); // Value + getdisplay().print(" "); + getdisplay().print(unit2); // Unit + } + else{ + getdisplay().print(svalue2old); // Value old + getdisplay().print(" "); + getdisplay().print(unit2old); // Unit old + } + + Point c = {200, 145}; + + // Draw instrument + getdisplay().fillCircle(c.x, c.y, lp + 5, commonData.fgcolor); + getdisplay().fillCircle(c.x, c.y, lp + 1, commonData.bgcolor); + + // Wind pointer + if (bvalue2->valid) { + uint8_t lp0 = lp * 0.6; // effective pointer outside size + uint8_t lp1 = lp * 0.4; // effective pointer inside size + // zero position + std::vector pts = { + {c.x, c.y - lp}, + {c.x - 7, c.y - lp + lp0}, + {c.x, c.y - lp + lp1}, + {c.x + 7, c.y - lp + lp0} + }; + fillPoly4(rotatePoints(c, pts, RadToDeg(value2)), commonData.fgcolor); + } else { + getdisplay().setFont(&Ubuntu_Bold12pt7b); + drawTextCenter(c.x, c.y, "no data"); + } + + } else if (mode == 'L') { // Mode (L)ens + + Point c = {200, 155}; + uint16_t r = 150; + + Point p; + std::vector pts = { // polygon lines + {c.x - 2, c.y - r}, + {c.x + 2, c.y - r}, + {c.x + 2, c.y - (r - 16)}, + {c.x - 2, c.y - (r - 16)} + }; + int angle; + + getdisplay().setFont(&Ubuntu_Bold12pt7b); + + // starbord + // text with line + angle = 20; + for (int i = 30; i < 150; i += 30) { + p = rotatePoint(c, {c.x, c.y - r + 40}, i); + drawTextCenter(p.x, p.y, String(angle)); + angle += 10; + fillPoly4(rotatePoints(c, pts, i), commonData.fgcolor); + } + // dots + for (int i = 30; i < 138; i += 6) { + if (i % 15 != 0) { + p = rotatePoint(c, {c.x, c.y - r + 5}, i); + getdisplay().fillCircle(p.x, p.y, 2, commonData.fgcolor); + } + } + + // port + angle = 50; + // text with line + for (int i = 240; i <= 330; i += 30) { + p = rotatePoint(c, {c.x, c.y - r + 40}, i); + drawTextCenter(p.x, p.y, String(angle)); + angle -= 10; + fillPoly4(rotatePoints(c, pts, i), commonData.fgcolor); + } + // dots + for (int i = 228; i < 330; i += 6) { + if (i % 15 != 0) { + p = rotatePoint(c, {c.x, c.y - r + 5}, i); + getdisplay().fillCircle(p.x, p.y, 2, commonData.fgcolor); + } + } + + // data source + getdisplay().setFont(&Ubuntu_Bold12pt7b); + getdisplay().setCursor(8, 50); + if (source == 'A') { + getdisplay().print("APP"); + } else { + getdisplay().print("TRUE"); + } + + // Wind pointer (angle) + if (bvalue2->valid) { + float alpha = RadToDeg(value2); + bool port = (alpha > 180); + if (port) { + alpha = 360 - alpha; + } + if (alpha < 15) { + alpha = 15; // stop at start of scale + } else if (alpha > 55) { + alpha = 55; // stop at end of scale + } + alpha = 3 * alpha - 30; // convert to lens scale + if (port) { + alpha *= -1; + } + + getdisplay().fillCircle(c.x, c.y, 8, commonData.fgcolor); + pts = { + {c.x - 1, c.y - (r - 20)}, + {c.x + 1, c.y - (r - 20)}, + {c.x + 6, c.y + 15}, + {c.x - 6, c.y + 15} + }; + fillPoly4(rotatePoints(c, pts, alpha), commonData.fgcolor); + getdisplay().fillCircle(c.x, c.y, 6, commonData.bgcolor); + } else { + getdisplay().setFont(&Ubuntu_Bold12pt7b); + drawTextCenter(c.x, c.y, "no data"); + } + + // Wind speed as decimal number + getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b); + getdisplay().setCursor(150, 250); + if (holdvalues == false) { + getdisplay().print(svalue1); + } else { + getdisplay().print(svalue1old); + } + // unit + getdisplay().setFont(&Ubuntu_Bold8pt7b); + getdisplay().setCursor(220, 265); + getdisplay().print("kts"); + } + else { + // Normal mode + + // data source + getdisplay().setFont(&Ubuntu_Bold12pt7b); + getdisplay().setCursor(8, 50); + if (source == 'A') { + getdisplay().print("APP"); + } else { + getdisplay().print("TRUE"); + } + + // draw ship front symbol (as bitmap) + getdisplay().drawXBitmap(140, 30, front_bits, front_width, front_height, commonData.fgcolor); + + Point c = {200, 155}; + uint16_t r = 150; + + Point p; + std::vector pts = { // polygon lines + {c.x - 2, c.y - r}, + {c.x + 2, c.y - r}, + {c.x + 2, c.y - (r - 16)}, + {c.x - 2, c.y - (r - 16)} + }; + int angle; + + // starbord + // text with line + for (int i = 30; i < 150; i += 30) { + p = rotatePoint(c, {c.x, c.y - r + 40}, i); + drawTextCenter(p.x, p.y, String(i)); + fillPoly4(rotatePoints(c, pts, i), commonData.fgcolor); + } + // dots + for (int i = 30; i < 150; i += 10) { + if (i % 30 != 0) { + p = rotatePoint(c, {c.x, c.y - r + 5}, i); + getdisplay().fillCircle(p.x, p.y, 3, commonData.fgcolor); + } + } + + // port + // text with line + angle = 120; + for (int i = 240; i <= 330; i += 30) { + p = rotatePoint(c, {c.x, c.y - r + 40}, i); + drawTextCenter(p.x, p.y, String(angle)); + angle -= 30; + fillPoly4(rotatePoints(c, pts, i), commonData.fgcolor); + } + // dots + for (int i = 210; i < 340; i += 10) { + if (i % 30 != 0) { + p = rotatePoint(c, {c.x, c.y - r + 5}, i); + getdisplay().fillCircle(p.x, p.y, 3, commonData.fgcolor); + } + } + + // Wind speed as decimal number + getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b); + getdisplay().setCursor(150, 250); + if (holdvalues == false) { + getdisplay().print(svalue1); + } else { + getdisplay().print(svalue1old); + } + // unit + getdisplay().setFont(&Ubuntu_Bold8pt7b); + getdisplay().setCursor(220, 265); + getdisplay().print("kts"); + + // Wind pointer (angle) + if (bvalue2->valid) { + float alpha = RadToDeg(value2); + getdisplay().fillCircle(c.x, c.y, 8, commonData.fgcolor); + pts = { + {c.x - 1, c.y - (r - 20)}, + {c.x + 1, c.y - (r - 20)}, + {c.x + 6, c.y + 15}, + {c.x - 6, c.y + 15} + }; + fillPoly4(rotatePoints(c, pts, alpha), commonData.fgcolor); + getdisplay().fillCircle(c.x, c.y, 6, commonData.bgcolor); + } else { + getdisplay().setFont(&Ubuntu_Bold12pt7b); + drawTextCenter(c.x, c.y, "no data"); + } + + } + + // Key Layout + getdisplay().setFont(&Ubuntu_Bold8pt7b); + if(keylock == false){ + getdisplay().setCursor(10, 290); + getdisplay().print("[MODE]"); + getdisplay().setCursor(130, 290); + getdisplay().print("[ <<<< " + String(commonData.data.actpage) + "/" + String(commonData.data.maxpage) + " >>>> ]"); + + if (mode == 'X') { + getdisplay().setCursor(85, 290); + getdisplay().print("[ - ]"); + getdisplay().setCursor(295, 290); + getdisplay().print("[ + ]"); + } + + if(String(backlightMode) == "Control by Key"){ // Key for illumination + getdisplay().setCursor(343, 290); + getdisplay().print("[ILUM]"); + } + } + else{ + getdisplay().setCursor(130, 290); + getdisplay().print(" [ Keylock active ]"); + } + + // Update display + getdisplay().nextPage(); // Partial update (fast) + + }; +}; + +static Page *createPage(CommonData &common){ + return new PageWind(common); +} +/** + * with the code below we make this page known to the PageTask + * we give it a type (name) that can be selected in the config + * we define which function is to be called + * and we provide the number of user parameters we expect (0 here) + * and will will provide the names of the fixed values we need + */ +PageDescription registerPageWind( + "Wind", // Page name + createPage, // Action + 0, // Number of bus values depends on selection in Web configuration + {"AWS","AWA", "TWS", "TWA"}, // Bus values we need in the page + true // Show display header on/off +); + +#endif diff --git a/lib/obp60task/config.json b/lib/obp60task/config.json index 9ba0fab..2b4c528 100644 --- a/lib/obp60task/config.json +++ b/lib/obp60task/config.json @@ -920,7 +920,7 @@ "type": "list", "default": "Voltage", "description": "Type of page for page 1", - "list":["OneValue","TwoValues","ThreeValues","FourValues","FourValues2","ApparentWind","WindRose","WindRoseFlex","Voltage","DST810","Clock","WhitePage","BME280","RudderPosition","KeelPosition","Battery","Battery2","RollPitch","Solar","Generator","XTETrack","Fluid"], + "list":["OneValue","TwoValues","ThreeValues","FourValues","FourValues2","Wind","WindRose","WindRoseFlex","Voltage","DST810","Clock","WhitePage","BME280","RudderPosition","KeelPosition","Battery","Battery2","RollPitch","Solar","Generator","XTETrack","Fluid"], "category": "OBP60 Page 1", "capabilities": { "obp60":"true" @@ -1025,7 +1025,7 @@ "type": "list", "default": "WindRose", "description": "Type of page for page 2", - "list":["OneValue","TwoValues","ThreeValues","FourValues","FourValues2","ApparentWind","WindRose","WindRoseFlex","Voltage","DST810","Clock","WhitePage","BME280","RudderPosition","KeelPosition","Battery","Battery2","RollPitch","Solar","Generator","XTETrack","Fluid"], + "list":["OneValue","TwoValues","ThreeValues","FourValues","FourValues2","Wind","WindRose","WindRoseFlex","Voltage","DST810","Clock","WhitePage","BME280","RudderPosition","KeelPosition","Battery","Battery2","RollPitch","Solar","Generator","XTETrack","Fluid"], "category": "OBP60 Page 2", "capabilities": { "obp60":"true" @@ -1131,7 +1131,7 @@ "type": "list", "default": "OneValue", "description": "Type of page for page 3", - "list":["OneValue","TwoValues","ThreeValues","FourValues","FourValues2","ApparentWind","WindRose","WindRoseFlex","Voltage","DST810","Clock","WhitePage","BME280","RudderPosition","KeelPosition","Battery","Battery2","RollPitch","Solar","Generator","XTETrack","Fluid"], + "list":["OneValue","TwoValues","ThreeValues","FourValues","FourValues2","Wind","WindRose","WindRoseFlex","Voltage","DST810","Clock","WhitePage","BME280","RudderPosition","KeelPosition","Battery","Battery2","RollPitch","Solar","Generator","XTETrack","Fluid"], "category": "OBP60 Page 3", "capabilities": { "obp60":"true" @@ -1237,7 +1237,7 @@ "type": "list", "default": "TwoValues", "description": "Type of page for page 4", - "list":["OneValue","TwoValues","ThreeValues","FourValues","FourValues2","ApparentWind","WindRose","WindRoseFlex","Voltage","DST810","Clock","WhitePage","BME280","RudderPosition","KeelPosition","Battery","Battery2","RollPitch","Solar","Generator","XTETrack","Fluid"], + "list":["OneValue","TwoValues","ThreeValues","FourValues","FourValues2","Wind","WindRose","WindRoseFlex","Voltage","DST810","Clock","WhitePage","BME280","RudderPosition","KeelPosition","Battery","Battery2","RollPitch","Solar","Generator","XTETrack","Fluid"], "category": "OBP60 Page 4", "capabilities": { "obp60":"true" @@ -1343,7 +1343,7 @@ "type": "list", "default": "ThreeValues", "description": "Type of page for page 5", - "list":["OneValue","TwoValues","ThreeValues","FourValues","FourValues2","ApparentWind","WindRose","WindRoseFlex","Voltage","DST810","Clock","WhitePage","BME280","RudderPosition","KeelPosition","Battery","Battery2","RollPitch","Solar","Generator","XTETrack","Fluid"], + "list":["OneValue","TwoValues","ThreeValues","FourValues","FourValues2","Wind","WindRose","WindRoseFlex","Voltage","DST810","Clock","WhitePage","BME280","RudderPosition","KeelPosition","Battery","Battery2","RollPitch","Solar","Generator","XTETrack","Fluid"], "category": "OBP60 Page 5", "capabilities": { "obp60":"true" @@ -1449,7 +1449,7 @@ "type": "list", "default": "FourValues", "description": "Type of page for page 6", - "list":["OneValue","TwoValues","ThreeValues","FourValues","FourValues2","ApparentWind","WindRose","WindRoseFlex","Voltage","DST810","Clock","WhitePage","BME280","RudderPosition","KeelPosition","Battery","Battery2","RollPitch","Solar","Generator","XTETrack","Fluid"], + "list":["OneValue","TwoValues","ThreeValues","FourValues","FourValues2","Wind","WindRose","WindRoseFlex","Voltage","DST810","Clock","WhitePage","BME280","RudderPosition","KeelPosition","Battery","Battery2","RollPitch","Solar","Generator","XTETrack","Fluid"], "category": "OBP60 Page 6", "capabilities": { "obp60":"true" @@ -1555,7 +1555,7 @@ "type": "list", "default": "FourValues2", "description": "Type of page for page 7", - "list":["OneValue","TwoValues","ThreeValues","FourValues","FourValues2","ApparentWind","WindRose","WindRoseFlex","Voltage","DST810","Clock","WhitePage","BME280","RudderPosition","KeelPosition","Battery","Battery2","RollPitch","Solar","Generator","XTETrack","Fluid"], + "list":["OneValue","TwoValues","ThreeValues","FourValues","FourValues2","Wind","WindRose","WindRoseFlex","Voltage","DST810","Clock","WhitePage","BME280","RudderPosition","KeelPosition","Battery","Battery2","RollPitch","Solar","Generator","XTETrack","Fluid"], "category": "OBP60 Page 7", "capabilities": { "obp60":"true" @@ -1661,7 +1661,7 @@ "type": "list", "default": "Clock", "description": "Type of page for page 8", - "list":["OneValue","TwoValues","ThreeValues","FourValues","FourValues2","ApparentWind","WindRose","WindRoseFlex","Voltage","DST810","Clock","WhitePage","BME280","RudderPosition","KeelPosition","Battery","Battery2","RollPitch","Solar","Generator","XTETrack","Fluid"], + "list":["OneValue","TwoValues","ThreeValues","FourValues","FourValues2","Wind","WindRose","WindRoseFlex","Voltage","DST810","Clock","WhitePage","BME280","RudderPosition","KeelPosition","Battery","Battery2","RollPitch","Solar","Generator","XTETrack","Fluid"], "category": "OBP60 Page 8", "capabilities": { "obp60":"true" @@ -1767,7 +1767,7 @@ "type": "list", "default": "RollPitch", "description": "Type of page for page 9", - "list":["OneValue","TwoValues","ThreeValues","FourValues","FourValues2","ApparentWind","WindRose","WindRoseFlex","Voltage","DST810","Clock","WhitePage","BME280","RudderPosition","KeelPosition","Battery","Battery2","RollPitch","Solar","Generator","XTETrack","Fluid"], + "list":["OneValue","TwoValues","ThreeValues","FourValues","FourValues2","Wind","WindRose","WindRoseFlex","Voltage","DST810","Clock","WhitePage","BME280","RudderPosition","KeelPosition","Battery","Battery2","RollPitch","Solar","Generator","XTETrack","Fluid"], "category": "OBP60 Page 9", "capabilities": { "obp60":"true" @@ -1873,7 +1873,7 @@ "type": "list", "default": "Battery2", "description": "Type of page for page 10", - "list":["OneValue","TwoValues","ThreeValues","FourValues","FourValues2","ApparentWind","WindRose","WindRoseFlex","Voltage","DST810","Clock","WhitePage","BME280","RudderPosition","KeelPosition","Battery","Battery2","RollPitch","Solar","Generator","XTETrack","Fluid"], + "list":["OneValue","TwoValues","ThreeValues","FourValues","FourValues2","Wind","WindRose","WindRoseFlex","Voltage","DST810","Clock","WhitePage","BME280","RudderPosition","KeelPosition","Battery","Battery2","RollPitch","Solar","Generator","XTETrack","Fluid"], "category": "OBP60 Page 10", "capabilities": { "obp60":"true" diff --git a/lib/obp60task/obp60task.cpp b/lib/obp60task/obp60task.cpp index 73bd9fe..a2bf5a9 100644 --- a/lib/obp60task/obp60task.cpp +++ b/lib/obp60task/obp60task.cpp @@ -205,8 +205,8 @@ void registerAllPages(PageList &list){ list.add(®isterPageFourValues); extern PageDescription registerPageFourValues2; list.add(®isterPageFourValues2); - extern PageDescription registerPageApparentWind; - list.add(®isterPageApparentWind); + extern PageDescription registerPageWind; + list.add(®isterPageWind); extern PageDescription registerPageWindRose; list.add(®isterPageWindRose); extern PageDescription registerPageWindRoseFlex;