Bmag incl gps rettelse
Dependencies: mbed WDT MODSERIAL BME280
Diff: main.cpp
- Branch:
- MbedBMAGThrRev
- Revision:
- 44:14ec59d2170c
- Parent:
- 43:358e853ba2c9
- Child:
- 45:27a34d0936de
diff -r 358e853ba2c9 -r 14ec59d2170c main.cpp --- a/main.cpp Fri Oct 06 13:05:07 2017 +0000 +++ b/main.cpp Tue Oct 10 10:39:59 2017 +0000 @@ -10,7 +10,7 @@ #define BATTERYLOWLIMIT 10.5 //change BARCODE string inside double quotes to barcode of BMAG equipment -char BARCODE[6] = "00000"; +char BARCODE[6] = "11111"; //Global GPS variables Timer t; @@ -200,7 +200,9 @@ } if(hours == 24){ hours = 0; - //prompt for date change when this happens. + //prompt for date change when this happens. + + fileNameUpdated = false; } } @@ -210,6 +212,13 @@ pps_Tick(); } +//test without mag data +void testMagWithoutMag(void){ + ///used for test of date change + BMAG_Data_Rdy = true; + /// +} + //bmag interrupt enable void bmagSerialInterruptEnable(void){ //BMAG communication init @@ -371,6 +380,10 @@ Ticker gpsAvailableTicker; gpsAvailableTicker.attach(gpsAvailCheck, 10.0); + //test ticker emulating mag data 1Hz + Ticker TestMagTicker; + + //clock freqency info dbg.printf("SystemCoreClock = %d Hz\r\n", SystemCoreClock); @@ -384,7 +397,11 @@ //disable continuous magtick detach if(detachMag){ magTicker.detach(); - detachMag = false; + detachMag = false; + + //for test without mag data + TestMagTicker.attach(testMagWithoutMag, 1.0); + } //display txt on disp @@ -422,21 +439,27 @@ dispTxtHandler.setErrorState(NO_GPS); } - if(gpsCheckedAfter10Sec && gpsRunning){ - gpsAvailableTicker.attach(NULL, 10.0); + if(gpsCheckedAfter10Sec){ - //bme pth sensor init - if(!BME.init(BME280_i2c, 0x77)){ - dbg.printf("BME280 init failed!\r\n"); - - } - if(!BME.start()){ - dbg.printf("BME280 start failed!\r\n"); + if(gpsRunning){ + gpsAvailableTicker.detach(); } - if(BME.is_ok()){ - PTHSensorActive = true; - } + if(!PTHSensorActive){ + //bme pth sensor init + if(!BME.init(BME280_i2c, 0x77)){ + dbg.printf("BME280 init failed!\r\n"); + } + if(!BME.start()){ + dbg.printf("BME280 start failed!\r\n"); + } + + if(BME.is_ok()){ + PTHSensorActive = true; + } + } + + gpsCheckedAfter10Sec = false; } //missingGpsConnectionCounter gets cleared at every received gps string @@ -569,7 +592,6 @@ //remkark hvis dette sker i error fil } - //if bmag data string is available if(BMAG_Data_Rdy) { @@ -756,7 +778,7 @@ if(GPS_Data_Rdy){ - + gpsRunning = true; missingGpsConnectionCounter = 0;