diff --git a/lib/obp60task/GwOBP60Task.cpp b/lib/obp60task/GwOBP60Task.cpp index f68449f..f4f8a17 100644 --- a/lib/obp60task/GwOBP60Task.cpp +++ b/lib/obp60task/GwOBP60Task.cpp @@ -235,6 +235,11 @@ void OBP60Task(void *param){ // OBP60 Settings bool exampleSwitch = api->getConfig()->getConfigItem(api->getConfig()->obp60Config,true)->asBoolean(); LOG_DEBUG(GwLog::DEBUG,"example switch ist %s",exampleSwitch?"true":"false"); + api->getConfig()->getConfigItem(api->getConfig()->lengthFormat,true)->asString().toCharArray(busInfo.lengthformat, 16); + api->getConfig()->getConfigItem(api->getConfig()->distanceFormat,true)->asString().toCharArray(busInfo.distanceformat, 16); + api->getConfig()->getConfigItem(api->getConfig()->speedFormat,true)->asString().toCharArray(busInfo.speedformat, 16); + api->getConfig()->getConfigItem(api->getConfig()->windspeedFormat,true)->asString().toCharArray(busInfo.windspeedformat, 16); + api->getConfig()->getConfigItem(api->getConfig()->tempFormat,true)->asString().toCharArray(busInfo.tempformat, 16); api->getConfig()->getConfigItem(api->getConfig()->dateFormat,true)->asString().toCharArray(busInfo.dateformat, 3); busInfo.timezone = api->getConfig()->getConfigItem(api->getConfig()->timeZone,true)->asInt(); busInfo.draft = api->getConfig()->getConfigItem(api->getConfig()->draft,true)->asString().toFloat(); @@ -255,6 +260,7 @@ void OBP60Task(void *param){ api->getConfig()->getConfigItem(api->getConfig()->display,true)->asString().toCharArray(busInfo.displaymode, 16); busInfo.statusline = api->getConfig()->getConfigItem(api->getConfig()->statusLine,true)->asBoolean(); busInfo.refresh = api->getConfig()->getConfigItem(api->getConfig()->refresh,true)->asBoolean(); + busInfo.holdvalues = api->getConfig()->getConfigItem(api->getConfig()->holdvalues,true)->asBoolean(); api->getConfig()->getConfigItem(api->getConfig()->backlight,true)->asString().toCharArray(busInfo.backlight, 16); api->getConfig()->getConfigItem(api->getConfig()->powerMode,true)->asString().toCharArray(busInfo.powermode, 16); // OBP60 Buzzer diff --git a/lib/obp60task/GwOBP60Task.h b/lib/obp60task/GwOBP60Task.h index c1efe03..b6e8b3b 100644 --- a/lib/obp60task/GwOBP60Task.h +++ b/lib/obp60task/GwOBP60Task.h @@ -7,19 +7,19 @@ #define ESP32_CAN_TX_PIN GPIO_NUM_13 #define ESP32_CAN_RX_PIN GPIO_NUM_12 // Bus load in 50mA steps - #define N2K_LOAD_LEVEL 5 // 250mA max bus load with back light on + #define N2K_LOAD_LEVEL 5 // 5x50mA = 250mA max bus load with back light on // RS485 NMEA0183 #define GWSERIAL_TX 26 #define GWSERIAL_RX 14 #define GWSERIAL_MODE "UNI" + + // Init OBP60 Task + void OBP60Init(GwApi *param); + DECLARE_INITFUNCTION(OBP60Init); -// Init OBP60 Task -void OBP60Init(GwApi *param); -DECLARE_INITFUNCTION(OBP60Init); - -// OBP60 Task -void OBP60Task(void *param); -DECLARE_USERTASK_PARAM(OBP60Task, 25000) // Need 25k RAM as stack size -DECLARE_CAPABILITY(obp60,true); + // OBP60 Task + void OBP60Task(void *param); + DECLARE_USERTASK_PARAM(OBP60Task, 25000) // Need 25k RAM as stack size + DECLARE_CAPABILITY(obp60,true); #endif #endif diff --git a/lib/obp60task/OBP60Data.h b/lib/obp60task/OBP60Data.h index 0e7308e..62187c4 100644 --- a/lib/obp60task/OBP60Data.h +++ b/lib/obp60task/OBP60Data.h @@ -3,6 +3,10 @@ #include +float convert_m2ft(float inputvalue){ + return inputvalue * 3.28084; +} + typedef struct{ // Sub structure for bus data float fvalue = 0; // Float value char svalue[16] = ""; // Char value @@ -38,7 +42,12 @@ typedef struct{ char wificlientssid[32] = ""; // Wifi client SSID char wificlientpass[32] = ""; // Wifi client password // OBP60 Settings - char dateformat[3] = "GB"; // Date format for status line [DE|GB|US] + char lengthformat[16] = ""; // Length format [m|ft] + char distanceformat[16] = ""; // Distance format [m|km|nm] + char speedformat[16] = ""; // Speed format [m/s|km/h|kn] + char windspeedformat[16] = ""; // Speed format [m/s|km/h|kn|bft] + char tempformat[16] = ""; // Temperature format [K|C|F] + char dateformat[3] = ""; // Date format for status line [DE|GB|US] int timezone = 0; // Time zone [-12...+12] float draft = 0; // Boat draft up to keel [m] float fueltank = 0; // Fuel tank capacity [0...10m] @@ -46,25 +55,26 @@ typedef struct{ float watertank = 0; // Water tank kapacity [0...5000l] float wastetank = 0; // Waste tank kapacity [0...5000l] float batvoltage = 0; // Battery voltage [0...1000V] - char battype[16] = "Pb"; // Battery type [Pb|Gel|AGM|LiFePo4] + char battype[16] = ""; // Battery type [Pb|Gel|AGM|LiFePo4] float batcapacity = 0; // Battery capacity [0...10000Ah] // OBP60 Hardware bool gps = false; // Internal GPS [on|off] bool bme280 = false; // Internat BME280 [on|off] bool onewire = false; // Internal 1Wire bus [on|off] - char powermode[16] = "Max Power"; // Power mode [Max Power|Only 3.3V|Only 5.0V|Min Power] + char powermode[16] = ""; // Power mode [Max Power|Only 3.3V|Only 5.0V|Min Power] bool simulation = false; // Simulation data [on|off] // OBP60 Display - char displaymode[16] = "Logo + QR Code"; // Dislpay mode [White Screen|Logo|Logo + QR Code|Off] + char displaymode[16] = ""; // Dislpay mode [White Screen|Logo|Logo + QR Code|Off] bool statusline = true; // Show status line [on|off] bool refresh = false; // Refresh display after select a new page [on|off] - char backlight[16] = "Control by Key"; // Backlight mode [Off|Control by Sun|Control by Bus|Control by Time|Control by Key|On] - char flashled[16] = "Off"; // Flash LED mode [Off|Bus Data|GPX Fix|Limits Overrun] + bool holdvalues = false; // Hold values on missing data stream [on|off] + char backlight[16] = ""; // Backlight mode [Off|Control by Sun|Control by Bus|Control by Time|Control by Key|On] + char flashled[16] = ""; // Flash LED mode [Off|Bus Data|GPX Fix|Limits Overrun] // OBP60 Buzzer bool buzerror = false; // Buzzer error [on|off] bool buzgps = false; // Buzzer by GPS error [on|off] bool buzlimits = false; // Buzzer by limit underruns and overruns [on|off] - char buzmode[16] = "Off"; // Buzzer mode [Off|Short Single Beep|Lond Single Beep|Beep until Confirmation] + char buzmode[16] = ""; // Buzzer mode [Off|Short Single Beep|Lond Single Beep|Beep until Confirmation] int buzpower = 0; // Buzzer power [0...100%] // OBP60 Pages int numpages = 1; // Numper of listed pages diff --git a/lib/obp60task/OBP60Hardware.h b/lib/obp60task/OBP60Hardware.h index 24b3be7..14b10e5 100644 --- a/lib/obp60task/OBP60Hardware.h +++ b/lib/obp60task/OBP60Hardware.h @@ -1,5 +1,6 @@ - // Other pin definititins see GwOBP60Task.h - + // General hardware definitions + // CAN bus pin definitions see GwOBP60Task.h + // Direction pin for RS485 NMEA0183 #define OBP_DIRECTION_PIN 27 // SeaTalk diff --git a/lib/obp60task/Page_0.h b/lib/obp60task/Page_0.h index fc91f27..2cab176 100644 --- a/lib/obp60task/Page_0.h +++ b/lib/obp60task/Page_0.h @@ -5,14 +5,20 @@ #include "OBP60Hardware.h" void page_0(busData pvalues){ - // Name and unit + // Show name display.setFont(&Ubuntu_Bold32pt7b); display.setTextColor(GxEPD_BLACK); display.setCursor(20, 100); display.print("Depth"); display.setFont(&Ubuntu_Bold20pt7b); display.setCursor(270, 100); - display.print("m"); + // Show unit + if(String(pvalues.lengthformat) == "m"){ + display.print("m"); + } + if(String(pvalues.lengthformat) == "ft"){ + display.print("ft"); + } display.setFont(&DSEG7Classic_BoldItalic60pt7b); display.setCursor(20, 240); @@ -24,8 +30,16 @@ void page_0(busData pvalues){ display.print(depth,1); } else{ - if(pvalues.WaterDepth.valid == true){ // Check vor valid real data - depth = pvalues.WaterDepth.fvalue; // Real bus data + // Check vor valid real data, display also if hold values activated + if(pvalues.WaterDepth.valid == true || pvalues.holdvalues == true){ + // Unit conversion + if(String(pvalues.lengthformat) == "m"){ + depth = pvalues.WaterDepth.fvalue; // Real bus data m + } + if(String(pvalues.lengthformat) == "ft"){ + depth = convert_m2ft(pvalues.WaterDepth.fvalue); // Bus data in ft + } + // Resolution switching if(depth <= 99.9){ display.print(depth,1); } diff --git a/lib/obp60task/config.json b/lib/obp60task/config.json index 1216cce..deb87d6 100644 --- a/lib/obp60task/config.json +++ b/lib/obp60task/config.json @@ -10,22 +10,6 @@ "obp60":"true" } }, - { - "name": "dateFormat", - "label": "Date Format", - "type": "list", - "default": "GB", - "description": "Date format [DE|GB|US] DE: 31.12.2022, GB: 31/12/2022, US: 12/31/2022", - "list": [ - "DE", - "GB", - "US" - ], - "category": "OBP60 Settings", - "capabilities": { - "obp60":"true" - } - }, { "name": "timeZone", "label": "Time Zone", @@ -155,6 +139,102 @@ "obp60":"true" } }, + { + "name": "lengthFormat", + "label": "Length Format", + "type": "list", + "default": "m", + "description": "Length format [m|ft]", + "list": [ + "m", + "ft" + ], + "category": "OBP60 Units", + "capabilities": { + "obp60":"true" + } + }, + { + "name": "distanceFormat", + "label": "Distance Format", + "type": "list", + "default": "m", + "description": "Distance format [m|km|nm]", + "list": [ + "m", + "km", + "nm" + ], + "category": "OBP60 Units", + "capabilities": { + "obp60":"true" + } + }, + { + "name": "speedFormat", + "label": "Speed Format", + "type": "list", + "default": "m/s", + "description": "Distance format [m/s|km/h|kn]", + "list": [ + "m/s", + "km/h", + "kn" + ], + "category": "OBP60 Units", + "capabilities": { + "obp60":"true" + } + }, + { + "name": "windspeedFormat", + "label": "Wind Speed Format", + "type": "list", + "default": "m/s", + "description": "Distance format [m/s|km/h|kn|bft]", + "list": [ + "m/s", + "km/h", + "kn", + "bft" + ], + "category": "OBP60 Units", + "capabilities": { + "obp60":"true" + } + }, + { + "name": "tempFormat", + "label": "Temperature Format", + "type": "list", + "default": "C", + "description": "Length format [K|°C|°F]", + "list": [ + "K", + "C", + "F" + ], + "category": "OBP60 Units", + "capabilities": { + "obp60":"true" + } + }, + { + "name": "dateFormat", + "label": "Date Format", + "type": "list", + "default": "GB", + "description": "Date format [DE|GB|US] DE: 31.12.2022, GB: 31/12/2022, US: 12/31/2022", + "list": [ + "DE", + "GB", + "US" + ], + "category": "OBP60 Units", + "capabilities": { + "obp60":"true" + } + }, { "name": "useGPS", "label": "GPS NEO-6M", @@ -235,7 +315,7 @@ }, { "name": "statusLine", - "label": "Status line", + "label": "Status Line", "type": "boolean", "default": "true", "description": "Show status line [on|off]", @@ -255,6 +335,17 @@ "obp60":"true" } }, + { + "name": "holdvalues", + "label": "Hold Values", + "type": "boolean", + "default": "false", + "description": "Hold old measuring values by missing data stream [on|off]", + "category": "OBP60 Display", + "capabilities": { + "obp60":"true" + } + }, { "name": "backlight", "label": "Backlight Mode", @@ -296,7 +387,7 @@ "label": "Buzzer Error", "type": "boolean", "default": "false", - "description": "Settings for buzzer", + "description": "Sound on error", "category": "OBP60 Buzzer", "capabilities": { "obp60":"true" @@ -307,7 +398,7 @@ "label": "Buzzer GPS Fix", "type": "boolean", "default": "false", - "description": "Settings for buzzer", + "description": "Sound on missing or lost GPS fix", "category": "OBP60 Buzzer", "capabilities": { "obp60":"true" @@ -318,7 +409,7 @@ "label": "Buzzer by Limits", "type": "boolean", "default": "false", - "description": "Tone by limit overrun", + "description": "Sound on limit overrun", "category": "OBP60 Buzzer", "capabilities": { "obp60":"true"