Play and Setup menu only and no Tracker

This commit is contained in:
Dejvino
2026-02-18 19:08:04 +01:00
parent 5ea0070283
commit da30471f31
5 changed files with 45 additions and 195 deletions
+10 -93
View File
@@ -44,32 +44,29 @@ void UIManager::showMessage(const char* msg) {
delay(500);
display.setTextSize(1);
}
void UIManager::draw(UIState currentState, int menuSelection, int navSelection, EditMode editMode,
void UIManager::draw(UIState currentState, int menuSelection,
int midiChannel, int tempo, MelodyStrategy* currentStrategy,
int queuedTheme, int currentThemeIndex,
int numScaleNotes, const int* scaleNotes, int melodySeed,
bool mutationEnabled, bool songModeEnabled,
const Step sequence[][NUM_STEPS], int scrollOffset, int playbackStep, bool isPlaying,
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 currentTrack, int randomizeTrack, const bool* trackMute) {
PlayMode playMode, int randomizeTrack, const bool* trackMute) {
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 0);
switch(currentState) {
case UI_TRACKER:
drawTracker(navSelection, editMode, midiChannel, sequence, scrollOffset, playbackStep, isPlaying, playMode, currentTrack);
break;
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:
drawMenu("RANDOMIZE", randomizeMenu, randomizeMenuCount, menuSelection, currentState, midiChannel, tempo, currentStrategy->getName(), queuedTheme, currentThemeIndex, numScaleNotes, scaleNotes, melodySeed, mutationEnabled, songModeEnabled, theme1Index, playMode, randomizeTrack, trackMute);
drawMenu("PLAY", 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);
@@ -197,81 +194,6 @@ void UIManager::drawMenu(const char* title, const char* items[], int count, int
}
}
void UIManager::drawTracker(int navSelection, EditMode editMode, int midiChannel,
const Step sequence[][NUM_STEPS], int scrollOffset, int playbackStep, bool isPlaying,
PlayMode playMode, int currentTrack) {
display.print(F("SEQ "));
if (playMode == MODE_POLY) {
switch(editMode) {
case NAV_STEP: display.print(F("[STP]")); break;
case NAV_TRACK: display.print(F("[TRK]")); break;
case EDIT_NOTE: display.print(F("[EDT]")); break;
}
} else {
if (navSelection > 0 && editMode == EDIT_NOTE) display.print(F("[EDT]"));
else display.print(F("[NAV]"));
}
display.print(F(" CH:")); display.print(midiChannel);
display.println();
display.drawLine(0, 8, 128, 8, SSD1306_WHITE);
int y = 10;
for (int i = 0; i < 6; i++) {
int itemIndex = i + scrollOffset;
if (itemIndex > NUM_STEPS) break;
if (itemIndex == navSelection && editMode != NAV_TRACK) {
display.fillRect(0, y, 128, 8, SSD1306_WHITE);
display.setTextColor(SSD1306_BLACK, SSD1306_WHITE);
} else {
display.setTextColor(SSD1306_WHITE);
}
display.setCursor(2, y);
if (itemIndex == 0) {
display.print(F(">> MENU"));
} else {
int stepIndex = itemIndex - 1;
bool isPlayback = isPlaying && (stepIndex == playbackStep);
if (isPlayback && editMode != NAV_TRACK) {
if (itemIndex == navSelection) display.setTextColor(SSD1306_WHITE, SSD1306_BLACK); // Cursor on playback row
else display.setTextColor(SSD1306_BLACK, SSD1306_WHITE);
}
if (stepIndex < 10) display.print(F("0"));
display.print(stepIndex);
if (isPlayback && editMode != NAV_TRACK) {
if (itemIndex == navSelection) display.setTextColor(SSD1306_BLACK, SSD1306_WHITE);
else display.setTextColor(SSD1306_WHITE);
}
display.print(F(" | "));
int tracksToShow = (playMode == MODE_POLY) ? NUM_TRACKS : 1;
for(int t=0; t<tracksToShow; t++) {
if (playMode == MODE_POLY && t == currentTrack && (editMode == NAV_TRACK || (editMode == EDIT_NOTE && itemIndex == navSelection))) {
display.fillRect(display.getCursorX(), y, 28, 8, SSD1306_WHITE);
display.setTextColor(SSD1306_BLACK, SSD1306_WHITE);
} else if (itemIndex == navSelection && editMode != NAV_TRACK) {
display.setTextColor(SSD1306_BLACK, SSD1306_WHITE);
} else {
display.setTextColor(SSD1306_WHITE);
}
int n = sequence[t][stepIndex].note;
if (n == -1) {
display.print(F(" ---"));
} else {
const char* noteNames[] = {"C-", "C#", "D-", "D#", "E-", "F-", "F#", "G-", "G#", "A-", "A#", "B-"};
display.print(noteNames[n % 12]);
display.print(n / 12 - 1);
}
display.print(" ");
}
}
y += 9;
}
}
uint32_t UIManager::getNoteColor(int note, bool dim) {
if (note == -1) return 0;
uint16_t hue = 30000 + (note % 12) * 3628;
@@ -282,9 +204,9 @@ int UIManager::getPixelIndex(int x, int y) {
return y * 8 + x;
}
void UIManager::updateLeds(const Step sequence[][NUM_STEPS], int navSelection, int playbackStep, bool isPlaying,
UIState currentState, EditMode editMode, bool songModeEnabled,
int songRepeatsRemaining, bool sequenceChangeScheduled, PlayMode playMode, int currentTrack,
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) {
pixels.clear();
@@ -313,8 +235,6 @@ void UIManager::updateLeds(const Step sequence[][NUM_STEPS], int navSelection, i
} else {
color = (note != -1) ? COLOR_PLAYHEAD : COLOR_PLAYHEAD_DIM;
}
} else if (!isPlaying && currentState == UI_TRACKER && (navSelection - 1) == s && currentTrack == t) {
color = (note != -1) ? COLOR_CURSOR : COLOR_CURSOR_DIM;
}
pixels.setPixelColor(getPixelIndex(col, row), color);
@@ -337,7 +257,6 @@ void UIManager::updateLeds(const Step sequence[][NUM_STEPS], int navSelection, i
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; } }
}
int stepNavIndex = navSelection - 1;
uint32_t cursorColor = 0;
if (isPlaying) {
cursorColor = pixels.Color(0, 50, 0);
@@ -345,11 +264,9 @@ void UIManager::updateLeds(const Step sequence[][NUM_STEPS], int navSelection, i
int repeats = min(songRepeatsRemaining, 8);
if (x >= (8 - repeats)) cursorColor = (songRepeatsRemaining == 1 && x == 7 && (millis()/250)%2) ? pixels.Color(255, 200, 0) : pixels.Color(100, 220, 40);
}
} else if (currentState == UI_TRACKER) {
cursorColor = (editMode == EDIT_NOTE) ? pixels.Color(50, 0, 0) : pixels.Color(40, 40, 40);
}
bool isCursorHere = (isPlaying && s == playbackStep) || (!isPlaying && currentState == UI_TRACKER && s == stepNavIndex);
bool isCursorHere = (isPlaying && s == playbackStep);
if (cursorColor != 0) {
if (isCursorHere) c[3] = cursorColor;
else {