diff --git a/src/main.c b/src/main.c --- a/src/main.c +++ b/src/main.c @@ -43,6 +43,9 @@ int main(void) uint16_t blink_rate = BLINK_FAST; uint8_t state = SYSTEM_GPSACQ; + uint32_t fixinfo_timer = 0; + uint8_t fix_ok = 0; + uint8_t numsats = 0; while (1) { @@ -58,7 +61,7 @@ int main(void) //enter_sleep(); // Somehow go to another state when we get an interrupt - state = SYSTEM_GPSACQ; +// state = SYSTEM_GPSACQ; } break; @@ -70,17 +73,19 @@ int main(void) // TODO: probably don't power on all the time, just on state transition // gps_poweron(); // HAL_Delay(100); - HAL_Delay(1000); // gps_update_position(); - uint8_t fix_ok = 0; - uint8_t numsats = 0; - gps_check_lock(&fix_ok, &numsats); + // Update fix status every 2 seconds + if(HAL_GetTick() - fixinfo_timer > 2000) + { + gps_check_lock(&fix_ok, &numsats); + fixinfo_timer = HAL_GetTick(); + } - if(fix_ok) + if(fix_ok > 0) { // Disable GPS module - gps_poweroff(); + //gps_poweroff(); // TODO: Set RTC from GPS time @@ -100,6 +105,7 @@ int main(void) // Wait for wspr timeslot and start transmitting case SYSTEM_WSPRTX: { + blink_rate = BLINK_SLOW; // Wait for wspr countdown timer to expire and go to tx // if(timeout_expired) // { @@ -109,7 +115,7 @@ int main(void) // Schedule next wakeup (maybe 2mins prior ot timeslot if no osc trim) // Next wakeup should enter SYSTEM_GPSACQ state... - state = SYSTEM_IDLE; +// state = SYSTEM_IDLE; } break;