menu redesign: hierarchical entries
This commit is contained in:
parent
8ae1f5f501
commit
d70e30d76f
@ -12,18 +12,42 @@ Step nextSequence[NUM_TRACKS][NUM_STEPS];
|
||||
volatile bool sequenceChangeScheduled = false;
|
||||
volatile bool needsPanic = false;
|
||||
|
||||
UIState currentState = UI_MENU_RANDOMIZE;
|
||||
UIState currentState = UI_MENU_MAIN;
|
||||
|
||||
// Menus
|
||||
const char* mainMenu[] = { "Randomize", "Setup" };
|
||||
extern const int mainMenuCount = sizeof(mainMenu) / sizeof(char*);
|
||||
MenuItem menuItems[] = {
|
||||
{ "Main", MENU_ID_GROUP_MAIN, true, true, 0 },
|
||||
{ "Melody", MENU_ID_MELODY, false, false, 1 },
|
||||
{ "Scale", MENU_ID_SCALE, false, false, 1 },
|
||||
{ "Tempo", MENU_ID_TEMPO, false, false, 1 },
|
||||
{ "Song Mode", MENU_ID_SONG_MODE, false, false, 1 },
|
||||
{ "Track", MENU_ID_GROUP_TRACK, true, true, 0 },
|
||||
{ "Track", MENU_ID_TRACK_SELECT, false, false, 1 },
|
||||
{ "Mute", MENU_ID_MUTE, false, false, 1 },
|
||||
{ "Flavour", MENU_ID_FLAVOUR, false, false, 1 },
|
||||
{ "Mutation", MENU_ID_MUTATION, false, false, 1 },
|
||||
{ "Theme 1", MENU_ID_THEME_1, false, false, 1 },
|
||||
{ "Theme 2", MENU_ID_THEME_2, false, false, 1 },
|
||||
{ "Theme 3", MENU_ID_THEME_3, false, false, 1 },
|
||||
{ "Theme 4", MENU_ID_THEME_4, false, false, 1 },
|
||||
{ "Theme 5", MENU_ID_THEME_5, false, false, 1 },
|
||||
{ "Theme 6", MENU_ID_THEME_6, false, false, 1 },
|
||||
{ "Theme 7", MENU_ID_THEME_7, false, false, 1 },
|
||||
{ "Setup", MENU_ID_GROUP_SETUP, true, false, 0 },
|
||||
{ "Channel", MENU_ID_CHANNEL, false, false, 1 },
|
||||
{ "Reset", MENU_ID_RESET, false, false, 1 }
|
||||
};
|
||||
extern const int menuItemsCount = sizeof(menuItems) / sizeof(MenuItem);
|
||||
|
||||
const char* randomizeMenuPoly[] = { "Setup", "Melody", "Scale", "Tempo", "Song Mode", "Track", "Mute", "Flavour", "Mutation", "Theme 1", "Theme 2", "Theme 3", "Theme 4", "Theme 5", "Theme 6", "Theme 7" };
|
||||
extern const int randomizeMenuPolyCount = sizeof(randomizeMenuPoly) / sizeof(char*);
|
||||
extern const int THEME_1_INDEX_POLY = 9;
|
||||
|
||||
const char* setupMenu[] = { "Back", "Channel", "Factory Reset" };
|
||||
extern const int setupMenuCount = sizeof(setupMenu) / sizeof(char*);
|
||||
bool isItemVisible(int index) {
|
||||
if (menuItems[index].indentLevel == 0) return true;
|
||||
for (int i = index - 1; i >= 0; i--) {
|
||||
if (menuItems[i].indentLevel < menuItems[index].indentLevel) {
|
||||
return menuItems[i].expanded;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int menuSelection = 0;
|
||||
volatile bool trackMute[NUM_TRACKS];
|
||||
|
||||
@ -14,13 +14,42 @@ extern volatile bool needsPanic;
|
||||
extern UIState currentState;
|
||||
|
||||
// Menus
|
||||
extern const char* mainMenu[];
|
||||
extern const int mainMenuCount;
|
||||
extern const char* randomizeMenuPoly[];
|
||||
extern const int randomizeMenuPolyCount;
|
||||
extern const int THEME_1_INDEX_POLY;
|
||||
extern const char* setupMenu[];
|
||||
extern const int setupMenuCount;
|
||||
enum MenuItemID {
|
||||
MENU_ID_GROUP_MAIN,
|
||||
MENU_ID_MELODY,
|
||||
MENU_ID_SCALE,
|
||||
MENU_ID_TEMPO,
|
||||
MENU_ID_SONG_MODE,
|
||||
|
||||
MENU_ID_GROUP_TRACK,
|
||||
MENU_ID_TRACK_SELECT,
|
||||
MENU_ID_MUTE,
|
||||
MENU_ID_FLAVOUR,
|
||||
MENU_ID_MUTATION,
|
||||
MENU_ID_THEME_1,
|
||||
MENU_ID_THEME_2,
|
||||
MENU_ID_THEME_3,
|
||||
MENU_ID_THEME_4,
|
||||
MENU_ID_THEME_5,
|
||||
MENU_ID_THEME_6,
|
||||
MENU_ID_THEME_7,
|
||||
|
||||
MENU_ID_GROUP_SETUP,
|
||||
MENU_ID_CHANNEL,
|
||||
MENU_ID_RESET
|
||||
};
|
||||
|
||||
struct MenuItem {
|
||||
const char* label;
|
||||
MenuItemID id;
|
||||
bool isGroup;
|
||||
bool expanded;
|
||||
int indentLevel;
|
||||
};
|
||||
|
||||
extern MenuItem menuItems[];
|
||||
extern const int menuItemsCount;
|
||||
bool isItemVisible(int index);
|
||||
|
||||
extern int menuSelection;
|
||||
extern volatile bool trackMute[NUM_TRACKS];
|
||||
|
||||
@ -17,8 +17,6 @@ enum PlayMode {
|
||||
|
||||
enum UIState {
|
||||
UI_MENU_MAIN,
|
||||
UI_MENU_RANDOMIZE,
|
||||
UI_MENU_SETUP,
|
||||
UI_SETUP_CHANNEL_EDIT,
|
||||
UI_EDIT_TEMPO,
|
||||
UI_EDIT_FLAVOUR,
|
||||
|
||||
134
UIManager.cpp
134
UIManager.cpp
@ -1,5 +1,6 @@
|
||||
#include "UIManager.h"
|
||||
#include "config.h"
|
||||
#include "SharedState.h"
|
||||
|
||||
// --- HARDWARE CONFIGURATION ---
|
||||
#define SCREEN_WIDTH 128
|
||||
@ -51,10 +52,7 @@ void UIManager::draw(UIState currentState, int menuSelection,
|
||||
int numScaleNotes, const int* scaleNotes, int melodySeed,
|
||||
bool mutationEnabled, bool songModeEnabled,
|
||||
const Step sequence[][NUM_STEPS], int playbackStep, bool isPlaying,
|
||||
const char* mainMenu[], int mainMenuCount,
|
||||
const char* randomizeMenu[], int randomizeMenuCount,
|
||||
const char* setupMenu[], int setupMenuCount, int theme1Index,
|
||||
PlayMode playMode, int randomizeTrack, const bool* trackMute) {
|
||||
int randomizeTrack, const bool* trackMute) {
|
||||
|
||||
display.clearDisplay();
|
||||
display.setTextSize(1);
|
||||
@ -63,20 +61,7 @@ void UIManager::draw(UIState currentState, int menuSelection,
|
||||
|
||||
switch(currentState) {
|
||||
case UI_MENU_MAIN:
|
||||
drawMenu("MAIN MENU", mainMenu, mainMenuCount, menuSelection, currentState, midiChannel, tempo, currentStrategy->getName(), queuedTheme, currentThemeIndex, numScaleNotes, scaleNotes, melodySeed, mutationEnabled, songModeEnabled, theme1Index, playMode, randomizeTrack, trackMute);
|
||||
break;
|
||||
case UI_MENU_RANDOMIZE:
|
||||
{
|
||||
const char* title = "TRACK";
|
||||
// Main section items: Setup(0), Melody(1), Scale(2), Tempo(3), Song Mode(4)
|
||||
if (menuSelection <= 4) {
|
||||
title = "MAIN";
|
||||
}
|
||||
drawMenu(title, randomizeMenu, randomizeMenuCount, menuSelection, currentState, midiChannel, tempo, currentStrategy->getName(), queuedTheme, currentThemeIndex, numScaleNotes, scaleNotes, melodySeed, mutationEnabled, songModeEnabled, theme1Index, playMode, randomizeTrack, trackMute);
|
||||
}
|
||||
break;
|
||||
case UI_MENU_SETUP:
|
||||
drawMenu("SETUP", setupMenu, setupMenuCount, menuSelection, currentState, midiChannel, tempo, currentStrategy->getName(), queuedTheme, currentThemeIndex, numScaleNotes, scaleNotes, melodySeed, mutationEnabled, songModeEnabled, theme1Index, playMode, randomizeTrack, trackMute);
|
||||
drawMenu(menuSelection, currentState, midiChannel, tempo, currentStrategy->getName(), queuedTheme, currentThemeIndex, numScaleNotes, scaleNotes, melodySeed, mutationEnabled, songModeEnabled, randomizeTrack, trackMute);
|
||||
break;
|
||||
case UI_SETUP_CHANNEL_EDIT:
|
||||
display.println(F("SET MIDI CHANNEL"));
|
||||
@ -111,16 +96,6 @@ void UIManager::draw(UIState currentState, int menuSelection,
|
||||
display.setCursor(0, 50);
|
||||
display.println(F(" (Press to confirm)"));
|
||||
break;
|
||||
case UI_SETUP_PLAYMODE_EDIT:
|
||||
display.println(F("SET PLAY MODE"));
|
||||
display.drawLine(0, 8, 128, 8, SSD1306_WHITE);
|
||||
display.setCursor(20, 25);
|
||||
display.setTextSize(2);
|
||||
display.print(playMode == MODE_MONO ? "Mono" : "Poly");
|
||||
display.setTextSize(1);
|
||||
display.setCursor(0, 50);
|
||||
display.println(F(" (Press to confirm)"));
|
||||
break;
|
||||
case UI_RANDOMIZE_TRACK_EDIT:
|
||||
display.println(F("SET TRACK"));
|
||||
display.drawLine(0, 8, 128, 8, SSD1306_WHITE);
|
||||
@ -136,43 +111,58 @@ void UIManager::draw(UIState currentState, int menuSelection,
|
||||
display.display();
|
||||
}
|
||||
|
||||
void UIManager::drawMenu(const char* title, const char* items[], int count, int selection,
|
||||
UIState currentState, int midiChannel, int tempo, const char* flavourName,
|
||||
void UIManager::drawMenu(int selection, UIState currentState, int midiChannel, int tempo, const char* flavourName,
|
||||
int queuedTheme, int currentThemeIndex, int numScaleNotes,
|
||||
const int* scaleNotes, int melodySeed, bool mutationEnabled,
|
||||
bool songModeEnabled, int theme1Index, PlayMode playMode, int randomizeTrack, const bool* trackMute) {
|
||||
display.println(title);
|
||||
display.drawLine(0, 8, 128, 8, SSD1306_WHITE);
|
||||
bool songModeEnabled, int randomizeTrack, const bool* trackMute) {
|
||||
|
||||
int start = 0;
|
||||
if (selection >= 5) start = selection - 4;
|
||||
// Calculate visual cursor position and scroll offset
|
||||
int visualCursor = 0;
|
||||
for(int i=0; i<selection; i++) {
|
||||
if(isItemVisible(i)) visualCursor++;
|
||||
}
|
||||
|
||||
int y = 10;
|
||||
for (int i = start; i < count; i++) {
|
||||
if (y > 55) break;
|
||||
const int MAX_LINES = 7; // No title, so we have more space
|
||||
int startVisualIndex = 0;
|
||||
if (visualCursor >= MAX_LINES) {
|
||||
startVisualIndex = visualCursor - (MAX_LINES - 1);
|
||||
}
|
||||
|
||||
int currentVisualIndex = 0;
|
||||
int y = 0;
|
||||
|
||||
for (int i = 0; i < menuItemsCount; i++) {
|
||||
if (!isItemVisible(i)) continue;
|
||||
|
||||
if (currentVisualIndex >= startVisualIndex) {
|
||||
if (y > 55) break;
|
||||
|
||||
if (i == selection) {
|
||||
display.fillRect(0, y, 128, 8, SSD1306_WHITE);
|
||||
display.fillRect(0, y, 128, 9, SSD1306_WHITE);
|
||||
display.setTextColor(SSD1306_BLACK, SSD1306_WHITE);
|
||||
} else {
|
||||
display.setTextColor(SSD1306_WHITE);
|
||||
}
|
||||
display.setCursor(2, y);
|
||||
display.print(items[i]);
|
||||
|
||||
if (currentState == UI_MENU_SETUP && i == 1) {
|
||||
int x = 2 + (menuItems[i].indentLevel * 6);
|
||||
display.setCursor(x, y + 1);
|
||||
|
||||
if (menuItems[i].isGroup) {
|
||||
display.print(menuItems[i].expanded ? F("v ") : F("> "));
|
||||
}
|
||||
|
||||
display.print(menuItems[i].label);
|
||||
|
||||
MenuItemID id = menuItems[i].id;
|
||||
|
||||
if (id == MENU_ID_CHANNEL) {
|
||||
display.print(F(": ")); display.print(midiChannel);
|
||||
}
|
||||
if (currentState == UI_MENU_RANDOMIZE && i >= theme1Index && queuedTheme == (i - theme1Index + 1)) {
|
||||
display.print(F(" [NEXT]"));
|
||||
}
|
||||
if (currentState == UI_MENU_RANDOMIZE && i >= theme1Index && currentThemeIndex == (i - theme1Index + 1)) {
|
||||
display.print(F(" *"));
|
||||
}
|
||||
if (currentState == UI_MENU_RANDOMIZE) {
|
||||
if (i == 1) { // Melody
|
||||
|
||||
// Dynamic values
|
||||
if (id == MENU_ID_MELODY) {
|
||||
display.print(F(": ")); display.print(melodySeed);
|
||||
} else if (i == 2) { // Scale
|
||||
} else if (id == MENU_ID_SCALE) {
|
||||
display.print(F(": "));
|
||||
if (numScaleNotes > 0) {
|
||||
const char* noteNames[] = {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"};
|
||||
@ -181,14 +171,23 @@ void UIManager::drawMenu(const char* title, const char* items[], int count, int
|
||||
if (j < min(numScaleNotes, 6) - 1) display.print(F(" "));
|
||||
}
|
||||
}
|
||||
} else if (i == 3) { display.print(F(": ")); display.print(tempo); }
|
||||
else if (i == 4) { display.print(F(": ")); display.print(songModeEnabled ? F("ON") : F("OFF")); }
|
||||
else if (i == 5) { display.print(F(": ")); display.print(randomizeTrack + 1); }
|
||||
else if (i == 6) { display.print(F(": ")); display.print(trackMute[randomizeTrack] ? F("YES") : F("NO")); }
|
||||
else if (i == 7) { display.print(F(": ")); display.print(flavourName); }
|
||||
else if (i == 8) { display.print(F(": ")); display.print(mutationEnabled ? F("ON") : F("OFF")); }
|
||||
}
|
||||
} else if (id == MENU_ID_TEMPO) { display.print(F(": ")); display.print(tempo); }
|
||||
else if (id == MENU_ID_SONG_MODE) { display.print(F(": ")); display.print(songModeEnabled ? F("ON") : F("OFF")); }
|
||||
else if (id == MENU_ID_TRACK_SELECT) { display.print(F(": ")); display.print(randomizeTrack + 1); }
|
||||
else if (id == MENU_ID_MUTE) { display.print(F(": ")); display.print(trackMute[randomizeTrack] ? F("YES") : F("NO")); }
|
||||
else if (id == MENU_ID_FLAVOUR) { display.print(F(": ")); display.print(flavourName); }
|
||||
else if (id == MENU_ID_MUTATION) { display.print(F(": ")); display.print(mutationEnabled ? F("ON") : F("OFF")); }
|
||||
|
||||
if (id >= MENU_ID_THEME_1 && id <= MENU_ID_THEME_7) {
|
||||
int themeIdx = id - MENU_ID_THEME_1 + 1;
|
||||
if (queuedTheme == themeIdx) display.print(F(" [NEXT]"));
|
||||
if (currentThemeIndex == themeIdx) display.print(F(" *"));
|
||||
}
|
||||
|
||||
y += 9;
|
||||
}
|
||||
|
||||
currentVisualIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -205,7 +204,7 @@ int UIManager::getPixelIndex(int x, int y) {
|
||||
void UIManager::updateLeds(const Step sequence[][NUM_STEPS], int playbackStep, bool isPlaying,
|
||||
UIState currentState, bool songModeEnabled,
|
||||
int songRepeatsRemaining, bool sequenceChangeScheduled, PlayMode playMode,
|
||||
int numScaleNotes, const int* scaleNotes, const bool* trackMute) {
|
||||
int selectedTrack, int numScaleNotes, const int* scaleNotes, const bool* trackMute) {
|
||||
pixels.clear();
|
||||
|
||||
const uint32_t COLOR_PLAYHEAD = pixels.Color(0, 255, 0);
|
||||
@ -240,21 +239,22 @@ void UIManager::updateLeds(const Step sequence[][NUM_STEPS], int playbackStep, b
|
||||
}
|
||||
} else {
|
||||
// --- Mono Mode (original) ---
|
||||
const Step* trackSequence = sequence[selectedTrack];
|
||||
for (int s = 0; s < NUM_STEPS; s++) {
|
||||
int x = s % 8;
|
||||
int yBase = (s / 8) * 4;
|
||||
uint32_t color = 0, dimColor = 0;
|
||||
bool isCursorHere = (isPlaying && s == playbackStep);
|
||||
if (sequence[0][s].note != -1) {
|
||||
color = getNoteColor(sequence[0][s].note, sequence[0][s].tie);
|
||||
dimColor = getNoteColor(sequence[0][s].note, true);
|
||||
if (trackSequence[s].note != -1) {
|
||||
color = getNoteColor(trackSequence[s].note, trackSequence[s].tie);
|
||||
dimColor = getNoteColor(trackSequence[s].note, true);
|
||||
}
|
||||
uint32_t c[4] = {0};
|
||||
if (sequence[0][s].note != -1) {
|
||||
int octave = sequence[0][s].note / 12;
|
||||
if (octave > 4) { c[0] = color; if (sequence[0][s].accent) c[1] = dimColor; }
|
||||
else if (octave < 4) { c[2] = color; if (sequence[0][s].accent) c[1] = dimColor; }
|
||||
else { c[1] = color; if (sequence[0][s].accent) { c[0] = dimColor; c[2] = dimColor; } }
|
||||
if (trackSequence[s].note != -1) {
|
||||
int octave = trackSequence[s].note / 12;
|
||||
if (octave > 4) { c[0] = color; if (trackSequence[s].accent) c[1] = dimColor; }
|
||||
else if (octave < 4) { c[2] = color; if (trackSequence[s].accent) c[1] = dimColor; }
|
||||
else { c[1] = color; if (trackSequence[s].accent) { c[0] = dimColor; c[2] = dimColor; } }
|
||||
}
|
||||
uint32_t cursorColor = pixels.Color(0, 0, 50);
|
||||
if (isPlaying) {
|
||||
|
||||
12
UIManager.h
12
UIManager.h
@ -20,26 +20,22 @@ public:
|
||||
int numScaleNotes, const int* scaleNotes, int melodySeed,
|
||||
bool mutationEnabled, bool songModeEnabled,
|
||||
const Step sequence[][NUM_STEPS], int playbackStep, bool isPlaying,
|
||||
const char* mainMenu[], int mainMenuCount,
|
||||
const char* randomizeMenu[], int randomizeMenuCount,
|
||||
const char* setupMenu[], int setupMenuCount, int theme1Index,
|
||||
PlayMode playMode, int randomizeTrack, const bool* trackMute);
|
||||
int randomizeTrack, const bool* trackMute);
|
||||
|
||||
void updateLeds(const Step sequence[][NUM_STEPS], int playbackStep, bool isPlaying,
|
||||
UIState currentState, bool songModeEnabled,
|
||||
int songRepeatsRemaining, bool sequenceChangeScheduled, PlayMode playMode,
|
||||
int numScaleNotes, const int* scaleNotes, const bool* trackMute);
|
||||
int selectedTrack, int numScaleNotes, const int* scaleNotes, const bool* trackMute);
|
||||
|
||||
private:
|
||||
Adafruit_SSD1306 display;
|
||||
Adafruit_NeoPixel pixels;
|
||||
uint32_t leds_buffer[8][8]; // For piano roll
|
||||
|
||||
void drawMenu(const char* title, const char* items[], int count, int selection,
|
||||
UIState currentState, int midiChannel, int tempo, const char* flavourName,
|
||||
void drawMenu(int selection, UIState currentState, int midiChannel, int tempo, const char* flavourName,
|
||||
int queuedTheme, int currentThemeIndex,
|
||||
int numScaleNotes, const int* scaleNotes, int melodySeed,
|
||||
bool mutationEnabled, bool songModeEnabled, int theme1Index, PlayMode playMode, int randomizeTrack, const bool* trackMute);
|
||||
bool mutationEnabled, bool songModeEnabled, int randomizeTrack, const bool* trackMute);
|
||||
|
||||
uint32_t getNoteColor(int note, bool dim);
|
||||
int getPixelIndex(int x, int y);
|
||||
|
||||
93
UIThread.cpp
93
UIThread.cpp
@ -132,22 +132,18 @@ static void handleInput() {
|
||||
if (delta != 0) {
|
||||
switch(currentState) {
|
||||
case UI_MENU_MAIN:
|
||||
menuSelection += (delta > 0 ? 1 : -1);
|
||||
if (menuSelection < 0) menuSelection = mainMenuCount - 1;
|
||||
if (menuSelection >= mainMenuCount) menuSelection = 0;
|
||||
break;
|
||||
case UI_MENU_RANDOMIZE:
|
||||
{
|
||||
menuSelection += (delta > 0 ? 1 : -1);
|
||||
if (menuSelection < 0) menuSelection = randomizeMenuPolyCount - 1;
|
||||
if (menuSelection >= randomizeMenuPolyCount) menuSelection = 0;
|
||||
int next = menuSelection;
|
||||
int count = 0;
|
||||
do {
|
||||
next += (delta > 0 ? 1 : -1);
|
||||
if (next < 0) next = menuItemsCount - 1;
|
||||
if (next >= menuItemsCount) next = 0;
|
||||
count++;
|
||||
} while (!isItemVisible(next) && count < menuItemsCount);
|
||||
menuSelection = next;
|
||||
}
|
||||
break;
|
||||
case UI_MENU_SETUP:
|
||||
menuSelection += (delta > 0 ? 1 : -1);
|
||||
if (menuSelection < 0) menuSelection = setupMenuCount - 1;
|
||||
if (menuSelection >= setupMenuCount) menuSelection = 0;
|
||||
break;
|
||||
case UI_SETUP_CHANNEL_EDIT:
|
||||
{
|
||||
midiChannels[randomizeTrack] += (delta > 0 ? 1 : -1);
|
||||
@ -198,14 +194,13 @@ static void handleInput() {
|
||||
if (!buttonConsumed) { // Short press action
|
||||
switch(currentState) {
|
||||
case UI_MENU_MAIN:
|
||||
if (menuSelection == 0) { currentState = UI_MENU_RANDOMIZE; menuSelection = 0; break; }
|
||||
if (menuSelection == 1) { currentState = UI_MENU_SETUP; menuSelection = 0; break; }
|
||||
break;
|
||||
case UI_MENU_RANDOMIZE:
|
||||
{
|
||||
if (menuSelection == 0) { currentState = UI_MENU_SETUP; menuSelection = 0; break; }
|
||||
if (menuItems[menuSelection].isGroup) {
|
||||
menuItems[menuSelection].expanded = !menuItems[menuSelection].expanded;
|
||||
break;
|
||||
}
|
||||
|
||||
if (menuSelection == 1) { // Melody
|
||||
switch(menuItems[menuSelection].id) {
|
||||
case MENU_ID_MELODY:
|
||||
midi.lock();
|
||||
melodySeeds[randomizeTrack] = random(10000);
|
||||
if (isPlaying) {
|
||||
@ -219,8 +214,8 @@ static void handleInput() {
|
||||
midi.unlock();
|
||||
saveSequence(true);
|
||||
break;
|
||||
}
|
||||
if (menuSelection == 2) { // Scale
|
||||
|
||||
case MENU_ID_SCALE:
|
||||
generateRandomScale();
|
||||
if (isPlaying) {
|
||||
int theme = (queuedTheme != -1) ? queuedTheme : currentThemeIndex;
|
||||
@ -232,23 +227,27 @@ static void handleInput() {
|
||||
}
|
||||
saveSequence(true);
|
||||
break;
|
||||
}
|
||||
if (menuSelection == 3) { currentState = UI_EDIT_TEMPO; break; } // Tempo
|
||||
if (menuSelection == 4) { // Song Mode
|
||||
|
||||
case MENU_ID_TEMPO: currentState = UI_EDIT_TEMPO; break;
|
||||
|
||||
case MENU_ID_SONG_MODE:
|
||||
songModeEnabled = !songModeEnabled;
|
||||
if (songModeEnabled) {
|
||||
songModeNeedsNext = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (menuSelection == 5) { currentState = UI_RANDOMIZE_TRACK_EDIT; break; } // Track
|
||||
if (menuSelection == 6) { trackMute[randomizeTrack] = !trackMute[randomizeTrack]; break; } // Mute
|
||||
if (menuSelection == 7) { currentState = UI_EDIT_FLAVOUR; break; } // Flavour
|
||||
if (menuSelection == 8) { mutationEnabled = !mutationEnabled; break; } // Mutation
|
||||
case MENU_ID_TRACK_SELECT: currentState = UI_RANDOMIZE_TRACK_EDIT; break;
|
||||
case MENU_ID_MUTE: trackMute[randomizeTrack] = !trackMute[randomizeTrack]; break;
|
||||
case MENU_ID_FLAVOUR: currentState = UI_EDIT_FLAVOUR; break;
|
||||
case MENU_ID_MUTATION: mutationEnabled = !mutationEnabled; break;
|
||||
|
||||
if (menuSelection >= THEME_1_INDEX_POLY) { // Themes
|
||||
const int selectedTheme = menuSelection - THEME_1_INDEX_POLY + 1;
|
||||
case MENU_ID_CHANNEL: currentState = UI_SETUP_CHANNEL_EDIT; break;
|
||||
case MENU_ID_RESET: factoryReset(); break;
|
||||
|
||||
default:
|
||||
if (menuItems[menuSelection].id >= MENU_ID_THEME_1 && menuItems[menuSelection].id <= MENU_ID_THEME_7) {
|
||||
const int selectedTheme = menuItems[menuSelection].id - MENU_ID_THEME_1 + 1;
|
||||
if (isPlaying) {
|
||||
queuedTheme = selectedTheme;
|
||||
midi.lock();
|
||||
@ -260,23 +259,19 @@ static void handleInput() {
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case UI_MENU_SETUP:
|
||||
if (menuSelection == 0) { currentState = UI_MENU_RANDOMIZE; menuSelection = 0; break; }
|
||||
if (menuSelection == 1) { currentState = UI_SETUP_CHANNEL_EDIT; break; }
|
||||
if (menuSelection == 2) { factoryReset(); break; }
|
||||
break;
|
||||
case UI_SETUP_CHANNEL_EDIT:
|
||||
currentState = UI_MENU_SETUP;
|
||||
currentState = UI_MENU_MAIN;
|
||||
saveSequence(true);
|
||||
break;
|
||||
case UI_EDIT_TEMPO:
|
||||
currentState = UI_MENU_RANDOMIZE;
|
||||
currentState = UI_MENU_MAIN;
|
||||
saveSequence(true);
|
||||
break;
|
||||
case UI_EDIT_FLAVOUR:
|
||||
currentState = UI_MENU_RANDOMIZE;
|
||||
currentState = UI_MENU_MAIN;
|
||||
if (isPlaying) {
|
||||
int theme = (queuedTheme != -1) ? queuedTheme : currentThemeIndex;
|
||||
midi.lock();
|
||||
@ -290,7 +285,7 @@ static void handleInput() {
|
||||
saveSequence(true);
|
||||
break;
|
||||
case UI_RANDOMIZE_TRACK_EDIT:
|
||||
currentState = UI_MENU_RANDOMIZE;
|
||||
currentState = UI_MENU_MAIN;
|
||||
saveSequence(true);
|
||||
break;
|
||||
}
|
||||
@ -352,9 +347,7 @@ static void drawUI() {
|
||||
ui.draw(local_currentState, local_menuSelection,
|
||||
local_midiChannel, local_tempo, local_strategy,
|
||||
local_queuedTheme, local_currentThemeIndex, local_numScaleNotes, local_scaleNotes, local_melodySeed,
|
||||
local_mutationEnabled, local_songModeEnabled, (const Step (*)[NUM_STEPS])local_sequence, local_playbackStep, local_isPlaying,
|
||||
mainMenu, mainMenuCount, randomizeMenuPoly, randomizeMenuPolyCount, setupMenu, setupMenuCount,
|
||||
THEME_1_INDEX_POLY, MODE_POLY, local_randomizeTrack, (const bool*)local_trackMute);
|
||||
local_mutationEnabled, local_songModeEnabled, (const Step (*)[NUM_STEPS])local_sequence, local_playbackStep, local_isPlaying, local_randomizeTrack, (const bool*)local_trackMute);
|
||||
}
|
||||
|
||||
static void updateLeds() {
|
||||
@ -371,6 +364,7 @@ static void updateLeds() {
|
||||
int local_numScaleNotes;
|
||||
int local_scaleNotes[12];
|
||||
bool local_trackMute[NUM_TRACKS];
|
||||
int local_randomizeTrack;
|
||||
|
||||
midi.lock();
|
||||
memcpy(local_sequence, sequence, sizeof(local_sequence));
|
||||
@ -383,16 +377,17 @@ static void updateLeds() {
|
||||
local_sequenceChangeScheduled = sequenceChangeScheduled;
|
||||
local_playMode = playMode;
|
||||
local_numScaleNotes = numScaleNotes;
|
||||
local_randomizeTrack = randomizeTrack;
|
||||
memcpy(local_scaleNotes, scaleNotes, sizeof(local_scaleNotes));
|
||||
memcpy(local_trackMute, (const void*)trackMute, sizeof(local_trackMute));
|
||||
midi.unlock();
|
||||
|
||||
PlayMode ledDisplayMode = MODE_POLY; // Default to POLY (MAIN section view)
|
||||
|
||||
if (local_currentState == UI_MENU_RANDOMIZE) {
|
||||
// Main section items: Setup(0), Melody(1), Scale(2), Tempo(3), Song Mode(4)
|
||||
bool isMainSection = (local_menuSelection <= 4);
|
||||
if (!isMainSection) {
|
||||
if (local_currentState == UI_MENU_MAIN) {
|
||||
MenuItemID id = menuItems[local_menuSelection].id;
|
||||
// Check if we are in the Track group (IDs between TRACK_SELECT and THEME_7)
|
||||
if (id >= MENU_ID_TRACK_SELECT && id <= MENU_ID_THEME_7) {
|
||||
// It's a TRACK section item (Track, Mute, Flavour, Mutation, Themes)
|
||||
ledDisplayMode = MODE_MONO;
|
||||
}
|
||||
@ -403,7 +398,7 @@ static void updateLeds() {
|
||||
|
||||
ui.updateLeds((const Step (*)[NUM_STEPS])local_sequence, local_playbackStep, local_isPlaying,
|
||||
local_currentState, local_songModeEnabled, local_songRepeatsRemaining,
|
||||
local_sequenceChangeScheduled, ledDisplayMode, local_numScaleNotes,
|
||||
local_sequenceChangeScheduled, ledDisplayMode, local_randomizeTrack, local_numScaleNotes,
|
||||
local_scaleNotes, (const bool*)local_trackMute);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user