diff options
author | Christian Pointner <equinox@helsinki.at> | 2014-06-02 00:21:12 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2014-06-02 00:21:12 (GMT) |
commit | 23b29a81a9df8768ca88a8015f02fbb34f5328cb (patch) | |
tree | 66d600c77034d6d6d5e51bd2e2f57cb16e24be27 /software | |
parent | 767786e8d6af9c21a7df0259eec17a5c79f171bd (diff) |
GPIO outputs are now MIDI controlable
Diffstat (limited to 'software')
-rw-r--r-- | software/rhmixxx/gpio.c | 22 | ||||
-rw-r--r-- | software/rhmixxx/gpio.h | 5 | ||||
-rw-r--r-- | software/rhmixxx/rhmixxx.c | 10 |
3 files changed, 34 insertions, 3 deletions
diff --git a/software/rhmixxx/gpio.c b/software/rhmixxx/gpio.c index 6edf376..bdc1378 100644 --- a/software/rhmixxx/gpio.c +++ b/software/rhmixxx/gpio.c @@ -29,10 +29,28 @@ void gpio_init(void) { GPIO_DDR = 0x0F; - GPIO_PORT = 0xFA; + GPIO_PORT = 0xF0; +} + +void gpio_out_on(uint8_t num) +{ + if(num < 4) + GPIO_PORT |= (1 << num); +} + +void gpio_out_off(uint8_t num) +{ + if(num < 4) + GPIO_PORT &= ~(1 << num); +} + +void gpio_out_toggle(uint8_t num) +{ + if(num < 4) + GPIO_PORT ^= (1 << num); } void gpio_task(void) { - GPIO_PORT ^= 0x0F; + // TODO generate events on change of GPI } diff --git a/software/rhmixxx/gpio.h b/software/rhmixxx/gpio.h index 58a3fe4..3c27d78 100644 --- a/software/rhmixxx/gpio.h +++ b/software/rhmixxx/gpio.h @@ -23,6 +23,11 @@ #define RHMIXXX_gpio_h_INCLUDED void gpio_init(void); + +void gpio_out_on(uint8_t num); +void gpio_out_off(uint8_t num); +void gpio_out_toggle(uint8_t num); + void gpio_task(void); #endif diff --git a/software/rhmixxx/rhmixxx.c b/software/rhmixxx/rhmixxx.c index 106c64a..d5ac080 100644 --- a/software/rhmixxx/rhmixxx.c +++ b/software/rhmixxx/rhmixxx.c @@ -83,7 +83,7 @@ static void process_incoming_midi(void) uint8_t cmd = ReceivedMIDIEvent.Data1 & 0xF0;
uint8_t note = ReceivedMIDIEvent.Data2;
uint8_t value = ReceivedMIDIEvent.Data3 & 0x7F;
- if(note < 16 || note == 0x7F) { // TODO: hardcoded value
+ if(note < 16 || note == 0x7F) { // KEYPAD
if(cmd == MIDI_COMMAND_NOTE_ON) {
if(value <= 2) {
switch(value) {
@@ -95,6 +95,14 @@ static void process_incoming_midi(void) keypad_led_blink(note, value);
}
}
+ } else if(note >= 64 && note <= 68) { // GPIO
+ if(cmd == MIDI_COMMAND_NOTE_ON) {
+ switch(value) {
+ case 0: gpio_out_off(note - 64); break;
+ case 1: gpio_out_on(note - 64); break;
+ case 2: gpio_out_toggle(note - 64); break;
+ }
+ }
}
}
}
|