From ae2b7047f5afb5ecefca2fa2c11179b1898baa7a Mon Sep 17 00:00:00 2001 From: norbert-walter Date: Fri, 5 Dec 2025 18:33:42 +0100 Subject: [PATCH] Add settings for PageNavigation (multi map) --- lib/obp60task/PageNavigation.cpp | 116 +++++++++++++++++++++++++++---- lib/obp60task/config.json | 111 +++++++++++++++++++++++++++++ lib/obp60task/config_obp40.json | 111 +++++++++++++++++++++++++++++ 3 files changed, 324 insertions(+), 14 deletions(-) diff --git a/lib/obp60task/PageNavigation.cpp b/lib/obp60task/PageNavigation.cpp index 43803fa..b27f830 100644 --- a/lib/obp60task/PageNavigation.cpp +++ b/lib/obp60task/PageNavigation.cpp @@ -15,7 +15,8 @@ ImageDecoder decoder; // Define image decoder class PageNavigation : public Page { // Values for buttons -int zoom = 15; // Zoom level 1...17 +bool firstRun = true; // Detect the first page run +int zoom = 15; // Default zoom level bool showValues = false; // Show values COG, SOG, DBT in navigation map public: @@ -57,6 +58,31 @@ public: GwConfigHandler *config = commonData->config; GwLog *logger = commonData->logger; + // Get config data + String mapsource = config->getString(config->mapsource); + String ipAddress = config->getString(config->ipAddress); + int localPort = config->getInt(config->localPort); + String mapType = config->getString(config->maptype); + int zoomLevel = config->getInt(config->zoomlevel); + bool grid = config->getBool(config->grid); + String orientation = config->getString(config->orientation); + int refreshDistance = config->getInt(config->refreshDistance); + + if(firstRun == true){ + zoom = zoomLevel; // Over write zoom level with setup value + firstRun = false; // Restet variable + } + + // Local variables + String server = "norbert-walter.dnshome.de"; + int port = 80; + int mType = 1; + int dType = 1; + int mapRot = 0; + int symbolRot = 0; + int mapGrid = 0; + + // Old values for hold function static double value1old = 0; static String svalue1old = ""; @@ -185,29 +211,91 @@ public: depthBelowTransducer = value5old; } - // Server settings - String server = "norbert-walter.dnshome.de"; - int port = 80; + // Prepare config values for URL + //************************************************* + + // Server settings + if(mapsource == "OBP Service"){ + server = "norbert-walter.dnshome.de"; + port = 80; + } + else if(mapsource == "Local Service"){ + server = String(ipAddress); + port = localPort; + } + else{ + server = "norbert-walter.dnshome.de"; + port = 80; + } + + // Type of navigation map + if(mapType == "Open Street Map"){ + mType = 1; + dType = 1; + } + else if(mapType == "Google Street"){ + mType = 3; + dType = 2; + } + else if(mapType == "Open Topo Map"){ + mType = 5; + dType = 2; + } + else if(mapType == "Stadimaps Toner"){ + mType = 7; + dType = 1; + } + else if(mapType == "Free Nautical Chart"){ + mType = 9; + dType = 1; + } + else{ + mType = 1; + dType = 1; + } + + // Map grid on/off + if(grid == true){ + mapGrid = 1; + } + else{ + mapGrid = 0; + } + + // Map orientation + if(orientation == "North Direction"){ + mapRot = 0; + symbolRot = courseOverGround;mapGrid = 0; + } + else if(orientation == "Travel Direction"){ + mapRot = courseOverGround; + symbolRot = courseOverGround; + } + else{ + mapRot = 0; + symbolRot = courseOverGround; + } + // URL to OBP Maps Converter // For more details see: https://github.com/norbert-walter/maps-converter String url = String("http://") + server + ":" + port + // OBP Server String("/get_image_json?") + // Service: Output B&W picture as JSON (Base64 + gzip) - "zoom=" + zoom + // Zoom level: 15 + "zoom=" + zoom + // Default zoom level: 15 "&lat=" + String(latitude, 6) + // Latitude "&lon=" + String(longitude, 6) + // Longitude - "&mrot=" + int(courseOverGround) + // Rotation angle navigation map in degree - "&mtype=1" + // Open Street Map - "&dtype=4" + // Dithering type: Atkinson dithering + "&mrot=" + mapRot + // Rotation angle navigation map in degree + "&mtype=" + mType + // Default Map: Open Street Map + "&dtype=" + dType + // Dithering type: Atkinson dithering "&width=400" + // With navigation map "&height=250" + // Height navigation map "&cutout=0" + // No picture cutouts "&tab=0" + // No tab size "&border=2" + // Border line size: 2 pixel "&symbol=2" + // Symbol: Triangle - "&srot=" + int(courseOverGround) + // Symbol rotation angle + "&srot=" + symbolRot + // Symbol rotation angle "&ssize=15" + // Symbole size: 15 pixel - "&grid=0" // Show grid: On + "&grid=" + mapGrid // Show grid: On ; // Draw page @@ -238,9 +326,9 @@ public: memcpy(b64, b64src, b64len + 1); // Copy Base64 content in PSRAM // Set image buffer in PSRAM - //size_t imgSize = getdisplay().width() * getdisplay().height(); // Calculate image size + //size_t imgSize = getdisplay().width() * getdisplay().height(); size_t imgSize = numPix; // Calculate image size - uint8_t* imageData = (uint8_t*) heap_caps_malloc(imgSize, MALLOC_CAP_SPIRAM); // Allocate PSRAM for image + uint8_t* imageData = (uint8_t*) heap_caps_malloc(imgSize, MALLOC_CAP_SPIRAM); // Allocate PSRAM for image if (!imageData) { LOG_DEBUG(GwLog::ERROR,"Error PageNavigation: PPSRAM alloc image buffer failed"); free(b64); @@ -271,8 +359,8 @@ public: if(showValues == true){ // Frame - getdisplay().fillRect(0, 25 , 130, 70, commonData->fgcolor); // Black rect - getdisplay().fillRect(2, 27 , 126, 66, commonData->bgcolor); // White rect + getdisplay().fillRect(0, 25 , 130, 65, commonData->fgcolor); // Black rect + getdisplay().fillRect(2, 27 , 126, 61, commonData->bgcolor); // White rect // COG getdisplay().setCursor(10, 45); getdisplay().print(name3); diff --git a/lib/obp60task/config.json b/lib/obp60task/config.json index 2de3c59..a0080a4 100644 --- a/lib/obp60task/config.json +++ b/lib/obp60task/config.json @@ -913,6 +913,117 @@ { "calInstance3": ["AWA", "AWS", "COG", "DBT", "HDM", "PRPOS", "RPOS", "SOG", "STW", "TWA", "TWS", "TWD", "WTemp" ] } ] }, + { + "name": "mapsource", + "label": "Map Source", + "type": "list", + "default": "OBP Service", + "description": "Type of map source, cloud service or local service", + "list": [ + "OBP Service", + "Local Service" + ], + "category": "OBP60 Navigation", + "capabilities": { + "obp60":"true" + } + }, + { + "name": "ipAddress", + "label": "IP Address", + "type": "string", + "default": "192.168.15.10", + "check": "checkIpAddress", + "description": "IP address only for local map service e.g. 192.168.15.10\nor an MDNS name like Raspi.local", + "category": "OBP60 Navigation", + "capabilities": { + "obp60":"true" + } + }, + { + "name": "localPort", + "label": "Port", + "type": "number", + "default": "8080", + "check":"checkPort", + "description": "TCP port for local map server", + "category": "TCP client", + "capabilities": { + "obp60":"true" + } + }, + { + "name": "maptype", + "label": "Map Type", + "type": "list", + "default": "Open Street Map", + "description": "Type of base navigation map with sea marks overlay", + "list": [ + "Open Street Map", + "Google Street", + "Open Topo Map", + "Stadimaps Toner", + "Free Nautical Chart" + ], + "category": "OBP60 Navigation", + "capabilities": { + "obp60":"true" + } + }, + { + "name": "zoomlevel", + "label": "Default Zool Level", + "type": "number", + "default": "15", + "check": "checkMinMax", + "min": 7, + "max": 17, + "description": "Zoom level for map [7..17]; 15 = default", + "category": "OBP60 Navigation", + "capabilities": { + "obp60":"true" + } + }, + { + "name": "grid", + "label": "Show Grid", + "type": "boolean", + "default": "false", + "description": "Show the grid for latutude and longitude", + "category": "OBP60 Navigation", + "capabilities": { + "obp60": "true" + } + }, + { + "name": "orientation", + "label": "Map Orientation", + "type": "list", + "default": "North Dirirection", + "description": "Map orientation for navigation", + "list": [ + "North Direction", + "Travel Direction" + ], + "category": "OBP60 Navigation", + "capabilities": { + "obp60":"true" + } + }, + { + "name": "refreshDistance", + "label": "Refresh Distance [m]", + "type": "number", + "default": "15", + "check": "checkMinMax", + "min": 1, + "max": 50, + "description": "Refresh distance between updates [1..50 m], 15 m = default", + "category": "OBP60 Navigation", + "capabilities": { + "obp60":"true" + } + }, { "name": "display", "label": "Display Mode", diff --git a/lib/obp60task/config_obp40.json b/lib/obp60task/config_obp40.json index 30c7b2d..ff84a89 100644 --- a/lib/obp60task/config_obp40.json +++ b/lib/obp60task/config_obp40.json @@ -924,6 +924,117 @@ { "calInstance3": ["AWA", "AWS", "COG", "DBT", "HDM", "PRPOS", "RPOS", "SOG", "STW", "TWA", "TWS", "TWD", "WTemp" ] } ] }, + { + "name": "mapsource", + "label": "Map Source", + "type": "list", + "default": "OBP Service", + "description": "Type of map source, cloud service or local service", + "list": [ + "OBP Service", + "Local Service" + ], + "category": "OBP60 Navigation", + "capabilities": { + "obp40":"true" + } + }, + { + "name": "ipAddress", + "label": "IP Address", + "type": "string", + "default": "192.168.15.10", + "check": "checkIpAddress", + "description": "IP address only for local map service e.g. 192.168.15.10\nor an MDNS name like Raspi.local", + "category": "OBP60 Navigation", + "capabilities": { + "obp40":"true" + } + }, + { + "name": "localPort", + "label": "Port", + "type": "number", + "default": "8080", + "check":"checkPort", + "description": "TCP port for local map server", + "category": "TCP client", + "capabilities": { + "obp40":"true" + } + }, + { + "name": "maptype", + "label": "Map Type", + "type": "list", + "default": "Open Street Map", + "description": "Type of base navigation map with sea marks overlay", + "list": [ + "Open Street Map", + "Google Street", + "Open Topo Map", + "Stadimaps Toner", + "Free Nautical Chart" + ], + "category": "OBP60 Navigation", + "capabilities": { + "obp40":"true" + } + }, + { + "name": "zoomlevel", + "label": "Default Zool Level", + "type": "number", + "default": "15", + "check": "checkMinMax", + "min": 7, + "max": 17, + "description": "Zoom level for map [7..17]; 15 = default", + "category": "OBP60 Navigation", + "capabilities": { + "obp40":"true" + } + }, + { + "name": "grid", + "label": "Show Grid", + "type": "boolean", + "default": "false", + "description": "Show the grid for latutude and longitude", + "category": "OBP60 Navigation", + "capabilities": { + "obp40": "true" + } + }, + { + "name": "orientation", + "label": "Map Orientation", + "type": "list", + "default": "North Dirirection", + "description": "Map orientation for navigation", + "list": [ + "North Direction", + "Travel Direction" + ], + "category": "OBP60 Navigation", + "capabilities": { + "obp40":"true" + } + }, + { + "name": "refreshDistance", + "label": "Refresh Distance [m]", + "type": "number", + "default": "15", + "check": "checkMinMax", + "min": 1, + "max": 50, + "description": "Refresh distance between updates [1..50 m], 15 m = default", + "category": "OBP60 Navigation", + "capabilities": { + "obp40":"true" + } + }, { "name": "display", "label": "Display Mode",