From 38c35e3e6af757d00b314479bf19e35a369ceb8a Mon Sep 17 00:00:00 2001 From: Lukas Date: Tue, 14 May 2013 22:03:11 +0200 Subject: [PATCH] update --- source/bombatu/bombatu.ino | 112 +++++++++++++++ source/bombatuino_debug/bombatuino_debug.ino | 129 ++++++++++++++++++ .../bombatuino_ROTARY_ENCODER.cpp | 13 +- .../ConnectionChecker/ConnectionChecker.ino | 0 .../INPUT_MCP23017_test.ino | 0 .../MIDI_library_test/MIDI_library_test.ino | 0 .../_2013_05_08/_2013_05_08.ino | 0 .../_4051_test/_4051_test.ino | 0 .../deubug/deubug.ino} | 61 +++++---- .../input_4051_library_test.ino | 0 .../midi_in_out/midi_in_out.ino | 0 .../midi_in_out_softwareserial.ino | 0 .../midi_led/midi_led.ino | 0 .../piezo_input/piezo_input.ino | 0 14 files changed, 282 insertions(+), 33 deletions(-) create mode 100644 source/bombatu/bombatu.ino create mode 100644 source/bombatuino_debug/bombatuino_debug.ino rename source/{ => old testing stuff}/ConnectionChecker/ConnectionChecker.ino (100%) rename source/{ => old testing stuff}/INPUT_MCP23017_test/INPUT_MCP23017_test.ino (100%) rename source/{ => old testing stuff}/MIDI_library_test/MIDI_library_test.ino (100%) rename source/{ => old testing stuff}/_2013_05_08/_2013_05_08.ino (100%) rename source/{ => old testing stuff}/_4051_test/_4051_test.ino (100%) rename source/{bombatuino/bombatu.ino => old testing stuff/deubug/deubug.ino} (63%) rename source/{ => old testing stuff}/input_4051_library_test/input_4051_library_test.ino (100%) rename source/{ => old testing stuff}/midi_in_out/midi_in_out.ino (100%) rename source/{ => old testing stuff}/midi_in_out_softwareserial/midi_in_out_softwareserial.ino (100%) rename source/{ => old testing stuff}/midi_led/midi_led.ino (100%) rename source/{ => old testing stuff}/piezo_input/piezo_input.ino (100%) diff --git a/source/bombatu/bombatu.ino b/source/bombatu/bombatu.ino new file mode 100644 index 0000000..5503912 --- /dev/null +++ b/source/bombatu/bombatu.ino @@ -0,0 +1,112 @@ +#include + +#include +#include +#include +#include + +MIDI Midi; + +INPUT_MCP23017 input_MCP23017_0; +INPUT_MCP23017 input_MCP23017_1; +INPUT_MCP23017 input_MCP23017_3; +INPUT_MCP23017 input_MCP23017_4; + +INPUT_74HC4051 input_4051_A0; +INPUT_74HC4051 input_4051_A1; +INPUT_74HC4051 input_4051_A2; + +ROTARY_ENCODER rotary_encoder_jogwheel_left(rotary_encoder_jogwheel_left_inc, rotary_encoder_jogwheel_left_dec); +ROTARY_ENCODER rotary_encoder_jogwheel_right(rotary_encoder_jogwheel_right_inc, rotary_encoder_jogwheel_right_dec); +ROTARY_ENCODER rotary_encoder_browse(rotary_encoder_browse_inc,rotary_encoder_browse_dec); + + +void setup() { + Midi.begin(); + input_MCP23017_0.begin(0,digitalCallback); + input_MCP23017_1.begin(1,digitalCallback1); + input_MCP23017_3.begin(3,digitalCallback3); + input_MCP23017_4.begin(4,digitalCallback); + + input_4051_A0.begin(A0,8,9,10,analogCallback); + input_4051_A1.begin(A1,8,9,10,analogCallback); + input_4051_A2.begin(A2,8,9,10,analogCallback); +} + +void loop() { + input_MCP23017_0.loop(); + input_MCP23017_1.loop(); + input_MCP23017_3.loop(); + input_MCP23017_4.loop(); + input_4051_A0.loop(); + input_4051_A1.loop(); + input_4051_A2.loop(); +} + +void analogCallback(int id, int pin, int value) { + Midi.controlChange((id-A0) * 8 + pin,value); +} + +void digitalCallback(int id, int pin, int value) { + if (value == HIGH) + Midi.noteOn(id * 16 + pin, MIDI_MAX_DATA); + else Midi.noteOff(id * 16 + pin); +} + + +void digitalCallback1(int id, int pin, int value) { + if (pin == 6) + rotary_encoder_jogwheel_left.setPinA(value); + if (pin == 7) + rotary_encoder_jogwheel_left.setPinB(value); + if (pin != 6 && pin !=7) { + if (value == HIGH) + Midi.noteOn(id * 16 + pin, MIDI_MAX_DATA); + else Midi.noteOff(id * 16 + pin); + } +} + +void digitalCallback3(int id, int pin, int value) { + if (pin == 9) + rotary_encoder_jogwheel_right.setPinA(value); + if (pin == 10) + rotary_encoder_jogwheel_right.setPinB(value); + if (pin == 6) + rotary_encoder_browse.setPinA(value); + if (pin == 5) + rotary_encoder_browse.setPinB(value); + if (pin!= 9 && pin != 10 && pin != 6 && pin != 5){ + if (value == HIGH) + Midi.noteOn(id * 16 + pin, MIDI_MAX_DATA); + else Midi.noteOff(id * 16 + pin); + } +} + +//left jogwheel +void rotary_encoder_jogwheel_left_inc() { + Midi.controlChange(MIDI_MAX_DATA-5,65); +} + +void rotary_encoder_jogwheel_left_dec() { + Midi.controlChange(MIDI_MAX_DATA-5,63); +} + +//right jogwheel +void rotary_encoder_jogwheel_right_inc() { + Midi.controlChange(MIDI_MAX_DATA-6,65); +} + +void rotary_encoder_jogwheel_right_dec() { + Midi.controlChange(MIDI_MAX_DATA-6,63); +} + +//Browse +void rotary_encoder_browse_inc() { + Midi.noteOn(3 * 16 + 6, MIDI_MAX_DATA); + Midi.noteOff(3 * 16 + 6); +} + +void rotary_encoder_browse_dec() { + Midi.noteOn(3 * 16 + 5, MIDI_MAX_DATA); + Midi.noteOff(3 * 16 + 5); +} diff --git a/source/bombatuino_debug/bombatuino_debug.ino b/source/bombatuino_debug/bombatuino_debug.ino new file mode 100644 index 0000000..27bb6f5 --- /dev/null +++ b/source/bombatuino_debug/bombatuino_debug.ino @@ -0,0 +1,129 @@ +#include + +#include +#include +#include +#include + +MIDI Midi; + +INPUT_MCP23017 input_MCP23017_0; +INPUT_MCP23017 input_MCP23017_1; +INPUT_MCP23017 input_MCP23017_3; +INPUT_MCP23017 input_MCP23017_4; + +INPUT_74HC4051 input_4051_A0; +INPUT_74HC4051 input_4051_A1; +INPUT_74HC4051 input_4051_A2; + +ROTARY_ENCODER rotary_encoder_jogwheel_left(rotary_encoder_jogwheel_left_inc, rotary_encoder_jogwheel_left_dec); +ROTARY_ENCODER rotary_encoder_jogwheel_right(rotary_encoder_jogwheel_right_inc, rotary_encoder_jogwheel_right_dec); +ROTARY_ENCODER rotary_encoder_browse(rotary_encoder_browse_inc,rotary_encoder_browse_dec); + + +void setup() { + Serial.begin(9600); + input_MCP23017_0.begin(0,digitalCallback); + input_MCP23017_1.begin(1,digitalCallback1); + input_MCP23017_3.begin(3,digitalCallback3); + input_MCP23017_4.begin(4,digitalCallback); + + input_4051_A0.begin(A0,8,9,10,analogCallback); + input_4051_A1.begin(A1,8,9,10,analogCallback); + input_4051_A2.begin(A2,8,9,10,analogCallback); +} + +void loop() { + input_MCP23017_0.loop(); + input_MCP23017_1.loop(); + input_MCP23017_3.loop(); + input_MCP23017_4.loop(); + input_4051_A0.loop(); + input_4051_A1.loop(); + input_4051_A2.loop(); +} + +void analogCallback(int id, int pin, int value) { + Serial.print("id "); + Serial.print(id); + Serial.print(" pin "); + Serial.print(pin); + Serial.print(" : "); + Serial.print(value); + Serial.println(); +} + + +void digitalCallback(int id, int pin, int value) { + Serial.print("id "); + Serial.print(id); + Serial.print(" pin "); + Serial.print(pin); + Serial.print(" : "); + Serial.print(value); + Serial.println(); +} + + +void digitalCallback1(int id, int pin, int value) { + if (pin == 6) + rotary_encoder_jogwheel_left.setPinA(value); + if (pin == 7) + rotary_encoder_jogwheel_left.setPinB(value); + if (pin != 6 && pin !=7) { + Serial.print("id "); + Serial.print(id); + Serial.print(" pin "); + Serial.print(pin); + Serial.print(" : "); + Serial.print(value); + Serial.println(); + } +} + +void digitalCallback3(int id, int pin, int value) { + if (pin == 9) + rotary_encoder_jogwheel_right.setPinA(value); + if (pin == 10) + rotary_encoder_jogwheel_right.setPinB(value); + if (pin == 6) + rotary_encoder_browse.setPinA(value); + if (pin == 5) + rotary_encoder_browse.setPinB(value); + if (pin!= 9 && pin != 10 && pin != 6 && pin != 5){ + Serial.print("id "); + Serial.print(id); + Serial.print(" pin "); + Serial.print(pin); + Serial.print(" : "); + Serial.print(value); + Serial.println(); + } +} + +//left jogwheel +void rotary_encoder_jogwheel_left_inc() { + Serial.println("jogwheel_left_inc"); +} + +void rotary_encoder_jogwheel_left_dec() { + Serial.println("jogwheel_left_dec"); +} + +//right jogwheel +void rotary_encoder_jogwheel_right_inc() { + Serial.println("jogwheel_right_inc"); +} + +void rotary_encoder_jogwheel_right_dec() { + Serial.println("jogwheel_right_dec"); +} + +//Browse +void rotary_encoder_browse_inc() { + Serial.println("browse inc"); +} + +void rotary_encoder_browse_dec() { + Serial.println("browse dec"); +} diff --git a/source/libraries/bombatuino_ROTARY_ENCODER/bombatuino_ROTARY_ENCODER.cpp b/source/libraries/bombatuino_ROTARY_ENCODER/bombatuino_ROTARY_ENCODER.cpp index 3fe4237..7a873c1 100644 --- a/source/libraries/bombatuino_ROTARY_ENCODER/bombatuino_ROTARY_ENCODER.cpp +++ b/source/libraries/bombatuino_ROTARY_ENCODER/bombatuino_ROTARY_ENCODER.cpp @@ -1,4 +1,3 @@ - #include "Arduino.h" #include "bombatuino_ROTARY_ENCODER.h" @@ -7,12 +6,7 @@ ROTARY_ENCODER::ROTARY_ENCODER(XcrementFunction incrementFunction, XcrementFunct _decrement = decrementFunction; _pinA = LOW; _pinB = LOW; - _oldA = LOW; -} - -void ROTARY_ENCODER::setPinB(int value) { - _pinB = value; - onPinChange(); + _oldA = LOW; } void ROTARY_ENCODER::setPinA(int value) { @@ -20,6 +14,11 @@ void ROTARY_ENCODER::setPinA(int value) { onPinChange(); } +void ROTARY_ENCODER::setPinB(int value) { + _pinB = value; + onPinChange(); +} + void ROTARY_ENCODER::onPinChange() { if ((_oldA == LOW) && (_pinA == HIGH)) { if (_pinB == LOW) { diff --git a/source/ConnectionChecker/ConnectionChecker.ino b/source/old testing stuff/ConnectionChecker/ConnectionChecker.ino similarity index 100% rename from source/ConnectionChecker/ConnectionChecker.ino rename to source/old testing stuff/ConnectionChecker/ConnectionChecker.ino diff --git a/source/INPUT_MCP23017_test/INPUT_MCP23017_test.ino b/source/old testing stuff/INPUT_MCP23017_test/INPUT_MCP23017_test.ino similarity index 100% rename from source/INPUT_MCP23017_test/INPUT_MCP23017_test.ino rename to source/old testing stuff/INPUT_MCP23017_test/INPUT_MCP23017_test.ino diff --git a/source/MIDI_library_test/MIDI_library_test.ino b/source/old testing stuff/MIDI_library_test/MIDI_library_test.ino similarity index 100% rename from source/MIDI_library_test/MIDI_library_test.ino rename to source/old testing stuff/MIDI_library_test/MIDI_library_test.ino diff --git a/source/_2013_05_08/_2013_05_08.ino b/source/old testing stuff/_2013_05_08/_2013_05_08.ino similarity index 100% rename from source/_2013_05_08/_2013_05_08.ino rename to source/old testing stuff/_2013_05_08/_2013_05_08.ino diff --git a/source/_4051_test/_4051_test.ino b/source/old testing stuff/_4051_test/_4051_test.ino similarity index 100% rename from source/_4051_test/_4051_test.ino rename to source/old testing stuff/_4051_test/_4051_test.ino diff --git a/source/bombatuino/bombatu.ino b/source/old testing stuff/deubug/deubug.ino similarity index 63% rename from source/bombatuino/bombatu.ino rename to source/old testing stuff/deubug/deubug.ino index 99e1aab..5347c48 100644 --- a/source/bombatuino/bombatu.ino +++ b/source/old testing stuff/deubug/deubug.ino @@ -3,10 +3,6 @@ #include #include #include -#include - - -MIDI Midi; INPUT_MCP23017 input_MCP23017_0; INPUT_MCP23017 input_MCP23017_1; @@ -17,12 +13,14 @@ INPUT_74HC4051 input_4051_A0; INPUT_74HC4051 input_4051_A1; INPUT_74HC4051 input_4051_A2; -ROTARY_ENCODER re_JogWheel1(rotaryLeftJogWheel1,rotaryRightJogWheel1); -ROTARY_ENCODER re_JogWheel2(rotaryLeftJogWheel2,rotaryRightJogWheel2); -ROTARY_ENCODER re_Browse(rotaryLeftBrowse,rotaryRightBrowse); + +ROTARY_ENCODER re_jogwheel(jogwheel); +//ROTARY_ENCODER re_JogWheel1(rotaryLeftJogWheel1,rotaryRightJogWheel1); +//ROTARY_ENCODER re_JogWheel2(rotaryLeftJogWheel2,rotaryRightJogWheel2); +//ROTARY_ENCODER re_Browse(rotaryLeftBrowse,rotaryRightBrowse); void setup() { - Midi.begin(); + Serial.begin(9600); input_MCP23017_0.begin(0,digitalCallback); input_MCP23017_1.begin(1,digitalCallback); input_MCP23017_3.begin(3,digitalCallback); @@ -44,14 +42,22 @@ void loop() { } void analogCallback(int id, int pin, int value) { - Midi.controlChange((id-A0) * 8 + pin,value); + Serial.print("id "); + Serial.print(pin); + Serial.print(" pin "); + Serial.print(pin); + Serial.print(" : "); + Serial.print(value); + Serial.println(); } void digitalCallback(int id, int pin, int value) { if (id == 1 && pin == 6) - re_JogWheel1.setPinA(value); + re_jogwheel.setPinA(value); if (id == 1 && pin == 7) - re_JogWheel1.setPinB(value); + re_jogwheel.setPinB(value); + + /* if (id == 3 && pin == 9) re_JogWheel2.setPinA(value); if (id == 3 && pin == 10) @@ -60,44 +66,47 @@ void digitalCallback(int id, int pin, int value) { re_Browse.setPinA(value); if (id == 3 && pin == 5) re_Browse.setPinB(value); + */ if ((id == 3 && pin != 5 && pin != 6 && pin!= 9 && pin != 10) || (id == 1 && pin != 6 && pin !=7) || (id == 0) || (id == 4)) { - if (value == HIGH) - Midi.noteOn(id * 16 + pin, MIDI_MAX_DATA); - else Midi.noteOff(id * 16 + pin); + Serial.print("id "); + Serial.print(pin); + Serial.print(" pin "); + Serial.print(pin); + Serial.print(" : "); + Serial.print(value); + Serial.println(); } } +void jogwheel(int c) { + Serial.println(c); +} + //JogWheel1 void rotaryLeftJogWheel1() { - Midi.noteOn(1 * 16 + 6, MIDI_MAX_DATA); - Midi.noteOff(1 * 16 + 6); + Serial.println("wheel1 left"); } void rotaryRightJogWheel1() { - Midi.noteOn(1 * 16 + 7, MIDI_MAX_DATA); - Midi.noteOff(1 * 16 + 7); + Serial.println("wheel1 right"); } //JogWheel2 void rotaryLeftJogWheel2() { - Midi.noteOn(3 * 16 + 9, MIDI_MAX_DATA); - Midi.noteOff(3 * 16 + 9); + Serial.println("wheel2 left"); } void rotaryRightJogWheel2() { - Midi.noteOn(3 * 16 + 10, MIDI_MAX_DATA); - Midi.noteOff(3 * 16 + 10); + Serial.println("wheel2 right"); } //Browse void rotaryLeftBrowse() { - Midi.noteOn(3 * 16 + 6, MIDI_MAX_DATA); - Midi.noteOff(3 * 16 + 6); + Serial.println("wheel3 left"); } void rotaryRightBrowse() { - Midi.noteOn(3 * 16 + 5, MIDI_MAX_DATA); - Midi.noteOff(3 * 16 + 5); + Serial.println("wheel3 right"); } diff --git a/source/input_4051_library_test/input_4051_library_test.ino b/source/old testing stuff/input_4051_library_test/input_4051_library_test.ino similarity index 100% rename from source/input_4051_library_test/input_4051_library_test.ino rename to source/old testing stuff/input_4051_library_test/input_4051_library_test.ino diff --git a/source/midi_in_out/midi_in_out.ino b/source/old testing stuff/midi_in_out/midi_in_out.ino similarity index 100% rename from source/midi_in_out/midi_in_out.ino rename to source/old testing stuff/midi_in_out/midi_in_out.ino diff --git a/source/midi_in_out_softwareserial/midi_in_out_softwareserial.ino b/source/old testing stuff/midi_in_out_softwareserial/midi_in_out_softwareserial.ino similarity index 100% rename from source/midi_in_out_softwareserial/midi_in_out_softwareserial.ino rename to source/old testing stuff/midi_in_out_softwareserial/midi_in_out_softwareserial.ino diff --git a/source/midi_led/midi_led.ino b/source/old testing stuff/midi_led/midi_led.ino similarity index 100% rename from source/midi_led/midi_led.ino rename to source/old testing stuff/midi_led/midi_led.ino diff --git a/source/piezo_input/piezo_input.ino b/source/old testing stuff/piezo_input/piezo_input.ino similarity index 100% rename from source/piezo_input/piezo_input.ino rename to source/old testing stuff/piezo_input/piezo_input.ino