diff --git a/src/main.c b/src/main.c --- a/src/main.c +++ b/src/main.c @@ -85,6 +85,8 @@ void encode_wspr(void) } + + TIM_HandleTypeDef htim1; int main(void) @@ -101,8 +103,7 @@ int main(void) HAL_Delay(300); - // Turn GPS on - HAL_GPIO_WritePin(GPS_NOTEN, 0); + //gps_poweroff(); // Disable ICs HAL_GPIO_WritePin(OSC_NOTEN, 1); @@ -140,26 +141,39 @@ int main(void) uint8_t lastMinute = 0; uint16_t blink_rate = 250; + while (1) { + // TODO: Trigger this when RTC thinks its time to go if(HAL_GetTick() - last_wspr > 500) { - if(get_hdop()[0] == '9' && get_hdop()[1] == '9') - blink_rate = 250; - else - blink_rate = 100; - - volatile uint8_t minute = get_timestamp()[3] - 0x30; - - // If last minute was odd and this minute is even (transition) - if(lastMinute%2 == 1 && minute%2 == 0) + switch(gps_getstate()) { - // Wait until the first second of the minute - HAL_Delay(1000); - encode_wspr(); + case GPS_STATE_ACQUIRING: + blink_rate = 250; + break; + case GPS_STATE_FRESHFIX: + blink_rate = 50; + break; + case GPS_STATE_STALEFIX: + case GPS_STATE_NOFIX: + gps_acquirefix(); + blink_rate = 500; + break; } - lastMinute = minute; + // EMZ TODO: this needs to trigger off of RTC minute, not GPS minute +// volatile uint8_t minute = get_timestamp()[3] - 0x30; +// +// // If last minute was odd and this minute is even (transition) +// if(lastMinute%2 == 1 && minute%2 == 0) +// { +// // Wait until the first second of the minute +// HAL_Delay(1000); +// encode_wspr(); +// } + +// lastMinute = minute; last_wspr = HAL_GetTick(); } @@ -170,7 +184,7 @@ int main(void) } if(HAL_GetTick() - last_gps > 10) { - parse_gps_transmission(); + gps_process(); last_gps = HAL_GetTick(); }