mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2026-02-24 20:53:07 +01:00
Work on Page Anchor
This commit is contained in:
@@ -26,6 +26,25 @@
|
|||||||
force map update if new position is different from old position by
|
force map update if new position is different from old position by
|
||||||
a certain level (e.g. 10m)
|
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 <WiFi.h>
|
#include <WiFi.h>
|
||||||
@@ -53,9 +72,11 @@ private:
|
|||||||
const uint16_t map_width = 264;
|
const uint16_t map_width = 264;
|
||||||
const uint16_t map_height = 260;
|
const uint16_t map_height = 260;
|
||||||
bool map_valid = false;
|
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_lat = 0; // current center of valid map
|
||||||
double map_lon = 0;
|
double map_lon = 0;
|
||||||
String server_name; // server with map service
|
String server_name; // server with map service
|
||||||
|
uint16_t server_port = 80;
|
||||||
String tile_path;
|
String tile_path;
|
||||||
|
|
||||||
String lengthformat;
|
String lengthformat;
|
||||||
@@ -109,7 +130,7 @@ private:
|
|||||||
if (posdiff > 25) {
|
if (posdiff > 25) {
|
||||||
map_lat = bv_lat->value;
|
map_lat = bv_lat->value;
|
||||||
map_lon = bv_lon->value;
|
map_lon = bv_lon->value;
|
||||||
getBackgroundMap(map_lat, map_lon, zoom);
|
map_valid = getBackgroundMap(map_lat, map_lon, zoom);
|
||||||
if (map_valid) {
|
if (map_valid) {
|
||||||
// prepare visible space for anchor-symbol or boat
|
// prepare visible space for anchor-symbol or boat
|
||||||
canvas->fillCircle(132, 130, 12, commonData->fgcolor);
|
canvas->fillCircle(132, 130, 12, commonData->fgcolor);
|
||||||
@@ -139,10 +160,10 @@ private:
|
|||||||
// TODO rotate boat according to current heading
|
// TODO rotate boat according to current heading
|
||||||
if (bv_hdt->valid) {
|
if (bv_hdt->valid) {
|
||||||
if (map_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);
|
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 {
|
} else {
|
||||||
// no heading available draw north oriented
|
// no heading available draw north oriented
|
||||||
if (map_valid) {
|
if (map_valid) {
|
||||||
@@ -246,13 +267,33 @@ private:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void displayModeConfig() {
|
void displayModeConfig(PageData &pageData) {
|
||||||
|
|
||||||
|
|
||||||
getdisplay().setTextColor(commonData->fgcolor);
|
getdisplay().setTextColor(commonData->fgcolor);
|
||||||
getdisplay().setFont(&Ubuntu_Bold12pt8b);
|
getdisplay().setFont(&Ubuntu_Bold12pt8b);
|
||||||
getdisplay().setCursor(8, 48);
|
getdisplay().setCursor(8, 48);
|
||||||
getdisplay().print("Anchor configuration");
|
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:
|
public:
|
||||||
@@ -261,8 +302,22 @@ public:
|
|||||||
commonData = &common;
|
commonData = &common;
|
||||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageAnchor");
|
common.logger->logDebug(GwLog::LOG,"Instantiate PageAnchor");
|
||||||
|
|
||||||
server_name = common.config->getString(common.config->mapServer);
|
String mapsource = common.config->getString(common.config->mapsource);
|
||||||
tile_path = common.config->getString(common.config->mapTilePath);
|
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);
|
lengthformat = common.config->getString(common.config->lengthFormat);
|
||||||
chain_length = common.config->getInt(common.config->chainLength);
|
chain_length = common.config->getInt(common.config->chainLength);
|
||||||
@@ -414,7 +469,7 @@ public:
|
|||||||
if (mode == 'N') {
|
if (mode == 'N') {
|
||||||
displayModeNormal(pageData);
|
displayModeNormal(pageData);
|
||||||
} else if (mode == 'C') {
|
} else if (mode == 'C') {
|
||||||
displayModeConfig();
|
displayModeConfig(pageData);
|
||||||
}
|
}
|
||||||
|
|
||||||
return PAGE_UPDATE;
|
return PAGE_UPDATE;
|
||||||
|
|||||||
@@ -19,28 +19,6 @@
|
|||||||
"obp40": "true"
|
"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",
|
"name": "timeZone",
|
||||||
"label": "Time Zone",
|
"label": "Time Zone",
|
||||||
@@ -108,7 +86,7 @@
|
|||||||
"description": "The length of the anchor chain [0...255m]",
|
"description": "The length of the anchor chain [0...255m]",
|
||||||
"category": "OBP40 Settings",
|
"category": "OBP40 Settings",
|
||||||
"capabilities": {
|
"capabilities": {
|
||||||
"obp40":"true"
|
"obp40": "true"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -714,7 +692,7 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"default": "text1",
|
"default": "text1",
|
||||||
"description": "Button name",
|
"description": "Button name",
|
||||||
"category": "OBP60 IO-Modul1",
|
"category": "OBP40 IO-Modul1",
|
||||||
"capabilities": {
|
"capabilities": {
|
||||||
"obp40":"true"
|
"obp40":"true"
|
||||||
}
|
}
|
||||||
@@ -725,7 +703,7 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"default": "text2",
|
"default": "text2",
|
||||||
"description": "Button name",
|
"description": "Button name",
|
||||||
"category": "OBP60 IO-Modul1",
|
"category": "OBP40 IO-Modul1",
|
||||||
"capabilities": {
|
"capabilities": {
|
||||||
"obp40":"true"
|
"obp40":"true"
|
||||||
}
|
}
|
||||||
@@ -736,7 +714,7 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"default": "text3",
|
"default": "text3",
|
||||||
"description": "Button name",
|
"description": "Button name",
|
||||||
"category": "OBP60 IO-Modul1",
|
"category": "OBP40 IO-Modul1",
|
||||||
"capabilities": {
|
"capabilities": {
|
||||||
"obp40":"true"
|
"obp40":"true"
|
||||||
}
|
}
|
||||||
@@ -747,7 +725,7 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"default": "text4",
|
"default": "text4",
|
||||||
"description": "Button name",
|
"description": "Button name",
|
||||||
"category": "OBP60 IO-Modul1",
|
"category": "OBP40 IO-Modul1",
|
||||||
"capabilities": {
|
"capabilities": {
|
||||||
"obp40":"true"
|
"obp40":"true"
|
||||||
}
|
}
|
||||||
@@ -758,7 +736,7 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"default": "text5",
|
"default": "text5",
|
||||||
"description": "Button name",
|
"description": "Button name",
|
||||||
"category": "OBP60 IO-Modul1",
|
"category": "OBP40 IO-Modul1",
|
||||||
"capabilities": {
|
"capabilities": {
|
||||||
"obp40":"true"
|
"obp40":"true"
|
||||||
}
|
}
|
||||||
@@ -1103,7 +1081,8 @@
|
|||||||
"description": "Type of map source, cloud service or local service",
|
"description": "Type of map source, cloud service or local service",
|
||||||
"list": [
|
"list": [
|
||||||
"OBP Service",
|
"OBP Service",
|
||||||
"Local Service"
|
"Local Service",
|
||||||
|
"Remote Service"
|
||||||
],
|
],
|
||||||
"category": "OBP40 Navigation",
|
"category": "OBP40 Navigation",
|
||||||
"capabilities": {
|
"capabilities": {
|
||||||
@@ -1140,6 +1119,34 @@
|
|||||||
{ "mapsource": ["Local Service"] }
|
{ "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",
|
"name": "maptype",
|
||||||
"label": "Map Type",
|
"label": "Map Type",
|
||||||
|
|||||||
Reference in New Issue
Block a user