Add unit parameter and unit conversion
This commit is contained in:
parent
25c9ec0afe
commit
9d0799f2cf
|
@ -235,6 +235,11 @@ void OBP60Task(void *param){
|
||||||
// OBP60 Settings
|
// OBP60 Settings
|
||||||
bool exampleSwitch = api->getConfig()->getConfigItem(api->getConfig()->obp60Config,true)->asBoolean();
|
bool exampleSwitch = api->getConfig()->getConfigItem(api->getConfig()->obp60Config,true)->asBoolean();
|
||||||
LOG_DEBUG(GwLog::DEBUG,"example switch ist %s",exampleSwitch?"true":"false");
|
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);
|
api->getConfig()->getConfigItem(api->getConfig()->dateFormat,true)->asString().toCharArray(busInfo.dateformat, 3);
|
||||||
busInfo.timezone = api->getConfig()->getConfigItem(api->getConfig()->timeZone,true)->asInt();
|
busInfo.timezone = api->getConfig()->getConfigItem(api->getConfig()->timeZone,true)->asInt();
|
||||||
busInfo.draft = api->getConfig()->getConfigItem(api->getConfig()->draft,true)->asString().toFloat();
|
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);
|
api->getConfig()->getConfigItem(api->getConfig()->display,true)->asString().toCharArray(busInfo.displaymode, 16);
|
||||||
busInfo.statusline = api->getConfig()->getConfigItem(api->getConfig()->statusLine,true)->asBoolean();
|
busInfo.statusline = api->getConfig()->getConfigItem(api->getConfig()->statusLine,true)->asBoolean();
|
||||||
busInfo.refresh = api->getConfig()->getConfigItem(api->getConfig()->refresh,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()->backlight,true)->asString().toCharArray(busInfo.backlight, 16);
|
||||||
api->getConfig()->getConfigItem(api->getConfig()->powerMode,true)->asString().toCharArray(busInfo.powermode, 16);
|
api->getConfig()->getConfigItem(api->getConfig()->powerMode,true)->asString().toCharArray(busInfo.powermode, 16);
|
||||||
// OBP60 Buzzer
|
// OBP60 Buzzer
|
||||||
|
|
|
@ -7,19 +7,19 @@
|
||||||
#define ESP32_CAN_TX_PIN GPIO_NUM_13
|
#define ESP32_CAN_TX_PIN GPIO_NUM_13
|
||||||
#define ESP32_CAN_RX_PIN GPIO_NUM_12
|
#define ESP32_CAN_RX_PIN GPIO_NUM_12
|
||||||
// Bus load in 50mA steps
|
// 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
|
// RS485 NMEA0183
|
||||||
#define GWSERIAL_TX 26
|
#define GWSERIAL_TX 26
|
||||||
#define GWSERIAL_RX 14
|
#define GWSERIAL_RX 14
|
||||||
#define GWSERIAL_MODE "UNI"
|
#define GWSERIAL_MODE "UNI"
|
||||||
|
|
||||||
// Init OBP60 Task
|
// Init OBP60 Task
|
||||||
void OBP60Init(GwApi *param);
|
void OBP60Init(GwApi *param);
|
||||||
DECLARE_INITFUNCTION(OBP60Init);
|
DECLARE_INITFUNCTION(OBP60Init);
|
||||||
|
|
||||||
// OBP60 Task
|
// OBP60 Task
|
||||||
void OBP60Task(void *param);
|
void OBP60Task(void *param);
|
||||||
DECLARE_USERTASK_PARAM(OBP60Task, 25000) // Need 25k RAM as stack size
|
DECLARE_USERTASK_PARAM(OBP60Task, 25000) // Need 25k RAM as stack size
|
||||||
DECLARE_CAPABILITY(obp60,true);
|
DECLARE_CAPABILITY(obp60,true);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -3,6 +3,10 @@
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
float convert_m2ft(float inputvalue){
|
||||||
|
return inputvalue * 3.28084;
|
||||||
|
}
|
||||||
|
|
||||||
typedef struct{ // Sub structure for bus data
|
typedef struct{ // Sub structure for bus data
|
||||||
float fvalue = 0; // Float value
|
float fvalue = 0; // Float value
|
||||||
char svalue[16] = ""; // Char value
|
char svalue[16] = ""; // Char value
|
||||||
|
@ -38,7 +42,12 @@ typedef struct{
|
||||||
char wificlientssid[32] = ""; // Wifi client SSID
|
char wificlientssid[32] = ""; // Wifi client SSID
|
||||||
char wificlientpass[32] = ""; // Wifi client password
|
char wificlientpass[32] = ""; // Wifi client password
|
||||||
// OBP60 Settings
|
// 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]
|
int timezone = 0; // Time zone [-12...+12]
|
||||||
float draft = 0; // Boat draft up to keel [m]
|
float draft = 0; // Boat draft up to keel [m]
|
||||||
float fueltank = 0; // Fuel tank capacity [0...10m]
|
float fueltank = 0; // Fuel tank capacity [0...10m]
|
||||||
|
@ -46,25 +55,26 @@ typedef struct{
|
||||||
float watertank = 0; // Water tank kapacity [0...5000l]
|
float watertank = 0; // Water tank kapacity [0...5000l]
|
||||||
float wastetank = 0; // Waste tank kapacity [0...5000l]
|
float wastetank = 0; // Waste tank kapacity [0...5000l]
|
||||||
float batvoltage = 0; // Battery voltage [0...1000V]
|
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]
|
float batcapacity = 0; // Battery capacity [0...10000Ah]
|
||||||
// OBP60 Hardware
|
// OBP60 Hardware
|
||||||
bool gps = false; // Internal GPS [on|off]
|
bool gps = false; // Internal GPS [on|off]
|
||||||
bool bme280 = false; // Internat BME280 [on|off]
|
bool bme280 = false; // Internat BME280 [on|off]
|
||||||
bool onewire = false; // Internal 1Wire bus [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]
|
bool simulation = false; // Simulation data [on|off]
|
||||||
// OBP60 Display
|
// 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 statusline = true; // Show status line [on|off]
|
||||||
bool refresh = false; // Refresh display after select a new page [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]
|
bool holdvalues = false; // Hold values on missing data stream [on|off]
|
||||||
char flashled[16] = "Off"; // Flash LED mode [Off|Bus Data|GPX Fix|Limits Overrun]
|
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
|
// OBP60 Buzzer
|
||||||
bool buzerror = false; // Buzzer error [on|off]
|
bool buzerror = false; // Buzzer error [on|off]
|
||||||
bool buzgps = false; // Buzzer by GPS error [on|off]
|
bool buzgps = false; // Buzzer by GPS error [on|off]
|
||||||
bool buzlimits = false; // Buzzer by limit underruns and overruns [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%]
|
int buzpower = 0; // Buzzer power [0...100%]
|
||||||
// OBP60 Pages
|
// OBP60 Pages
|
||||||
int numpages = 1; // Numper of listed pages
|
int numpages = 1; // Numper of listed pages
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
// Other pin definititins see GwOBP60Task.h
|
// General hardware definitions
|
||||||
|
// CAN bus pin definitions see GwOBP60Task.h
|
||||||
|
|
||||||
// Direction pin for RS485 NMEA0183
|
// Direction pin for RS485 NMEA0183
|
||||||
#define OBP_DIRECTION_PIN 27
|
#define OBP_DIRECTION_PIN 27
|
||||||
|
|
|
@ -5,14 +5,20 @@
|
||||||
#include "OBP60Hardware.h"
|
#include "OBP60Hardware.h"
|
||||||
|
|
||||||
void page_0(busData pvalues){
|
void page_0(busData pvalues){
|
||||||
// Name and unit
|
// Show name
|
||||||
display.setFont(&Ubuntu_Bold32pt7b);
|
display.setFont(&Ubuntu_Bold32pt7b);
|
||||||
display.setTextColor(GxEPD_BLACK);
|
display.setTextColor(GxEPD_BLACK);
|
||||||
display.setCursor(20, 100);
|
display.setCursor(20, 100);
|
||||||
display.print("Depth");
|
display.print("Depth");
|
||||||
display.setFont(&Ubuntu_Bold20pt7b);
|
display.setFont(&Ubuntu_Bold20pt7b);
|
||||||
display.setCursor(270, 100);
|
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.setFont(&DSEG7Classic_BoldItalic60pt7b);
|
||||||
display.setCursor(20, 240);
|
display.setCursor(20, 240);
|
||||||
|
|
||||||
|
@ -24,8 +30,16 @@ void page_0(busData pvalues){
|
||||||
display.print(depth,1);
|
display.print(depth,1);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if(pvalues.WaterDepth.valid == true){ // Check vor valid real data
|
// Check vor valid real data, display also if hold values activated
|
||||||
depth = pvalues.WaterDepth.fvalue; // Real bus data
|
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){
|
if(depth <= 99.9){
|
||||||
display.print(depth,1);
|
display.print(depth,1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,22 +10,6 @@
|
||||||
"obp60":"true"
|
"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",
|
"name": "timeZone",
|
||||||
"label": "Time Zone",
|
"label": "Time Zone",
|
||||||
|
@ -155,6 +139,102 @@
|
||||||
"obp60":"true"
|
"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",
|
"name": "useGPS",
|
||||||
"label": "GPS NEO-6M",
|
"label": "GPS NEO-6M",
|
||||||
|
@ -235,7 +315,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "statusLine",
|
"name": "statusLine",
|
||||||
"label": "Status line",
|
"label": "Status Line",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": "true",
|
"default": "true",
|
||||||
"description": "Show status line [on|off]",
|
"description": "Show status line [on|off]",
|
||||||
|
@ -255,6 +335,17 @@
|
||||||
"obp60":"true"
|
"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",
|
"name": "backlight",
|
||||||
"label": "Backlight Mode",
|
"label": "Backlight Mode",
|
||||||
|
@ -296,7 +387,7 @@
|
||||||
"label": "Buzzer Error",
|
"label": "Buzzer Error",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": "false",
|
"default": "false",
|
||||||
"description": "Settings for buzzer",
|
"description": "Sound on error",
|
||||||
"category": "OBP60 Buzzer",
|
"category": "OBP60 Buzzer",
|
||||||
"capabilities": {
|
"capabilities": {
|
||||||
"obp60":"true"
|
"obp60":"true"
|
||||||
|
@ -307,7 +398,7 @@
|
||||||
"label": "Buzzer GPS Fix",
|
"label": "Buzzer GPS Fix",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": "false",
|
"default": "false",
|
||||||
"description": "Settings for buzzer",
|
"description": "Sound on missing or lost GPS fix",
|
||||||
"category": "OBP60 Buzzer",
|
"category": "OBP60 Buzzer",
|
||||||
"capabilities": {
|
"capabilities": {
|
||||||
"obp60":"true"
|
"obp60":"true"
|
||||||
|
@ -318,7 +409,7 @@
|
||||||
"label": "Buzzer by Limits",
|
"label": "Buzzer by Limits",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": "false",
|
"default": "false",
|
||||||
"description": "Tone by limit overrun",
|
"description": "Sound on limit overrun",
|
||||||
"category": "OBP60 Buzzer",
|
"category": "OBP60 Buzzer",
|
||||||
"capabilities": {
|
"capabilities": {
|
||||||
"obp60":"true"
|
"obp60":"true"
|
||||||
|
|
Loading…
Reference in New Issue