Add cv run reset options to main menu

This commit is contained in:
2025-08-08 09:03:09 -07:00
parent b6402380c0
commit f969482426
3 changed files with 64 additions and 3 deletions

View File

@ -95,6 +95,8 @@ void loop() {
int cv1 = gravity.cv1.Read(); int cv1 = gravity.cv1.Read();
int cv2 = gravity.cv2.Read(); int cv2 = gravity.cv2.Read();
CheckRunReset(cv1, cv2);
for (int i = 0; i < Gravity::OUTPUT_COUNT; i++) { for (int i = 0; i < Gravity::OUTPUT_COUNT; i++) {
auto& ch = app.channel[i]; auto& ch = app.channel[i];
// Only apply CV to the channel when the current channel has cv // Only apply CV to the channel when the current channel has cv
@ -171,6 +173,25 @@ void HandleExtClockTick() {
app.refresh_screen = true; app.refresh_screen = true;
} }
void CheckRunReset(int cv1, int cv2) {
if (app.cv_run == 1 && cv1 > 255 && !gravity.clock.IsPaused()) {
gravity.clock.Stop();
} else if (app.cv_run == 1 && cv1 < 255 && gravity.clock.IsPaused()) {
gravity.clock.Start();
} else if (app.cv_run == 2 && cv2 > 255 && !gravity.clock.IsPaused()) {
gravity.clock.Stop();
} else if (app.cv_run == 2 && cv2 < 255 && gravity.clock.IsPaused()) {
gravity.clock.Start();
}
// Clock Reset
if (app.cv_reset == 1 && cv1 > 255) {
gravity.clock.Reset();
} else if (app.cv_reset == 2 && cv2 < 255) {
gravity.clock.Reset();
}
}
// //
// UI handlers for encoder and buttons. // UI handlers for encoder and buttons.
// //
@ -282,6 +303,14 @@ void editMainParameter(int val) {
gravity.clock.SetTempo(gravity.clock.Tempo() + val); gravity.clock.SetTempo(gravity.clock.Tempo() + val);
app.tempo = gravity.clock.Tempo(); app.tempo = gravity.clock.Tempo();
break; break;
case PARAM_MAIN_RUN:
updateSelection(app.selected_sub_param, val, 3);
app.cv_run = app.selected_sub_param;
break;
case PARAM_MAIN_RESET:
updateSelection(app.selected_sub_param, val, 3);
app.cv_reset = app.selected_sub_param;
break;
case PARAM_MAIN_SOURCE: { case PARAM_MAIN_SOURCE: {
byte source = static_cast<int>(app.selected_source); byte source = static_cast<int>(app.selected_source);
updateSelection(source, val, Clock::SOURCE_LAST); updateSelection(source, val, Clock::SOURCE_LAST);

View File

@ -25,6 +25,8 @@ struct AppState {
byte selected_channel = 0; // 0=tempo, 1-6=output channel byte selected_channel = 0; // 0=tempo, 1-6=output channel
byte selected_swing = 0; byte selected_swing = 0;
byte selected_save_slot = 0; // The currently active save slot. byte selected_save_slot = 0; // The currently active save slot.
byte cv_run = 0;
byte cv_reset = 0;
Clock::Source selected_source = Clock::SOURCE_INTERNAL; Clock::Source selected_source = Clock::SOURCE_INTERNAL;
Clock::Pulse selected_pulse = Clock::PULSE_PPQN_24; Clock::Pulse selected_pulse = Clock::PULSE_PPQN_24;
bool editing_param = false; bool editing_param = false;

View File

@ -100,6 +100,8 @@ constexpr uint8_t CHANNEL_BOX_HEIGHT = 14;
enum ParamsMainPage : uint8_t { enum ParamsMainPage : uint8_t {
PARAM_MAIN_TEMPO, PARAM_MAIN_TEMPO,
PARAM_MAIN_SOURCE, PARAM_MAIN_SOURCE,
PARAM_MAIN_RUN,
PARAM_MAIN_RESET,
PARAM_MAIN_PULSE, PARAM_MAIN_PULSE,
PARAM_MAIN_ENCODER_DIR, PARAM_MAIN_ENCODER_DIR,
PARAM_MAIN_SAVE_DATA, PARAM_MAIN_SAVE_DATA,
@ -260,6 +262,34 @@ void DisplayMainPage() {
break; break;
} }
break; break;
case PARAM_MAIN_RUN:
mainText = F("RUN SRC");
switch (app.selected_sub_param) {
case 0:
subText = F("NONE");
break;
case 1:
subText = F("CV 1");
break;
case 2:
subText = F("CV 2");
break;
}
break;
case PARAM_MAIN_RESET:
mainText = F("RST SRC");
switch (app.selected_sub_param) {
case 0:
subText = F("NONE");
break;
case 1:
subText = F("CV 1");
break;
case 2:
subText = F("CV 2");
break;
}
break;
case PARAM_MAIN_PULSE: case PARAM_MAIN_PULSE:
mainText = F("OUT"); mainText = F("OUT");
switch (app.selected_pulse) { switch (app.selected_pulse) {
@ -321,7 +351,7 @@ void DisplayMainPage() {
drawCenteredText(subText.c_str(), SUB_TEXT_Y, TEXT_FONT); drawCenteredText(subText.c_str(), SUB_TEXT_Y, TEXT_FONT);
// Draw Main Page menu items // Draw Main Page menu items
String menu_items[PARAM_MAIN_LAST] = {F("TEMPO"), F("SOURCE"), F("PULSE OUT"), F("ENCODER DIR"), F("SAVE"), F("LOAD"), F("RESET"), F("ERASE")}; String menu_items[PARAM_MAIN_LAST] = {F("TEMPO"), F("SOURCE"), F("CLK RUN"), F("CLK RESET"), F("PULSE OUT"), F("ENCODER DIR"), F("SAVE"), F("LOAD"), F("RESET"), F("ERASE")};
drawMenuItems(menu_items, PARAM_MAIN_LAST); drawMenuItems(menu_items, PARAM_MAIN_LAST);
} }
@ -465,7 +495,7 @@ void UpdateDisplay() {
DisplayChannelPage(); DisplayChannelPage();
} }
// Global channel select UI. // Global channel select UI.
DisplaySelectedChannel(); DisplaySelectedChannel();
} while (gravity.display.nextPage()); } while (gravity.display.nextPage());
} }