diff options
Diffstat (limited to 'keyboards/owlab/voice65/soldered/soldered.c')
-rw-r--r-- | keyboards/owlab/voice65/soldered/soldered.c | 329 |
1 files changed, 1 insertions, 328 deletions
diff --git a/keyboards/owlab/voice65/soldered/soldered.c b/keyboards/owlab/voice65/soldered/soldered.c index cfdaaad4ae..1444b05864 100644 --- a/keyboards/owlab/voice65/soldered/soldered.c +++ b/keyboards/owlab/voice65/soldered/soldered.c @@ -14,7 +14,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "soldered.h" +#include "quantum.h" #ifdef RGB_MATRIX_ENABLE const is31_led g_is31_leds[RGB_MATRIX_LED_COUNT] = { @@ -126,330 +126,3 @@ bool rgb_matrix_indicators_kb(void) { } return true; } - -enum encoder_modes{ - ENCODER_MODE_ONE, - ENCODER_MODE_TWO, - ENCODER_MODE_THREE -}; - -keyboard_config_t keyboard_config; -rgblight_config_t rgblight_config; - -uint8_t pre_hue, pre_sat, pre_val; -uint8_t previous_rgb_mode = 0; -uint8_t dir_hue, dir_sat; - -bool encoder_in = false; -uint32_t encoder_timer; - -bool encoder_ani_start= false; -uint32_t encoder_ani_timer = 0; - -bool encoder_direction_start = false; -uint32_t encoder_direction_timer = 0; - - -bool lizm_restart_snake = false; -void rgblight_snake_restart(uint8_t hue, uint8_t sat, uint8_t val){ - lizm_restart_snake = true; // restart signal to local each effect - rgblight_config.hue = hue; - rgblight_config.sat = sat; - rgblight_config.val = val; -} - - -void keyboard_post_init_kb(void){ - keyboard_config.raw = eeconfig_read_kb(); - if( keyboard_config.encoder_mode_index > ENCODER_MODE_THREE ){ - keyboard_config.encoder_mode_index = ENCODER_MODE_ONE; - eeconfig_update_kb(keyboard_config.raw); - } -} - -void switch_encoder_mode(uint8_t mode){ - switch(mode){ - case ENCODER_MODE_ONE: - dir_hue = 88; - dir_sat = 255; - break; - - case ENCODER_MODE_TWO: - dir_hue = 0; - dir_sat = 240; - break; - - case ENCODER_MODE_THREE: - dir_hue = 176; - dir_sat = 255; - break; - } - rgblight_sethsv_noeeprom(dir_hue,dir_sat,pre_val); -} - - -void init_encoder_mode(uint8_t mode){ - previous_rgb_mode = rgblight_get_mode(); - pre_hue = rgblight_get_hue(); - pre_sat = rgblight_get_sat(); - pre_val = rgblight_get_val(); - encoder_in = true; - - rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT); - - switch_encoder_mode(mode); -} - - -void set_encoder_mode(uint8_t mode){ - if(encoder_in == false){ - init_encoder_mode(mode); - }else{ - switch_encoder_mode(mode); - } - eeconfig_update_kb(keyboard_config.raw); - encoder_timer = timer_read32(); -} - -bool process_record_kb(uint16_t keycode, keyrecord_t *record) { - if (record->event.pressed) { - switch(keycode) { - case RGB_MOD: - case RGB_RMOD: - case RGB_HUI: - case RGB_HUD: - case RGB_SAI: - case RGB_SAD: - case RGB_VAI: - case RGB_VAD: - - if(encoder_in){ - return false; - } - break; - - case KC_F13: - rgb_matrix_toggle(); - break; - - case KC_F14: - rgb_matrix_step(); - break; - - case KC_F15: - rgb_matrix_step_reverse(); - break; - - case KC_F16: - rgb_matrix_increase_hue(); //Increase the hue for effect range LEDs - break; - - case KC_F17: - rgb_matrix_decrease_hue(); //Decrease the hue for effect range LEDs - break; - - case KC_F18: - rgb_matrix_increase_sat(); //Increase the saturation for effect range LEDs - break; - - case KC_F19: - rgb_matrix_decrease_sat(); //Decrease the saturation for effect range LEDs - break; - - case KC_F20: - rgb_matrix_increase_val(); //Increase the value for effect range LEDs - break; - - case KC_F21: - rgb_matrix_decrease_val();//Decrease the value for effect range LEDs - break; - - case KC_F22: //change encoder mode upward - if(!encoder_direction_start){ - if(keyboard_config.encoder_mode_index < ENCODER_MODE_THREE){ - keyboard_config.encoder_mode_index++; - } - else{ - keyboard_config.encoder_mode_index = ENCODER_MODE_ONE; - } - set_encoder_mode(keyboard_config.encoder_mode_index); - } - return false; - - case KC_F23: - if(!encoder_direction_start){ - if(keyboard_config.encoder_mode_index > ENCODER_MODE_ONE){ - keyboard_config.encoder_mode_index--; - } - else{ - keyboard_config.encoder_mode_index = ENCODER_MODE_THREE; - } - set_encoder_mode(keyboard_config.encoder_mode_index); - } - return false; - - default: - break; - } - } - return process_record_user(keycode, record); -} - - -void matrix_scan_kb(void) { - if(encoder_in){ - if(timer_elapsed32(encoder_timer) > 5000){ - rgblight_mode(previous_rgb_mode); - rgblight_sethsv(pre_hue, pre_sat, pre_val); - encoder_in = false; - } - } - - if(encoder_ani_start){ - if(timer_elapsed32(encoder_ani_timer) > VOLUME_ANIMATION_TIMER){ - encoder_ani_start = false; - rgblight_sethsv_noeeprom(0,0,0); - } - } - - if(encoder_direction_start){ - if(timer_elapsed32(encoder_direction_timer) > (VOLUME_ANIMATION_TIMER+1500)){ - rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT); - rgblight_sethsv_noeeprom(dir_hue, dir_sat, pre_val); - encoder_direction_start = false; - } - } - matrix_scan_user(); -} - - -void set_volume_animation(bool increase){ - if(!encoder_ani_start){ - rgblight_snake_restart(dir_hue, dir_sat, pre_val); - } - - if(increase){ - rgblight_mode_noeeprom(17); - } else { - rgblight_mode_noeeprom(18); - } - - encoder_ani_timer = timer_read32(); - encoder_direction_timer = encoder_ani_timer; - encoder_ani_start = true; - encoder_direction_start = true; -} - - -bool encoder_update_kb(uint8_t index, bool clockwise) { - uint8_t layer_now = keyboard_config.encoder_mode_index +1; - uint16_t encoder_cw_keycode = keymap_key_to_keycode(layer_now, (keypos_t){.row=2, .col=1 }); - uint16_t encoder_ccw_keycode = keymap_key_to_keycode(layer_now, (keypos_t){.row=2, .col=2 }); - if (index == 0) { /* First encoder */ - if(encoder_in == false){ - init_encoder_mode(keyboard_config.encoder_mode_index); - } - - if (!clockwise) { - switch(encoder_cw_keycode) { - - case KC_F13: - rgb_matrix_toggle(); - break; - - case KC_F14: - rgb_matrix_step(); - break; - - case KC_F15: - rgb_matrix_step_reverse(); - break; - - case KC_F16: - rgb_matrix_increase_hue(); //Increase the hue for effect range LEDs - break; - - case KC_F17: - rgb_matrix_decrease_hue(); //Decrease the hue for effect range LEDs - break; - - case KC_F18: - rgb_matrix_increase_sat(); //Increase the saturation for effect range LEDs - break; - - case KC_F19: - rgb_matrix_decrease_sat(); //Decrease the saturation for effect range LEDs - break; - - case KC_F20: - rgb_matrix_increase_val(); //Increase the value for effect range LEDs - break; - - case KC_F21: - rgb_matrix_decrease_val();//Decrease the value for effect range LEDs - break; - - case KC_VOLU: - case KC_VOLD: - tap_code(encoder_cw_keycode); - break; - - default: - tap_code(encoder_cw_keycode); - break; - } - set_volume_animation(true); - } else { - switch(encoder_ccw_keycode) { - - case KC_F13: - rgb_matrix_toggle(); - break; - - case KC_F14: - rgb_matrix_step(); - break; - - case KC_F15: - rgb_matrix_step_reverse(); - break; - - case KC_F16: - rgb_matrix_increase_hue(); //Increase the hue for effect range LEDs - break; - - case KC_F17: - rgb_matrix_decrease_hue(); //Decrease the hue for effect range LEDs - break; - - case KC_F18: - rgb_matrix_increase_sat(); //Increase the saturation for effect range LEDs - break; - - case KC_F19: - rgb_matrix_decrease_sat(); //Decrease the saturation for effect range LEDs - break; - - case KC_F20: - rgb_matrix_increase_val(); //Increase the value for effect range LEDs - break; - - case KC_F21: - rgb_matrix_decrease_val();//Decrease the value for effect range LEDs - break; - - case KC_VOLU: - case KC_VOLD: - tap_code(encoder_ccw_keycode); - break; - - default: - tap_code(encoder_ccw_keycode); - break; - } - set_volume_animation(false); - } - encoder_timer = timer_read32(); - } - return true; -} |