Changeset - e1db5d4a8be4
[Not reviewed]
default
0 1 0
Ethan Zonca - 10 years ago 2016-04-02 22:05:28
ez@ethanzonca.com
Change LED blink rate based on GPS fix status
1 file changed with 11 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/main.c
Show inline comments
 
@@ -135,28 +135,38 @@ int main(void)
 
    HAL_GPIO_TogglePin(LED_BLUE);
 
    HAL_Delay(100);
 
    HAL_GPIO_TogglePin(LED_BLUE);
 
    HAL_Delay(100);
 
 
    uint8_t lastMinute = 0;
 
    uint16_t blink_rate = 250;
 
 
    while (1)
 
    {
 
        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)
 
            {
 
                // Wait until the first second of the minute
 
                HAL_Delay(1000);
 
                encode_wspr();
 
            }
 
 
            lastMinute = minute;
 
            last_wspr = HAL_GetTick();
 
        }
 
 
        if(HAL_GetTick() - led_timer > 100)
 
        if(HAL_GetTick() - led_timer > blink_rate)
 
        {
 
            HAL_GPIO_TogglePin(LED_BLUE);
 
            led_timer = HAL_GetTick();
 
        }
 
        if(HAL_GetTick() - last_gps > 10)
 
        {
0 comments (0 inline, 0 general)