diff --git a/lib/obp60task/PageAnchor.cpp b/lib/obp60task/PageAnchor.cpp new file mode 100644 index 0000000..06b4ff5 --- /dev/null +++ b/lib/obp60task/PageAnchor.cpp @@ -0,0 +1,100 @@ +#if defined BOARD_OBP60S3 || defined BOARD_OBP40S3 + +#include "Pagedata.h" +#include "OBP60Extensions.h" + +/* + Anchor overview with additional associated data + This page is in experimental stage so be warned! + + DBS - Water depth + HDT - Boat heading + TWS - Wind strength + TWD - Wind direction + + This is the fist page to contain a configuration page with + data entry option. + Also it will make use of the new alarm function. + +*/ + +#define anchor_width 16 +#define anchor_height 16 +static unsigned char anchor_bits[] = { + 0x80, 0x01, 0x40, 0x02, 0x40, 0x02, 0x80, 0x01, 0xf0, 0x0f, 0x80, 0x01, + 0x80, 0x01, 0x88, 0x11, 0x8c, 0x31, 0x8e, 0x71, 0x84, 0x21, 0x86, 0x61, + 0x86, 0x61, 0xfc, 0x3f, 0xf8, 0x1f, 0x80, 0x01 }; + +class PageAnchor : public Page +{ + bool simulation = false; + bool holdvalues = false; + String flashLED; + String backlightMode; + + public: + PageAnchor(CommonData &common){ + commonData = &common; + common.logger->logDebug(GwLog::LOG,"Instantiate PageAnchor"); + + // preload configuration data + simulation = common.config->getBool(common.config->useSimuData); + holdvalues = common.config->getBool(common.config->holdvalues); + flashLED = common.config->getString(common.config->flashLED); + backlightMode = common.config->getString(common.config->backlight); + } + + virtual int handleKey(int key){ + // Code for keylock + if (key == 11) { + commonData->keylock = !commonData->keylock; + return 0; // Commit the key + } + return key; + } + + void displayNew(PageData &pageData){ + } + + int displayPage(PageData &pageData){ + GwConfigHandler *config = commonData->config; + GwLog *logger = commonData->logger; + + // Logging boat values + LOG_DEBUG(GwLog::LOG,"Drawing at PageAnchor"); + + // Set display in partial refresh mode + getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update + + uint16_t cx = 200; // center = anchor position + uint16_t cy = 150; + + // draw anchor symbol (as bitmap) + getdisplay().drawXBitmap(cx - anchor_width / 2, cy - anchor_height / 2, + anchor_bits, anchor_width, anchor_height, commonData->fgcolor); + + + getdisplay().setTextColor(commonData->fgcolor); + + return PAGE_UPDATE; + }; +}; + +static Page *createPage(CommonData &common){ + return new PageAnchor(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 + * this will be number of BoatValue pointers in pageData.values + */ +PageDescription registerPageAnchor( + "Anchor", // Page name + createPage, // Action + 0, // Number of bus values depends on selection in Web configuration + {"DBS", "HDT", "TWS", "TWD"}, // Names of bus values undepends on selection in Web configuration (refer GwBoatData.h) + true // Show display header on/off +); + +#endif diff --git a/lib/obp60task/config.json b/lib/obp60task/config.json index eed7ba2..820ce59 100644 --- a/lib/obp60task/config.json +++ b/lib/obp60task/config.json @@ -1303,6 +1303,7 @@ "default": "Voltage", "description": "Type of page for page 1", "list": [ + "Anchor", "BME280", "Battery", "Battery2", @@ -1584,6 +1585,7 @@ "default": "WindRose", "description": "Type of page for page 2", "list": [ + "Anchor", "BME280", "Battery", "Battery2", @@ -1862,6 +1864,7 @@ "default": "OneValue", "description": "Type of page for page 3", "list": [ + "Anchor", "BME280", "Battery", "Battery2", @@ -2137,6 +2140,7 @@ "default": "TwoValues", "description": "Type of page for page 4", "list": [ + "Anchor", "BME280", "Battery", "Battery2", @@ -2409,6 +2413,7 @@ "default": "ThreeValues", "description": "Type of page for page 5", "list": [ + "Anchor", "BME280", "Battery", "Battery2", @@ -2678,6 +2683,7 @@ "default": "FourValues", "description": "Type of page for page 6", "list": [ + "Anchor", "BME280", "Battery", "Battery2", @@ -2944,6 +2950,7 @@ "default": "FourValues2", "description": "Type of page for page 7", "list": [ + "Anchor", "BME280", "Battery", "Battery2", @@ -3207,6 +3214,7 @@ "default": "Clock", "description": "Type of page for page 8", "list": [ + "Anchor", "BME280", "Battery", "Battery2", @@ -3467,6 +3475,7 @@ "default": "RollPitch", "description": "Type of page for page 9", "list": [ + "Anchor", "BME280", "Battery", "Battery2", @@ -3724,6 +3733,7 @@ "default": "Battery2", "description": "Type of page for page 10", "list": [ + "Anchor", "BME280", "Battery", "Battery2", diff --git a/lib/obp60task/config_obp40.json b/lib/obp60task/config_obp40.json index 92cb0f6..2e6c55b 100644 --- a/lib/obp60task/config_obp40.json +++ b/lib/obp60task/config_obp40.json @@ -1326,6 +1326,7 @@ "default": "Clock", "description": "Type of page for page 1", "list": [ + "Anchor", "BME280", "Battery", "Battery2", @@ -1607,6 +1608,7 @@ "default": "Wind", "description": "Type of page for page 2", "list": [ + "Anchor", "BME280", "Battery", "Battery2", @@ -1885,6 +1887,7 @@ "default": "OneValue", "description": "Type of page for page 3", "list": [ + "Anchor", "BME280", "Battery", "Battery2", @@ -2160,6 +2163,7 @@ "default": "TwoValues", "description": "Type of page for page 4", "list": [ + "Anchor", "BME280", "Battery", "Battery2", @@ -2432,6 +2436,7 @@ "default": "ThreeValues", "description": "Type of page for page 5", "list": [ + "Anchor", "BME280", "Battery", "Battery2", @@ -2701,6 +2706,7 @@ "default": "FourValues", "description": "Type of page for page 6", "list": [ + "Anchor", "BME280", "Battery", "Battery2", @@ -2967,6 +2973,7 @@ "default": "FourValues2", "description": "Type of page for page 7", "list": [ + "Anchor", "BME280", "Battery", "Battery2", @@ -3230,6 +3237,7 @@ "default": "Fluid", "description": "Type of page for page 8", "list": [ + "Anchor", "BME280", "Battery", "Battery2", @@ -3490,6 +3498,7 @@ "default": "RollPitch", "description": "Type of page for page 9", "list": [ + "Anchor", "BME280", "Battery", "Battery2", @@ -3747,6 +3756,7 @@ "default": "Battery2", "description": "Type of page for page 10", "list": [ + "Anchor", "BME280", "Battery", "Battery2", diff --git a/lib/obp60task/gen_set.py b/lib/obp60task/gen_set.py index fd3a3e0..dcebb2c 100755 --- a/lib/obp60task/gen_set.py +++ b/lib/obp60task/gen_set.py @@ -34,6 +34,7 @@ no_of_fields_per_page = { "WindPlot": 0, "WindRose": 0, "WindRoseFlex": 6, + "Anchor", 0 } # No changes needed beyond this point diff --git a/lib/obp60task/obp60task.cpp b/lib/obp60task/obp60task.cpp index 11b986d..cd247e1 100644 --- a/lib/obp60task/obp60task.cpp +++ b/lib/obp60task/obp60task.cpp @@ -313,6 +313,8 @@ void registerAllPages(PageList &list){ list.add(®isterPageXTETrack); extern PageDescription registerPageFluid; list.add(®isterPageFluid); + extern PageDescription registerPageAnchor; + list.add(®isterPageAnchor); } // Undervoltage detection for shutdown display