main.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*********************************************************************
  2. * dimmer example for Versa1.0
  3. * Connect dimmer board to Versa1's VNH2 port.
  4. *********************************************************************/
  5. #define BOARD Versa1
  6. #include <fruit.h>
  7. #include <dimmer.h>
  8. t_delay mainDelay;
  9. //----------- Setup ----------------
  10. void setup(void) {
  11. fruitInit();
  12. dimmerInit(); // init dimmer module
  13. delayStart(mainDelay, 20000); // init the mainDelay to 20 ms
  14. }
  15. // ---------- Main loop ------------
  16. void loop() {
  17. fraiseService();// listen to Fraise events
  18. dimmerService(); // dimmer management routine
  19. if(delayFinished(mainDelay)) // when mainDelay triggers :
  20. {
  21. delayStart(mainDelay, 20000); // re-init mainDelay
  22. //dimmerPrintDebug(); //
  23. }
  24. }
  25. // ---------- Interrupts ------------
  26. void highInterrupts()
  27. {
  28. dimmerHighInterrupt();
  29. }
  30. void lowInterrupts()
  31. {
  32. dimmerLowInterrupt();
  33. }
  34. // ---------- Receiving ------------
  35. void fraiseReceive() // receive raw bytes
  36. {
  37. unsigned char c=fraiseGetChar();
  38. if(c==40) dimmerReceive(); // if first byte is 40, then call dimmer receive function.
  39. }