evtActions.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #include <Eventually.h>
  2. EvtManager mgr;
  3. bool play0() {
  4. trigSound("0.wav");
  5. return true;
  6. }
  7. bool play1() {
  8. trigSound("1.wav");
  9. return true;
  10. }
  11. bool play2() {
  12. trigSound("2.wav");
  13. return true;
  14. }
  15. bool play3() {
  16. trigSound("3.wav");
  17. return true;
  18. }
  19. bool play4() {
  20. trigSound("4.wav");
  21. return true;
  22. }
  23. bool play5() {
  24. trigSound("5.wav");
  25. return true;
  26. }
  27. bool play6() {
  28. trigSound("6.wav");
  29. return true;
  30. }
  31. bool play7() {
  32. trigSound("7.wav");
  33. return true;
  34. }
  35. bool play8() {
  36. trigSound("8.wav");
  37. return true;
  38. }
  39. bool play9() {
  40. trigSound("9.wav");
  41. return true;
  42. }
  43. bool play10() {
  44. trigSound("10.wav");
  45. return true;
  46. }
  47. void trigSound(String filename ) {
  48. eventuallyContext();
  49. playWav1.play(filename.c_str());
  50. delay(5);
  51. }
  52. bool checkVolume() {
  53. float vol = analogRead(15);
  54. vol = vol / 1024;
  55. sgtl5000_1.volume(vol);
  56. }
  57. void eventuallyContext () {
  58. mgr.resetContext();
  59. mgr.addListener(new EvtTimeListener(10, true, (EvtAction)checkVolume));
  60. mgr.addListener(new EvtPinListener(buttonPins[0], (EvtAction)play0));
  61. mgr.addListener(new EvtPinListener(buttonPins[1], (EvtAction)play1));
  62. mgr.addListener(new EvtPinListener(buttonPins[2], (EvtAction)play2));
  63. mgr.addListener(new EvtPinListener(buttonPins[3], (EvtAction)play3));
  64. mgr.addListener(new EvtPinListener(buttonPins[4], (EvtAction)play4));
  65. mgr.addListener(new EvtPinListener(buttonPins[5], (EvtAction)play5));
  66. mgr.addListener(new EvtPinListener(buttonPins[6], (EvtAction)play6));
  67. mgr.addListener(new EvtPinListener(buttonPins[7], (EvtAction)play7));
  68. mgr.addListener(new EvtPinListener(buttonPins[8], (EvtAction)play8));
  69. mgr.addListener(new EvtPinListener(buttonPins[9], (EvtAction)play9));
  70. mgr.addListener(new EvtPinListener(buttonPins[10], (EvtAction)play10));
  71. }