real bus data for depth
This commit is contained in:
parent
9af2fbcee8
commit
2ca4cfbd38
|
@ -31,6 +31,7 @@
|
||||||
#include "Logo_OBP_400x300_sw.h" // OBP Logo
|
#include "Logo_OBP_400x300_sw.h" // OBP Logo
|
||||||
|
|
||||||
#include "OBP60QRWiFi.h" // Functions lib for WiFi QR code
|
#include "OBP60QRWiFi.h" // Functions lib for WiFi QR code
|
||||||
|
#include "OBP60Data.h" // Data stucture
|
||||||
#include "Page_0.h" // Page 0 Depth
|
#include "Page_0.h" // Page 0 Depth
|
||||||
#include "Page_1.h" // Page 1 Speed
|
#include "Page_1.h" // Page 1 Speed
|
||||||
#include "Page_2.h" // Page 2 VBat
|
#include "Page_2.h" // Page 2 VBat
|
||||||
|
@ -191,17 +192,19 @@ void OBP60Task(void *param){
|
||||||
bool gpsOn = api->getConfig()->getConfigItem(api->getConfig()->useGPS,true)->asBoolean();
|
bool gpsOn = api->getConfig()->getConfigItem(api->getConfig()->useGPS,true)->asBoolean();
|
||||||
bool bme280On = api->getConfig()->getConfigItem(api->getConfig()->useBME280,true)->asBoolean();
|
bool bme280On = api->getConfig()->getConfigItem(api->getConfig()->useBME280,true)->asBoolean();
|
||||||
bool onewireOn = api->getConfig()->getConfigItem(api->getConfig()->use1Wire,true)->asBoolean();
|
bool onewireOn = api->getConfig()->getConfigItem(api->getConfig()->use1Wire,true)->asBoolean();
|
||||||
|
busInfo.simulation = api->getConfig()->getConfigItem(api->getConfig()->useSimuData,true)->asBoolean();
|
||||||
String powerMode=api->getConfig()->getConfigItem(api->getConfig()->powerMode,true)->asString();
|
String powerMode=api->getConfig()->getConfigItem(api->getConfig()->powerMode,true)->asString();
|
||||||
String displayMode=api->getConfig()->getConfigItem(api->getConfig()->display,true)->asString();
|
String displayMode=api->getConfig()->getConfigItem(api->getConfig()->display,true)->asString();
|
||||||
String backlightMode=api->getConfig()->getConfigItem(api->getConfig()->backlight,true)->asString();
|
String backlightMode=api->getConfig()->getConfigItem(api->getConfig()->backlight,true)->asString();
|
||||||
|
|
||||||
// Initializing all necessary boat data
|
// Initializing all necessary boat data
|
||||||
double lastWaterDepth=0;
|
GwApi::BoatValue *sog=new GwApi::BoatValue(F("SOG"));
|
||||||
bool lastWaterDepthValid=false;
|
GwApi::BoatValue *date=new GwApi::BoatValue(F("DaysSince1970"));
|
||||||
|
GwApi::BoatValue *time=new GwApi::BoatValue(F("SecondsSinceMidnight"));
|
||||||
GwApi::BoatValue *longitude=new GwApi::BoatValue(F("Longitude"));
|
GwApi::BoatValue *longitude=new GwApi::BoatValue(F("Longitude"));
|
||||||
GwApi::BoatValue *latitude=new GwApi::BoatValue(F("Latitude"));
|
GwApi::BoatValue *latitude=new GwApi::BoatValue(F("Latitude"));
|
||||||
GwApi::BoatValue *waterdepth=new GwApi::BoatValue(F("WaterDepth"));
|
GwApi::BoatValue *waterdepth=new GwApi::BoatValue(F("WaterDepth"));
|
||||||
GwApi::BoatValue *valueList[]={longitude, latitude, waterdepth};
|
GwApi::BoatValue *valueList[]={sog, date, time, longitude, latitude, waterdepth};
|
||||||
|
|
||||||
//Init E-Ink display
|
//Init E-Ink display
|
||||||
display.init(); // Initialize and clear display
|
display.init(); // Initialize and clear display
|
||||||
|
@ -260,16 +263,6 @@ void OBP60Task(void *param){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Subtask all 1000ms show pages
|
|
||||||
if((taskRunCounter % 100) == 0 || first_view == true){
|
|
||||||
// LOG_DEBUG(GwLog::DEBUG,"Subtask 1");
|
|
||||||
LOG_DEBUG(GwLog::DEBUG,"Keystatus: %s", keystatus);
|
|
||||||
LOG_DEBUG(GwLog::DEBUG,"Pagenumber: %d", pageNumber);
|
|
||||||
if(displayMode == "Logo + QR Code" || displayMode == "Logo" || displayMode == "White Screen"){
|
|
||||||
showPage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Subtask all 3000ms
|
// Subtask all 3000ms
|
||||||
if((taskRunCounter % 300) == 0){
|
if((taskRunCounter % 300) == 0){
|
||||||
// LOG_DEBUG(GwLog::DEBUG,"Subtask 2");
|
// LOG_DEBUG(GwLog::DEBUG,"Subtask 2");
|
||||||
|
@ -279,12 +272,6 @@ void OBP60Task(void *param){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Subtask E-Ink full refresh
|
|
||||||
if((taskRunCounter % (FULL_REFRESH_TIME * 100)) == 0){
|
|
||||||
LOG_DEBUG(GwLog::DEBUG,"E-Ink full refresh");
|
|
||||||
display.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send NMEA0183 GPS data on several bus systems
|
// Send NMEA0183 GPS data on several bus systems
|
||||||
if(gpsOn == true){ // If config enabled
|
if(gpsOn == true){ // If config enabled
|
||||||
if(gps_ready = true){
|
if(gps_ready = true){
|
||||||
|
@ -296,22 +283,25 @@ 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(3,valueList);
|
api->getBoatDataValues(6,valueList);
|
||||||
//check if the values are valid (i.e. the values we requested have been found in boatData)
|
busInfo.WaterDepth.fvalue = waterdepth->value;
|
||||||
if (waterdepth->valid){
|
busInfo.WaterDepth.valid = int(waterdepth->valid);
|
||||||
//both values are there - so we have a valid position
|
busInfo.SOG.fvalue = sog->value;
|
||||||
if (! lastWaterDepthValid){
|
busInfo.SOG.valid = int(sog->valid);
|
||||||
//access to the values via iterator->second (iterator->first would be the name)
|
|
||||||
LOG_DEBUG(GwLog::LOG,"%s new value %f",waterdepth->getName().c_str(),waterdepth->value);
|
// Subtask all 1000ms show pages
|
||||||
lastWaterDepthValid=true;
|
if((taskRunCounter % 100) == 0 || first_view == true){
|
||||||
lastWaterDepth=waterdepth->value;
|
LOG_DEBUG(GwLog::DEBUG,"Keystatus: %s", keystatus);
|
||||||
|
LOG_DEBUG(GwLog::DEBUG,"Pagenumber: %d", pageNumber);
|
||||||
|
if(displayMode == "Logo + QR Code" || displayMode == "Logo" || displayMode == "White Screen"){
|
||||||
|
showPage(busInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
|
||||||
if (lastWaterDepthValid){
|
// Subtask E-Ink full refresh
|
||||||
if (exampleSwitch) LOG_DEBUG(GwLog::LOG,"Water depth lost");
|
if((taskRunCounter % (FULL_REFRESH_TIME * 100)) == 0){
|
||||||
lastWaterDepthValid=false;
|
LOG_DEBUG(GwLog::DEBUG,"E-Ink full refresh");
|
||||||
}
|
display.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
taskRunCounter++;
|
taskRunCounter++;
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
#ifndef _OBP60Data_H
|
||||||
|
#define _OBP60Data_H
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
float fvalue = 0; // Float value
|
||||||
|
char svalue[31] = ""; // Char value
|
||||||
|
int valid = 0; // Valid flag
|
||||||
|
} dataContainer;
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
bool simulation = false; // Simulate boat data
|
||||||
|
dataContainer AWA;
|
||||||
|
dataContainer AWD;
|
||||||
|
dataContainer AWS;
|
||||||
|
dataContainer Altitude;
|
||||||
|
dataContainer BTW;
|
||||||
|
dataContainer COG;
|
||||||
|
dataContainer DTW;
|
||||||
|
dataContainer Date;
|
||||||
|
dataContainer DepthTransducer;
|
||||||
|
dataContainer Deviation;
|
||||||
|
dataContainer HDOP;
|
||||||
|
dataContainer Heading;
|
||||||
|
dataContainer Latitude;
|
||||||
|
dataContainer Log;
|
||||||
|
dataContainer Longitude;
|
||||||
|
dataContainer MagneticHeading;
|
||||||
|
dataContainer MaxAws;
|
||||||
|
dataContainer MaxTws;
|
||||||
|
dataContainer PDOP;
|
||||||
|
dataContainer ROT;
|
||||||
|
dataContainer RudderPosition;
|
||||||
|
dataContainer SOG;
|
||||||
|
dataContainer STW;
|
||||||
|
dataContainer SatInfo;
|
||||||
|
dataContainer Time;
|
||||||
|
dataContainer TWD;
|
||||||
|
dataContainer TWS;
|
||||||
|
dataContainer Timezone;
|
||||||
|
dataContainer TripLog;
|
||||||
|
dataContainer VDOP;
|
||||||
|
dataContainer Variation;
|
||||||
|
dataContainer WPLatitude;
|
||||||
|
dataContainer WPLongitude;
|
||||||
|
dataContainer WaterDepth;
|
||||||
|
dataContainer WaterTemperature;
|
||||||
|
dataContainer XTE;
|
||||||
|
} busData;
|
||||||
|
|
||||||
|
busData busInfo;
|
||||||
|
|
||||||
|
#endif
|
|
@ -7,8 +7,7 @@
|
||||||
int pageNumber = 0; // Page number for actual page
|
int pageNumber = 0; // Page number for actual page
|
||||||
bool first_view = true;
|
bool first_view = true;
|
||||||
|
|
||||||
|
void showPage(busData values){
|
||||||
void showPage(){
|
|
||||||
// Clear display
|
// Clear display
|
||||||
display.fillRect(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, GxEPD_WHITE); // Draw white sreen
|
display.fillRect(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, GxEPD_WHITE); // Draw white sreen
|
||||||
|
|
||||||
|
@ -24,7 +23,7 @@ void showPage(){
|
||||||
// Read page number
|
// Read page number
|
||||||
switch (pageNumber) {
|
switch (pageNumber) {
|
||||||
case 0:
|
case 0:
|
||||||
page_0();
|
page_0(values);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
page_1();
|
page_1();
|
||||||
|
@ -42,7 +41,7 @@ void showPage(){
|
||||||
// Statement(s)
|
// Statement(s)
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
page_0();
|
page_0(values);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include "OBP60Hardware.h"
|
#include "OBP60Hardware.h"
|
||||||
|
|
||||||
void page_0(){
|
void page_0(busData pvalues){
|
||||||
// Measuring Values
|
// Measuring Values
|
||||||
display.setFont(&Ubuntu_Bold32pt7b);
|
display.setFont(&Ubuntu_Bold32pt7b);
|
||||||
display.setTextColor(GxEPD_BLACK);
|
display.setTextColor(GxEPD_BLACK);
|
||||||
|
@ -15,9 +15,28 @@ void page_0(){
|
||||||
display.print("m");
|
display.print("m");
|
||||||
display.setFont(&DSEG7Classic_BoldItalic60pt7b);
|
display.setFont(&DSEG7Classic_BoldItalic60pt7b);
|
||||||
display.setCursor(20, 240);
|
display.setCursor(20, 240);
|
||||||
float depth = 84;
|
|
||||||
depth += float(random(0, 13)) / 10;
|
// Reading bus data or using simulation data
|
||||||
|
float depth = 0;
|
||||||
|
if(pvalues.simulation == true){
|
||||||
|
depth = 84;
|
||||||
|
depth += float(random(0, 120)) / 10; // Simulation data
|
||||||
display.print(depth,1);
|
display.print(depth,1);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(pvalues.WaterDepth.valid == true){ // Check vor valid real data
|
||||||
|
depth = pvalues.WaterDepth.fvalue; // Real bus data
|
||||||
|
if(depth <= 99.9){
|
||||||
|
display.print(depth,1);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
display.print(depth,0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
display.print("---"); // Missing bus data
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Key Layout
|
// Key Layout
|
||||||
display.setFont(&Ubuntu_Bold8pt7b);
|
display.setFont(&Ubuntu_Bold8pt7b);
|
||||||
|
|
|
@ -60,6 +60,17 @@
|
||||||
"obp60":"true"
|
"obp60":"true"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "useSimuData",
|
||||||
|
"label": "Simulation Data",
|
||||||
|
"type": "boolean",
|
||||||
|
"default": "false",
|
||||||
|
"description": "Can use for simulation data by missing bus data.",
|
||||||
|
"category": "OBP60",
|
||||||
|
"capabilities": {
|
||||||
|
"obp60":"true"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "display",
|
"name": "display",
|
||||||
"label": "Display Mode",
|
"label": "Display Mode",
|
||||||
|
|
Loading…
Reference in New Issue