Controllers.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #ifndef CONTROLLERS_H
  2. #define CONTROLLERS_H
  3. #include <EncoderButton.h>
  4. #include "Arduino.h"
  5. #include "MIDIUSB.h"
  6. // Uncomment this line if you want pin and values printed on the serial, remember to open a console because it waits until a connection is established.
  7. #define DEBUG
  8. // Analog controls (sliders and potentiometers), the deadzone is the smallest increment that the control must have to trigger the effect.
  9. #define DEAD_ZONE 15
  10. // Stickyness is a deazone that lies around extreme positions (0-1023) and the middle (511, but trimmable) of readings.
  11. #define STICKYNESS 30
  12. // Time, in ms, needed for a long press
  13. #define LONG_INTERVAL 1000
  14. void noteOn(byte channel, byte pitch, byte velocity);
  15. void noteOff(byte channel, byte pitch, byte velocity);
  16. void controlChange(byte channel, byte control, byte value);
  17. class AnalogControl {
  18. private:
  19. int pin;
  20. byte effect;
  21. int middle;
  22. int value;
  23. int prev_value;
  24. public:
  25. AnalogControl(int pin, byte effect, int middle);
  26. void checkStatus();
  27. };
  28. class DigitalButton {
  29. private:
  30. int pin;
  31. bool pressed;
  32. long debounce;
  33. long countdown;
  34. byte effect;
  35. byte effect_toggle;
  36. bool toggled;
  37. byte effect_long;
  38. byte effect_long_toggle;
  39. bool long_toggled;
  40. bool long_pressed;
  41. public:
  42. DigitalButton(int pin, byte effect, byte effect_toggle, byte effect_long, byte effect_long_toggle);
  43. void checkStatus();
  44. };
  45. #endif