diff --git a/src/main.c b/src/main.c --- a/src/main.c +++ b/src/main.c @@ -33,7 +33,6 @@ int main(void) gpio_init(); adc_init(); i2c_init(); - gps_init(); wspr_init(); uint32_t led_timer = HAL_GetTick(); @@ -53,7 +52,8 @@ int main(void) // Update fix status every 2 seconds if(HAL_GetTick() - fixinfo_timer > 2000) { - gps_update_data(); + if(gps_ison()) + gps_update_data(); fixinfo_timer = HAL_GetTick(); } @@ -80,16 +80,14 @@ int main(void) { blink_rate = BLINK_FAST; - // TODO: probably don't power on all the time, just on state transition -// gps_poweron(); -// HAL_Delay(100); -// gps_update_position(); + if(!gps_ison()) + gps_poweron(); // power on and initialize GPS module - if(gps_getdata()->fixtype > 0) + if(gps_getdata()->fixtype > 0 && gps_getdata()->pdop < 5) { // Disable GPS module - //gps_poweroff(); + gps_poweroff(); // TODO: Set RTC from GPS time