Subversion Repositories HomeAutomation

Rev

Rev 363 | Blame | Compare with Previous | Last modification | View Log | SVN | RSS feed

  1. #define THIS_IS_SCHEDULER
  2.  
  3. #include "..\Include\Helpers.h"
  4. #include "..\Include\UART.h"
  5. #include "..\Include\StackTsk.h"
  6. #include "..\Include\TimeSync.h"
  7. #include "..\Include\Scheduler.h"
  8.  
  9. #if defined(STACK_USE_SCHEDULER)
  10.  
  11.  
  12.  
  13.  
  14. #define MAX_EVENTS 2
  15.  
  16. EVENT events[MAX_EVENTS];
  17.  
  18.  
  19. void scheduler(void)
  20. {
  21.     DWORD ct;
  22.     BYTE i;
  23.  
  24.     if (ct=getTime(CURRENT))
  25.     {
  26.         for(i=0;i<MAX_EVENTS;i++)
  27.         {
  28.             if (events[i].active==TRUE && ct>events[i].time)
  29.             {
  30.                 setVariable(events[i].what,events[i].value);
  31.                 events[i].active=FALSE;
  32.             }
  33.         }
  34.     }
  35.  
  36. }
  37.  
  38. void loadEvents(void)
  39. {
  40.     events[0].active=TRUE;
  41.     events[0].repeat=0;
  42.     events[0].time=1159170615;
  43.     events[0].what=VAR_LED1;
  44.     events[0].value=1;
  45.  
  46.     events[1].active=TRUE;
  47.     events[1].repeat=0;
  48.     events[1].time=events[0].time+20;
  49.     events[1].what=VAR_LED1;
  50.     events[1].value=0;
  51.  
  52. }
  53.  
  54. EVENT getEvent(BYTE id)
  55. {
  56.     EVENT event;
  57.  
  58.     if (id<0 || id>(MAX_EVENTS-1)) return event;
  59.  
  60.     return events[id];
  61. }
  62.  
  63.  
  64. BYTE numEvents(void)
  65. {
  66.     return MAX_EVENTS;
  67. }
  68.  
  69. #endif
  70.