From 617251ffc2bd1f1a78ef4741f2fed56f3deed44c Mon Sep 17 00:00:00 2001 From: Dejvino Date: Thu, 19 Feb 2026 11:15:47 +0100 Subject: [PATCH] playback menu entry --- SharedState.cpp | 1 + SharedState.h | 1 + UIManager.cpp | 7 ++++--- UIManager.h | 2 +- UIThread.cpp | 10 ++++++++++ 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/SharedState.cpp b/SharedState.cpp index 7b3047b..5be1abf 100644 --- a/SharedState.cpp +++ b/SharedState.cpp @@ -17,6 +17,7 @@ UIState currentState = UI_MENU_MAIN; // Menus MenuItem menuItems[] = { { "Main", MENU_ID_GROUP_MAIN, true, true, 0 }, + { "Playback", MENU_ID_PLAYBACK, false, false, 1 }, { "Melody", MENU_ID_MELODY, false, false, 1 }, { "Scale", MENU_ID_SCALE, false, false, 1 }, { "Tempo", MENU_ID_TEMPO, false, false, 1 }, diff --git a/SharedState.h b/SharedState.h index 413e15f..9b18064 100644 --- a/SharedState.h +++ b/SharedState.h @@ -16,6 +16,7 @@ extern UIState currentState; // Menus enum MenuItemID { MENU_ID_GROUP_MAIN, + MENU_ID_PLAYBACK, MENU_ID_MELODY, MENU_ID_SCALE, MENU_ID_TEMPO, diff --git a/UIManager.cpp b/UIManager.cpp index 322df12..b72874f 100644 --- a/UIManager.cpp +++ b/UIManager.cpp @@ -61,7 +61,7 @@ void UIManager::draw(UIState currentState, int menuSelection, switch(currentState) { case UI_MENU_MAIN: - drawMenu(menuSelection, currentState, midiChannel, tempo, currentStrategy->getName(), queuedTheme, currentThemeIndex, numScaleNotes, scaleNotes, melodySeed, mutationEnabled, songModeEnabled, randomizeTrack, trackMute); + drawMenu(menuSelection, currentState, midiChannel, tempo, currentStrategy->getName(), queuedTheme, currentThemeIndex, numScaleNotes, scaleNotes, melodySeed, mutationEnabled, songModeEnabled, isPlaying, randomizeTrack, trackMute); break; case UI_SETUP_CHANNEL_EDIT: display.println(F("SET MIDI CHANNEL")); @@ -114,7 +114,7 @@ void UIManager::draw(UIState currentState, int menuSelection, 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 randomizeTrack, const bool* trackMute) { + bool songModeEnabled, bool isPlaying, int randomizeTrack, const bool* trackMute) { // Calculate visual cursor position and scroll offset int visualCursor = 0; @@ -160,7 +160,8 @@ void UIManager::drawMenu(int selection, UIState currentState, int midiChannel, i } // Dynamic values - if (id == MENU_ID_MELODY) { + if (id == MENU_ID_PLAYBACK) { display.print(F(": ")); display.print(isPlaying ? F("ON") : F("OFF")); } + else if (id == MENU_ID_MELODY) { display.print(F(": ")); display.print(melodySeed); } else if (id == MENU_ID_SCALE) { display.print(F(": ")); diff --git a/UIManager.h b/UIManager.h index 344beec..31a00b2 100644 --- a/UIManager.h +++ b/UIManager.h @@ -35,7 +35,7 @@ private: 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 randomizeTrack, const bool* trackMute); + bool mutationEnabled, bool songModeEnabled, bool isPlaying, int randomizeTrack, const bool* trackMute); uint32_t getNoteColor(int note, bool dim); int getPixelIndex(int x, int y); diff --git a/UIThread.cpp b/UIThread.cpp index dc0b4a5..977932d 100644 --- a/UIThread.cpp +++ b/UIThread.cpp @@ -200,6 +200,16 @@ static void handleInput() { } switch(menuItems[menuSelection].id) { + case MENU_ID_PLAYBACK: + isPlaying = !isPlaying; + if (isPlaying) { + playbackStep = 0; + clockCount = 0; + lastClockTime = micros(); + } else { + queuedTheme = -1; + } + break; case MENU_ID_MELODY: midi.lock(); melodySeeds[randomizeTrack] = random(10000);