Add pulse output configuration.
This commit is contained in:
@ -101,6 +101,33 @@ void HandleIntClockTick(uint32_t tick) {
|
||||
}
|
||||
}
|
||||
|
||||
// Pulse Out gate
|
||||
if (app.selected_pulse != Clock::PULSE_NONE) {
|
||||
int clock_index;
|
||||
switch(app.selected_pulse) {
|
||||
case Clock::PULSE_PPQN_24:
|
||||
clock_index = 0;
|
||||
break;
|
||||
case Clock::PULSE_PPQN_4:
|
||||
clock_index = 4;
|
||||
break;
|
||||
case Clock::PULSE_PPQN_1:
|
||||
clock_index = 7;
|
||||
break;
|
||||
}
|
||||
|
||||
const uint16_t pulse_high_ticks = clock_mod_pulses[clock_index];
|
||||
const uint16_t pulse_low_ticks = tick + max((long)(pulse_high_ticks * 0.5), 1L);
|
||||
|
||||
if (tick % pulse_high_ticks == 0) {
|
||||
gravity.pulse.High();
|
||||
}
|
||||
if (pulse_low_ticks % pulse_high_ticks == 0) {
|
||||
gravity.pulse.Low();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!app.editing_param) {
|
||||
app.refresh_screen |= refresh;
|
||||
}
|
||||
@ -197,6 +224,10 @@ void editMainParameter(int val) {
|
||||
gravity.clock.SetSource(app.selected_source);
|
||||
break;
|
||||
}
|
||||
case PARAM_MAIN_PULSE:
|
||||
byte pulse = static_cast<int>(app.selected_pulse);
|
||||
updateSelection(pulse, val, Clock::PULSE_LAST);
|
||||
app.selected_pulse = static_cast<Clock::Pulse>(pulse);
|
||||
case PARAM_MAIN_ENCODER_DIR:
|
||||
updateSelection(app.selected_sub_param, val, 2);
|
||||
break;
|
||||
|
||||
@ -16,6 +16,7 @@ struct AppState {
|
||||
byte selected_channel = 0; // 0=tempo, 1-6=output channel
|
||||
byte selected_shuffle = 0;
|
||||
Clock::Source selected_source = Clock::SOURCE_INTERNAL;
|
||||
Clock::Pulse selected_pulse = Clock::PULSE_PPQN_24;
|
||||
Channel channel[Gravity::OUTPUT_COUNT];
|
||||
};
|
||||
|
||||
@ -28,6 +29,7 @@ static Channel& GetSelectedChannel() {
|
||||
enum ParamsMainPage {
|
||||
PARAM_MAIN_TEMPO,
|
||||
PARAM_MAIN_SOURCE,
|
||||
PARAM_MAIN_PULSE,
|
||||
PARAM_MAIN_ENCODER_DIR,
|
||||
PARAM_MAIN_RESET_STATE,
|
||||
PARAM_MAIN_LAST,
|
||||
|
||||
@ -68,16 +68,16 @@ static const unsigned char pause_icon[28] PROGMEM = {
|
||||
0x38, 0x0E, 0x00, 0x00};
|
||||
|
||||
// Constants for screen layout and fonts
|
||||
constexpr int SCREEN_CENTER_X = 32;
|
||||
constexpr int MAIN_TEXT_Y = 26;
|
||||
constexpr int SUB_TEXT_Y = 40;
|
||||
constexpr int VISIBLE_MENU_ITEMS = 3;
|
||||
constexpr int MENU_ITEM_HEIGHT = 14;
|
||||
constexpr int MENU_BOX_PADDING = 4;
|
||||
constexpr int MENU_BOX_WIDTH = 64;
|
||||
constexpr int CHANNEL_BOXES_Y = 50;
|
||||
constexpr int CHANNEL_BOX_WIDTH = 18;
|
||||
constexpr int CHANNEL_BOX_HEIGHT = 14;
|
||||
constexpr uint8_t SCREEN_CENTER_X = 32;
|
||||
constexpr uint8_t MAIN_TEXT_Y = 26;
|
||||
constexpr uint8_t SUB_TEXT_Y = 40;
|
||||
constexpr uint8_t VISIBLE_MENU_ITEMS = 3;
|
||||
constexpr uint8_t MENU_ITEM_HEIGHT = 14;
|
||||
constexpr uint8_t MENU_BOX_PADDING = 4;
|
||||
constexpr uint8_t MENU_BOX_WIDTH = 64;
|
||||
constexpr uint8_t CHANNEL_BOXES_Y = 50;
|
||||
constexpr uint8_t CHANNEL_BOX_WIDTH = 18;
|
||||
constexpr uint8_t CHANNEL_BOX_HEIGHT = 14;
|
||||
|
||||
// Helper function to draw centered text
|
||||
void drawCenteredText(const char* text, int y, const uint8_t* font) {
|
||||
@ -204,6 +204,23 @@ void DisplayMainPage() {
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case PARAM_MAIN_PULSE:
|
||||
mainText = F("OUT");
|
||||
switch (app.selected_pulse) {
|
||||
case Clock::PULSE_NONE:
|
||||
subText = F("PULSE OFF");
|
||||
break;
|
||||
case Clock::PULSE_PPQN_24:
|
||||
subText = F("24 PPQN PULSE");
|
||||
break;
|
||||
case Clock::PULSE_PPQN_4:
|
||||
subText = F("4 PPQN PULSE");
|
||||
break;
|
||||
case Clock::PULSE_PPQN_1:
|
||||
subText = F("1 PPQN PULSE");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case PARAM_MAIN_ENCODER_DIR:
|
||||
mainText = F("DIR");
|
||||
subText = app.selected_sub_param == 0 ? F("DEFAULT") : F("REVERSED");
|
||||
@ -218,7 +235,7 @@ void DisplayMainPage() {
|
||||
drawCenteredText(subText.c_str(), SUB_TEXT_Y, TEXT_FONT);
|
||||
|
||||
// Draw Main Page menu items
|
||||
String menu_items[PARAM_MAIN_LAST] = {F("TEMPO"), F("SOURCE"), F("ENCODER DIR"), F("RESET")};
|
||||
String menu_items[PARAM_MAIN_LAST] = {F("TEMPO"), F("SOURCE"), F("PULSE OUT"), F("ENCODER DIR"), F("RESET")};
|
||||
drawMenuItems(menu_items, PARAM_MAIN_LAST);
|
||||
}
|
||||
|
||||
|
||||
@ -17,6 +17,7 @@ bool StateManager::initialize(AppState& app) {
|
||||
app.selected_param = load_data.selected_param;
|
||||
app.selected_channel = load_data.selected_channel;
|
||||
app.selected_source = static_cast<Clock::Source>(load_data.selected_source);
|
||||
app.selected_pulse = static_cast<Clock::Pulse>(load_data.selected_pulse);
|
||||
|
||||
// Loop through and restore each channel's state.
|
||||
for (int i = 0; i < Gravity::OUTPUT_COUNT; i++) {
|
||||
@ -54,6 +55,7 @@ void StateManager::reset(AppState& app) {
|
||||
app.selected_param = 0;
|
||||
app.selected_channel = 0;
|
||||
app.selected_source = Clock::SOURCE_INTERNAL;
|
||||
app.selected_pulse = Clock::PULSE_PPQN_24;
|
||||
|
||||
for (int i = 0; i < Gravity::OUTPUT_COUNT; i++) {
|
||||
app.channel[i].Init();
|
||||
@ -97,6 +99,7 @@ void StateManager::_saveState(const AppState& app) {
|
||||
save_data.selected_param = app.selected_param;
|
||||
save_data.selected_channel = app.selected_channel;
|
||||
save_data.selected_source = static_cast<byte>(app.selected_source);
|
||||
save_data.selected_pulse = static_cast<byte>(app.selected_pulse);
|
||||
|
||||
// Loop through and populate each channel's state
|
||||
for (int i = 0; i < Gravity::OUTPUT_COUNT; i++) {
|
||||
|
||||
@ -54,6 +54,7 @@ class StateManager {
|
||||
byte selected_param;
|
||||
byte selected_channel;
|
||||
byte selected_source;
|
||||
byte selected_pulse;
|
||||
ChannelState channel_data[Gravity::OUTPUT_COUNT];
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user