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.

112 lines
2.6 KiB

12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
  1. #include <Wire.h>
  2. #include <bombatuino_INPUT_MCP23017.h>
  3. #include <bombatuino_INPUT_74HC4051.h>
  4. #include <bombatuino_ROTARY_ENCODER.h>
  5. INPUT_MCP23017 input_MCP23017_0;
  6. INPUT_MCP23017 input_MCP23017_1;
  7. INPUT_MCP23017 input_MCP23017_3;
  8. INPUT_MCP23017 input_MCP23017_4;
  9. INPUT_74HC4051 input_4051_A0;
  10. INPUT_74HC4051 input_4051_A1;
  11. INPUT_74HC4051 input_4051_A2;
  12. ROTARY_ENCODER re_jogwheel(jogwheel);
  13. //ROTARY_ENCODER re_JogWheel1(rotaryLeftJogWheel1,rotaryRightJogWheel1);
  14. //ROTARY_ENCODER re_JogWheel2(rotaryLeftJogWheel2,rotaryRightJogWheel2);
  15. //ROTARY_ENCODER re_Browse(rotaryLeftBrowse,rotaryRightBrowse);
  16. void setup() {
  17. Serial.begin(9600);
  18. input_MCP23017_0.begin(0,digitalCallback);
  19. input_MCP23017_1.begin(1,digitalCallback);
  20. input_MCP23017_3.begin(3,digitalCallback);
  21. input_MCP23017_4.begin(4,digitalCallback);
  22. input_4051_A0.begin(A0,8,9,10,analogCallback);
  23. input_4051_A1.begin(A1,8,9,10,analogCallback);
  24. input_4051_A2.begin(A2,8,9,10,analogCallback);
  25. }
  26. void loop() {
  27. input_MCP23017_0.loop();
  28. input_MCP23017_1.loop();
  29. input_MCP23017_3.loop();
  30. input_MCP23017_4.loop();
  31. input_4051_A0.loop();
  32. input_4051_A1.loop();
  33. input_4051_A2.loop();
  34. }
  35. void analogCallback(int id, int pin, int value) {
  36. Serial.print("id ");
  37. Serial.print(pin);
  38. Serial.print(" pin ");
  39. Serial.print(pin);
  40. Serial.print(" : ");
  41. Serial.print(value);
  42. Serial.println();
  43. }
  44. void digitalCallback(int id, int pin, int value) {
  45. if (id == 1 && pin == 6)
  46. re_jogwheel.setPinA(value);
  47. if (id == 1 && pin == 7)
  48. re_jogwheel.setPinB(value);
  49. /*
  50. if (id == 3 && pin == 9)
  51. re_JogWheel2.setPinA(value);
  52. if (id == 3 && pin == 10)
  53. re_JogWheel2.setPinB(value);
  54. if (id == 3 && pin == 6)
  55. re_Browse.setPinA(value);
  56. if (id == 3 && pin == 5)
  57. re_Browse.setPinB(value);
  58. */
  59. if ((id == 3 && pin != 5 && pin != 6 && pin!= 9 && pin != 10) || (id == 1 && pin != 6 && pin !=7) || (id == 0) || (id == 4)) {
  60. Serial.print("id ");
  61. Serial.print(pin);
  62. Serial.print(" pin ");
  63. Serial.print(pin);
  64. Serial.print(" : ");
  65. Serial.print(value);
  66. Serial.println();
  67. }
  68. }
  69. void jogwheel(int c) {
  70. Serial.println(c);
  71. }
  72. //JogWheel1
  73. void rotaryLeftJogWheel1() {
  74. Serial.println("wheel1 left");
  75. }
  76. void rotaryRightJogWheel1() {
  77. Serial.println("wheel1 right");
  78. }
  79. //JogWheel2
  80. void rotaryLeftJogWheel2() {
  81. Serial.println("wheel2 left");
  82. }
  83. void rotaryRightJogWheel2() {
  84. Serial.println("wheel2 right");
  85. }
  86. //Browse
  87. void rotaryLeftBrowse() {
  88. Serial.println("wheel3 left");
  89. }
  90. void rotaryRightBrowse() {
  91. Serial.println("wheel3 right");
  92. }