|
@@ -15,6 +15,32 @@
|
|
|
#define CENTER_Y ((int)(50))
|
|
|
#define NEUTRAL 2
|
|
|
|
|
|
+static void ui_sequencer_action(struct display_menu_entry *e, uint8_t b);
|
|
|
+static void ui_master_action(struct display_menu_entry *e, uint8_t b);
|
|
|
+static void ui_bpm_action(struct display_menu_entry *e, uint8_t b);
|
|
|
+static void ui_pattern_save_action(struct display_menu_entry *e, uint8_t b);
|
|
|
+static void main_menu_prepare(struct display_menu *m);
|
|
|
+extern struct display_menu PatternMenu;
|
|
|
+
|
|
|
+static void ui_submenu_action(struct display_menu_entry *e, uint8_t b)
|
|
|
+{
|
|
|
+ ui_display_menu(e->arg);
|
|
|
+}
|
|
|
+
|
|
|
+struct display_menu MainMenu = {
|
|
|
+ .entry_n = 7,
|
|
|
+ .render = main_menu_prepare,
|
|
|
+ .entry = {
|
|
|
+ { ENTRY_TYPE_BOOL, "Sequencer", ui_sequencer_action, .min = 0, .max = 0, .step = 0, NULL, .arg = NULL },
|
|
|
+ { ENTRY_TYPE_DEC, "Volume: ", ui_master_action, 0, 100, 2, NULL, NULL },
|
|
|
+ { ENTRY_TYPE_DEC, "BPM: ", ui_bpm_action, 30, 300, 1, NULL, NULL },
|
|
|
+ { ENTRY_TYPE_DEC, "Pattern :", NULL, 0, MAX_PATTERNS, 1, NULL, NULL },
|
|
|
+ { ENTRY_TYPE_DEC, "Pattern Len:", NULL, 8, MAX_PATTERN_LEN, 8, NULL, NULL },
|
|
|
+ { ENTRY_TYPE_TEXT, "Edit Pattern", ui_submenu_action, 0, 0, 0, NULL, &PatternMenu},
|
|
|
+ { ENTRY_TYPE_TEXT, "Save Pattern", ui_pattern_save_action, 0, 0, 0, NULL, NULL},
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
struct display_menu *CurrentMenu = &MainMenu;
|
|
|
|
|
|
extern volatile uint32_t jiffies;
|
|
@@ -197,6 +223,8 @@ static void ui_bpm_input(uint8_t press, int hold)
|
|
|
timer_stop();
|
|
|
timer_set_bpm();
|
|
|
led_beat(1);
|
|
|
+ settings_save();
|
|
|
+ timer_set_beat(1);
|
|
|
timer_set_beat(1);
|
|
|
timer_start();
|
|
|
}
|
|
@@ -207,6 +235,7 @@ static void ui_bpm_input(uint8_t press, int hold)
|
|
|
timer_stop();
|
|
|
timer_set_bpm(sys_bpm - 1);
|
|
|
led_beat(1);
|
|
|
+ settings_save();
|
|
|
timer_set_beat(1);
|
|
|
timer_start();
|
|
|
}
|
|
@@ -266,16 +295,6 @@ static void ui_bytebeat(const void *arg)
|
|
|
set_keepalive(ui_bytebeat_keepalive);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-const struct display_menu PatternMenu = {
|
|
|
- .entry_n = 1,
|
|
|
- .entry = {
|
|
|
- { "TODO! ", ui_submenu, &MainMenu},
|
|
|
- { "", NULL, NULL}
|
|
|
- }
|
|
|
-};
|
|
|
-
|
|
|
const struct display_menu DroneMenu = {
|
|
|
.entry_n = 2,
|
|
|
.entry = {
|
|
@@ -295,14 +314,10 @@ const struct display_menu SettingsMenu = {
|
|
|
|
|
|
#endif
|
|
|
|
|
|
-static void ui_submenu_action(struct display_menu_entry *e, uint8_t b)
|
|
|
-{
|
|
|
- ui_display_menu(e->arg);
|
|
|
-}
|
|
|
|
|
|
static void ui_sequencer_action(struct display_menu_entry *e, uint8_t b)
|
|
|
{
|
|
|
- if (Settings.sequencer_on) {
|
|
|
+ if (Settings->sequencer_on) {
|
|
|
timer_set_beat(1);
|
|
|
timer_start();
|
|
|
} else {
|
|
@@ -326,23 +341,27 @@ static void ui_bpm_action(struct display_menu_entry *e, uint8_t b)
|
|
|
timer_start();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-extern void ui_pattern_menu_action(struct display_menu_entry *e, uint8_t b);
|
|
|
-extern struct display_menu PatternMenu;
|
|
|
-const struct display_menu MainMenu = {
|
|
|
- .entry_n = 5,
|
|
|
- .entry = {
|
|
|
- /* TYPE, label, action, min, max, var, arg */
|
|
|
- { ENTRY_TYPE_BOOL, "Sequencer", ui_sequencer_action, 0, 0, 0, &Settings.sequencer_on, NULL },
|
|
|
- { ENTRY_TYPE_DEC, "Volume: ", ui_master_action, 0, 100, 2, &Settings.levels[2], NULL },
|
|
|
- { ENTRY_TYPE_DEC, "BPM: ", ui_bpm_action, 30, 300, 1, &Settings.bpm, NULL },
|
|
|
- { ENTRY_TYPE_DEC, "Pattern Len:", NULL, 8, MAX_PATTERN_LEN, 8, &Settings.pattern_len, NULL },
|
|
|
- { ENTRY_TYPE_TEXT, "Edit Pattern", ui_pattern_menu_action, 0, 0, 0, NULL, &PatternMenu},
|
|
|
- {0, "", NULL, 0,0,0,NULL,NULL}
|
|
|
- }
|
|
|
-};
|
|
|
+static void ui_pattern_save_action(struct display_menu_entry *e, uint8_t b)
|
|
|
+{
|
|
|
+ display_clear();
|
|
|
+ display_scroll(NULL, 0);
|
|
|
+ display_text(5, "Saving to FLASH");
|
|
|
+ settings_save();
|
|
|
+ ui_display_menu(&MainMenu);
|
|
|
+}
|
|
|
|
|
|
|
|
|
+static void main_menu_prepare(struct display_menu *m)
|
|
|
+{
|
|
|
+ if (m != &MainMenu)
|
|
|
+ return;
|
|
|
+ MainMenu.entry[0].var = &Settings->sequencer_on;
|
|
|
+ MainMenu.entry[1].var = &Settings->levels[2];
|
|
|
+ MainMenu.entry[2].var = &Settings->bpm;
|
|
|
+ MainMenu.entry[3].var = &Settings->current_pattern;
|
|
|
+ MainMenu.entry[4].var = &(Settings->drums[Settings->current_pattern].len);
|
|
|
+}
|
|
|
|
|
|
|
|
|
+extern void ui_pattern_menu_action(struct display_menu_entry *e, uint8_t b);
|
|
|
|