Fix for missing data on I2C bus for BME280, BMP280 and SHT21

This commit is contained in:
norbert-walter 2022-03-12 17:47:16 +01:00
parent 509166216d
commit 918e286f34
2 changed files with 10 additions and 6 deletions

View File

@ -40,6 +40,8 @@ typedef struct{
GwLog *logger=NULL; GwLog *logger=NULL;
GwConfigHandler *config=NULL; GwConfigHandler *config=NULL;
SensorData data; SensorData data;
GwApi::BoatValue *time=NULL;
GwApi::BoatValue *date=NULL;
} CommonData; } CommonData;
//a base class that all pages must inherit from //a base class that all pages must inherit from

View File

@ -54,7 +54,7 @@ Ticker Timer2(blinkingFlashLED, 500);
// Undervoltage function for shutdown display // Undervoltage function for shutdown display
void underVoltageDetection(){ void underVoltageDetection(){
float actVoltage = (float(analogRead(OBP_ANALOG0)) * 3.3 / 4096 + 0.17) * 20; // V = 1/20 * Vin float actVoltage = (float(analogRead(OBP_ANALOG0)) * 3.3 / 4096 + 0.17) * 20; // V = 1/20 * Vin
long starttime; long starttime = 0;
static bool undervoltage = false; static bool undervoltage = false;
if(actVoltage < MIN_VOLTAGE){ if(actVoltage < MIN_VOLTAGE){
@ -504,13 +504,15 @@ void OBP60Task(GwApi *api){
int lastPage=pageNumber; int lastPage=pageNumber;
commonData.data.actpage = pageNumber + 1; commonData.data.actpage = pageNumber + 1;
commonData.data.maxpage = numPages; commonData.data.maxpage = numPages;
commonData.time = boatValues.findValueOrCreate("GPST"); // Load GpsTime
commonData.date = boatValues.findValueOrCreate("GPSD"); // Load GpsTime
bool delayedDisplayUpdate = false; // If select a new pages then make a delayed full display update bool delayedDisplayUpdate = false; // If select a new pages then make a delayed full display update
long firststart = millis(); // First start long firststart = millis(); // First start
long starttime0 = millis(); // Mainloop long starttime0 = millis(); // Mainloop
long starttime1 = millis(); // Full display refresh for the first 5 min (more often as normal) long starttime1 = millis(); // Full display refresh for the first 5 min (more often as normal)
long starttime2 = millis(); // Full display refresh after 5 min long starttime2 = millis(); // Full display refresh after 5 min
long starttime3 = millis(); // Display update all 1s long starttime3 = millis(); // Display update all 1s
long starttime4 = millis(); // Delayed display update after 2s when select a new page long starttime4 = millis(); // Delayed display update after 4s when select a new page
long starttime5 = millis(); // Voltage update all 1s long starttime5 = millis(); // Voltage update all 1s
long starttime6 = millis(); // Environment sensor update all 1s long starttime6 = millis(); // Environment sensor update all 1s
@ -522,7 +524,7 @@ void OBP60Task(GwApi *api){
// Send NMEA0183 GPS data on several bus systems all 1000ms // Send NMEA0183 GPS data on several bus systems all 1000ms
if(String(gps) == "NEO-6M" || String(gps) == "NEO-M8N"){ // If config enabled if(String(gps) == "NEO-6M" || String(gps) == "NEO-M8N"){ // 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);
@ -585,7 +587,7 @@ void OBP60Task(GwApi *api){
display.update(); // Full update display.update(); // Full update
} }
*/ */
// #9 or #10 Refresh display after a new page after 2s waiting time and if refresh is disabled // #9 or #10 Refresh display after a new page after 4s waiting time and if refresh is disabled
if(refreshmode == true && (keyboardMessage == 9 || keyboardMessage == 10)){ if(refreshmode == true && (keyboardMessage == 9 || keyboardMessage == 10)){
starttime4 = millis(); starttime4 = millis();
delayedDisplayUpdate = true; delayedDisplayUpdate = true;
@ -594,8 +596,8 @@ void OBP60Task(GwApi *api){
LOG_DEBUG(GwLog::LOG,"set pagenumber to %d",pageNumber); LOG_DEBUG(GwLog::LOG,"set pagenumber to %d",pageNumber);
} }
// Full display update afer a new selected page and 2s wait time // Full display update afer a new selected page and 4s wait time
if(millis() > starttime4 + 2000 && delayedDisplayUpdate == true){ if(millis() > starttime4 + 4000 && delayedDisplayUpdate == true){
display.update(); // Full update display.update(); // Full update
delayedDisplayUpdate = false; delayedDisplayUpdate = false;
} }