Intensity setting
This commit is contained in:
+44
-4
@@ -50,10 +50,10 @@ 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 numSteps,
|
||||
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) {
|
||||
int randomizeTrack, const bool* trackMute, const int* trackIntensities) {
|
||||
|
||||
display.clearDisplay();
|
||||
display.setTextSize(1);
|
||||
@@ -62,7 +62,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, numSteps, mutationEnabled, songModeEnabled, isPlaying, randomizeTrack, trackMute);
|
||||
drawMenu(menuSelection, currentState, midiChannel, tempo, currentStrategy->getName(), queuedTheme, currentThemeIndex, numScaleNotes, scaleNotes, melodySeed, numSteps, mutationEnabled, songModeEnabled, isPlaying, randomizeTrack, trackMute, trackIntensities);
|
||||
break;
|
||||
case UI_SETUP_CHANNEL_EDIT:
|
||||
display.println(F("SET MIDI CHANNEL"));
|
||||
@@ -108,6 +108,9 @@ void UIManager::draw(UIState currentState, int menuSelection,
|
||||
display.setCursor(0, 50);
|
||||
display.println(F(" (Press to confirm)"));
|
||||
break;
|
||||
case UI_EDIT_INTENSITY:
|
||||
drawNumberEditor("SET INTENSITY", trackIntensities[randomizeTrack], 1, 10);
|
||||
break;
|
||||
case UI_RANDOMIZE_TRACK_EDIT:
|
||||
display.println(F("SET TRACK"));
|
||||
display.drawLine(0, 8, 128, 8, SSD1306_WHITE);
|
||||
@@ -202,10 +205,35 @@ void UIManager::draw(UIState currentState, int menuSelection,
|
||||
display.display();
|
||||
}
|
||||
|
||||
void UIManager::drawNumberEditor(const char* title, int value, int minVal, int maxVal) {
|
||||
display.println(title);
|
||||
display.drawLine(0, 8, 128, 8, SSD1306_WHITE);
|
||||
|
||||
// Display value
|
||||
display.setCursor(20, 20);
|
||||
display.setTextSize(2);
|
||||
display.print(value);
|
||||
|
||||
// Graphical bar
|
||||
int barWidth = 100;
|
||||
int barX = (SCREEN_WIDTH - barWidth) / 2;
|
||||
int barY = 40;
|
||||
int barHeight = 10;
|
||||
float percentage = (float)(value - minVal) / (maxVal - minVal);
|
||||
int fillWidth = (int)(percentage * barWidth);
|
||||
|
||||
display.drawRect(barX, barY, barWidth, barHeight, SSD1306_WHITE);
|
||||
display.fillRect(barX, barY, fillWidth, barHeight, SSD1306_WHITE);
|
||||
|
||||
display.setTextSize(1);
|
||||
display.setCursor(0, 54);
|
||||
display.println(F(" (Press to confirm)"));
|
||||
}
|
||||
|
||||
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, int numSteps, bool mutationEnabled,
|
||||
bool songModeEnabled, bool isPlaying, int randomizeTrack, const bool* trackMute) {
|
||||
bool songModeEnabled, bool isPlaying, int randomizeTrack, const bool* trackMute, const int* trackIntensities) {
|
||||
|
||||
// Calculate visual cursor position and scroll offset
|
||||
int visualCursor = 0;
|
||||
@@ -269,6 +297,18 @@ void UIManager::drawMenu(int selection, UIState currentState, int midiChannel, i
|
||||
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_INTENSITY) {
|
||||
display.print(F(": "));
|
||||
display.print(trackIntensities[randomizeTrack]);
|
||||
int val = trackIntensities[randomizeTrack];
|
||||
int barX = display.getCursorX() + 3;
|
||||
int barY = y + 2;
|
||||
int maxW = 20;
|
||||
int h = 5;
|
||||
uint16_t color = (i == selection) ? SSD1306_BLACK : SSD1306_WHITE;
|
||||
display.drawRect(barX, barY, maxW + 2, h, color);
|
||||
display.fillRect(barX + 1, barY + 1, (val * maxW) / 10, h - 2, color);
|
||||
}
|
||||
else if (id == MENU_ID_MUTATION) { display.print(F(": ")); display.print(mutationEnabled ? F("ON") : F("OFF")); }
|
||||
else if (id == MENU_ID_PROTECTED_MODE) { display.print(F(": ")); display.print(protectedMode ? F("ON") : F("OFF")); }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user