Fix deadlock in loading + configurable steps count

This commit is contained in:
Dejvino
2026-02-19 13:34:06 +01:00
parent 617251ffc2
commit 46ecc57cde
9 changed files with 72 additions and 20 deletions
+20 -4
View File
@@ -49,7 +49,7 @@ void UIManager::showMessage(const char* msg) {
void UIManager::draw(UIState currentState, int menuSelection,
int midiChannel, int tempo, MelodyStrategy* currentStrategy,
int queuedTheme, int currentThemeIndex,
int numScaleNotes, const int* scaleNotes, int melodySeed,
int numScaleNotes, const int* scaleNotes, int melodySeed, int numSteps,
bool mutationEnabled, bool songModeEnabled,
const Step sequence[][NUM_STEPS], int playbackStep, bool isPlaying,
int randomizeTrack, const bool* trackMute) {
@@ -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, isPlaying, randomizeTrack, trackMute);
drawMenu(menuSelection, currentState, midiChannel, tempo, currentStrategy->getName(), queuedTheme, currentThemeIndex, numScaleNotes, scaleNotes, melodySeed, numSteps, mutationEnabled, songModeEnabled, isPlaying, randomizeTrack, trackMute);
break;
case UI_SETUP_CHANNEL_EDIT:
display.println(F("SET MIDI CHANNEL"));
@@ -86,6 +86,17 @@ void UIManager::draw(UIState currentState, int menuSelection,
display.setCursor(0, 50);
display.println(F(" (Press to confirm)"));
break;
case UI_EDIT_STEPS:
display.println(F("SET STEPS"));
display.drawLine(0, 8, 128, 8, SSD1306_WHITE);
display.setCursor(20, 25);
display.setTextSize(2);
display.print(F("LEN: "));
display.print(numSteps);
display.setTextSize(1);
display.setCursor(0, 50);
display.println(F(" (Press to confirm)"));
break;
case UI_EDIT_FLAVOUR:
display.println(F("SET FLAVOUR"));
display.drawLine(0, 8, 128, 8, SSD1306_WHITE);
@@ -113,7 +124,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,
const int* scaleNotes, int melodySeed, int numSteps, bool mutationEnabled,
bool songModeEnabled, bool isPlaying, int randomizeTrack, const bool* trackMute) {
// Calculate visual cursor position and scroll offset
@@ -173,6 +184,7 @@ void UIManager::drawMenu(int selection, UIState currentState, int midiChannel, i
}
}
} else if (id == MENU_ID_TEMPO) { display.print(F(": ")); display.print(tempo); }
else if (id == MENU_ID_STEPS) { display.print(F(": ")); display.print(numSteps); }
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")); }
@@ -205,7 +217,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 selectedTrack, int numScaleNotes, const int* scaleNotes, const bool* trackMute) {
int selectedTrack, int numSteps, int numScaleNotes, const int* scaleNotes, const bool* trackMute) {
pixels.clear();
const uint32_t COLOR_PLAYHEAD = pixels.Color(0, 255, 0);
@@ -217,6 +229,8 @@ void UIManager::updateLeds(const Step sequence[][NUM_STEPS], int playbackStep, b
if(playMode == MODE_POLY) {
for(int t=0; t<NUM_TRACKS; t++) {
for(int s=0; s<NUM_STEPS; s++) {
if (s >= numSteps) continue;
int row = t * 2 + (s / 8);
int col = s % 8;
@@ -242,6 +256,8 @@ void UIManager::updateLeds(const Step sequence[][NUM_STEPS], int playbackStep, b
// --- Mono Mode (original) ---
const Step* trackSequence = sequence[selectedTrack];
for (int s = 0; s < NUM_STEPS; s++) {
if (s >= numSteps) continue;
int x = s % 8;
int yBase = (s / 8) * 4;
uint32_t color = 0, dimColor = 0;