Add all setup data in structure, save problem solved
This commit is contained in:
parent
3efba049f6
commit
88363e2bc1
|
@ -218,18 +218,40 @@ void OBP60Task(void *param){
|
||||||
|
|
||||||
bool hasPosition = false;
|
bool hasPosition = false;
|
||||||
|
|
||||||
// Get some configuration data from webside
|
// Get configuration data from webside
|
||||||
|
// 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");
|
||||||
bool gpsOn = api->getConfig()->getConfigItem(api->getConfig()->useGPS,true)->asBoolean();
|
api->getConfig()->getConfigItem(api->getConfig()->dateFormat,true)->asString().toCharArray(busInfo.dateformat, 3);
|
||||||
bool bme280On = api->getConfig()->getConfigItem(api->getConfig()->useBME280,true)->asBoolean();
|
busInfo.timezone = api->getConfig()->getConfigItem(api->getConfig()->timeZone,true)->asInt();
|
||||||
bool onewireOn = api->getConfig()->getConfigItem(api->getConfig()->use1Wire,true)->asBoolean();
|
busInfo.draft = api->getConfig()->getConfigItem(api->getConfig()->draft,true)->asString().toFloat();
|
||||||
busInfo.simulation = api->getConfig()->getConfigItem(api->getConfig()->useSimuData,true)->asBoolean();
|
busInfo.fueltank = api->getConfig()->getConfigItem(api->getConfig()->fuelTank,true)->asString().toFloat();
|
||||||
|
busInfo.fuelconsumption = api->getConfig()->getConfigItem(api->getConfig()->fuelConsumption,true)->asString().toFloat();
|
||||||
|
busInfo.watertank = api->getConfig()->getConfigItem(api->getConfig()->waterTank,true)->asString().toFloat();
|
||||||
|
busInfo.wastetank = api->getConfig()->getConfigItem(api->getConfig()->wasteTank,true)->asString().toFloat();
|
||||||
|
busInfo.batvoltage = api->getConfig()->getConfigItem(api->getConfig()->batteryVoltage,true)->asString().toFloat();
|
||||||
|
api->getConfig()->getConfigItem(api->getConfig()->batteryType,true)->asString().toCharArray(busInfo.battype, 16);
|
||||||
|
busInfo.batcapacity = api->getConfig()->getConfigItem(api->getConfig()->batteryCapacity,true)->asString().toFloat();
|
||||||
|
// OBP60 Hardware
|
||||||
|
busInfo.gps = api->getConfig()->getConfigItem(api->getConfig()->useGPS,true)->asBoolean();
|
||||||
|
busInfo.bme280 = api->getConfig()->getConfigItem(api->getConfig()->useBME280,true)->asBoolean();
|
||||||
|
busInfo.onewire = api->getConfig()->getConfigItem(api->getConfig()->use1Wire,true)->asBoolean();
|
||||||
String powerMode = api->getConfig()->getConfigItem(api->getConfig()->powerMode,true)->asString();
|
String powerMode = api->getConfig()->getConfigItem(api->getConfig()->powerMode,true)->asString();
|
||||||
|
busInfo.simulation = api->getConfig()->getConfigItem(api->getConfig()->useSimuData,true)->asBoolean();
|
||||||
|
// OBP60 Display
|
||||||
String displayMode = api->getConfig()->getConfigItem(api->getConfig()->display,true)->asString();
|
String displayMode = api->getConfig()->getConfigItem(api->getConfig()->display,true)->asString();
|
||||||
busInfo.statusline = api->getConfig()->getConfigItem(api->getConfig()->statusLine,true)->asBoolean();
|
busInfo.statusline = api->getConfig()->getConfigItem(api->getConfig()->statusLine,true)->asBoolean();
|
||||||
bool refreshOn = api->getConfig()->getConfigItem(api->getConfig()->refresh,true)->asBoolean();
|
busInfo.refresh = api->getConfig()->getConfigItem(api->getConfig()->refresh,true)->asBoolean();
|
||||||
String backlightMode = api->getConfig()->getConfigItem(api->getConfig()->backlight,true)->asString();
|
String backlightMode = api->getConfig()->getConfigItem(api->getConfig()->backlight,true)->asString();
|
||||||
|
api->getConfig()->getConfigItem(api->getConfig()->flashLED,true)->asString().toCharArray(busInfo.flashled, 16);
|
||||||
|
// OBP60 Buzzer
|
||||||
|
busInfo.buzerror = api->getConfig()->getConfigItem(api->getConfig()->buzzerError,true)->asBoolean();
|
||||||
|
busInfo.buzgps = api->getConfig()->getConfigItem(api->getConfig()->buzzerGps,true)->asBoolean();
|
||||||
|
busInfo.buzlimits = api->getConfig()->getConfigItem(api->getConfig()->buzzerLim,true)->asBoolean();
|
||||||
|
api->getConfig()->getConfigItem(api->getConfig()->buzzerMode,true)->asString().toCharArray(busInfo.buzmode, 16);
|
||||||
|
busInfo.buzpower = api->getConfig()->getConfigItem(api->getConfig()->buzzerPower,true)->asInt();
|
||||||
|
// OBP60 Pages
|
||||||
|
busInfo.numpages = api->getConfig()->getConfigItem(api->getConfig()->numberPages,true)->asInt();
|
||||||
|
|
||||||
// Initializing all necessary boat data
|
// Initializing all necessary boat data
|
||||||
GwApi::BoatValue *sog=new GwApi::BoatValue(F("SOG"));
|
GwApi::BoatValue *sog=new GwApi::BoatValue(F("SOG"));
|
||||||
|
@ -308,7 +330,7 @@ void OBP60Task(void *param){
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send NMEA0183 GPS data on several bus systems
|
// Send NMEA0183 GPS data on several bus systems
|
||||||
if(gpsOn == true){ // If config enabled
|
if(busInfo.gps == true){ // If config enabled
|
||||||
if(gps_ready = true){
|
if(gps_ready = true){
|
||||||
tNMEA0183Msg NMEA0183Msg;
|
tNMEA0183Msg NMEA0183Msg;
|
||||||
while(NMEA0183.GetMessage(NMEA0183Msg)){
|
while(NMEA0183.GetMessage(NMEA0183Msg)){
|
||||||
|
@ -319,16 +341,21 @@ void OBP60Task(void *param){
|
||||||
|
|
||||||
//fetch the current values of the items that we have in itemNames
|
//fetch the current values of the items that we have in itemNames
|
||||||
api->getBoatDataValues(7,valueList);
|
api->getBoatDataValues(7,valueList);
|
||||||
|
|
||||||
busInfo.WaterDepth.fvalue = waterdepth->value;
|
busInfo.WaterDepth.fvalue = waterdepth->value;
|
||||||
waterdepth->getFormat().toCharArray(busInfo.WaterDepth.unit, 8, 0);
|
waterdepth->getFormat().toCharArray(busInfo.WaterDepth.unit, 8, 0);
|
||||||
busInfo.WaterDepth.valid = int(waterdepth->valid);
|
busInfo.WaterDepth.valid = int(waterdepth->valid);
|
||||||
|
|
||||||
busInfo.SOG.fvalue = sog->value;
|
busInfo.SOG.fvalue = sog->value;
|
||||||
sog->getFormat().toCharArray(busInfo.SOG.unit, 8, 0);
|
sog->getFormat().toCharArray(busInfo.SOG.unit, 8, 0);
|
||||||
busInfo.SOG.valid = int(sog->valid);
|
busInfo.SOG.valid = int(sog->valid);
|
||||||
|
|
||||||
formatValue(date).toCharArray(busInfo.Date.svalue, 16, 0);
|
formatValue(date).toCharArray(busInfo.Date.svalue, 16, 0);
|
||||||
busInfo.Date.valid = date->valid;
|
busInfo.Date.valid = date->valid;
|
||||||
|
|
||||||
formatValue(time).toCharArray(busInfo.Time.svalue, 16, 0);
|
formatValue(time).toCharArray(busInfo.Time.svalue, 16, 0);
|
||||||
busInfo.Time.valid = time->valid;
|
busInfo.Time.valid = time->valid;
|
||||||
|
|
||||||
busInfo.PDOP.fvalue = pdop->value;
|
busInfo.PDOP.fvalue = pdop->value;
|
||||||
busInfo.PDOP.valid = pdop->valid;
|
busInfo.PDOP.valid = pdop->valid;
|
||||||
|
|
||||||
|
|
|
@ -7,15 +7,42 @@ typedef struct{
|
||||||
float fvalue = 0; // Float value
|
float fvalue = 0; // Float value
|
||||||
char svalue[16] = ""; // Char value
|
char svalue[16] = ""; // Char value
|
||||||
char unit[8] = ""; // Unit
|
char unit[8] = ""; // Unit
|
||||||
int valid = 0; // Valid flag
|
bool valid = 0; // Valid flag
|
||||||
} dataContainer;
|
} dataContainer;
|
||||||
|
|
||||||
typedef struct{
|
typedef struct{
|
||||||
bool simulation = false; // Simulate boat data
|
// OBP60 Settings
|
||||||
bool statusline = true;
|
|
||||||
char dateformat[3] = "GB";
|
char dateformat[3] = "GB";
|
||||||
int timezone = 0;
|
int timezone = 0;
|
||||||
|
float draft = 0;
|
||||||
|
float fueltank = 0;
|
||||||
|
float fuelconsumption = 0;
|
||||||
|
float watertank = 0;
|
||||||
|
float wastetank = 0;
|
||||||
|
float batvoltage = 0;
|
||||||
|
char battype[16] = "Pb";
|
||||||
|
float batcapacity = 0;
|
||||||
|
// OBP60 Hardware
|
||||||
|
bool gps = false;
|
||||||
|
bool bme280 = false;
|
||||||
|
bool onewire = false;
|
||||||
|
char powermode[16] = "Max Power";
|
||||||
|
bool simulation = false;
|
||||||
|
// OBP60 Display
|
||||||
|
char displaymode[16] = "Logo + QR Code";
|
||||||
|
bool statusline = true;
|
||||||
bool refresh = false;
|
bool refresh = false;
|
||||||
|
char backlight[16] = "Control by Key";
|
||||||
|
char flashled[16] = "Off";
|
||||||
|
// OBP60 Buzzer
|
||||||
|
bool buzerror = false;
|
||||||
|
bool buzgps = false;
|
||||||
|
bool buzlimits = false;
|
||||||
|
char buzmode[16] = "Off";
|
||||||
|
int buzpower = 0;
|
||||||
|
// OBP60 Pages
|
||||||
|
int numpages = 1;
|
||||||
|
// Bus data
|
||||||
dataContainer AWA;
|
dataContainer AWA;
|
||||||
dataContainer AWD;
|
dataContainer AWD;
|
||||||
dataContainer AWS;
|
dataContainer AWS;
|
||||||
|
|
|
@ -18,7 +18,7 @@ void showPage(busData values){
|
||||||
display.setTextColor(GxEPD_BLACK);
|
display.setTextColor(GxEPD_BLACK);
|
||||||
display.setCursor(0, 15);
|
display.setCursor(0, 15);
|
||||||
display.print(" WiFi AP TCP N2K 183 ");
|
display.print(" WiFi AP TCP N2K 183 ");
|
||||||
if(values.PDOP.valid == true && values.PDOP.fvalue <= 50){
|
if(values.gps == true && values.PDOP.valid == true && values.PDOP.fvalue <= 50){
|
||||||
display.print("GPS");
|
display.print("GPS");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,8 +36,9 @@ void showPage(busData values){
|
||||||
// Date and time
|
// Date and time
|
||||||
display.setFont(&Ubuntu_Bold8pt7b);
|
display.setFont(&Ubuntu_Bold8pt7b);
|
||||||
display.setCursor(230, 15);
|
display.setCursor(230, 15);
|
||||||
char newdate[16] = "";
|
if(values.gps == true){
|
||||||
if(values.PDOP.valid == true && values.PDOP.fvalue <= 50){
|
if(values.PDOP.valid == true && values.PDOP.fvalue <= 50){
|
||||||
|
char newdate[16] = "";
|
||||||
if(String(values.dateformat) == "DE"){
|
if(String(values.dateformat) == "DE"){
|
||||||
display.print(values.Date.svalue);
|
display.print(values.Date.svalue);
|
||||||
}
|
}
|
||||||
|
@ -58,14 +59,39 @@ void showPage(busData values){
|
||||||
display.print(newdate);
|
display.print(newdate);
|
||||||
}
|
}
|
||||||
display.print(" ");
|
display.print(" ");
|
||||||
|
if(values.timezone == 0){
|
||||||
display.print(values.Time.svalue);
|
display.print(values.Time.svalue);
|
||||||
display.print(" ");
|
display.print(" ");
|
||||||
display.print("UTC");
|
display.print("UTC");
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
char newtime[16] = "";
|
||||||
|
char newhour[3] = "";
|
||||||
|
int hour = 0;
|
||||||
|
strcpy(newtime, values.Time.svalue);
|
||||||
|
newhour[0] = values.Time.svalue[0];
|
||||||
|
newhour[1] = values.Time.svalue[1];
|
||||||
|
hour = strtol(newhour, 0, 10);
|
||||||
|
if(values.timezone > 0){
|
||||||
|
hour += values.timezone;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
hour += values.timezone + 24;
|
||||||
|
}
|
||||||
|
hour %= 24;
|
||||||
|
sprintf(newhour, "%d", hour);
|
||||||
|
newtime[0] = newhour[0];
|
||||||
|
newtime[1] = newhour[1];
|
||||||
|
display.print(newtime);
|
||||||
|
display.print(" ");
|
||||||
|
display.print("LOT");
|
||||||
|
}
|
||||||
|
}
|
||||||
else{
|
else{
|
||||||
display.print("No GPS data");
|
display.print("No GPS data");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Read page number
|
// Read page number
|
||||||
switch (pageNumber) {
|
switch (pageNumber) {
|
||||||
|
@ -94,11 +120,17 @@ void showPage(busData values){
|
||||||
|
|
||||||
// Update display
|
// Update display
|
||||||
if(values.refresh == true){
|
if(values.refresh == true){
|
||||||
|
if(first_view == true){
|
||||||
|
display.updateWindow(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, true); // Needs partial update before full update to refresh the frame buffer
|
||||||
display.update(); // Full update
|
display.update(); // Full update
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
display.updateWindow(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, true); // Partial update (fast)
|
display.updateWindow(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, true); // Partial update (fast)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
display.updateWindow(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, true); // Partial update (fast)
|
||||||
|
}
|
||||||
|
|
||||||
first_view = false;
|
first_view = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Name, Type, SubType, Offset, Size, Flags
|
# Name, Type, SubType, Offset, Size, Flags
|
||||||
nvs, data, nvs, 0x9000, 0x4000,
|
nvs, data, nvs, 0x9000, 0x5000
|
||||||
otadata, data, ota, 0xd000, 0x2000,
|
otadata, data, ota, 0xe000, 0x2000,
|
||||||
app0, app, ota_0, 0x10000, 0x1f0000,
|
app0, app, ota_0, 0x10000, 0x1f0000,
|
||||||
app1, app, ota_1, 0x200000,0x1f0000,
|
app1, app, ota_1, 0x200000,0x1f0000,
|
|
Loading…
Reference in New Issue