Guido Ottaviani / Mbed 2 deprecated LeonardoMbos

Dependencies:   mbos Watchdog TextLCD mbed ConfigFile

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Task7Dim.cpp Source File

Task7Dim.cpp

00001 #include "Task7Dim.h"
00002 
00003 void LcdLightDimTask(void)
00004 {/** 
00005  *\brief TASK 7, control the LCD backlight intensity to smoothly
00006          switch it on or off
00007  */
00008  static float LightVal=1;
00009         
00010  while(1)
00011  {       
00012     os.WaitEvent(LCD_LIGHT_DIM_ON_EVT | LCD_LIGHT_DIM_OFF_EVT); 
00013     if(os.GetEvent()==LCD_LIGHT_DIM_ON_EVT)
00014     {
00015       if(LightVal<1)
00016       {
00017         for (LightVal=0; LightVal<=1; LightVal+=0.01f)
00018         {
00019             LcdBklight=LightVal;
00020             wait_ms(10);
00021         }
00022       }
00023     // Set the timer for the power saving backlight switch off
00024     os.ClearTimer(LCD_LIGHT_DIM_OFF_TMR);
00025     os.SetTimer(LCD_LIGHT_DIM_OFF_TMR, LCD_LIGHT_DIM_TIMER, 0);
00026     }
00027     else if(os.GetEvent()==LCD_LIGHT_DIM_OFF_EVT)
00028     {// The dimming off is slower than lighting up
00029         for (LightVal=1; LightVal>=0; LightVal-=0.01f)
00030         {
00031             LcdBklight=LightVal;           
00032             wait_ms(30);
00033         }        
00034     }
00035  }
00036 }