diff --git a/midi2cv/menu/menu.cc b/midi2cv/menu/menu.cc index 1d8b9ae..ff812f4 100644 --- a/midi2cv/menu/menu.cc +++ b/midi2cv/menu/menu.cc @@ -12,7 +12,7 @@ void Menu::render(u8g2_t* u8g2_, uint8_t xStart, uint8_t yStart, uint8_t width, uint8_t maxVisibleItems = height / kMenuItemHeight; uint8_t itemsToRender = std::min(maxVisibleItems, uint8_t(this->itemCount - currentScrollStart)); - u8g2_SetFont(u8g2_, u8g2_font_6x12_tf); + u8g2_SetFont(u8g2_, u8g2_font_6x10_tf); for (uint8_t i = 0; i < itemsToRender; i++) { bool selected = this->selectedItem == (i + this->currentScrollStart); bool editing = this->currentEditingItem == (i + this->currentScrollStart); diff --git a/midi2cv/menu/menu_items.h b/midi2cv/menu/menu_items.h index f9e7339..fd315ca 100644 --- a/midi2cv/menu/menu_items.h +++ b/midi2cv/menu/menu_items.h @@ -102,6 +102,56 @@ class UIntMenuItem : public NumberMenuItem { : NumberMenuItem(_label, _initialValue, _minimumValue, _maximumValue, _step) {}; }; +class IntMenuItem : public NumberMenuItem { + private: + protected: + const char* get_format_string() + { + return "%d"; + } + + public: + IntMenuItem(const char* _label, int32_t _initialValue, int32_t _minimumValue, int32_t _maximumValue, int32_t _step) + : NumberMenuItem(_label, _initialValue, _minimumValue, _maximumValue, _step) {}; +}; + +class FloatMenuItem : public NumberMenuItem { + private: + protected: + const char* get_format_string() + { + return "%.2f"; + } + + public: + FloatMenuItem(const char* _label, float _initialValue, float _minimumValue, float _maximumValue, float _step) + : NumberMenuItem(_label, _initialValue, _minimumValue, _maximumValue, _step) {}; +}; + +class BoolMenuItem : public NumberMenuItem { + + private: + const char* on_string; + const char* off_string; + + protected: + const char* get_format_string() + { + bool value = this->get_value(); + + if (value) + return this->on_string; + else + return this->off_string; + } + + public: + BoolMenuItem(const char* _label, bool _initialValue, const char* _on_string, const char* _off_string) + : NumberMenuItem(_label, _initialValue, 0, 1, 1) + , on_string(_on_string) + , off_string(_off_string) {}; +}; + class MidiNoteMenuItem : public NumberMenuItem { private: char string_buffer[4]; @@ -139,29 +189,3 @@ class MidiNoteMenuItem : public NumberMenuItem { note_strings[11] = "B"; }; }; - -class IntMenuItem : public NumberMenuItem { - private: - protected: - const char* get_format_string() - { - return "%d"; - } - - public: - IntMenuItem(const char* _label, int32_t _initialValue, int32_t _minimumValue, int32_t _maximumValue, int32_t _step) - : NumberMenuItem(_label, _initialValue, _minimumValue, _maximumValue, _step) {}; -}; - -class FloatMenuItem : public NumberMenuItem { - private: - protected: - const char* get_format_string() - { - return "%.2f"; - } - - public: - FloatMenuItem(const char* _label, float _initialValue, float _minimumValue, float _maximumValue, float _step) - : NumberMenuItem(_label, _initialValue, _minimumValue, _maximumValue, _step) {}; -}; diff --git a/midi2cv/ui/main_menu.cc b/midi2cv/ui/main_menu.cc index 9620670..0aa0dd4 100644 --- a/midi2cv/ui/main_menu.cc +++ b/midi2cv/ui/main_menu.cc @@ -66,5 +66,7 @@ void MainMenu::render(u8g2_t* u8g2, int x, int y, int width, int height) u8g2_SetDrawColor(u8g2, 1); } - this->partMenus[this->selectedPart].render(u8g2, x, y + kHeaderHeight, width, height - kHeaderHeight); + u8g2_DrawHLine(u8g2, 0, kHeaderHeight + 1, width); + + this->partMenus[this->selectedPart].render(u8g2, x, y + kHeaderHeight + 3, width, height - kHeaderHeight - 3); } diff --git a/midi2cv/ui/part_menu.cc b/midi2cv/ui/part_menu.cc index 0f36c85..d478da6 100644 --- a/midi2cv/ui/part_menu.cc +++ b/midi2cv/ui/part_menu.cc @@ -5,12 +5,12 @@ PartMenu::PartMenu() : menu(128, 64) - , item_voice_count("Voice Count", 1, 1, 4, 1) - , item_voice_detail("Voice Detail", 1, 1, 4, 1) - , item_midi_filter_enabled("MIDI Filter Enabled", 0, 0, 1, 1) - , item_midi_channel("MIDI Channel", 0, 0, 100, 1) - , item_midi_lowest_note("MIDI Lowest Note", 0) - , item_midi_highest_note("MIDI Highest Note", 0) + , item_voice_count("voice count", 1, 1, 4, 1) + , item_voice_detail("voice detail", 1, 1, 4, 1) + , item_midi_filter_enabled("MIDI filter", 0, "on", "off") + , item_midi_channel("MIDI channel", 0, 0, 100, 1) + , item_midi_lowest_note("MIDI lowest", 0) + , item_midi_highest_note("MIDI highest", 127) { this->menu.add_item(&this->item_voice_count); this->menu.add_item(&this->item_voice_detail); diff --git a/midi2cv/ui/part_menu.h b/midi2cv/ui/part_menu.h index 9309e9b..5ce1294 100644 --- a/midi2cv/ui/part_menu.h +++ b/midi2cv/ui/part_menu.h @@ -19,7 +19,7 @@ class PartMenu { Menu menu; UIntMenuItem item_voice_count; UIntMenuItem item_voice_detail; - UIntMenuItem item_midi_filter_enabled; + BoolMenuItem item_midi_filter_enabled; UIntMenuItem item_midi_channel; MidiNoteMenuItem item_midi_lowest_note; MidiNoteMenuItem item_midi_highest_note;