|
|
@ -59,21 +59,8 @@ void setup() { |
|
|
|
|
|
|
|
|
|
|
|
tm.displayBegin(); |
|
|
|
tm.displayBegin(); |
|
|
|
tm.brightness(BRIGHTNESS); |
|
|
|
tm.brightness(BRIGHTNESS); |
|
|
|
//tm.DisplayStr("HLLOWRLD", 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint8_t tmp_channel = EEPROM.read(EEPROM_ADDRESS); |
|
|
|
actual_channel=read_channel_from_eeprom(); |
|
|
|
if (tmp_channel & 0xf0 != 0xf0) { |
|
|
|
|
|
|
|
actual_channel = 1; |
|
|
|
|
|
|
|
#if defined(DEBUG) |
|
|
|
|
|
|
|
Serial.println("Setting channel to 1"); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
actual_channel = 0x0f & tmp_channel; |
|
|
|
|
|
|
|
#if defined(DEBUG) |
|
|
|
|
|
|
|
Serial.print("Reading channel from EEPROM: "); |
|
|
|
|
|
|
|
Serial.println(actual_channel, DEC); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
new_channel = actual_channel; |
|
|
|
new_channel = actual_channel; |
|
|
|
|
|
|
|
|
|
|
|
pinMode(MIDI_CH_BIT3, OUTPUT); |
|
|
|
pinMode(MIDI_CH_BIT3, OUTPUT); |
|
|
@ -83,8 +70,6 @@ void setup() { |
|
|
|
|
|
|
|
|
|
|
|
SetMidiChannel(INITIAL_MIDI_CHANNEL); |
|
|
|
SetMidiChannel(INITIAL_MIDI_CHANNEL); |
|
|
|
|
|
|
|
|
|
|
|
//Scrolling_Text();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tm.DisplayDecNum(actual_channel, 0, false, TMAlignTextRight); |
|
|
|
tm.DisplayDecNum(actual_channel, 0, false, TMAlignTextRight); |
|
|
|
|
|
|
|
|
|
|
|
#if defined(DEBUG) |
|
|
|
#if defined(DEBUG) |
|
|
@ -161,23 +146,19 @@ void SetMidiChannel(uint8_t channel) { |
|
|
|
digitalWrite(MIDI_CH_BIT3, channel & 0x08); |
|
|
|
digitalWrite(MIDI_CH_BIT3, channel & 0x08); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Scrolling_Text(void) { |
|
|
|
uint8_t read_channel_from_eeprom(void) { |
|
|
|
char textScroll[] = " 42 IS THE ANSWER "; |
|
|
|
uint8_t tmp_channel = EEPROM.read(EEPROM_ADDRESS); |
|
|
|
unsigned long previousMillis_display = 0; // will store last time display was updated
|
|
|
|
if (tmp_channel & 0xf0 != 0xf0) { |
|
|
|
const long interval_display = 150; // interval at which to update display (milliseconds)
|
|
|
|
actual_channel = 1; |
|
|
|
|
|
|
|
#if defined(DEBUG) |
|
|
|
while (42 == 42) { |
|
|
|
Serial.println("Setting channel to 1"); |
|
|
|
tm.DisplayStr(textScroll, 0); |
|
|
|
#endif |
|
|
|
unsigned long currentMillis = millis(); |
|
|
|
} else { |
|
|
|
// update data every interval_display delay
|
|
|
|
actual_channel = 0x0f & tmp_channel; |
|
|
|
if (currentMillis - previousMillis_display >= interval_display) { |
|
|
|
#if defined(DEBUG) |
|
|
|
previousMillis_display = currentMillis; |
|
|
|
Serial.print("Reading channel from EEPROM: "); |
|
|
|
if (strlen(textScroll) > 0) { |
|
|
|
Serial.println(actual_channel, DEC); |
|
|
|
memmove(textScroll, textScroll + 1, strlen(textScroll)); // delete first char in array.
|
|
|
|
#endif |
|
|
|
} else { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|