setup-loop.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include "all-headers.h"
  2. // Bit operation references
  3. const uint32_t bufferEmpty(0);
  4. const uint32_t bufferFull(~ bufferEmpty);
  5. // Button variables
  6. uint32_t antiBlinkBuffer[5];
  7. bool buttonReleased[5];
  8. bool actionDone[5];
  9. DigitalPort LED[5];
  10. DigitalPort BUTTON[5];
  11. // Counter
  12. uint32_t counter(0);
  13. void setup (USER_MODE) {
  14. // Start
  15. digitalWrite(L0_LED, true);
  16. // Init buttons and LEDs
  17. BUTTON[0] = P0_PUSH_BUTTON;
  18. BUTTON[1] = P1_PUSH_BUTTON;
  19. BUTTON[2] = P2_PUSH_BUTTON;
  20. BUTTON[3] = P3_PUSH_BUTTON;
  21. BUTTON[4] = P4_PUSH_BUTTON;
  22. LED[0] = L0_LED;
  23. LED[1] = L1_LED;
  24. LED[2] = L2_LED;
  25. LED[3] = L3_LED;
  26. LED[4] = L4_LED;
  27. for (unsigned int i(0); i < 5; i++) {
  28. antiBlinkBuffer[i] = 0;
  29. buttonReleased[i] = digitalRead(BUTTON[i]);
  30. actionDone[i] = false;
  31. }
  32. // Init LCD
  33. printString(MODE_ "Wake up in ");
  34. printUnsigned(MODE_ millis(MODE));
  35. printString(MODE_ "ms");
  36. gotoLineColumn(MODE_ 1, 0);
  37. }
  38. void loop (USER_MODE) {
  39. busyWaitDuring(MODE_ 1000);
  40. gotoLineColumn(MODE_ 1, 0);
  41. printString(MODE_ "Date:");
  42. printUnsigned(MODE_ millis(MODE));
  43. }