mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2025-12-28 21:23:07 +01:00
Add settings for PageNavigation (multi map)
This commit is contained in:
@@ -15,7 +15,8 @@ ImageDecoder decoder; // Define image decoder
|
|||||||
class PageNavigation : public Page
|
class PageNavigation : public Page
|
||||||
{
|
{
|
||||||
// Values for buttons
|
// 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
|
bool showValues = false; // Show values COG, SOG, DBT in navigation map
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -57,6 +58,31 @@ public:
|
|||||||
GwConfigHandler *config = commonData->config;
|
GwConfigHandler *config = commonData->config;
|
||||||
GwLog *logger = commonData->logger;
|
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
|
// Old values for hold function
|
||||||
static double value1old = 0;
|
static double value1old = 0;
|
||||||
static String svalue1old = "";
|
static String svalue1old = "";
|
||||||
@@ -185,29 +211,91 @@ public:
|
|||||||
depthBelowTransducer = value5old;
|
depthBelowTransducer = value5old;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Server settings
|
// Prepare config values for URL
|
||||||
String server = "norbert-walter.dnshome.de";
|
//*************************************************
|
||||||
int port = 80;
|
|
||||||
|
// 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
|
// URL to OBP Maps Converter
|
||||||
// For more details see: https://github.com/norbert-walter/maps-converter
|
// For more details see: https://github.com/norbert-walter/maps-converter
|
||||||
String url = String("http://") + server + ":" + port + // OBP Server
|
String url = String("http://") + server + ":" + port + // OBP Server
|
||||||
String("/get_image_json?") + // Service: Output B&W picture as JSON (Base64 + gzip)
|
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
|
"&lat=" + String(latitude, 6) + // Latitude
|
||||||
"&lon=" + String(longitude, 6) + // Longitude
|
"&lon=" + String(longitude, 6) + // Longitude
|
||||||
"&mrot=" + int(courseOverGround) + // Rotation angle navigation map in degree
|
"&mrot=" + mapRot + // Rotation angle navigation map in degree
|
||||||
"&mtype=1" + // Open Street Map
|
"&mtype=" + mType + // Default Map: Open Street Map
|
||||||
"&dtype=4" + // Dithering type: Atkinson dithering
|
"&dtype=" + dType + // Dithering type: Atkinson dithering
|
||||||
"&width=400" + // With navigation map
|
"&width=400" + // With navigation map
|
||||||
"&height=250" + // Height navigation map
|
"&height=250" + // Height navigation map
|
||||||
"&cutout=0" + // No picture cutouts
|
"&cutout=0" + // No picture cutouts
|
||||||
"&tab=0" + // No tab size
|
"&tab=0" + // No tab size
|
||||||
"&border=2" + // Border line size: 2 pixel
|
"&border=2" + // Border line size: 2 pixel
|
||||||
"&symbol=2" + // Symbol: Triangle
|
"&symbol=2" + // Symbol: Triangle
|
||||||
"&srot=" + int(courseOverGround) + // Symbol rotation angle
|
"&srot=" + symbolRot + // Symbol rotation angle
|
||||||
"&ssize=15" + // Symbole size: 15 pixel
|
"&ssize=15" + // Symbole size: 15 pixel
|
||||||
"&grid=0" // Show grid: On
|
"&grid=" + mapGrid // Show grid: On
|
||||||
;
|
;
|
||||||
|
|
||||||
// Draw page
|
// Draw page
|
||||||
@@ -238,9 +326,9 @@ public:
|
|||||||
memcpy(b64, b64src, b64len + 1); // Copy Base64 content in PSRAM
|
memcpy(b64, b64src, b64len + 1); // Copy Base64 content in PSRAM
|
||||||
|
|
||||||
// Set image buffer 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
|
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) {
|
if (!imageData) {
|
||||||
LOG_DEBUG(GwLog::ERROR,"Error PageNavigation: PPSRAM alloc image buffer failed");
|
LOG_DEBUG(GwLog::ERROR,"Error PageNavigation: PPSRAM alloc image buffer failed");
|
||||||
free(b64);
|
free(b64);
|
||||||
@@ -271,8 +359,8 @@ public:
|
|||||||
|
|
||||||
if(showValues == true){
|
if(showValues == true){
|
||||||
// Frame
|
// Frame
|
||||||
getdisplay().fillRect(0, 25 , 130, 70, commonData->fgcolor); // Black rect
|
getdisplay().fillRect(0, 25 , 130, 65, commonData->fgcolor); // Black rect
|
||||||
getdisplay().fillRect(2, 27 , 126, 66, commonData->bgcolor); // White rect
|
getdisplay().fillRect(2, 27 , 126, 61, commonData->bgcolor); // White rect
|
||||||
// COG
|
// COG
|
||||||
getdisplay().setCursor(10, 45);
|
getdisplay().setCursor(10, 45);
|
||||||
getdisplay().print(name3);
|
getdisplay().print(name3);
|
||||||
|
|||||||
@@ -913,6 +913,117 @@
|
|||||||
{ "calInstance3": ["AWA", "AWS", "COG", "DBT", "HDM", "PRPOS", "RPOS", "SOG", "STW", "TWA", "TWS", "TWD", "WTemp" ] }
|
{ "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",
|
"name": "display",
|
||||||
"label": "Display Mode",
|
"label": "Display Mode",
|
||||||
|
|||||||
@@ -924,6 +924,117 @@
|
|||||||
{ "calInstance3": ["AWA", "AWS", "COG", "DBT", "HDM", "PRPOS", "RPOS", "SOG", "STW", "TWA", "TWS", "TWD", "WTemp" ] }
|
{ "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",
|
"name": "display",
|
||||||
"label": "Display Mode",
|
"label": "Display Mode",
|
||||||
|
|||||||
Reference in New Issue
Block a user