playback menu entry

This commit is contained in:
Dejvino 2026-02-19 11:15:47 +01:00
parent d70e30d76f
commit 617251ffc2
5 changed files with 17 additions and 4 deletions

View File

@ -17,6 +17,7 @@ UIState currentState = UI_MENU_MAIN;
// Menus // Menus
MenuItem menuItems[] = { MenuItem menuItems[] = {
{ "Main", MENU_ID_GROUP_MAIN, true, true, 0 }, { "Main", MENU_ID_GROUP_MAIN, true, true, 0 },
{ "Playback", MENU_ID_PLAYBACK, false, false, 1 },
{ "Melody", MENU_ID_MELODY, false, false, 1 }, { "Melody", MENU_ID_MELODY, false, false, 1 },
{ "Scale", MENU_ID_SCALE, false, false, 1 }, { "Scale", MENU_ID_SCALE, false, false, 1 },
{ "Tempo", MENU_ID_TEMPO, false, false, 1 }, { "Tempo", MENU_ID_TEMPO, false, false, 1 },

View File

@ -16,6 +16,7 @@ extern UIState currentState;
// Menus // Menus
enum MenuItemID { enum MenuItemID {
MENU_ID_GROUP_MAIN, MENU_ID_GROUP_MAIN,
MENU_ID_PLAYBACK,
MENU_ID_MELODY, MENU_ID_MELODY,
MENU_ID_SCALE, MENU_ID_SCALE,
MENU_ID_TEMPO, MENU_ID_TEMPO,

View File

@ -61,7 +61,7 @@ void UIManager::draw(UIState currentState, int menuSelection,
switch(currentState) { switch(currentState) {
case UI_MENU_MAIN: 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; break;
case UI_SETUP_CHANNEL_EDIT: case UI_SETUP_CHANNEL_EDIT:
display.println(F("SET MIDI CHANNEL")); 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, void UIManager::drawMenu(int selection, UIState currentState, int midiChannel, int tempo, const char* flavourName,
int queuedTheme, int currentThemeIndex, int numScaleNotes, int queuedTheme, int currentThemeIndex, int numScaleNotes,
const int* scaleNotes, int melodySeed, bool mutationEnabled, 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 // Calculate visual cursor position and scroll offset
int visualCursor = 0; int visualCursor = 0;
@ -160,7 +160,8 @@ void UIManager::drawMenu(int selection, UIState currentState, int midiChannel, i
} }
// Dynamic values // 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); display.print(F(": ")); display.print(melodySeed);
} else if (id == MENU_ID_SCALE) { } else if (id == MENU_ID_SCALE) {
display.print(F(": ")); display.print(F(": "));

View File

@ -35,7 +35,7 @@ private:
void drawMenu(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 queuedTheme, int currentThemeIndex,
int numScaleNotes, const int* scaleNotes, int melodySeed, 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); uint32_t getNoteColor(int note, bool dim);
int getPixelIndex(int x, int y); int getPixelIndex(int x, int y);

View File

@ -200,6 +200,16 @@ static void handleInput() {
} }
switch(menuItems[menuSelection].id) { 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: case MENU_ID_MELODY:
midi.lock(); midi.lock();
melodySeeds[randomizeTrack] = random(10000); melodySeeds[randomizeTrack] = random(10000);