Code cleanup.

main
Holger Wirtz 1 year ago
parent ae5677ed30
commit 1d619775db
  1. 47
      MIDI-Host-Adapter.ino

@ -59,21 +59,8 @@ void setup() {
tm.displayBegin();
tm.brightness(BRIGHTNESS);
//tm.DisplayStr("HLLOWRLD", 0);
uint8_t tmp_channel = EEPROM.read(EEPROM_ADDRESS);
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
}
actual_channel=read_channel_from_eeprom();
new_channel = actual_channel;
pinMode(MIDI_CH_BIT3, OUTPUT);
@ -83,8 +70,6 @@ void setup() {
SetMidiChannel(INITIAL_MIDI_CHANNEL);
//Scrolling_Text();
tm.DisplayDecNum(actual_channel, 0, false, TMAlignTextRight);
#if defined(DEBUG)
@ -161,23 +146,19 @@ 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;
}
}
uint8_t read_channel_from_eeprom(void) {
uint8_t tmp_channel = EEPROM.read(EEPROM_ADDRESS);
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
}
}

Loading…
Cancel
Save