From 47d9d9f5ca89cd9407f71d9c2343688f19422b47 Mon Sep 17 00:00:00 2001 From: Thomas Hooge Date: Sun, 15 Feb 2026 18:36:01 +0100 Subject: [PATCH] Work on Page Anchor --- lib/obp60task/PageAnchor.cpp | 69 +++++++++++++++++++++++++++++---- lib/obp60task/config_obp40.json | 65 +++++++++++++++++-------------- 2 files changed, 98 insertions(+), 36 deletions(-) diff --git a/lib/obp60task/PageAnchor.cpp b/lib/obp60task/PageAnchor.cpp index cd28179..b98fef0 100644 --- a/lib/obp60task/PageAnchor.cpp +++ b/lib/obp60task/PageAnchor.cpp @@ -26,6 +26,25 @@ force map update if new position is different from old position by a certain level (e.g. 10m) + Map service options / URL parameters + - mandatory + lat: latitude + lon: longitude + width: image width in px + height: image height in px + - optional + zoom: zoom level, default 15 + mrot: map rotation angle in degrees + mtype: map type, default="Open Street Map" + dtype: dithering type, default="Atkinson" + cutout: image cutout type 0=none + tab: tab size, 0=none + border: border line zize in px, default 2 + symbol: synmol number, default=2 triangle + srot: symbol rotation in degrees + ssize: symbol size in px, default=15 + grid: show map grid + */ #include @@ -53,9 +72,11 @@ private: const uint16_t map_width = 264; const uint16_t map_height = 260; bool map_valid = false; + char map_service = 'R'; // (O)BP Service, (L)ocal Service, (R)emote Service double map_lat = 0; // current center of valid map double map_lon = 0; String server_name; // server with map service + uint16_t server_port = 80; String tile_path; String lengthformat; @@ -109,7 +130,7 @@ private: if (posdiff > 25) { map_lat = bv_lat->value; map_lon = bv_lon->value; - getBackgroundMap(map_lat, map_lon, zoom); + map_valid = getBackgroundMap(map_lat, map_lon, zoom); if (map_valid) { // prepare visible space for anchor-symbol or boat canvas->fillCircle(132, 130, 12, commonData->fgcolor); @@ -139,10 +160,10 @@ private: // TODO rotate boat according to current heading if (bv_hdt->valid) { if (map_valid) { - Point b1 = rotatePoint(c, {b.x, b.y - 8}, RadToDeg(bv_hdt->value)); + Point b1 = rotatePoint(c, {b.x, b.y - 8}, bv_hdt->value * RAD_TO_DEG); getdisplay().fillCircle(b1.x, b1.y, 10, commonData->bgcolor); } - drawPoly(rotatePoints(c, pts_boat, RadToDeg(bv_hdt->value)), commonData->fgcolor); + drawPoly(rotatePoints(c, pts_boat, bv_hdt->value * RAD_TO_DEG), commonData->fgcolor); } else { // no heading available draw north oriented if (map_valid) { @@ -246,13 +267,33 @@ private: } - void displayModeConfig() { + void displayModeConfig(PageData &pageData) { + getdisplay().setTextColor(commonData->fgcolor); getdisplay().setFont(&Ubuntu_Bold12pt8b); getdisplay().setCursor(8, 48); getdisplay().print("Anchor configuration"); + getdisplay().setFont(&Ubuntu_Bold8pt8b); + + getdisplay().setCursor(8, 250); + getdisplay().print("Press MODE to leave config"); + + getdisplay().setCursor(8, 68); + getdisplay().printf("Server: %s", server_name.c_str()); + getdisplay().setCursor(8, 88); + getdisplay().printf("Port: %d", server_port); + getdisplay().setCursor(8, 108); + getdisplay().printf("Tilepath: %s", tile_path.c_str()); + + GwApi::BoatValue *bv_lat = pageData.values[4]; // LAT + GwApi::BoatValue *bv_lon = pageData.values[5]; // LON + if (!bv_lat->valid or !bv_lon->valid) { + getdisplay().setCursor(8, 128); + getdisplay().printf("No valid position: background map disabled"); + } + } public: @@ -261,8 +302,22 @@ public: commonData = &common; common.logger->logDebug(GwLog::LOG,"Instantiate PageAnchor"); - server_name = common.config->getString(common.config->mapServer); - tile_path = common.config->getString(common.config->mapTilePath); + String mapsource = common.config->getString(common.config->mapsource); + if (mapsource == "Local Service") { + map_service = 'L'; + server_name = common.config->getString(common.config->ipAddress); + server_port = common.config->getInt(common.config->localPort); + tile_path = ""; + } else if (mapsource == "Remote Service") { + map_service = 'R'; + server_name = common.config->getString(common.config->mapServer); + tile_path = common.config->getString(common.config->mapTilePath); + } else { // OBP Service or undefined + map_service = 'O'; + server_name = "norbert-walter.dnshome.de"; + tile_path = ""; + } + zoom = common.config->getInt(common.config->zoomlevel); lengthformat = common.config->getString(common.config->lengthFormat); chain_length = common.config->getInt(common.config->chainLength); @@ -414,7 +469,7 @@ public: if (mode == 'N') { displayModeNormal(pageData); } else if (mode == 'C') { - displayModeConfig(); + displayModeConfig(pageData); } return PAGE_UPDATE; diff --git a/lib/obp60task/config_obp40.json b/lib/obp60task/config_obp40.json index a3ef4db..508c3f5 100644 --- a/lib/obp60task/config_obp40.json +++ b/lib/obp60task/config_obp40.json @@ -19,28 +19,6 @@ "obp40": "true" } }, - { - "name": "mapServer", - "label": "map server", - "type": "string", - "default": "", - "description": "Server for converting map tiles. Use only one hostname or IP address", - "category": "wifi client", - "capabilities": { - "obp40": "true" - } - }, - { - "name": "mapTilePath", - "label": "map tile path", - "type": "string", - "default": "map.php", - "description": "Path to converter access e.g. index.php or map.php", - "category": "wifi client", - "capabilities": { - "obp40": "true" - } - }, { "name": "timeZone", "label": "Time Zone", @@ -108,7 +86,7 @@ "description": "The length of the anchor chain [0...255m]", "category": "OBP40 Settings", "capabilities": { - "obp40":"true" + "obp40": "true" } }, { @@ -714,7 +692,7 @@ "type": "string", "default": "text1", "description": "Button name", - "category": "OBP60 IO-Modul1", + "category": "OBP40 IO-Modul1", "capabilities": { "obp40":"true" } @@ -725,7 +703,7 @@ "type": "string", "default": "text2", "description": "Button name", - "category": "OBP60 IO-Modul1", + "category": "OBP40 IO-Modul1", "capabilities": { "obp40":"true" } @@ -736,7 +714,7 @@ "type": "string", "default": "text3", "description": "Button name", - "category": "OBP60 IO-Modul1", + "category": "OBP40 IO-Modul1", "capabilities": { "obp40":"true" } @@ -747,7 +725,7 @@ "type": "string", "default": "text4", "description": "Button name", - "category": "OBP60 IO-Modul1", + "category": "OBP40 IO-Modul1", "capabilities": { "obp40":"true" } @@ -758,7 +736,7 @@ "type": "string", "default": "text5", "description": "Button name", - "category": "OBP60 IO-Modul1", + "category": "OBP40 IO-Modul1", "capabilities": { "obp40":"true" } @@ -1103,7 +1081,8 @@ "description": "Type of map source, cloud service or local service", "list": [ "OBP Service", - "Local Service" + "Local Service", + "Remote Service" ], "category": "OBP40 Navigation", "capabilities": { @@ -1140,6 +1119,34 @@ { "mapsource": ["Local Service"] } ] }, + { + "name": "mapServer", + "label": "map server", + "type": "string", + "default": "", + "description": "Server for converting map tiles. Use only one hostname or IP address", + "category": "OBP40 Navigation", + "capabilities": { + "obp40": "true" + }, + "condition": [ + { "mapsource": ["Remote Service"] } + ] + }, + { + "name": "mapTilePath", + "label": "map tile path", + "type": "string", + "default": "map.php", + "description": "Path to converter access e.g. index.php or map.php", + "category": "OBP40 Navigation", + "capabilities": { + "obp40": "true" + }, + "condition": [ + { "mapsource": ["Remote Service"] } + ] + }, { "name": "maptype", "label": "Map Type",