fix theme indexing
This commit is contained in:
parent
46d0ca5250
commit
c1b2d6d996
@ -61,6 +61,7 @@ UIState currentState = UI_MENU_MAIN;
|
|||||||
const char* mainMenu[] = { "Tracker", "Randomize", "Setup" };
|
const char* mainMenu[] = { "Tracker", "Randomize", "Setup" };
|
||||||
const int mainMenuCount = sizeof(mainMenu) / sizeof(char*);
|
const int mainMenuCount = sizeof(mainMenu) / sizeof(char*);
|
||||||
const char* randomizeMenu[] = { "Back", "Scale", "Melody", "Mutation", "Song Mode", "Theme 1", "Theme 2", "Theme 3", "Theme 4", "Theme 5", "Theme 6", "Theme 7" };
|
const char* randomizeMenu[] = { "Back", "Scale", "Melody", "Mutation", "Song Mode", "Theme 1", "Theme 2", "Theme 3", "Theme 4", "Theme 5", "Theme 6", "Theme 7" };
|
||||||
|
const int THEME_1_INDEX = 5;
|
||||||
const int randomizeMenuCount = sizeof(randomizeMenu) / sizeof(char*);
|
const int randomizeMenuCount = sizeof(randomizeMenu) / sizeof(char*);
|
||||||
const char* setupMenu[] = { "Back", "Channel", "Tempo", "Save", "Load" };
|
const char* setupMenu[] = { "Back", "Channel", "Tempo", "Save", "Load" };
|
||||||
const int setupMenuCount = sizeof(setupMenu) / sizeof(char*);
|
const int setupMenuCount = sizeof(setupMenu) / sizeof(char*);
|
||||||
@ -68,7 +69,8 @@ const int setupMenuCount = sizeof(setupMenu) / sizeof(char*);
|
|||||||
int menuSelection = 0;
|
int menuSelection = 0;
|
||||||
volatile int navigationSelection = 1;
|
volatile int navigationSelection = 1;
|
||||||
volatile int playbackStep = 0;
|
volatile int playbackStep = 0;
|
||||||
volatile int midiChannel = 1;
|
int midiChannel = 1;
|
||||||
|
volatile int shMidiChannel = midiChannel;
|
||||||
int scaleNotes[12];
|
int scaleNotes[12];
|
||||||
int numScaleNotes = 0;
|
int numScaleNotes = 0;
|
||||||
int melodySeed = 0;
|
int melodySeed = 0;
|
||||||
@ -170,6 +172,7 @@ bool loadSequence() {
|
|||||||
if (magic != EEPROM_MAGIC) return false;
|
if (magic != EEPROM_MAGIC) return false;
|
||||||
|
|
||||||
EEPROM.get(addr, midiChannel); addr += sizeof(midiChannel);
|
EEPROM.get(addr, midiChannel); addr += sizeof(midiChannel);
|
||||||
|
shMidiChannel = midiChannel;
|
||||||
EEPROM.get(addr, melodySeed); addr += sizeof(melodySeed);
|
EEPROM.get(addr, melodySeed); addr += sizeof(melodySeed);
|
||||||
|
|
||||||
EEPROM.get(addr, numScaleNotes); addr += sizeof(numScaleNotes);
|
EEPROM.get(addr, numScaleNotes); addr += sizeof(numScaleNotes);
|
||||||
@ -240,7 +243,7 @@ void setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void sendMidi(uint8_t status, uint8_t note, uint8_t velocity) {
|
void sendMidi(uint8_t status, uint8_t note, uint8_t velocity) {
|
||||||
uint8_t channelStatus = status | (midiChannel - 1);
|
uint8_t channelStatus = status | (shMidiChannel - 1);
|
||||||
Serial1.write(channelStatus);
|
Serial1.write(channelStatus);
|
||||||
Serial1.write(note);
|
Serial1.write(note);
|
||||||
Serial1.write(velocity);
|
Serial1.write(velocity);
|
||||||
@ -359,6 +362,7 @@ void handleInput() {
|
|||||||
midiChannel += (delta > 0 ? 1 : -1);
|
midiChannel += (delta > 0 ? 1 : -1);
|
||||||
if (midiChannel < 1) midiChannel = 16;
|
if (midiChannel < 1) midiChannel = 16;
|
||||||
if (midiChannel > 16) midiChannel = 1;
|
if (midiChannel > 16) midiChannel = 1;
|
||||||
|
shMidiChannel = midiChannel;
|
||||||
break;
|
break;
|
||||||
case UI_SETUP_TEMPO_EDIT:
|
case UI_SETUP_TEMPO_EDIT:
|
||||||
tempo += delta;
|
tempo += delta;
|
||||||
@ -438,15 +442,16 @@ void handleInput() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (menuSelection >= 5) { // Themes
|
if (menuSelection >= THEME_1_INDEX) { // Themes
|
||||||
|
const int selectedTheme = menuSelection - THEME_1_INDEX + 1;
|
||||||
if (isPlaying) {
|
if (isPlaying) {
|
||||||
queuedTheme = menuSelection - 2;
|
queuedTheme = selectedTheme;
|
||||||
mutex_enter_blocking(&midiMutex);
|
mutex_enter_blocking(&midiMutex);
|
||||||
generateSequenceData(queuedTheme, nextSequence);
|
generateSequenceData(queuedTheme, nextSequence);
|
||||||
nextSequenceReady = true;
|
nextSequenceReady = true;
|
||||||
mutex_exit(&midiMutex);
|
mutex_exit(&midiMutex);
|
||||||
} else {
|
} else {
|
||||||
generateTheme(menuSelection - 2);
|
generateTheme(selectedTheme);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -612,12 +617,12 @@ void drawMenu(const char* title, const char* items[], int count, int selection)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Special case for queued theme
|
// Special case for queued theme
|
||||||
if (currentState == UI_MENU_RANDOMIZE && i >= 5 && queuedTheme == (i - 4)) {
|
if (currentState == UI_MENU_RANDOMIZE && i >= THEME_1_INDEX && queuedTheme == (i - THEME_1_INDEX + 1)) {
|
||||||
display.print(F(" [NEXT]"));
|
display.print(F(" [NEXT]"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Special case for active theme
|
// Special case for active theme
|
||||||
if (currentState == UI_MENU_RANDOMIZE && i >= 5 && currentThemeIndex == (i - 4)) {
|
if (currentState == UI_MENU_RANDOMIZE && i >= THEME_1_INDEX && currentThemeIndex == (i - THEME_1_INDEX + 1)) {
|
||||||
display.print(F(" *"));
|
display.print(F(" *"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user