sources and files for the bombatuino project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 lines
3.2 KiB

12 years ago
  1. #include <Wire.h>
  2. #include <bombatuino_INPUT_MCP23017.h>
  3. #include <bombatuino_INPUT_74HC4051.h>
  4. #include <bombatuino_MIDI.h>
  5. #include <bombatuino_ROTARY_ENCODER.h>
  6. MIDI Midi;
  7. INPUT_MCP23017 input_MCP23017_0;
  8. INPUT_MCP23017 input_MCP23017_1;
  9. INPUT_MCP23017 input_MCP23017_3;
  10. INPUT_MCP23017 input_MCP23017_4;
  11. INPUT_74HC4051 input_4051_A0;
  12. INPUT_74HC4051 input_4051_A1;
  13. INPUT_74HC4051 input_4051_A2;
  14. ROTARY_ENCODER rotary_encoder_jogwheel_left(rotary_encoder_jogwheel_left_inc, rotary_encoder_jogwheel_left_dec);
  15. ROTARY_ENCODER rotary_encoder_jogwheel_right(rotary_encoder_jogwheel_right_inc, rotary_encoder_jogwheel_right_dec);
  16. ROTARY_ENCODER rotary_encoder_browse(rotary_encoder_browse_inc,rotary_encoder_browse_dec);
  17. void setup() {
  18. Serial.begin(9600);
  19. input_MCP23017_0.begin(0,digitalCallback);
  20. input_MCP23017_1.begin(1,digitalCallback1);
  21. input_MCP23017_3.begin(3,digitalCallback3);
  22. input_MCP23017_4.begin(4,digitalCallback);
  23. input_4051_A0.begin(A0,8,9,10,analogCallback);
  24. input_4051_A1.begin(A1,8,9,10,analogCallback);
  25. input_4051_A2.begin(A2,8,9,10,analogCallback);
  26. }
  27. void loop() {
  28. input_MCP23017_0.loop();
  29. input_MCP23017_1.loop();
  30. input_MCP23017_3.loop();
  31. input_MCP23017_4.loop();
  32. input_4051_A0.loop();
  33. input_4051_A1.loop();
  34. input_4051_A2.loop();
  35. }
  36. void analogCallback(int id, int pin, int value) {
  37. Serial.print("id ");
  38. Serial.print(id);
  39. Serial.print(" pin ");
  40. Serial.print(pin);
  41. Serial.print(" : ");
  42. Serial.print(value);
  43. Serial.println();
  44. }
  45. void digitalCallback(int id, int pin, int value) {
  46. Serial.print("id ");
  47. Serial.print(id);
  48. Serial.print(" pin ");
  49. Serial.print(pin);
  50. Serial.print(" : ");
  51. Serial.print(value);
  52. Serial.println();
  53. }
  54. void digitalCallback1(int id, int pin, int value) {
  55. if (pin == 6)
  56. rotary_encoder_jogwheel_left.setPinA(value);
  57. if (pin == 7)
  58. rotary_encoder_jogwheel_left.setPinB(value);
  59. if (pin != 6 && pin !=7) {
  60. Serial.print("id ");
  61. Serial.print(id);
  62. Serial.print(" pin ");
  63. Serial.print(pin);
  64. Serial.print(" : ");
  65. Serial.print(value);
  66. Serial.println();
  67. }
  68. }
  69. void digitalCallback3(int id, int pin, int value) {
  70. if (pin == 9)
  71. rotary_encoder_jogwheel_right.setPinA(value);
  72. if (pin == 10)
  73. rotary_encoder_jogwheel_right.setPinB(value);
  74. if (pin == 6)
  75. rotary_encoder_browse.setPinA(value);
  76. if (pin == 5)
  77. rotary_encoder_browse.setPinB(value);
  78. if (pin!= 9 && pin != 10 && pin != 6 && pin != 5){
  79. Serial.print("id ");
  80. Serial.print(id);
  81. Serial.print(" pin ");
  82. Serial.print(pin);
  83. Serial.print(" : ");
  84. Serial.print(value);
  85. Serial.println();
  86. }
  87. }
  88. //left jogwheel
  89. void rotary_encoder_jogwheel_left_inc() {
  90. Serial.println("jogwheel_left_inc");
  91. }
  92. void rotary_encoder_jogwheel_left_dec() {
  93. Serial.println("jogwheel_left_dec");
  94. }
  95. //right jogwheel
  96. void rotary_encoder_jogwheel_right_inc() {
  97. Serial.println("jogwheel_right_inc");
  98. }
  99. void rotary_encoder_jogwheel_right_dec() {
  100. Serial.println("jogwheel_right_dec");
  101. }
  102. //Browse
  103. void rotary_encoder_browse_inc() {
  104. Serial.println("browse inc");
  105. }
  106. void rotary_encoder_browse_dec() {
  107. Serial.println("browse dec");
  108. }