GPS Fix LED
This commit is contained in:
parent
f30bd27ad6
commit
f4ac126ae3
|
@ -44,11 +44,8 @@ void MCP23017Init()
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPortPin(uint pin, bool value){
|
void setPortPin(uint pin, bool value){
|
||||||
|
|
||||||
if(pin <=7){
|
if(pin <=7){
|
||||||
|
|
||||||
outA &= ~(1 << pin); // Clear bit
|
outA &= ~(1 << pin); // Clear bit
|
||||||
|
|
||||||
outA |= (value << pin); // Set bit
|
outA |= (value << pin); // Set bit
|
||||||
mcp.writeRegister(MCP23017Register::GPIO_A, outA);
|
mcp.writeRegister(MCP23017Register::GPIO_A, outA);
|
||||||
}
|
}
|
||||||
|
@ -73,14 +70,9 @@ void togglePortPin(uint pin){
|
||||||
}
|
}
|
||||||
|
|
||||||
void blinkingFlashLED(){
|
void blinkingFlashLED(){
|
||||||
noInterrupts();
|
|
||||||
if(blinkingLED == true){
|
if(blinkingLED == true){
|
||||||
togglePortPin(OBP_FLASH_LED);
|
togglePortPin(OBP_FLASH_LED);
|
||||||
}
|
}
|
||||||
else{
|
|
||||||
setPortPin(OBP_FLASH_LED, false);
|
|
||||||
}
|
|
||||||
interrupts();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setBlinkingLED(bool on){
|
void setBlinkingLED(bool on){
|
||||||
|
|
|
@ -8,8 +8,17 @@
|
||||||
// different unit convertion
|
// different unit convertion
|
||||||
|
|
||||||
FormatedData formatValue(GwApi::BoatValue *value){
|
FormatedData formatValue(GwApi::BoatValue *value){
|
||||||
|
// GwApi *api;
|
||||||
FormatedData result;
|
FormatedData result;
|
||||||
|
/*
|
||||||
|
// Load configuration values
|
||||||
|
String lengthFormat = api->getConfig()->getConfigItem(api->getConfig()->lengthFormat,true)->asString(); // [m|ft]
|
||||||
|
String distanceFormat = api->getConfig()->getConfigItem(api->getConfig()->distanceFormat,true)->asString(); // [m|km|nm]
|
||||||
|
String speedFormat = api->getConfig()->getConfigItem(api->getConfig()->speedFormat,true)->asString(); // [m/s|km/h|kn]
|
||||||
|
String windspeedFormat = api->getConfig()->getConfigItem(api->getConfig()->windspeedFormat,true)->asString(); // [m/s|km/h|kn|bft]
|
||||||
|
String tempFormat = api->getConfig()->getConfigItem(api->getConfig()->tempFormat,true)->asString(); // [K|°C|°F]
|
||||||
|
String dateFormat = api->getConfig()->getConfigItem(api->getConfig()->dateFormat,true)->asString(); // [DE|GB|US]
|
||||||
|
*/
|
||||||
if (! value->valid){
|
if (! value->valid){
|
||||||
result.svalue = "---";
|
result.svalue = "---";
|
||||||
result.unit = "";
|
result.unit = "";
|
||||||
|
@ -22,8 +31,18 @@ FormatedData formatValue(GwApi::BoatValue *value){
|
||||||
time_t tv=tNMEA0183Msg::daysToTime_t(value->value);
|
time_t tv=tNMEA0183Msg::daysToTime_t(value->value);
|
||||||
tmElements_t parts;
|
tmElements_t parts;
|
||||||
tNMEA0183Msg::breakTime(tv,parts);
|
tNMEA0183Msg::breakTime(tv,parts);
|
||||||
snprintf(buffer,bsize,"%04d/%02d/%02d",parts.tm_year+1900,parts.tm_mon+1,parts.tm_mday);
|
/*
|
||||||
result.unit = "";
|
if(String(dateFormat) == "DE"){
|
||||||
|
snprintf(buffer,bsize,"%02d.%02d.%04d",parts.tm_mday,parts.tm_mon+1,parts.tm_year+1900);
|
||||||
|
}
|
||||||
|
if(String(dateFormat) == "GB"){
|
||||||
|
snprintf(buffer,bsize,"%02d/%02d/%04d",parts.tm_mday,parts.tm_mon+1,parts.tm_year+1900);
|
||||||
|
}
|
||||||
|
if(String(dateFormat) == "US"){
|
||||||
|
snprintf(buffer,bsize,"%02d/%02d/%04d",parts.tm_mon+1,parts.tm_mday,parts.tm_year+1900);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
snprintf(buffer,bsize,"%02d.%02d.%04d",parts.tm_mday,parts.tm_mon+1,parts.tm_year+1900);
|
||||||
}
|
}
|
||||||
else if(value->getFormat() == "formatTime"){
|
else if(value->getFormat() == "formatTime"){
|
||||||
double inthr;
|
double inthr;
|
||||||
|
|
|
@ -12,6 +12,7 @@ class PageOneValue : public Page{
|
||||||
bool simulation = config->getBool(config->useSimuData);
|
bool simulation = config->getBool(config->useSimuData);
|
||||||
String displaycolor = config->getString(config->displaycolor);
|
String displaycolor = config->getString(config->displaycolor);
|
||||||
bool holdvalues = config->getBool(config->holdvalues);
|
bool holdvalues = config->getBool(config->holdvalues);
|
||||||
|
String flashLED = config->getString(config->flashLED);
|
||||||
|
|
||||||
// Get boat values
|
// Get boat values
|
||||||
GwApi::BoatValue *bvalue=pageData.values[0]; // First element in list (only one value by PageOneValue)
|
GwApi::BoatValue *bvalue=pageData.values[0]; // First element in list (only one value by PageOneValue)
|
||||||
|
@ -19,7 +20,12 @@ class PageOneValue : public Page{
|
||||||
double value1 = bvalue->value; // Value as double in SI unit
|
double value1 = bvalue->value; // Value as double in SI unit
|
||||||
String svalue1 = formatValue(bvalue).svalue; // Formatted value as string including unit conversion and switching decimal places
|
String svalue1 = formatValue(bvalue).svalue; // Formatted value as string including unit conversion and switching decimal places
|
||||||
String unit1 = formatValue(bvalue).unit; // Unit of value
|
String unit1 = formatValue(bvalue).unit; // Unit of value
|
||||||
bool valid1 = bvalue->valid; // Valid flag of value
|
|
||||||
|
// Optical warning by limit violation
|
||||||
|
if(String(flashLED) == "Limit Violation"){
|
||||||
|
setBlinkingLED(false);
|
||||||
|
setPortPin(OBP_FLASH_LED, false);
|
||||||
|
}
|
||||||
|
|
||||||
// Logging boat values
|
// Logging boat values
|
||||||
if (bvalue == NULL) return;
|
if (bvalue == NULL) return;
|
||||||
|
@ -55,11 +61,15 @@ class PageOneValue : public Page{
|
||||||
display.setCursor(270, 100);
|
display.setCursor(270, 100);
|
||||||
display.print(unit1);
|
display.print(unit1);
|
||||||
|
|
||||||
// Switch font if format latitude or longitude
|
// Switch font if format for any values
|
||||||
if(bvalue->getFormat() == "formatLatitude" || bvalue->getFormat() == "formatLongitude"){
|
if(bvalue->getFormat() == "formatLatitude" || bvalue->getFormat() == "formatLongitude"){
|
||||||
display.setFont(&Ubuntu_Bold20pt7b);
|
display.setFont(&Ubuntu_Bold20pt7b);
|
||||||
display.setCursor(20, 180);
|
display.setCursor(20, 180);
|
||||||
}
|
}
|
||||||
|
else if(bvalue->getFormat() == "formatTime" || bvalue->getFormat() == "formatDate"){
|
||||||
|
display.setFont(&Ubuntu_Bold32pt7b);
|
||||||
|
display.setCursor(20, 200);
|
||||||
|
}
|
||||||
else{
|
else{
|
||||||
display.setFont(&DSEG7Classic_BoldItalic60pt7b);
|
display.setFont(&DSEG7Classic_BoldItalic60pt7b);
|
||||||
display.setCursor(20, 240);
|
display.setCursor(20, 240);
|
||||||
|
|
|
@ -37,16 +37,14 @@ public:
|
||||||
bool valid1 = true;
|
bool valid1 = true;
|
||||||
|
|
||||||
// Optical warning by limit violation
|
// Optical warning by limit violation
|
||||||
bool activViolation = false;
|
|
||||||
if(String(flashLED) == "Limit Violation"){
|
if(String(flashLED) == "Limit Violation"){
|
||||||
// Limits for Pb battery
|
// Limits for Pb battery
|
||||||
if(activViolation == false && String(batType) == "Pb" && (value1 < 10.0 || value1 > 14.5)){
|
if(String(batType) == "Pb" && (value1 < 10.0 || value1 > 14.5)){
|
||||||
setPortPin(OBP_FLASH_LED, true);
|
setBlinkingLED(true);
|
||||||
activViolation = true;
|
|
||||||
}
|
}
|
||||||
if(activViolation == true && String(batType) == "Pb" && !(value1 < 10.0 || value1 > 14.5)){
|
if(String(batType) == "Pb" && (value1 >= 10.0 && value1 <= 14.5)){
|
||||||
|
setBlinkingLED(false);
|
||||||
setPortPin(OBP_FLASH_LED, false);
|
setPortPin(OBP_FLASH_LED, false);
|
||||||
activViolation = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,14 +76,15 @@ public:
|
||||||
display.setFont(&Ubuntu_Bold32pt7b);
|
display.setFont(&Ubuntu_Bold32pt7b);
|
||||||
display.setCursor(20, 100);
|
display.setCursor(20, 100);
|
||||||
display.print(name1); // Page name
|
display.print(name1); // Page name
|
||||||
|
|
||||||
|
// Show unit
|
||||||
display.setFont(&Ubuntu_Bold20pt7b);
|
display.setFont(&Ubuntu_Bold20pt7b);
|
||||||
display.setCursor(270, 100);
|
display.setCursor(270, 100);
|
||||||
// Show unit
|
|
||||||
display.print("V");
|
display.print("V");
|
||||||
display.setFont(&DSEG7Classic_BoldItalic60pt7b);
|
|
||||||
display.setCursor(20, 240);
|
|
||||||
|
|
||||||
// Reading bus data or using simulation data
|
// Reading bus data or using simulation data
|
||||||
|
display.setFont(&DSEG7Classic_BoldItalic60pt7b);
|
||||||
|
display.setCursor(20, 240);
|
||||||
if(simulation == true){
|
if(simulation == true){
|
||||||
value1 = batVoltage;
|
value1 = batVoltage;
|
||||||
value1 += float(random(0, 5)) / 10; // Simulation data
|
value1 += float(random(0, 5)) / 10; // Simulation data
|
||||||
|
|
|
@ -100,9 +100,6 @@ void OBP60Init(GwApi *api){
|
||||||
if(String(ledMode) == "Off"){
|
if(String(ledMode) == "Off"){
|
||||||
setBlinkingLED(false);
|
setBlinkingLED(false);
|
||||||
}
|
}
|
||||||
if(String(ledMode) == "Limits Overrun"){
|
|
||||||
setBlinkingLED(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start serial stream and take over GPS data stream form internal GPS
|
// Start serial stream and take over GPS data stream form internal GPS
|
||||||
bool gpsOn=api->getConfig()->getConfigItem(api->getConfig()->useGPS,true)->asBoolean();
|
bool gpsOn=api->getConfig()->getConfigItem(api->getConfig()->useGPS,true)->asBoolean();
|
||||||
|
@ -373,31 +370,35 @@ void OBP60Task(GwApi *api){
|
||||||
int lastPage=pageNumber;
|
int lastPage=pageNumber;
|
||||||
long starttime0 = millis(); // Mainloop
|
long starttime0 = millis(); // Mainloop
|
||||||
long starttime1 = millis(); // Full display refresh
|
long starttime1 = millis(); // Full display refresh
|
||||||
|
long starttime3 = millis(); // GPS data
|
||||||
while (true){
|
while (true){
|
||||||
if(millis() > starttime0 + 100){
|
if(millis() > starttime0 + 100){
|
||||||
starttime0 = millis();
|
starttime0 = millis();
|
||||||
|
|
||||||
// Send NMEA0183 GPS data on several bus systems
|
// Send NMEA0183 GPS data on several bus systems all 1000ms
|
||||||
bool gps = api->getConfig()->getConfigItem(api->getConfig()->useGPS,true)->asBoolean();
|
if(millis() > starttime3 + 1000){
|
||||||
if(gps == true){ // If config enabled
|
bool gps = api->getConfig()->getConfigItem(api->getConfig()->useGPS,true)->asBoolean();
|
||||||
|
if(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)){
|
||||||
api->sendNMEA0183Message(NMEA0183Msg);
|
api->sendNMEA0183Message(NMEA0183Msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
// LED on by GPS fix
|
// If GPS fix then LED on (HDOP)
|
||||||
String gpsFix = api->getConfig()->getConfigItem(api->getConfig()->flashLED,true)->asString();
|
String gpsFix = api->getConfig()->getConfigItem(api->getConfig()->flashLED,true)->asString();
|
||||||
GwApi::BoatValue *pdop=new GwApi::BoatValue(F("PDOP"));
|
GwApi::BoatValue *hdop;
|
||||||
if(String(gpsFix) == "GPS Fix" && pdop->valid == true && int(pdop->value) <= 50){
|
hdop = boatValues.findValueOrCreate("HDOP");
|
||||||
|
if(String(gpsFix) == "GPS Fix" && hdop->valid == true && int(hdop->value) <= 50){
|
||||||
setPortPin(OBP_FLASH_LED, true);
|
setPortPin(OBP_FLASH_LED, true);
|
||||||
}
|
}
|
||||||
if(String(gpsFix) == "GPS Fix" && pdop->valid == true && int(pdop->value) > 50){
|
if(String(gpsFix) == "GPS Fix" && ((hdop->valid == true && int(hdop->value) > 50) || hdop->valid == false)){
|
||||||
setPortPin(OBP_FLASH_LED, false);
|
setPortPin(OBP_FLASH_LED, false);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
// Check the keyboard message
|
// Check the keyboard message
|
||||||
int keyboardMessage=0;
|
int keyboardMessage=0;
|
||||||
while (xQueueReceive(allParameters.queue,&keyboardMessage,0)){
|
while (xQueueReceive(allParameters.queue,&keyboardMessage,0)){
|
||||||
|
|
Loading…
Reference in New Issue