|
|
|
@ -38,7 +38,7 @@ bool high_freq = false; |
|
|
|
|
|
|
|
|
|
#define BRIGHTNESS 6 |
|
|
|
|
#define INITIAL_MIDI_CHANNEL 1 |
|
|
|
|
#define BUTTON_DEBOUNCE_TIME_MS 150 |
|
|
|
|
#define BUTTON_DEBOUNCE_TIME_MS 200 |
|
|
|
|
#define BLINK_FREQUENCY_MS 500 |
|
|
|
|
#define EEPROM_ADDRESS 0x42 |
|
|
|
|
|
|
|
|
@ -59,7 +59,7 @@ void setup() { |
|
|
|
|
|
|
|
|
|
tm.displayBegin(); |
|
|
|
|
tm.brightness(BRIGHTNESS); |
|
|
|
|
tm.DisplayStr("HLLOWRLD", 0); |
|
|
|
|
//tm.DisplayStr("HLLOWRLD", 0);
|
|
|
|
|
|
|
|
|
|
uint8_t tmp_channel = EEPROM.read(EEPROM_ADDRESS); |
|
|
|
|
if (tmp_channel & 0xf0 != 0xf0) { |
|
|
|
@ -83,7 +83,7 @@ void setup() { |
|
|
|
|
|
|
|
|
|
SetMidiChannel(INITIAL_MIDI_CHANNEL); |
|
|
|
|
|
|
|
|
|
delay(200); |
|
|
|
|
Scrolling_Text(); |
|
|
|
|
|
|
|
|
|
tm.DisplayDecNum(actual_channel, 0, false, TMAlignTextRight); |
|
|
|
|
|
|
|
|
@ -98,13 +98,13 @@ void loop() { |
|
|
|
|
button = tm.ReadKey16(); |
|
|
|
|
|
|
|
|
|
if (button > 0 && button != actual_channel && button_debounce_timer > BUTTON_DEBOUNCE_TIME_MS) { |
|
|
|
|
button_debounce_timer = 0; |
|
|
|
|
if (button != new_channel) { |
|
|
|
|
// Button pressed once
|
|
|
|
|
#if defined(DEBUG) |
|
|
|
|
Serial.print("Button pressed once: "); |
|
|
|
|
Serial.println(button, DEC); |
|
|
|
|
#endif |
|
|
|
|
button_debounce_timer = 0; |
|
|
|
|
blink_timer = 0; |
|
|
|
|
new_channel = button; |
|
|
|
|
tm.DisplayDecNumNibble(new_channel, actual_channel, 0, false, TMAlignTextRight); |
|
|
|
@ -119,6 +119,13 @@ void loop() { |
|
|
|
|
SetMidiChannel(actual_channel); |
|
|
|
|
tm.DisplayDecNum(actual_channel, 0, false, TMAlignTextRight); |
|
|
|
|
} |
|
|
|
|
} else if (button > 0 && button == actual_channel && button_debounce_timer > BUTTON_DEBOUNCE_TIME_MS) { |
|
|
|
|
button_debounce_timer = 0; |
|
|
|
|
#if defined(DEBUG) |
|
|
|
|
Serial.println("Same button as current MIDI channel pressed, doing nothing."); |
|
|
|
|
#endif |
|
|
|
|
new_channel = actual_channel; |
|
|
|
|
tm.DisplayDecNum(actual_channel, 0, false, TMAlignTextRight); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (actual_channel != new_channel) { |
|
|
|
@ -154,6 +161,26 @@ void SetMidiChannel(uint8_t channel) { |
|
|
|
|
digitalWrite(MIDI_CH_BIT3, channel & 0x08); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Scrolling_Text(void) { |
|
|
|
|
char textScroll[] = " 42 IS THE ANSWER "; |
|
|
|
|
unsigned long previousMillis_display = 0; // will store last time display was updated
|
|
|
|
|
const long interval_display = 150; // interval at which to update display (milliseconds)
|
|
|
|
|
|
|
|
|
|
while (42 == 42) { |
|
|
|
|
tm.DisplayStr(textScroll, 0); |
|
|
|
|
unsigned long currentMillis = millis(); |
|
|
|
|
// update data every interval_display delay
|
|
|
|
|
if (currentMillis - previousMillis_display >= interval_display) { |
|
|
|
|
previousMillis_display = currentMillis; |
|
|
|
|
if (strlen(textScroll) > 0) { |
|
|
|
|
memmove(textScroll, textScroll + 1, strlen(textScroll)); // delete first char in array.
|
|
|
|
|
} else { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#if defined(DEBUG) |
|
|
|
|
void printBinary(uint32_t value, uint8_t len) { |
|
|
|
|
for (uint8_t b = len; b > 0; --b) { |
|
|
|
|