Compare commits
4 Commits
cba21574cb
...
c932724473
Author | SHA1 | Date |
---|---|---|
|
c932724473 | |
|
672a3843d1 | |
|
1e0acf2a8f | |
|
63ae42588f |
|
@ -474,6 +474,7 @@ void displayHeader(CommonData &commonData, bool symbolmode, GwApi::BoatValue *da
|
||||||
uint16_t symbol_x = 2;
|
uint16_t symbol_x = 2;
|
||||||
static const uint16_t symbol_offset = 20;
|
static const uint16_t symbol_offset = 20;
|
||||||
|
|
||||||
|
// TODO invert and get rid of the if
|
||||||
if(commonData.config->getBool(commonData.config->statusLine) == true){
|
if(commonData.config->getBool(commonData.config->statusLine) == true){
|
||||||
|
|
||||||
// Show status info
|
// Show status info
|
||||||
|
@ -583,7 +584,7 @@ void displayHeader(CommonData &commonData, bool symbolmode, GwApi::BoatValue *da
|
||||||
heartbeat = !heartbeat;
|
heartbeat = !heartbeat;
|
||||||
|
|
||||||
// Date and time
|
// Date and time
|
||||||
String fmttype = commonData.config->getString(commonData.config->dateFormat);
|
fmtDate fmttype = commonData.fmt->getDateFormat(commonData.config->getString(commonData.config->dateFormat));
|
||||||
String timesource = commonData.config->getString(commonData.config->timeSource);
|
String timesource = commonData.config->getString(commonData.config->timeSource);
|
||||||
double tz = commonData.config->getString(commonData.config->timeZone).toDouble();
|
double tz = commonData.config->getString(commonData.config->timeZone).toDouble();
|
||||||
epd->setTextColor(commonData.fgcolor);
|
epd->setTextColor(commonData.fgcolor);
|
||||||
|
@ -594,7 +595,7 @@ void displayHeader(CommonData &commonData, bool symbolmode, GwApi::BoatValue *da
|
||||||
if (commonData.data.rtcValid) {
|
if (commonData.data.rtcValid) {
|
||||||
time_t tv = mktime(&commonData.data.rtcTime) + (int)(tz * 3600);
|
time_t tv = mktime(&commonData.data.rtcTime) + (int)(tz * 3600);
|
||||||
struct tm *local_tm = localtime(&tv);
|
struct tm *local_tm = localtime(&tv);
|
||||||
epd->print(formatTime('m', local_tm->tm_hour, local_tm->tm_min, 0));
|
epd->print(formatTime(fmtTime::MMHH, local_tm->tm_hour, local_tm->tm_min, 0));
|
||||||
epd->print(" ");
|
epd->print(" ");
|
||||||
epd->print(formatDate(fmttype, local_tm->tm_year + 1900, local_tm->tm_mon + 1, local_tm->tm_mday));
|
epd->print(formatDate(fmttype, local_tm->tm_year + 1900, local_tm->tm_mon + 1, local_tm->tm_mday));
|
||||||
epd->print(" ");
|
epd->print(" ");
|
||||||
|
|
|
@ -20,6 +20,7 @@ Formatter::Formatter(GwConfigHandler *config) {
|
||||||
windspeedFormat = config->getString(config->windspeedFormat);
|
windspeedFormat = config->getString(config->windspeedFormat);
|
||||||
tempFormat = config->getString(config->tempFormat);
|
tempFormat = config->getString(config->tempFormat);
|
||||||
dateFormat = config->getString(config->dateFormat);
|
dateFormat = config->getString(config->dateFormat);
|
||||||
|
dateFmt = getDateFormat(dateFormat);
|
||||||
usesimudata = config->getBool(config->useSimuData);
|
usesimudata = config->getBool(config->useSimuData);
|
||||||
precision = config->getString(config->valueprecision);
|
precision = config->getString(config->valueprecision);
|
||||||
|
|
||||||
|
@ -35,6 +36,37 @@ Formatter::Formatter(GwConfigHandler *config) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmtType Formatter::stringToFormat(const char* formatStr) {
|
||||||
|
auto it = formatMap.find(formatStr);
|
||||||
|
if (it != formatMap.end()) {
|
||||||
|
return it->second;
|
||||||
|
}
|
||||||
|
return fmtType::XDR_G; // generic as default
|
||||||
|
}
|
||||||
|
|
||||||
|
fmtDate Formatter::getDateFormat(String sformat) {
|
||||||
|
if (sformat == "DE") {
|
||||||
|
return fmtDate::DE;
|
||||||
|
}
|
||||||
|
if (sformat == "GB") {
|
||||||
|
return fmtDate::GB;
|
||||||
|
}
|
||||||
|
if (sformat == "US") {
|
||||||
|
return fmtDate::US;
|
||||||
|
}
|
||||||
|
return fmtDate::ISO; // default
|
||||||
|
}
|
||||||
|
|
||||||
|
fmtTime Formatter::getTimeFormat(String sformat) {
|
||||||
|
if (sformat == "MMHH") {
|
||||||
|
return fmtTime::MMHH;
|
||||||
|
}
|
||||||
|
if (sformat == "MMHHSS") {
|
||||||
|
return fmtTime::MMHHSS;
|
||||||
|
}
|
||||||
|
return fmtTime::MMHH; // default
|
||||||
|
}
|
||||||
|
|
||||||
FormattedData Formatter::formatValue(GwApi::BoatValue *value, CommonData &commondata){
|
FormattedData Formatter::formatValue(GwApi::BoatValue *value, CommonData &commondata){
|
||||||
GwLog *logger = commondata.logger;
|
GwLog *logger = commondata.logger;
|
||||||
FormattedData result;
|
FormattedData result;
|
||||||
|
@ -43,7 +75,7 @@ FormattedData Formatter::formatValue(GwApi::BoatValue *value, CommonData &common
|
||||||
|
|
||||||
// If boat value not valid
|
// If boat value not valid
|
||||||
if (! value->valid && !usesimudata){
|
if (! value->valid && !usesimudata){
|
||||||
result.svalue = "---";
|
result.svalue = placeholder;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,12 +118,7 @@ FormattedData Formatter::formatValue(GwApi::BoatValue *value, CommonData &common
|
||||||
else{
|
else{
|
||||||
snprintf(buffer, bsize, "01.01.2022");
|
snprintf(buffer, bsize, "01.01.2022");
|
||||||
}
|
}
|
||||||
if(timeZone == 0){
|
result.unit = ((timeZone == 0) ? "UTC" : "LOT");
|
||||||
result.unit = "UTC";
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
result.unit = "LOT";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//########################################################
|
//########################################################
|
||||||
else if(value->getFormat() == "formatTime"){
|
else if(value->getFormat() == "formatTime"){
|
||||||
|
@ -121,12 +148,7 @@ FormattedData Formatter::formatValue(GwApi::BoatValue *value, CommonData &common
|
||||||
snprintf(buffer, bsize, "11:36:%02i", int(sec));
|
snprintf(buffer, bsize, "11:36:%02i", int(sec));
|
||||||
lasttime = millis();
|
lasttime = millis();
|
||||||
}
|
}
|
||||||
if(timeZone == 0){
|
result.unit = ((timeZone == 0) ? "UTC" : "LOT");
|
||||||
result.unit = "UTC";
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
result.unit = "LOT";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//########################################################
|
//########################################################
|
||||||
else if (value->getFormat() == "formatFixed0"){
|
else if (value->getFormat() == "formatFixed0"){
|
||||||
|
@ -286,13 +308,13 @@ FormattedData Formatter::formatValue(GwApi::BoatValue *value, CommonData &common
|
||||||
if (rotation < -100){
|
if (rotation < -100){
|
||||||
rotation = -99;
|
rotation = -99;
|
||||||
}
|
}
|
||||||
if (rotation > 100){
|
else if (rotation > 100){
|
||||||
rotation = 99;
|
rotation = 99;
|
||||||
}
|
}
|
||||||
if (rotation > -10 && rotation < 10){
|
if (rotation > -10 && rotation < 10){
|
||||||
snprintf(buffer, bsize, "%3.2f", rotation);
|
snprintf(buffer, bsize, "%3.2f", rotation);
|
||||||
}
|
}
|
||||||
if (rotation <= -10 || rotation >= 10){
|
else {
|
||||||
snprintf(buffer, bsize, "%3.0f", rotation);
|
snprintf(buffer, bsize, "%3.0f", rotation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -330,12 +352,7 @@ FormattedData Formatter::formatValue(GwApi::BoatValue *value, CommonData &common
|
||||||
String latdir = "";
|
String latdir = "";
|
||||||
float degree = abs(int(lat));
|
float degree = abs(int(lat));
|
||||||
float minute = abs((lat - int(lat)) * 60);
|
float minute = abs((lat - int(lat)) * 60);
|
||||||
if (lat > 0){
|
latdir = (lat > 0) ? "N" : "S";
|
||||||
latdir = "N";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
latdir = "S";
|
|
||||||
}
|
|
||||||
latitude = String(degree,0) + "\x90 " + String(minute,4) + "' " + latdir;
|
latitude = String(degree,0) + "\x90 " + String(minute,4) + "' " + latdir;
|
||||||
result.unit = "";
|
result.unit = "";
|
||||||
strcpy(buffer, latitude.c_str());
|
strcpy(buffer, latitude.c_str());
|
||||||
|
@ -354,12 +371,7 @@ FormattedData Formatter::formatValue(GwApi::BoatValue *value, CommonData &common
|
||||||
String londir = "";
|
String londir = "";
|
||||||
float degree = abs(int(lon));
|
float degree = abs(int(lon));
|
||||||
float minute = abs((lon - int(lon)) * 60);
|
float minute = abs((lon - int(lon)) * 60);
|
||||||
if (lon > 0){
|
londir = (lon > 0) ? "E" : "W";
|
||||||
londir = "E";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
londir = "W";
|
|
||||||
}
|
|
||||||
longitude = String(degree,0) + "\x90 " + String(minute,4) + "' " + londir;
|
longitude = String(degree,0) + "\x90 " + String(minute,4) + "' " + londir;
|
||||||
result.unit = "";
|
result.unit = "";
|
||||||
strcpy(buffer, longitude.c_str());
|
strcpy(buffer, longitude.c_str());
|
||||||
|
@ -381,7 +393,7 @@ FormattedData Formatter::formatValue(GwApi::BoatValue *value, CommonData &common
|
||||||
depth = rawvalue;
|
depth = rawvalue;
|
||||||
}
|
}
|
||||||
if(String(lengthFormat) == "ft"){
|
if(String(lengthFormat) == "ft"){
|
||||||
depth = depth * 3.28084;
|
depth = depth * 3.28084; // TODO use global defined factor
|
||||||
result.unit = "ft";
|
result.unit = "ft";
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
@ -411,7 +423,7 @@ FormattedData Formatter::formatValue(GwApi::BoatValue *value, CommonData &common
|
||||||
xte = xte * 0.001;
|
xte = xte * 0.001;
|
||||||
result.unit = "km";
|
result.unit = "km";
|
||||||
} else if (distanceFormat == "nm") {
|
} else if (distanceFormat == "nm") {
|
||||||
xte = xte * 0.000539957;
|
xte = xte * 0.000539957; // TODO use global defined factor
|
||||||
result.unit = "nm";
|
result.unit = "nm";
|
||||||
} else {
|
} else {
|
||||||
result.unit = "m";
|
result.unit = "m";
|
||||||
|
@ -473,7 +485,7 @@ FormattedData Formatter::formatValue(GwApi::BoatValue *value, CommonData &common
|
||||||
result.unit = "km";
|
result.unit = "km";
|
||||||
}
|
}
|
||||||
else if (String(distanceFormat) == "nm") {
|
else if (String(distanceFormat) == "nm") {
|
||||||
distance = distance * 0.000539957;
|
distance = distance * 0.000539957; // TODO use global defined factor
|
||||||
result.unit = "nm";
|
result.unit = "nm";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -802,32 +814,36 @@ FormattedData Formatter::formatValue(GwApi::BoatValue *value, CommonData &common
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
String formatDate(String fmttype, uint16_t year, uint8_t month, uint8_t day) {
|
String formatDate(fmtDate fmttype, uint16_t year, uint8_t month, uint8_t day) {
|
||||||
char buffer[12];
|
char buffer[12];
|
||||||
if (fmttype == "GB") {
|
if (fmttype == fmtDate::GB) {
|
||||||
snprintf(buffer, 12, "%02d/%02d/%04d", day , month, year);
|
snprintf(buffer, 12, "%02d/%02d/%04d", day , month, year);
|
||||||
}
|
}
|
||||||
else if (fmttype == "US") {
|
else if (fmttype == fmtDate::US) {
|
||||||
snprintf(buffer, 12, "%02d/%02d/%04d", month, day, year);
|
snprintf(buffer, 12, "%02d/%02d/%04d", month, day, year);
|
||||||
}
|
}
|
||||||
else if (fmttype == "ISO") {
|
else if (fmttype == fmtDate::ISO) {
|
||||||
snprintf(buffer, 12, "%04d-%02d-%02d", year, month, day);
|
snprintf(buffer, 12, "%04d-%02d-%02d", year, month, day);
|
||||||
}
|
}
|
||||||
else {
|
else if (fmttype == fmtDate::DE) {
|
||||||
snprintf(buffer, 12, "%02d.%02d.%04d", day, month, year);
|
snprintf(buffer, 12, "%02d.%02d.%04d", day, month, year);
|
||||||
|
} else {
|
||||||
|
snprintf(buffer, 12, "%04d-%02d-%02d", year, month, day);
|
||||||
}
|
}
|
||||||
return String(buffer);
|
return String(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
String formatTime(char fmttype, uint8_t hour, uint8_t minute, uint8_t second) {
|
String formatTime(fmtTime fmttype, uint8_t hour, uint8_t minute, uint8_t second) {
|
||||||
// fmttype: s: with seconds, m: only minutes
|
|
||||||
char buffer[10];
|
char buffer[10];
|
||||||
if (fmttype == 'm') {
|
if (fmttype == fmtTime::MMHH) {
|
||||||
snprintf(buffer, 10, "%02d:%02d", hour , minute);
|
snprintf(buffer, 10, "%02d:%02d", hour , minute);
|
||||||
}
|
}
|
||||||
else {
|
else if (fmttype == fmtTime::MMHHSS) {
|
||||||
snprintf(buffer, 10, "%02d:%02d:%02d", hour, minute, second);
|
snprintf(buffer, 10, "%02d:%02d:%02d", hour, minute, second);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
snprintf(buffer, 10, "%02d%02d%02d", hour, minute, second);
|
||||||
|
}
|
||||||
return String(buffer);
|
return String(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,41 +2,10 @@
|
||||||
#ifndef _OBP60FORMATTER_H
|
#ifndef _OBP60FORMATTER_H
|
||||||
#define _OBP60FORMATTER_H
|
#define _OBP60FORMATTER_H
|
||||||
|
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
Formatter names as defined in BoatItemBase
|
|
||||||
formatCourse
|
|
||||||
formatKnots
|
|
||||||
formatWind
|
|
||||||
formatLatitude
|
|
||||||
formatLongitude
|
|
||||||
formatXte
|
|
||||||
formatFixed0
|
|
||||||
formatDepth
|
|
||||||
kelvinToC TODO not a format but conversion
|
|
||||||
mtr2nm TODO not a format but conversion
|
|
||||||
formatDop dilution of precision
|
|
||||||
formatRot
|
|
||||||
formatDate
|
|
||||||
formatTime
|
|
||||||
formatName
|
|
||||||
|
|
||||||
XDR Formatter names
|
|
||||||
formatXdr:P:P // pressure percent
|
|
||||||
formatXdr:P:B // pressure bar
|
|
||||||
formatXdr:U:V // voltage volt
|
|
||||||
formatXdr:I:A // current ampere
|
|
||||||
formatXdr:C:K // temperature kelvin
|
|
||||||
formatXdr:C:C // temperature celsius
|
|
||||||
formatXdr:H:P // humidity percent
|
|
||||||
formatXdr:V:P // volume percent
|
|
||||||
formatXdr:V:M // volume cubic meters
|
|
||||||
formatXdr:R:I // flow liter per second?
|
|
||||||
formatXdr:G: // generic
|
|
||||||
formatXdr:A:P // angle percent
|
|
||||||
formatXdr:A:D // angle degrees
|
|
||||||
formatXdr:T:R // tachometer rpm
|
|
||||||
|
|
||||||
XDR types
|
XDR types
|
||||||
A Angular displacement
|
A Angular displacement
|
||||||
C Temperature
|
C Temperature
|
||||||
|
@ -69,8 +38,77 @@ XDR units
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
enum class fmtType {
|
||||||
|
// Formatter names as defined in BoatItemBase
|
||||||
|
COURSE,
|
||||||
|
KNOTS,
|
||||||
|
WIND,
|
||||||
|
LATITUDE,
|
||||||
|
LONGITUDE,
|
||||||
|
XTE,
|
||||||
|
FIXED0,
|
||||||
|
DEPTH,
|
||||||
|
DOP, // dilution of precision
|
||||||
|
ROT,
|
||||||
|
DATE,
|
||||||
|
TIME,
|
||||||
|
NAME,
|
||||||
|
|
||||||
|
kelvinToC, // TODO not a format but conversion
|
||||||
|
mtr2nm, // TODO not a format but conversion
|
||||||
|
|
||||||
|
// XDR Formatter names
|
||||||
|
XDR_PP, // pressure percent
|
||||||
|
XDR_PB, // pressure bar
|
||||||
|
XDR_UV, // voltage volt
|
||||||
|
XDR_IA, // current ampere
|
||||||
|
XDR_CK, // temperature kelvin
|
||||||
|
XDR_CC, // temperature celsius
|
||||||
|
XDR_HP, // humidity percent
|
||||||
|
XDR_VP, // volume percent
|
||||||
|
XDR_VM, // volume cubic meters
|
||||||
|
XDR_RI, // flow liter per second?
|
||||||
|
XDR_G, // generic
|
||||||
|
XDR_AP, // angle percent
|
||||||
|
XDR_AD, // angle degrees
|
||||||
|
XDR_TR // tachometer rpm
|
||||||
|
};
|
||||||
|
|
||||||
|
// Hint: String is not supported
|
||||||
|
static std::unordered_map<const char*, fmtType> formatMap PROGMEM = {
|
||||||
|
{"formatCourse", fmtType::COURSE},
|
||||||
|
{"formatKnots", fmtType::KNOTS},
|
||||||
|
{"formatWind", fmtType::WIND},
|
||||||
|
{"formatLatitude", fmtType::LATITUDE},
|
||||||
|
{"formatLongitude", fmtType::LONGITUDE},
|
||||||
|
{"formatXte", fmtType::XTE},
|
||||||
|
{"formatFixed0", fmtType::FIXED0},
|
||||||
|
{"formatDepth", fmtType::DEPTH},
|
||||||
|
{"formatDop", fmtType::DOP},
|
||||||
|
{"formatRot", fmtType::ROT},
|
||||||
|
{"formatDate", fmtType::DATE},
|
||||||
|
{"formatTime", fmtType::TIME},
|
||||||
|
{"formatName", fmtType::NAME},
|
||||||
|
{"kelvinToC", fmtType::kelvinToC},
|
||||||
|
{"mtr2nm", fmtType::mtr2nm},
|
||||||
|
{"formatXdr:P:P", fmtType::XDR_PP},
|
||||||
|
{"formatXdr:P:B", fmtType::XDR_PB},
|
||||||
|
{"formatXdr:U:V", fmtType::XDR_UV},
|
||||||
|
{"formatXdr:I:A", fmtType::XDR_IA},
|
||||||
|
{"formatXdr:C:K", fmtType::XDR_CK},
|
||||||
|
{"formatXdr:C:C", fmtType::XDR_CC},
|
||||||
|
{"formatXdr:H:P", fmtType::XDR_HP},
|
||||||
|
{"formatXdr:V:P", fmtType::XDR_VP},
|
||||||
|
{"formatXdr:V:M", fmtType::XDR_VM},
|
||||||
|
{"formatXdr:R:I", fmtType::XDR_RI},
|
||||||
|
{"formatXdr:G:", fmtType::XDR_G},
|
||||||
|
{"formatXdr:A:P", fmtType::XDR_AP},
|
||||||
|
{"formatXdr:A:D", fmtType::XDR_AD},
|
||||||
|
{"formatXdr:T:R", fmtType::XDR_TR}
|
||||||
|
};
|
||||||
|
|
||||||
// Possible formats as scoped enums
|
// Possible formats as scoped enums
|
||||||
enum class fmtDate {DE, EN, GB, ISO};
|
enum class fmtDate {DE, GB, US, ISO};
|
||||||
enum class fmtTime {MMHH, MMHHSS};
|
enum class fmtTime {MMHH, MMHHSS};
|
||||||
enum class fmtLength {METER, FEET, FATHOM, CABLE};
|
enum class fmtLength {METER, FEET, FATHOM, CABLE};
|
||||||
enum class fmtDepth {METER, FEET, FATHOM};
|
enum class fmtDepth {METER, FEET, FATHOM};
|
||||||
|
@ -106,6 +144,7 @@ private:
|
||||||
String windspeedFormat = "kn"; // [m/s|km/h|kn|bft]
|
String windspeedFormat = "kn"; // [m/s|km/h|kn|bft]
|
||||||
String tempFormat = "C"; // [K|°C|°F]
|
String tempFormat = "C"; // [K|°C|°F]
|
||||||
String dateFormat = "ISO"; // [DE|GB|US|ISO]
|
String dateFormat = "ISO"; // [DE|GB|US|ISO]
|
||||||
|
fmtDate dateFmt;
|
||||||
bool usesimudata = false; // [on|off]
|
bool usesimudata = false; // [on|off]
|
||||||
|
|
||||||
String precision = "2"; // [1|2]
|
String precision = "2"; // [1|2]
|
||||||
|
@ -115,12 +154,16 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Formatter(GwConfigHandler *config);
|
Formatter(GwConfigHandler *config);
|
||||||
|
fmtType stringToFormat(const char* formatStr);
|
||||||
|
fmtDate getDateFormat(String sformat);
|
||||||
|
fmtTime getTimeFormat(String sformat);
|
||||||
FormattedData formatValue(GwApi::BoatValue *value, CommonData &commondata);
|
FormattedData formatValue(GwApi::BoatValue *value, CommonData &commondata);
|
||||||
|
String placeholder = "---";
|
||||||
};
|
};
|
||||||
|
|
||||||
// Standard format functions without overhead
|
// Standard format functions without class and overhead
|
||||||
String formatDate(String fmttype, uint16_t year, uint8_t month, uint8_t day);
|
String formatDate(fmtDate fmttype, uint16_t year, uint8_t month, uint8_t day);
|
||||||
String formatTime(char fmttype, uint8_t hour, uint8_t minute, uint8_t second);
|
String formatTime(fmtTime fmttype, uint8_t hour, uint8_t minute, uint8_t second);
|
||||||
String formatLatitude(double lat);
|
String formatLatitude(double lat);
|
||||||
String formatLongitude(double lon);
|
String formatLongitude(double lon);
|
||||||
|
|
||||||
|
|
|
@ -227,7 +227,7 @@ public:
|
||||||
epd->print(value1,2); // Real value as formated string
|
epd->print(value1,2); // Real value as formated string
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
epd->print("---"); // No sensor data (sensor is off)
|
epd->print(commonData->fmt->placeholder); // No sensor data (sensor is off)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ############### Horizontal Line ################
|
// ############### Horizontal Line ################
|
||||||
|
@ -256,7 +256,7 @@ public:
|
||||||
epd->print(value2,1); // Real value as formated string
|
epd->print(value2,1); // Real value as formated string
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
epd->print("---"); // No sensor data (sensor is off)
|
epd->print(commonData->fmt->placeholder); // No sensor data (sensor is off)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ############### Horizontal Line ################
|
// ############### Horizontal Line ################
|
||||||
|
@ -285,7 +285,7 @@ public:
|
||||||
epd->print(value3,1); // Real value as formated string
|
epd->print(value3,1); // Real value as formated string
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
epd->print("---"); // No sensor data (sensor is off)
|
epd->print(commonData->fmt->placeholder); // No sensor data (sensor is off)
|
||||||
}
|
}
|
||||||
|
|
||||||
return PAGE_UPDATE;
|
return PAGE_UPDATE;
|
||||||
|
|
|
@ -286,7 +286,7 @@ public:
|
||||||
if(value1 > 99.9) epd->print(value1, 0);
|
if(value1 > 99.9) epd->print(value1, 0);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
epd->print("---"); // Missing bus data
|
epd->print(commonData->fmt->placeholder); // Missing bus data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
epd->setFont(&Ubuntu_Bold16pt8b);
|
epd->setFont(&Ubuntu_Bold16pt8b);
|
||||||
|
@ -300,7 +300,9 @@ public:
|
||||||
if(value2 > 9.9 && value2 <= 99.9)epd->print(value2, 1);
|
if(value2 > 9.9 && value2 <= 99.9)epd->print(value2, 1);
|
||||||
if(value2 > 99.9) epd->print(value2, 0);
|
if(value2 > 99.9) epd->print(value2, 0);
|
||||||
}
|
}
|
||||||
else epd->print("---");
|
else {
|
||||||
|
epd->print(commonData->fmt->placeholder);
|
||||||
|
}
|
||||||
epd->setFont(&Ubuntu_Bold16pt8b);
|
epd->setFont(&Ubuntu_Bold16pt8b);
|
||||||
epd->print("A");
|
epd->print("A");
|
||||||
|
|
||||||
|
@ -312,7 +314,9 @@ public:
|
||||||
if(value3 > 9.9 && value3 <= 99.9)epd->print(value3, 1);
|
if(value3 > 9.9 && value3 <= 99.9)epd->print(value3, 1);
|
||||||
if(value3 > 99.9) epd->print(value3, 0);
|
if(value3 > 99.9) epd->print(value3, 0);
|
||||||
}
|
}
|
||||||
else epd->print("---");
|
else {
|
||||||
|
epd->print(commonData->fmt->placeholder);
|
||||||
|
}
|
||||||
epd->setFont(&Ubuntu_Bold16pt8b);
|
epd->setFont(&Ubuntu_Bold16pt8b);
|
||||||
epd->print("W");
|
epd->print("W");
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
class PageClock : public Page
|
class PageClock : public Page
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
String dateformat;
|
fmtDate dateformat;
|
||||||
int simtime;
|
int simtime;
|
||||||
bool keylock = false;
|
bool keylock = false;
|
||||||
char source = 'R'; // time source (R)TC | (G)PS | (N)TP
|
char source = 'R'; // time source (R)TC | (G)PS | (N)TP
|
||||||
|
@ -35,7 +35,7 @@ public:
|
||||||
logger->logDebug(GwLog::LOG, "Instantiate PageClock");
|
logger->logDebug(GwLog::LOG, "Instantiate PageClock");
|
||||||
|
|
||||||
// Get config data
|
// Get config data
|
||||||
dateformat = config->getString(config->dateFormat);
|
dateformat = common.fmt->getDateFormat(config->getString(config->dateFormat));
|
||||||
timezone = config->getString(config->timeZone).toDouble();
|
timezone = config->getString(config->timeZone).toDouble();
|
||||||
homelat = config->getString(config->homeLAT).toDouble();
|
homelat = config->getString(config->homeLAT).toDouble();
|
||||||
homelon = config->getString(config->homeLON).toDouble();
|
homelon = config->getString(config->homeLON).toDouble();
|
||||||
|
@ -208,7 +208,7 @@ public:
|
||||||
epd->print(formatDate(dateformat, commonData->data.rtcTime.tm_year + 1900, commonData->data.rtcTime.tm_mon + 1, commonData->data.rtcTime.tm_mday));
|
epd->print(formatDate(dateformat, commonData->data.rtcTime.tm_year + 1900, commonData->data.rtcTime.tm_mon + 1, commonData->data.rtcTime.tm_mday));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
epd->print("---");
|
epd->print(commonData->fmt->placeholder);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
epd->print(svalue2old);
|
epd->print(svalue2old);
|
||||||
|
@ -229,13 +229,13 @@ public:
|
||||||
}
|
}
|
||||||
else if (commonData->data.rtcValid) {
|
else if (commonData->data.rtcValid) {
|
||||||
if (tz == 'L') {
|
if (tz == 'L') {
|
||||||
epd->print(formatTime('s', local_tm->tm_hour, local_tm->tm_min, local_tm->tm_sec));
|
epd->print(formatTime(fmtTime::MMHHSS, local_tm->tm_hour, local_tm->tm_min, local_tm->tm_sec));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
epd->print(formatTime('s', commonData->data.rtcTime.tm_hour, commonData->data.rtcTime.tm_min, commonData->data.rtcTime.tm_sec));
|
epd->print(formatTime(fmtTime::MMHHSS, commonData->data.rtcTime.tm_hour, commonData->data.rtcTime.tm_min, commonData->data.rtcTime.tm_sec));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
epd->print("---");
|
epd->print(commonData->fmt->placeholder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -246,7 +246,7 @@ public:
|
||||||
epd->print("Time"); // Name
|
epd->print("Time"); // Name
|
||||||
|
|
||||||
// Show values sunrise
|
// Show values sunrise
|
||||||
String sunrise = "---";
|
String sunrise = commonData->fmt->placeholder;
|
||||||
if (((source == 'G') and gpsvalid) or (homevalid and commonData->data.rtcValid)) {
|
if (((source == 'G') and gpsvalid) or (homevalid and commonData->data.rtcValid)) {
|
||||||
sunrise = String(commonData->sundata.sunriseHour) + ":" + String(commonData->sundata.sunriseMinute + 100).substring(1);
|
sunrise = String(commonData->sundata.sunriseHour) + ":" + String(commonData->sundata.sunriseMinute + 100).substring(1);
|
||||||
svalue5old = sunrise;
|
svalue5old = sunrise;
|
||||||
|
@ -266,7 +266,7 @@ public:
|
||||||
epd->fillRect(340, 149, 80, 3, commonData->fgcolor);
|
epd->fillRect(340, 149, 80, 3, commonData->fgcolor);
|
||||||
|
|
||||||
// Show values sunset
|
// Show values sunset
|
||||||
String sunset = "---";
|
String sunset = commonData->fmt->placeholder;
|
||||||
if (((source == 'G') and gpsvalid) or (homevalid and commonData->data.rtcValid)) {
|
if (((source == 'G') and gpsvalid) or (homevalid and commonData->data.rtcValid)) {
|
||||||
sunset = String(commonData->sundata.sunsetHour) + ":" + String(commonData->sundata.sunsetMinute + 100).substring(1);
|
sunset = String(commonData->sundata.sunsetHour) + ":" + String(commonData->sundata.sunsetMinute + 100).substring(1);
|
||||||
svalue6old = sunset;
|
svalue6old = sunset;
|
||||||
|
|
|
@ -168,7 +168,7 @@ public:
|
||||||
if(value1 > 99.9) epd->print(value1, 0);
|
if(value1 > 99.9) epd->print(value1, 0);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
epd->print("---"); // Missing bus data
|
epd->print(commonData->fmt->placeholder); // Missing bus data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
epd->setFont(&Ubuntu_Bold16pt8b);
|
epd->setFont(&Ubuntu_Bold16pt8b);
|
||||||
|
@ -177,24 +177,37 @@ public:
|
||||||
// Show actual current in A
|
// Show actual current in A
|
||||||
epd->setFont(&DSEG7Classic_BoldItalic20pt7b);
|
epd->setFont(&DSEG7Classic_BoldItalic20pt7b);
|
||||||
epd->setCursor(260, 200);
|
epd->setCursor(260, 200);
|
||||||
if((powerSensor == "INA219" || powerSensor == "INA226") && simulation == false){
|
if ((powerSensor == "INA219" || powerSensor == "INA226") && (simulation == false)) {
|
||||||
if(value2 <= 9.9) epd->print(value2, 2);
|
// TODO use formatter for this?
|
||||||
if(value2 > 9.9 && value2 <= 99.9)epd->print(value2, 1);
|
if (value2 <= 9.9) {
|
||||||
if(value2 > 99.9) epd->print(value2, 0);
|
epd->print(value2, 2);
|
||||||
|
} else if (value2 <= 99.9) {
|
||||||
|
epd->print(value2, 1);
|
||||||
|
} else {
|
||||||
|
epd->print(value2, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
epd->print(commonData->fmt->placeholder);
|
||||||
}
|
}
|
||||||
else epd->print("---");
|
|
||||||
epd->setFont(&Ubuntu_Bold16pt8b);
|
epd->setFont(&Ubuntu_Bold16pt8b);
|
||||||
epd->print("A");
|
epd->print("A");
|
||||||
|
|
||||||
// Show actual consumption in W
|
// Show actual consumption in W
|
||||||
epd->setFont(&DSEG7Classic_BoldItalic20pt7b);
|
epd->setFont(&DSEG7Classic_BoldItalic20pt7b);
|
||||||
epd->setCursor(260, 260);
|
epd->setCursor(260, 260);
|
||||||
if((powerSensor == "INA219" || powerSensor == "INA226") && simulation == false){
|
if ((powerSensor == "INA219" || powerSensor == "INA226") && (simulation == false)) {
|
||||||
if(value3 <= 9.9) epd->print(value3, 2);
|
if(value3 <= 9.9) {
|
||||||
if(value3 > 9.9 && value3 <= 99.9)epd->print(value3, 1);
|
epd->print(value3, 2);
|
||||||
if(value3 > 99.9) epd->print(value3, 0);
|
} else if (value3 <= 99.9) {
|
||||||
|
epd->print(value3, 1);
|
||||||
|
} else {
|
||||||
|
epd->print(value3, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
epd->print(commonData->fmt->placeholder);
|
||||||
}
|
}
|
||||||
else epd->print("---");
|
|
||||||
epd->setFont(&Ubuntu_Bold16pt8b);
|
epd->setFont(&Ubuntu_Bold16pt8b);
|
||||||
epd->print("W");
|
epd->print("W");
|
||||||
|
|
||||||
|
|
|
@ -160,12 +160,16 @@ public:
|
||||||
// Check for valid real data, display also if hold values activated
|
// Check for valid real data, display also if hold values activated
|
||||||
if(valid1 == true || holdvalues == true){
|
if(valid1 == true || holdvalues == true){
|
||||||
// Resolution switching
|
// Resolution switching
|
||||||
if(value1 <= 9.9) epd->print(value1, 2);
|
if (value1 <= 9.9) {
|
||||||
if(value1 > 9.9 && value1 <= 99.9)epd->print(value1, 1);
|
epd->print(value1, 2);
|
||||||
if(value1 > 99.9) epd->print(value1, 0);
|
} else if (value1 <= 99.9) {
|
||||||
|
epd->print(value1, 1);
|
||||||
|
} else {
|
||||||
|
epd->print(value1, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
epd->print("---"); // Missing bus data
|
epd->print(commonData->fmt->placeholder); // Missing bus data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
epd->setFont(&Ubuntu_Bold16pt8b);
|
epd->setFont(&Ubuntu_Bold16pt8b);
|
||||||
|
@ -174,24 +178,36 @@ public:
|
||||||
// Show actual current in A
|
// Show actual current in A
|
||||||
epd->setFont(&DSEG7Classic_BoldItalic20pt7b);
|
epd->setFont(&DSEG7Classic_BoldItalic20pt7b);
|
||||||
epd->setCursor(260, 200);
|
epd->setCursor(260, 200);
|
||||||
if((powerSensor == "INA219" || powerSensor == "INA226") && simulation == false){
|
if ((powerSensor == "INA219" || powerSensor == "INA226") && (simulation == false)) {
|
||||||
if(value2 <= 9.9) epd->print(value2, 2);
|
if (value2 <= 9.9) {
|
||||||
if(value2 > 9.9 && value2 <= 99.9)epd->print(value2, 1);
|
epd->print(value2, 2);
|
||||||
if(value2 > 99.9) epd->print(value2, 0);
|
} else if (value2 <= 99.9) {
|
||||||
|
epd->print(value2, 1);
|
||||||
|
} else {
|
||||||
|
epd->print(value2, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
epd->print(commonData->fmt->placeholder);
|
||||||
}
|
}
|
||||||
else epd->print("---");
|
|
||||||
epd->setFont(&Ubuntu_Bold16pt8b);
|
epd->setFont(&Ubuntu_Bold16pt8b);
|
||||||
epd->print("A");
|
epd->print("A");
|
||||||
|
|
||||||
// Show actual consumption in W
|
// Show actual consumption in W
|
||||||
epd->setFont(&DSEG7Classic_BoldItalic20pt7b);
|
epd->setFont(&DSEG7Classic_BoldItalic20pt7b);
|
||||||
epd->setCursor(260, 260);
|
epd->setCursor(260, 260);
|
||||||
if((powerSensor == "INA219" || powerSensor == "INA226") && simulation == false){
|
if ((powerSensor == "INA219" || powerSensor == "INA226") && (simulation == false)) {
|
||||||
if(value3 <= 9.9) epd->print(value3, 2);
|
if (value3 <= 9.9) {
|
||||||
if(value3 > 9.9 && value3 <= 99.9)epd->print(value3, 1);
|
epd->print(value3, 2);
|
||||||
if(value3 > 99.9) epd->print(value3, 0);
|
} else if (value3 <= 99.9) {
|
||||||
|
epd->print(value3, 1);
|
||||||
|
} else {
|
||||||
|
epd->print(value3, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
epd->print(commonData->fmt->placeholder);
|
||||||
}
|
}
|
||||||
else epd->print("---");
|
|
||||||
epd->setFont(&Ubuntu_Bold16pt8b);
|
epd->setFont(&Ubuntu_Bold16pt8b);
|
||||||
epd->print("W");
|
epd->print("W");
|
||||||
|
|
||||||
|
|
|
@ -249,7 +249,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
epd->print("---"); // Missing bus data
|
epd->print(commonData->fmt->placeholder); // Missing bus data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -186,7 +186,7 @@ public:
|
||||||
epd->print(abs(value3 * 180 / PI), 0); // Value
|
epd->print(abs(value3 * 180 / PI), 0); // Value
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
epd->print("---"); // Value
|
epd->print(commonData->fmt->placeholder);
|
||||||
}
|
}
|
||||||
epd->setFont(&Ubuntu_Bold12pt8b);
|
epd->setFont(&Ubuntu_Bold12pt8b);
|
||||||
epd->setCursor(335, 95);
|
epd->setCursor(335, 95);
|
||||||
|
|
|
@ -207,7 +207,7 @@ public:
|
||||||
epd->print(svalue4); // Value
|
epd->print(svalue4); // Value
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
epd->print("---"); // Value
|
epd->print(commonData->fmt->placeholder);
|
||||||
}
|
}
|
||||||
epd->setFont(&Ubuntu_Bold12pt8b);
|
epd->setFont(&Ubuntu_Bold12pt8b);
|
||||||
epd->setCursor(335, 95);
|
epd->setCursor(335, 95);
|
||||||
|
|
|
@ -208,7 +208,7 @@ class PageDescription{
|
||||||
|
|
||||||
class PageStruct{
|
class PageStruct{
|
||||||
public:
|
public:
|
||||||
Page *page=NULL;
|
Page *page = nullptr;
|
||||||
PageData parameters;
|
PageData parameters;
|
||||||
PageDescription *description=NULL;
|
PageDescription *description = nullptr;
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,9 +8,10 @@ Coding style
|
||||||
------------
|
------------
|
||||||
WIP
|
WIP
|
||||||
Please format your new code the same as already existing code.
|
Please format your new code the same as already existing code.
|
||||||
Preprocessor directives go to column zero.
|
|
||||||
|
|
||||||
Identation is 4 spaces
|
Some rules:
|
||||||
|
- Preprocessor directives go to column zero
|
||||||
|
- Identation is 4 spaces
|
||||||
|
|
||||||
Git commands
|
Git commands
|
||||||
------------
|
------------
|
||||||
|
|
|
@ -65,7 +65,7 @@ void OBP60Init(GwApi *api){
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Settings for e-paper display
|
// Settings for e-paper display
|
||||||
String fastrefresh = api->getConfig()->getConfigItem(api->getConfig()->fastRefresh,true)->asString();
|
String fastrefresh = config->getConfigItem(config->fastRefresh,true)->asString();
|
||||||
logger->logDebug(GwLog::DEBUG, "Fast Refresh Mode is: %s", fastrefresh.c_str());
|
logger->logDebug(GwLog::DEBUG, "Fast Refresh Mode is: %s", fastrefresh.c_str());
|
||||||
#ifdef DISPLAY_GDEY042T81
|
#ifdef DISPLAY_GDEY042T81
|
||||||
if(fastrefresh == "true"){
|
if(fastrefresh == "true"){
|
||||||
|
@ -88,24 +88,24 @@ void OBP60Init(GwApi *api){
|
||||||
logger->logDebug(GwLog::LOG,"CPU speed at boot: %i MHz", freq);
|
logger->logDebug(GwLog::LOG,"CPU speed at boot: %i MHz", freq);
|
||||||
|
|
||||||
// Settings for backlight
|
// Settings for backlight
|
||||||
String backlightMode = api->getConfig()->getConfigItem(api->getConfig()->backlight,true)->asString();
|
String backlightMode = config->getConfigItem(config->backlight,true)->asString();
|
||||||
logger->logDebug(GwLog::DEBUG, "Backlight Mode is: %s", backlightMode.c_str());
|
logger->logDebug(GwLog::DEBUG, "Backlight Mode is: %s", backlightMode.c_str());
|
||||||
uint brightness = uint(api->getConfig()->getConfigItem(api->getConfig()->blBrightness,true)->asInt());
|
uint brightness = uint(config->getConfigItem(config->blBrightness,true)->asInt());
|
||||||
String backlightColor = api->getConfig()->getConfigItem(api->getConfig()->blColor,true)->asString();
|
String backlightColor = config->getConfigItem(config->blColor,true)->asString();
|
||||||
if(String(backlightMode) == "On"){
|
if (backlightMode == "On") {
|
||||||
setBacklightLED(brightness, colorMapping(backlightColor));
|
setBacklightLED(brightness, colorMapping(backlightColor));
|
||||||
}
|
}
|
||||||
else if(String(backlightMode) == "Off"){
|
else if (backlightMode == "Off") {
|
||||||
setBacklightLED(0, COLOR_BLACK); // Backlight LEDs off (blue without britghness)
|
setBacklightLED(0, COLOR_BLACK); // Backlight LEDs off (blue without britghness)
|
||||||
}
|
}
|
||||||
else if(String(backlightMode) == "Control by Key"){
|
else if (backlightMode == "Control by Key") {
|
||||||
setBacklightLED(0, COLOR_BLUE); // Backlight LEDs off (blue without britghness)
|
setBacklightLED(0, COLOR_BLUE); // Backlight LEDs off (blue without britghness)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Settings flash LED mode
|
// Settings flash LED mode
|
||||||
String ledMode = api->getConfig()->getConfigItem(api->getConfig()->flashLED,true)->asString();
|
String ledMode = config->getConfigItem(config->flashLED,true)->asString();
|
||||||
logger->logDebug(GwLog::DEBUG,"LED Mode is: %s", ledMode.c_str());
|
logger->logDebug(GwLog::DEBUG,"LED Mode is: %s", ledMode.c_str());
|
||||||
if(String(ledMode) == "Off"){
|
if (ledMode == "Off") {
|
||||||
setBlinkingLED(false);
|
setBlinkingLED(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ void OBP60Init(GwApi *api){
|
||||||
initComplete = true;
|
initComplete = true;
|
||||||
|
|
||||||
// Buzzer tone for initialization finish
|
// Buzzer tone for initialization finish
|
||||||
setBuzzerPower(uint(api->getConfig()->getConfigItem(api->getConfig()->buzzerPower,true)->asInt()));
|
setBuzzerPower(uint(config->getConfigItem(config->buzzerPower,true)->asInt()));
|
||||||
buzzer(TONE4, 500);
|
buzzer(TONE4, 500);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -186,7 +186,6 @@ class BoatValueList{
|
||||||
//this way each page can easily be added here
|
//this way each page can easily be added here
|
||||||
//needs some minor tricks for the safe static initialization
|
//needs some minor tricks for the safe static initialization
|
||||||
typedef std::vector<PageDescription*> Pages;
|
typedef std::vector<PageDescription*> Pages;
|
||||||
//the page list class
|
|
||||||
class PageList{
|
class PageList{
|
||||||
public:
|
public:
|
||||||
Pages pages;
|
Pages pages;
|
||||||
|
@ -280,20 +279,7 @@ void registerAllPages(GwLog *logger, PageList &list){
|
||||||
}
|
}
|
||||||
|
|
||||||
// Undervoltage detection for shutdown display
|
// Undervoltage detection for shutdown display
|
||||||
void underVoltageDetection(GwApi *api, CommonData &common){
|
void underVoltageError(CommonData &common) {
|
||||||
// Read settings
|
|
||||||
double voffset = (api->getConfig()->getConfigItem(api->getConfig()->vOffset,true)->asString()).toFloat();
|
|
||||||
double vslope = (api->getConfig()->getConfigItem(api->getConfig()->vSlope,true)->asString()).toFloat();
|
|
||||||
// Read supply voltage
|
|
||||||
#if defined VOLTAGE_SENSOR && defined LIPO_ACCU_1200
|
|
||||||
float actVoltage = (float(analogRead(OBP_ANALOG0)) * 3.3 / 4096 + 0.53) * 2; // Vin = 1/2 for OBP40
|
|
||||||
float minVoltage = 3.65; // Absolut minimum volatge for 3,7V LiPo accu
|
|
||||||
#else
|
|
||||||
float actVoltage = (float(analogRead(OBP_ANALOG0)) * 3.3 / 4096 + 0.17) * 20; // Vin = 1/20 for OBP60
|
|
||||||
float minVoltage = MIN_VOLTAGE;
|
|
||||||
#endif
|
|
||||||
double calVoltage = actVoltage * vslope + voffset; // Calibration
|
|
||||||
if(calVoltage < minVoltage){
|
|
||||||
#if defined VOLTAGE_SENSOR && defined LIPO_ACCU_1200
|
#if defined VOLTAGE_SENSOR && defined LIPO_ACCU_1200
|
||||||
// Switch off all power lines
|
// Switch off all power lines
|
||||||
setPortPin(OBP_BACKLIGHT_LED, false); // Backlight Off
|
setPortPin(OBP_BACKLIGHT_LED, false); // Backlight Off
|
||||||
|
@ -333,11 +319,22 @@ void underVoltageDetection(GwApi *api, CommonData &common){
|
||||||
epd->nextPage(); // Partial update
|
epd->nextPage(); // Partial update
|
||||||
epd->powerOff(); // Display power off
|
epd->powerOff(); // Display power off
|
||||||
#endif
|
#endif
|
||||||
// Stop system
|
|
||||||
while (true) {
|
while (true) {
|
||||||
esp_deep_sleep_start(); // Deep Sleep without weakup. Weakup only after power cycle (restart).
|
esp_deep_sleep_start(); // Deep Sleep without wakeup. Wakeup only after power cycle (restart).
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool underVoltageDetection(float voffset, float vslope) {
|
||||||
|
// Read supply voltage
|
||||||
|
#if defined VOLTAGE_SENSOR && defined LIPO_ACCU_1200
|
||||||
|
float actVoltage = (float(analogRead(OBP_ANALOG0)) * 3.3 / 4096 + 0.53) * 2; // Vin = 1/2 for OBP40
|
||||||
|
float minVoltage = 3.65; // Absolut minimum volatge for 3,7V LiPo accu
|
||||||
|
#else
|
||||||
|
float actVoltage = (float(analogRead(OBP_ANALOG0)) * 3.3 / 4096 + 0.17) * 20; // Vin = 1/20 for OBP60
|
||||||
|
float minVoltage = MIN_VOLTAGE;
|
||||||
|
#endif
|
||||||
|
float calVoltage = actVoltage * vslope + voffset; // Calibration
|
||||||
|
return (calVoltage < minVoltage);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate true wind data and add to obp60task boat data list
|
// Calculate true wind data and add to obp60task boat data list
|
||||||
|
@ -566,8 +563,8 @@ void OBP60Task(GwApi *api){
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init E-Ink display
|
// Init E-Ink display
|
||||||
String displaymode = api->getConfig()->getConfigItem(api->getConfig()->display,true)->asString();
|
String displaymode = config->getConfigItem(config->display,true)->asString();
|
||||||
String displaycolor = api->getConfig()->getConfigItem(api->getConfig()->displaycolor,true)->asString();
|
String displaycolor = config->getConfigItem(config->displaycolor,true)->asString();
|
||||||
if (displaycolor == "Normal") {
|
if (displaycolor == "Normal") {
|
||||||
commonData.fgcolor = GxEPD_BLACK;
|
commonData.fgcolor = GxEPD_BLACK;
|
||||||
commonData.bgcolor = GxEPD_WHITE;
|
commonData.bgcolor = GxEPD_WHITE;
|
||||||
|
@ -576,12 +573,12 @@ void OBP60Task(GwApi *api){
|
||||||
commonData.fgcolor = GxEPD_WHITE;
|
commonData.fgcolor = GxEPD_WHITE;
|
||||||
commonData.bgcolor = GxEPD_BLACK;
|
commonData.bgcolor = GxEPD_BLACK;
|
||||||
}
|
}
|
||||||
String systemname = api->getConfig()->getConfigItem(api->getConfig()->systemName,true)->asString();
|
String systemname = config->getConfigItem(config->systemName, true)->asString();
|
||||||
String wifipass = api->getConfig()->getConfigItem(api->getConfig()->apPassword,true)->asString();
|
String wifipass = config->getConfigItem(config->apPassword, true)->asString();
|
||||||
bool refreshmode = api->getConfig()->getConfigItem(api->getConfig()->refresh,true)->asBoolean();
|
bool refreshmode = config->getConfigItem(config->refresh, true)->asBoolean();
|
||||||
bool symbolmode = (config->getString(config->headerFormat) == "ICON");
|
bool symbolmode = (config->getString(config->headerFormat) == "ICON");
|
||||||
String fastrefresh = api->getConfig()->getConfigItem(api->getConfig()->fastRefresh,true)->asString();
|
String fastrefresh = config->getConfigItem(config->fastRefresh, true)->asString();
|
||||||
uint fullrefreshtime = uint(api->getConfig()->getConfigItem(api->getConfig()->fullRefreshTime,true)->asInt());
|
uint fullrefreshtime = uint(config->getConfigItem(config->fullRefreshTime, true)->asInt());
|
||||||
#ifdef BOARD_OBP40S3
|
#ifdef BOARD_OBP40S3
|
||||||
bool syspage_enabled = config->getBool(config->systemPage);
|
bool syspage_enabled = config->getBool(config->systemPage);
|
||||||
#endif
|
#endif
|
||||||
|
@ -738,21 +735,23 @@ void OBP60Task(GwApi *api){
|
||||||
//####################################################################################
|
//####################################################################################
|
||||||
|
|
||||||
// Configuration values for main loop
|
// Configuration values for main loop
|
||||||
String gpsFix = api->getConfig()->getConfigItem(api->getConfig()->flashLED,true)->asString();
|
String gpsFix = config->getConfigItem(config->flashLED,true)->asString();
|
||||||
String gpsOn=api->getConfig()->getConfigItem(api->getConfig()->useGPS,true)->asString();
|
String gpsOn = config->getConfigItem(config->useGPS,true)->asString();
|
||||||
float tz = api->getConfig()->getConfigItem(api->getConfig()->timeZone,true)->asFloat();
|
float tz = config->getConfigItem(config->timeZone,true)->asFloat();
|
||||||
|
|
||||||
commonData.backlight.mode = backlightMapping(config->getConfigItem(config->backlight, true)->asString());
|
commonData.backlight.mode = backlightMapping(config->getConfigItem(config->backlight, true)->asString());
|
||||||
commonData.backlight.color = colorMapping(config->getConfigItem(config->blColor, true)->asString());
|
commonData.backlight.color = colorMapping(config->getConfigItem(config->blColor, true)->asString());
|
||||||
commonData.backlight.brightness = 2.55 * uint(config->getConfigItem(config->blBrightness, true)->asInt());
|
commonData.backlight.brightness = 2.55 * uint(config->getConfigItem(config->blBrightness, true)->asInt());
|
||||||
commonData.powermode = api->getConfig()->getConfigItem(api->getConfig()->powerMode, true)->asString();
|
commonData.powermode = api->getConfig()->getConfigItem(api->getConfig()->powerMode, true)->asString();
|
||||||
|
|
||||||
bool uvoltage = api->getConfig()->getConfigItem(api->getConfig()->underVoltage,true)->asBoolean();
|
bool uvoltage = config->getConfigItem(config->underVoltage, true)->asBoolean();
|
||||||
String cpuspeed = api->getConfig()->getConfigItem(api->getConfig()->cpuSpeed,true)->asString();
|
float voffset = (config->getConfigItem(config->vOffset,true)->asString()).toFloat();
|
||||||
uint hdopAccuracy = uint(api->getConfig()->getConfigItem(api->getConfig()->hdopAccuracy,true)->asInt());
|
float vslope = (config->getConfigItem(config->vSlope,true)->asString()).toFloat();
|
||||||
|
String cpuspeed = config->getConfigItem(config->cpuSpeed, true)->asString();
|
||||||
|
uint hdopAccuracy = uint(config->getConfigItem(config->hdopAccuracy, true)->asInt());
|
||||||
|
|
||||||
double homelat = commonData.config->getString(commonData.config->homeLAT).toDouble();
|
double homelat = config->getString(config->homeLAT).toDouble();
|
||||||
double homelon = commonData.config->getString(commonData.config->homeLON).toDouble();
|
double homelon = config->getString(config->homeLON).toDouble();
|
||||||
bool homevalid = homelat >= -180.0 and homelat <= 180 and homelon >= -90.0 and homelon <= 90.0;
|
bool homevalid = homelat >= -180.0 and homelat <= 180 and homelon >= -90.0 and homelon <= 90.0;
|
||||||
if (homevalid) {
|
if (homevalid) {
|
||||||
logger->logDebug(GwLog::LOG, "Home location set to lat=%f, lon=%f", homelat, homelon);
|
logger->logDebug(GwLog::LOG, "Home location set to lat=%f, lon=%f", homelat, homelon);
|
||||||
|
@ -797,7 +796,10 @@ void OBP60Task(GwApi *api){
|
||||||
|
|
||||||
// Undervoltage detection
|
// Undervoltage detection
|
||||||
if (uvoltage == true) {
|
if (uvoltage == true) {
|
||||||
underVoltageDetection(api, commonData);
|
if (underVoltageDetection(voffset, vslope)) {
|
||||||
|
LOG_DEBUG(GwLog::ERROR, "Undervoltage detected, shutting down!");
|
||||||
|
underVoltageError(commonData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set CPU speed after boot after 1min
|
// Set CPU speed after boot after 1min
|
||||||
|
|
|
@ -41,5 +41,10 @@
|
||||||
#ifdef BOARD_OBP40S3
|
#ifdef BOARD_OBP40S3
|
||||||
DECLARE_CAPABILITY(obp40,true)
|
DECLARE_CAPABILITY(obp40,true)
|
||||||
#endif
|
#endif
|
||||||
DECLARE_STRING_CAPABILITY(HELP_URL, "https://obp60-v2-docu.readthedocs.io/de/latest/"); // Link to help pages
|
#ifdef BOARD_OBP60S3
|
||||||
|
DECLARE_STRING_CAPABILITY(HELP_URL, "https://obp60-v2-docu.readthedocs.io/en/latest/"); // Link to help pages
|
||||||
|
#endif
|
||||||
|
#ifdef BOARD_OBP40S3
|
||||||
|
DECLARE_STRING_CAPABILITY(HELP_URL, "https://obp40-v1-docu.readthedocs.io/en/latest/"); // Link to help pages
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue