A porting of a GPS decoding and presenting program within the mbos RTOS. It is not a definitive application but a study program to test NMEA full decoding library and a first approach to an RTOS. Many thanks to Andrew Levido for his support and his patience on teaching me the RTOS principles from the other side of the Earth. It uses NMEA library by Tim (xtimor@gmail.com) ported by Ken Todotani (http://mbed.org/users/todotani/) on public mbed library (http://mbed.org/users/todotani/programs/GPS_nmeaLib/5yo4h) also available, as original universal C library, on http://nmea.sourceforge.net

Dependencies:   mbos Watchdog TextLCD mbed ConfigFile

Task4LedBlink.cpp

Committer:
guiott
Date:
2012-01-31
Revision:
2:8917036cbf69

File content as of revision 2:8917036cbf69:

#include "Task4LedBlink.h"

void LedBlinkTask(void)
{/**
 *\brief TASK 4
         LED 1: Quick blink=NOT fix, Slow blink=fix OK  
         LED 2: blinks proportionally to HDOP
         LED 3: blinks proportionally to VDOP
 */

 static int LedCnt1=0;
 //    static int LedCnt2=0;
 int OnH=0;
 int OnV=0;

 #define MAX 20
  
 os.SetTimer(LED_BLINK_TMR, 100, 100);

 while(1)
 {
    os.WaitEvent(LED_BLINK_EVT);
            
    if((info.HDOP>0)&&(info.HDOP<=2))
    {
        OnH=2;
    }
    else if((info.HDOP>2)&&(info.HDOP<=4))
    {
        OnH=4;    
    }
    else if((info.HDOP>4)&&(info.HDOP<=6))
    {
        OnH=6;    
    }
    else if((info.HDOP>6))
    {
        OnH=MAX/2;    
    }        

    if((info.VDOP>0)&&(info.VDOP<=2))
    {
        OnV=2;
    }
    else if((info.VDOP>2)&&(info.VDOP<=4))
    {
        OnV=4;    
    }
    else if((info.VDOP>4)&&(info.VDOP<=6))
    {
        OnV=6;    
    }
    else if((info.VDOP>6))
    {
        OnV=MAX/2;    
    } 
           
    if(info.sig == 0)
    {
        led1=!led1;
        led2=0;
        led3=0;
    }
    else
    {
       if(LedCnt1<=MAX/2)
       {
            LedCnt1++;
            led1=0;
            if(LedCnt1<OnH)
            {
               led2=!led2; 
            }
            else 
            {
                led2=0;
            }    
            
            if(LedCnt1<OnV)
            {
               led3=!led3; 
            }
            else 
            {
                led3=0;
            }          
       } 
       else if((LedCnt1>MAX/2)&&(LedCnt1<=MAX))
       {
            LedCnt1++;
            led1=1;
            led2=0;
            led3=0;
       }
       else if(LedCnt1>MAX)
       {
            LedCnt1=0;       
       }
    }
 }
}