This commit is contained in:
Lukas 2013-05-14 22:03:11 +02:00
parent 732adb8d63
commit 38c35e3e6a
14 changed files with 282 additions and 33 deletions

112
source/bombatu/bombatu.ino Normal file
View File

@ -0,0 +1,112 @@
#include <Wire.h>
#include <bombatuino_INPUT_MCP23017.h>
#include <bombatuino_INPUT_74HC4051.h>
#include <bombatuino_MIDI.h>
#include <bombatuino_ROTARY_ENCODER.h>
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);
}

View File

@ -0,0 +1,129 @@
#include <Wire.h>
#include <bombatuino_INPUT_MCP23017.h>
#include <bombatuino_INPUT_74HC4051.h>
#include <bombatuino_MIDI.h>
#include <bombatuino_ROTARY_ENCODER.h>
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");
}

View File

@ -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) {

View File

@ -3,10 +3,6 @@
#include <bombatuino_INPUT_MCP23017.h>
#include <bombatuino_INPUT_74HC4051.h>
#include <bombatuino_ROTARY_ENCODER.h>
#include <bombatuino_MIDI.h>
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");
}