diff --git a/keyboards/bandominedoni/bandominedoni.c b/keyboards/bandominedoni/bandominedoni.c index 1b0365ac6a..eacbb40fa0 100644 --- a/keyboards/bandominedoni/bandominedoni.c +++ b/keyboards/bandominedoni/bandominedoni.c @@ -119,33 +119,53 @@ static enum { UNKNOWN, LEFT, RIGHT } hand_side = UNKNOWN; } #ifdef ENCODER_ENABLE -const uint16_t rt_matrix[2][2] = { - {5, 5}, {5, 6} -}; +# ifdef ENCODERS +static uint8_t encoder_state[ENCODERS] = {0}; +static keypos_t encoder_cw[ENCODERS] = ENCODERS_CW_KEY; +static keypos_t encoder_ccw[ENCODERS] = ENCODERS_CCW_KEY; +# endif + +void encoder_action_unregister(void) { +# ifdef ENCODERS + for (int index = 0; index < ENCODERS; ++index) { + if (encoder_state[index]) { + keyevent_t encoder_event = (keyevent_t) { + .key = encoder_state[index] >> 1 ? encoder_cw[index] : encoder_ccw[index], + .pressed = false, + .time = (timer_read() | 1) + }; + encoder_state[index] = 0; + action_exec(encoder_event); + } + } +# endif +} + +void encoder_action_register(uint8_t index, bool clockwise) { +# ifdef ENCODERS + keyevent_t encoder_event = (keyevent_t) { + .key = clockwise ? encoder_cw[index] : encoder_ccw[index], + .pressed = true, + .time = (timer_read() | 1) + }; + encoder_state[index] = (clockwise ^ 1) | (clockwise << 1); +# ifdef CONSOLE_ENABLE + uprintf("encoder_action_register index = %u, clockwise = %u, row = %u, col = %u\n", index, clockwise, encoder_event.key.row, encoder_event.key.col); +# endif + action_exec(encoder_event); +# endif +} + +void matrix_scan_kb(void) { + encoder_action_unregister(); + matrix_scan_user(); +} bool encoder_update_kb(uint8_t index, bool clockwise) { - if (index == 1) { /* An encoder on the right side */ - keypos_t key; - int cw = 0; - cw = clockwise ? 1 : 0; - key.row = rt_matrix[cw][0]; - key.col = rt_matrix[cw][1]; - uint8_t layer = layer_switch_get_layer(key); - uint16_t keycode = keymap_key_to_keycode(layer, key); - keyrecord_t record; - record.event.key = key; - - if (keycode < MI_ON){ - tap_code16(keycode); - } else { - record.event.pressed = true; - process_midi(keycode, &record); - wait_ms(TAP_CODE_DELAY); - record.event.pressed = false; - process_midi(keycode, &record); - } - - } + encoder_action_register(index, clockwise); + // don't return user actions, because they are in the keymap + // encoder_update_user(index, clockwise); return true; -} -#endif // ENCODER_ENABLE +}; + +#endif diff --git a/keyboards/bandominedoni/bandominedoni.h b/keyboards/bandominedoni/bandominedoni.h index 8e2470826c..1eca4f8d98 100644 --- a/keyboards/bandominedoni/bandominedoni.h +++ b/keyboards/bandominedoni/bandominedoni.h @@ -82,3 +82,7 @@ // reason: bandoMIneDonI has no space on right hand side to use "SPLIT_HAND_MATRIX_GRID". // However, It enables to decide the handedness by the HW by adding one condition: "not to press any keys (especially r30) dusing startup." bool is_keyboard_left(void); + +void encoder_action_unregister(void); + +void encoder_action_register(uint8_t index, bool clockwise); diff --git a/keyboards/bandominedoni/config.h b/keyboards/bandominedoni/config.h index 629c6af884..e1e4d87405 100644 --- a/keyboards/bandominedoni/config.h +++ b/keyboards/bandominedoni/config.h @@ -133,120 +133,54 @@ // Enable suspend mode. # define RGB_DISABLE_WHEN_USB_SUSPENDED true -// // enable below to shrink the firmware size ( -1974 bytes ) -// # define REDUCE_RGB_MATRIX_EFFECTS - -// enable below to shrink the firmware size ( -1574 bytes ) -// # define REDUCE_RGB_MATRIX_EFFECTS_2 - -// # ifdef AUDIO_ENABLE -# ifdef CONSOLE_ENABLE -# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE -# else +# ifdef CONSOLE_ENABLE +# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE +# else // #define ENABLE_RGB_MATRIX_ALPHAS_MODS -// #define ENABLE_RGB_MATRIX_GRADIENT_UP_DOWN -// #define ENABLE_RGB_MATRIX_GRADIENT_LEFT_RIGHT -// #define ENABLE_RGB_MATRIX_BREATHING -// #define ENABLE_RGB_MATRIX_BAND_SAT -// #define ENABLE_RGB_MATRIX_BAND_PINWHEEL_SAT -// #define ENABLE_RGB_MATRIX_BAND_SPIRAL_SAT -// #define ENABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT -// #define ENABLE_RGB_MATRIX_RAINBOW_PINWHEELS -// #define ENABLE_RGB_MATRIX_RAINDROPS -// #define ENABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS -# define ENABLE_RGB_MATRIX_HUE_BREATHING -# define ENABLE_RGB_MATRIX_HUE_PENDULUM -# define ENABLE_RGB_MATRIX_HUE_WAVE -# define ENABLE_RGB_MATRIX_FRACTAL -# define ENABLE_RGB_MATRIX_PIXEL_RAIN - -# if !defined(REDUCE_RGB_MATRIX_EFFECTS) && !defined(VIA_ENABLE) -// # ifdef REDUCE_RGB_MATRIX_EFFECTS -# define ENABLE_RGB_MATRIX_BAND_PINWHEEL_VAL -# define ENABLE_RGB_MATRIX_BAND_SPIRAL_VAL -# define ENABLE_RGB_MATRIX_CYCLE_OUT_IN -# define ENABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL -# define ENABLE_RGB_MATRIX_DUAL_BEACON -# define ENABLE_RGB_MATRIX_CYCLE_PINWHEEL -# define ENABLE_RGB_MATRIX_CYCLE_SPIRAL -# endif - -// #define ENABLE_RGB_MATRIX_HUE_BREATHING -// #define ENABLE_RGB_MATRIX_HUE_PENDULUM -// #define ENABLE_RGB_MATRIX_HUE_WAVE -// #define ENABLE_RGB_MATRIX_FRACTAL -// #define ENABLE_RGB_MATRIX_PIXEL_RAIN -// #define ENABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE -// #define ENABLE_RGB_MATRIX_SOLID_REACTIVE -// #define ENABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE -// #define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE -// #define ENABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS -// #define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS -// #define ENABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS - -# if !defined(REDUCE_RGB_MATRIX_EFFECTS_2) && !defined(VIA_ENABLE) -// # ifdef REDUCE_RGB_MATRIX_EFFECTS_2 -# define ENABLE_RGB_MATRIX_BAND_VAL -# define ENABLE_RGB_MATRIX_CYCLE_ALL -# define ENABLE_RGB_MATRIX_CYCLE_UP_DOWN -# define ENABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON -# define ENABLE_RGB_MATRIX_RAINBOW_BEACON -# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE -# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS -# define ENABLE_RGB_MATRIX_MULTISPLASH -# define ENABLE_RGB_MATRIX_SOLID_MULTISPLASH - -# endif -# define ENABLE_RGB_MATRIX_SOLID_REACTIVE -// #define ENABLE_RGB_MATRIX_SPLASH -// #define ENABLE_RGB_MATRIX_SOLID_SPLASH -# endif // AUDIO_ENABLE - -// #define ENABLE_RGB_MATRIX_ALPHAS_MODS -// #define ENABLE_RGB_MATRIX_GRADIENT_UP_DOWN -// #define ENABLE_RGB_MATRIX_GRADIENT_LEFT_RIGHT -// #define ENABLE_RGB_MATRIX_BREATHING -// #define ENABLE_RGB_MATRIX_BAND_SAT -// #define ENABLE_RGB_MATRIX_BAND_VAL -// #define ENABLE_RGB_MATRIX_BAND_PINWHEEL_SAT -// #define ENABLE_RGB_MATRIX_BAND_PINWHEEL_VAL -// #define ENABLE_RGB_MATRIX_BAND_SPIRAL_SAT -// #define ENABLE_RGB_MATRIX_BAND_SPIRAL_VAL -// #define ENABLE_RGB_MATRIX_CYCLE_ALL -// #define ENABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT -// #define ENABLE_RGB_MATRIX_CYCLE_UP_DOWN -// #define ENABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON -// #define ENABLE_RGB_MATRIX_CYCLE_OUT_IN -// #define ENABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL -// #define ENABLE_RGB_MATRIX_CYCLE_PINWHEEL -// #define ENABLE_RGB_MATRIX_CYCLE_SPIRAL -// #define ENABLE_RGB_MATRIX_DUAL_BEACON -// #define ENABLE_RGB_MATRIX_RAINBOW_BEACON -// #define ENABLE_RGB_MATRIX_RAINBOW_PINWHEELS -// #define ENABLE_RGB_MATRIX_RAINDROPS -// #define ENABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS -// #define ENABLE_RGB_MATRIX_HUE_BREATHING -// #define ENABLE_RGB_MATRIX_HUE_PENDULUM -// #define ENABLE_RGB_MATRIX_HUE_WAVE -// #define ENABLE_RGB_MATRIX_FRACTAL -// #define ENABLE_RGB_MATRIX_PIXEL_RAIN - +# define ENABLE_RGB_MATRIX_GRADIENT_UP_DOWN +# define ENABLE_RGB_MATRIX_BREATHING +# define ENABLE_RGB_MATRIX_BAND_SAT +# define ENABLE_RGB_MATRIX_BAND_PINWHEEL_SAT +# define ENABLE_RGB_MATRIX_BAND_SPIRAL_SAT +# define ENABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT +# define ENABLE_RGB_MATRIX_RAINBOW_PINWHEELS // #define ENABLE_RGB_MATRIX_TYPING_HEATMAP -// #define ENABLE_RGB_MATRIX_DIGITAL_RAIN - -// #define ENABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE -// #define ENABLE_RGB_MATRIX_SOLID_REACTIVE -// #define ENABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE -// #define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE -// #define ENABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS -// #define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS -// #define ENABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS -// #define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS -// #define ENABLE_RGB_MATRIX_SPLASH -// #define ENABLE_RGB_MATRIX_MULTISPLASH -// #define ENABLE_RGB_MATRIX_SOLID_SPLASH -// #define ENABLE_RGB_MATRIX_SOLID_MULTISPLASH - +# define ENABLE_RGB_MATRIX_DIGITAL_RAIN +# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE +# define ENABLE_RGB_MATRIX_SOLID_REACTIVE +# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE +# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS +# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS +# define ENABLE_RGB_MATRIX_SPLASH +# define ENABLE_RGB_MATRIX_SOLID_SPLASH +// RAINDROPS don't match well with layer LED indicator (oc) using rgb_matrix_set_color(). +// #define ENABLE_RGB_MATRIX_RAINDROPS +// #define ENABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS +// Recommendend not to use these. +# ifndef VIA_ENABLE +# define ENABLE_RGB_MATRIX_GRADIENT_LEFT_RIGHT +# define ENABLE_RGB_MATRIX_BAND_VAL +# define ENABLE_RGB_MATRIX_BAND_PINWHEEL_VAL +# define ENABLE_RGB_MATRIX_BAND_SPIRAL_VAL +# define ENABLE_RGB_MATRIX_CYCLE_ALL +# define ENABLE_RGB_MATRIX_CYCLE_UP_DOWN +# define ENABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON +# define ENABLE_RGB_MATRIX_CYCLE_OUT_IN +# define ENABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL +# define ENABLE_RGB_MATRIX_CYCLE_PINWHEEL +# define ENABLE_RGB_MATRIX_CYCLE_SPIRAL +# define ENABLE_RGB_MATRIX_DUAL_BEACON +# define ENABLE_RGB_MATRIX_RAINBOW_BEACON +# define ENABLE_RGB_MATRIX_HUE_BREATHING +# define ENABLE_RGB_MATRIX_HUE_PENDULUM +# define ENABLE_RGB_MATRIX_HUE_WAVE +# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE +# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS +# define ENABLE_RGB_MATRIX_MULTISPLASH +# define ENABLE_RGB_MATRIX_SOLID_MULTISPLASH +# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS +# endif +# endif // CONSOLE_ENABLE #endif // RGB_MATRIX_ENABLE /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ @@ -330,4 +264,7 @@ # define ENCODERS_PAD_B_RIGHT { F4 } # define ENCODER_RESOLUTION 4 # define TAP_CODE_DELAY 10 +# define ENCODERS 2 +# define ENCODERS_CW_KEY { {4, 5}, {6, 5} } +# define ENCODERS_CCW_KEY { {3, 5}, {5, 5} } #endif // ENCODER_ENABLE diff --git a/keyboards/bandominedoni/keymaps/led/keymap.c b/keyboards/bandominedoni/keymaps/led/keymap.c index 7693557df3..305756b5b1 100644 --- a/keyboards/bandominedoni/keymaps/led/keymap.c +++ b/keyboards/bandominedoni/keymaps/led/keymap.c @@ -141,7 +141,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { XXXXXXX, XXXXXXX, AG_NORM, AG_SWAP, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, _______, MI_OCTD, MI_OCTU, MI_VELD, MI_VELU, _______, - XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, RGB_RMOD, RGB_MOD, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, RGB_SAD, RGB_SAI, RGB_HUD, RGB_HUI, RGB_SPD, RGB_SPI, RGB_VAD, RGB_VAI, @@ -149,23 +149,29 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { ) }; -void eeconfig_init_user(void) { // EEPROM is getting reset! - #ifdef RGB_MATRIX_ENABLE - rgb_matrix_enable(); - rgb_matrix_set_speed(RGB_MATRIX_STARTUP_SPD); - rgb_matrix_sethsv(HSV_BLUE); - - rgb_matrix_mode(RGB_MATRIX_SOLID_REACTIVE); - // rgb_matrix_mode(RGB_MATRIX_RAINBOW_MOVING_CHEVRON); - #endif -} - -void keyboard_post_init_user(void) { +void my_init(void){ // Set octave to MI_OCT_0 midi_config.octave = MI_OCT_0 - MIDI_OCTAVE_MIN; // avoid using 127 since it is used as a special number in some sound sources. midi_config.velocity = MIDI_INITIAL_VELOCITY; +} + +void eeconfig_init_user(void) { // EEPROM is getting reset! + midi_init(); + my_init(); +#ifdef RGB_MATRIX_ENABLE + rgb_matrix_enable(); + rgb_matrix_set_speed(RGB_MATRIX_STARTUP_SPD); + rgb_matrix_sethsv(HSV_BLUE); + + rgb_matrix_mode(RGB_MATRIX_SOLID_REACTIVE); + // rgb_matrix_mode(RGB_MATRIX_RAINBOW_MOVING_CHEVRON); +#endif +} + +void keyboard_post_init_user(void) { + my_init(); // party mode (for LED soldering test. Enable rainbow color effect, and disable led_indicator to check all LEDs) rgb_matrix_mode(RGB_MATRIX_RAINBOW_MOVING_CHEVRON); diff --git a/keyboards/bandominedoni/keymaps/led/rules.mk b/keyboards/bandominedoni/keymaps/led/rules.mk index a7583d38c8..08ed472ad6 100644 --- a/keyboards/bandominedoni/keymaps/led/rules.mk +++ b/keyboards/bandominedoni/keymaps/led/rules.mk @@ -1,2 +1,2 @@ -RGB_MATRIX_ENABLE = yes # Use RGB matrix (Don't enable this when RGBLIGHT_ENABLE is used.) -RGB_MATRIX_CUSTOM_USER = yes # +RGB_MATRIX_ENABLE = yes # Use RGB matrix (Don't enable this when RGBLIGHT_ENABLE is used.) +RGB_MATRIX_CUSTOM_KB = yes # diff --git a/keyboards/bandominedoni/keymaps/via/config.h b/keyboards/bandominedoni/keymaps/via/config.h index 99e39626ce..4dcac5104f 100644 --- a/keyboards/bandominedoni/keymaps/via/config.h +++ b/keyboards/bandominedoni/keymaps/via/config.h @@ -15,4 +15,4 @@ */ #pragma once -#define DYNAMIC_KEYMAP_LAYER_COUNT 5 +#define DYNAMIC_KEYMAP_LAYER_COUNT 4 diff --git a/keyboards/bandominedoni/keymaps/via/keymap.c b/keyboards/bandominedoni/keymaps/via/keymap.c index 59e074228b..ad6833d692 100644 --- a/keyboards/bandominedoni/keymaps/via/keymap.c +++ b/keyboards/bandominedoni/keymaps/via/keymap.c @@ -82,7 +82,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, _______, MI_OCTD, MI_OCTU, MI_VELD, MI_VELU, _______, - XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, RGB_RMOD, RGB_MOD, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, RGB_SAD, RGB_SAI, RGB_HUD, RGB_HUI, RGB_SPD, RGB_SPI, RGB_VAD, RGB_VAI, @@ -90,23 +90,29 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { ) }; -void eeconfig_init_user(void) { // EEPROM is getting reset! - #ifdef RGB_MATRIX_ENABLE - rgb_matrix_enable(); - rgb_matrix_set_speed(RGB_MATRIX_STARTUP_SPD); - rgb_matrix_sethsv(HSV_BLUE); - - rgb_matrix_mode(RGB_MATRIX_SOLID_REACTIVE); - // rgb_matrix_mode(RGB_MATRIX_RAINBOW_MOVING_CHEVRON); - #endif -} - -void keyboard_post_init_user(void) { +void my_init(void){ // Set octave to MI_OCT_0 midi_config.octave = MI_OCT_0 - MIDI_OCTAVE_MIN; // avoid using 127 since it is used as a special number in some sound sources. midi_config.velocity = MIDI_INITIAL_VELOCITY; +} + +void eeconfig_init_user(void) { // EEPROM is getting reset! + midi_init(); + my_init(); +#ifdef RGB_MATRIX_ENABLE + rgb_matrix_enable(); + rgb_matrix_set_speed(RGB_MATRIX_STARTUP_SPD); + rgb_matrix_sethsv(HSV_BLUE); + + rgb_matrix_mode(RGB_MATRIX_SOLID_REACTIVE); + // rgb_matrix_mode(RGB_MATRIX_RAINBOW_MOVING_CHEVRON); +#endif +} + +void keyboard_post_init_user(void) { + my_init(); }; #ifdef RGB_MATRIX_ENABLE diff --git a/keyboards/bandominedoni/keymaps/via/rules.mk b/keyboards/bandominedoni/keymaps/via/rules.mk index 925056c3dc..95d7690567 100644 --- a/keyboards/bandominedoni/keymaps/via/rules.mk +++ b/keyboards/bandominedoni/keymaps/via/rules.mk @@ -1,3 +1,4 @@ -RGB_MATRIX_ENABLE = yes # Use RGB matrix (Don't enable this when RGBLIGHT_ENABLE is used.) +RGB_MATRIX_ENABLE = yes # Use RGB matrix (Don't enable this when RGBLIGHT_ENABLE is used.) +RGB_MATRIX_CUSTOM_KB = yes # VIA_ENABLE = yes MOUSEKEY_ENABLE = yes # Mouse keys diff --git a/keyboards/bandominedoni/rgb_matrix_user.inc b/keyboards/bandominedoni/rgb_matrix_kb.inc similarity index 100% rename from keyboards/bandominedoni/rgb_matrix_user.inc rename to keyboards/bandominedoni/rgb_matrix_kb.inc