Skip to content

Commit

Permalink
fixes - working version
Browse files Browse the repository at this point in the history
  • Loading branch information
Pi3rral committed Apr 5, 2020
1 parent 023a74f commit 86b4e1b
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions midi-controller/midi-controller.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,43 @@
#include "OLED.h"
#include "MIDI.h"

#define BUTTON1_PIN 2
#define BUTTON2_PIN 3
// FS Configuration
#define FS_TIP_PIN 2
#define FS_RING_PIN 3

#define NO_BUTTON 0
#define BUTTON_UP 1
#define BUTTON_DOWN 2
#define BUTTON_MODE 3


// MIDI Configuration
#define MIDI_CHANNEL 1
#define MIDI_BAUD_RATE 31250


// Global Variables
OLED oled;
uint8_t button_1_state = HIGH;
uint8_t button_2_state = HIGH;
uint8_t current_program = 1;
uint8_t next_program = 1;

uint8_t read_button_fs3x() {
if (digitalRead(BUTTON1_PIN) == LOW) {
if (digitalRead(BUTTON2_PIN) == LOW) {
if (digitalRead(FS_TIP_PIN) == LOW) {
if (digitalRead(FS_RING_PIN) == LOW) {
return BUTTON_UP;
}
return BUTTON_DOWN;
} else if (digitalRead(BUTTON2_PIN) == LOW) {
return BUTTON_MODE;
} else if (digitalRead(FS_RING_PIN) == LOW) {
return BUTTON_DOWN;
}
return NO_BUTTON;
}


void setup() {
oled.init();
pinMode(BUTTON1_PIN, INPUT_PULLUP);
pinMode(BUTTON2_PIN, INPUT_PULLUP);
Serial.begin(9600);
pinMode(FS_TIP_PIN, INPUT_PULLUP);
pinMode(FS_RING_PIN, INPUT_PULLUP);
Serial.begin(MIDI_BAUD_RATE);
oled.clearDisplay();
oled.printProgramChange(current_program);
}
Expand Down Expand Up @@ -79,12 +80,4 @@ void loop() {
delay(100);
break;
}
if (digitalRead(BUTTON1_PIN) == LOW) {
if (button_1_state == HIGH) {
button_1_state = LOW;

}
} else if (button_1_state == LOW) {
button_1_state = HIGH;
}
}

0 comments on commit 86b4e1b

Please sign in to comment.