harinin

Untitled

Aug 2nd, 2016
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * File:   events.h
  3.  * Author: maxL
  4.  *
  5.  * Created on July 28, 2016, 12:36 PM
  6.  */
  7.  
  8. #include <stdio.h>
  9. #include <timers.h>
  10. #include <AD.h>
  11. #include "events.h"
  12. #include "roach.h"
  13. #include "CalibConstants.h"
  14.  
  15. // Check for all events:
  16.  
  17. event_t CheckForEvents(void) {
  18.     event_t thisEvent = NO_EVENT;
  19.  
  20.     thisEvent = CheckForEnteredLight();
  21.     if (thisEvent != NO_EVENT) {
  22.         return thisEvent;
  23.     }
  24.  
  25.     thisEvent = CheckForEnteredDark();
  26.     if (thisEvent != NO_EVENT) {
  27.         return thisEvent;
  28.     }
  29.    
  30.     thisEvent = CheckForFrontBumpDown();
  31.     if (thisEvent != NO_EVENT) {
  32.         return thisEvent;
  33.     }
  34.    
  35.     thisEvent = CheckForFLBumpDown();
  36.     if (thisEvent != NO_EVENT) {
  37.         return thisEvent;
  38.     }
  39.    
  40.     thisEvent = CheckForFRBumpDown();
  41.     if (thisEvent != NO_EVENT) {
  42.         return thisEvent;
  43.     }
  44.    
  45.     thisEvent = CheckForBackBumpDown();
  46.     if (thisEvent != NO_EVENT) {
  47.         return thisEvent;
  48.     }
  49.  
  50.     thisEvent = CheckForTimer0Expired();
  51.     if (thisEvent != NO_EVENT) {
  52.         return thisEvent;
  53.     }
  54.     return NO_EVENT;
  55. }
  56.  
  57. // define each event checker
  58.  
  59. event_t CheckForEnteredLight(void) {
  60.     // all event checkers remember their previous Event:
  61.     static int previousEvent;
  62.  
  63.     // all event checkers update their event:
  64.     int currentEvent = (Roac
Add Comment
Please, Sign In to add comment