reform

MNT Reform: Open Source Portable Computer
Log (Feed) | Files | Refs (Tags) | README

commit 226dcb825f0f2c51020e1a9ff7a3f9a7da34dab7
parent 50d8345a644e4197d5c9de09ad19e96a259de337
Author: René Wagner <rwa@clttr.info>
Date:   Fri, 15 Dec 2023 11:16:54 +0100

add Hyper help display

While the Hyper key is pressed the OLED display while hints which keys have
a binding associated.
Display is cleared when Hyper key is released.

Diffstat:
Mreform2-keyboard-fw/README.md | 6+++++-
Mreform2-keyboard-fw/keyboard.c | 10+++++++++-
Mreform2-keyboard-fw/menu.c | 27+++++++++++++++++++++++++--
3 files changed, 39 insertions(+), 4 deletions(-)

diff --git a/reform2-keyboard-fw/README.md b/reform2-keyboard-fw/README.md @@ -23,6 +23,10 @@ `apt install gcc-avr avr-libc dfu-programmer` +### ArchLinux + +`pacman -U avr-gcc avr-binutils avr-libc dfu-programmer` + ### Mac *TODO: is this correct?* @@ -50,7 +54,7 @@ respectively, using the `REFORM_KBD_OPTIONS` argument to `make`. make REFORM_KBD_OPTIONS=-DKBD_VARIANT_3 # keyboard 3.0 layout (non-US) Without any options, `KBD_VARIANT_2` is the default. To build for the -standalone keyboard for, define `KBD_MODE_STANDALONE` using +standalone keyboard, define `KBD_MODE_STANDALONE` using `REFORM_KBD_OPTIONS` like this: make REFORM_KBD_OPTIONS="-DKBD_VARIANT_2_US -DKBD_MODE_STANDALONE" diff --git a/reform2-keyboard-fw/keyboard.c b/reform2-keyboard-fw/keyboard.c @@ -90,7 +90,7 @@ uint8_t* active_matrix = matrix; bool media_toggle = 0; bool fn_key = 0; // Am I holding FN? bool circle = 0; // Am I holding circle? - +bool help_display = 0; // Is the Hyper help screen displayed? bool should_run_fade_anim = false; // enter the menu @@ -201,6 +201,10 @@ int process_keyboard(uint8_t* resulting_scancodes) { } else if (keycode == HID_KEYBOARD_SC_EXECUTE) { fn_key = 1; active_matrix = matrix_fn; + if (!help_display) { + render_help(); + help_display = 1; + } } else { if (active_meta_mode) { // not holding the same key? @@ -234,6 +238,10 @@ int process_keyboard(uint8_t* resulting_scancodes) { // key not pressed if (keycode == HID_KEYBOARD_SC_EXECUTE) { fn_key = 0; + if (help_display) { + clear_display(); + help_display = 0; + } if (media_toggle) { active_matrix = matrix_fn_toggled; } else { diff --git a/reform2-keyboard-fw/menu.c b/reform2-keyboard-fw/menu.c @@ -18,6 +18,14 @@ int current_scroll_y = 0; int current_menu_page = 0; int8_t logo_timeout_ticks = 0; +#define HYPER_HELP_NUM_ITEMS 4 +const MenuItem help_items[] = { + { "Delete Backspace", KEY_ESCAPE }, + { "Home/End/Pg Arrows", KEY_ESCAPE }, + { "Player F7-F9", KEY_ESCAPE }, + { "Volume F10-F12", KEY_ESCAPE }, +}; + #ifdef KBD_MODE_STANDALONE #define MENU_NUM_ITEMS 5 const MenuItem menu_items[] = { @@ -68,6 +76,20 @@ void render_menu(int y) { gfx_flush(); } +void render_help() { + gfx_clear(); + for (int i=0; i<HYPER_HELP_NUM_ITEMS; i++) { + gfx_poke_str(0,i,help_items[i].title); + } + gfx_on(); + gfx_flush(); +} + +void clear_display() { + gfx_clear(); + gfx_flush(); +} + // automatically refresh the current menu page if needed void refresh_menu_page() { if (current_menu_page == MENU_PAGE_BATTERY_STATUS) { @@ -122,11 +144,13 @@ int execute_meta_function(int keycode) { /*else if (keycode == KEY_V) { remote_turn_off_aux(); }*/ +#ifndef KBD_MODE_STANDALONE else if (keycode == KEY_B) { current_menu_page = MENU_PAGE_BATTERY_STATUS; remote_get_voltages(); return 0; } +#endif else if (keycode == KEY_S) { remote_get_status(); return 0; @@ -158,8 +182,7 @@ int execute_meta_function(int keycode) { return execute_menu_function(current_menu_y); } else if (keycode == KEY_ESCAPE) { - gfx_clear(); - gfx_flush(); + clear_display(); } else if (keycode == KEY_X) { gfx_clear();