From 2664dc0a834b0a93b54ed5d058f34c54cb333ffb Mon Sep 17 00:00:00 2001 From: jonylee1986 <2532487686@qq.com> Date: Fri, 26 May 2023 11:20:14 +0800 Subject: [PATCH] Move code to info.json,and removed redundant features --- keyboards/akko/5075/5075.c | 418 +------------------ keyboards/akko/5075/config.h | 39 +- keyboards/akko/5075/info.json | 150 ++++++- keyboards/akko/5075/keymaps/default/keymap.c | 35 +- keyboards/akko/5075/keymaps/via/keymap.c | 35 +- keyboards/akko/5075/rules.mk | 4 - 6 files changed, 161 insertions(+), 520 deletions(-) diff --git a/keyboards/akko/5075/5075.c b/keyboards/akko/5075/5075.c index 44de320fec6..533b194e78e 100644 --- a/keyboards/akko/5075/5075.c +++ b/keyboards/akko/5075/5075.c @@ -18,9 +18,6 @@ // clang-format off #ifdef RGB_MATRIX_ENABLE -static uint16_t map_current_time = 0; -static bool pwron_flag = false; - const is31_led PROGMEM g_is31_leds[RGB_MATRIX_LED_COUNT] = { /* Refer to IS31 manual for these locations * driver @@ -145,141 +142,6 @@ const is31_led PROGMEM g_is31_leds[RGB_MATRIX_LED_COUNT] = { {1, J_11, K_11, L_11}, }; -led_config_t g_led_config = { - { - { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, NO_LED, NO_LED}, - { 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, NO_LED, 28}, - { 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, NO_LED, 43}, - { 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, NO_LED, 58}, - { 59, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 60, NO_LED, 71, 72, 73}, - { 74, 75, 76, NO_LED, NO_LED, 77, NO_LED, NO_LED, NO_LED, 78, 79, 80, NO_LED, 81, 82, 83} - }, - { - { 0, 0}, // 0 - { 14, 0}, // 1 - { 29, 0}, // 2 - { 44, 0}, // 3 - { 59, 0}, // 4 - { 74, 0}, // 5 - { 89, 0}, // 6 - {104, 0}, // 7 - {119, 0}, // 8 - {134, 0}, // 9 - {149, 0}, // 10 - {164, 0}, // 11 - {179, 0}, // 12 - {194, 0}, // 13 - - { 0, 12}, // 14 - { 14, 12}, // 15 - { 28, 12}, // 16 - { 42, 12}, // 17 - { 56, 12}, // 18 - { 70, 12}, // 19 - { 84, 12}, // 20 - { 98, 12}, // 21 - {112, 12}, // 22 - {126, 12}, // 23 - {140, 12}, // 24 - {154, 12}, // 25 - {168, 12}, // 26 - {182, 12}, // 27 - {224, 12}, // 28 - - { 0, 25}, // 29 - { 14, 25}, // 30 - { 28, 25}, // 31 - { 42, 25}, // 32 - { 56, 25}, // 33 - { 70, 25}, // 34 - { 84, 25}, // 35 - { 98, 25}, // 36 - {112, 25}, // 37 - {126, 25}, // 38 - {140, 25}, // 39 - {154, 25}, // 40 - {168, 25}, // 41 - {182, 25}, // 42 - {224, 25}, // 43 - - { 0, 38}, // 29 - { 14, 38}, // 30 - { 28, 38}, // 31 - { 42, 38}, // 32 - { 56, 38}, // 33 - { 70, 38}, // 34 - { 84, 38}, // 35 - { 98, 38}, // 36 - {112, 38}, // 37 - {126, 38}, // 38 - {140, 38}, // 39 - {154, 38}, // 40 - {168, 38}, // 41 - {182, 38}, // 42 - {224, 38}, // 43 - - { 0, 51}, // 29 - { 14, 51}, // 30 - { 28, 51}, // 31 - { 42, 51}, // 32 - { 56, 51}, // 33 - { 70, 51}, // 34 - { 84, 51}, // 35 - { 98, 51}, // 36 - {112, 51}, // 37 - {126, 51}, // 38 - {140, 51}, // 39 - {154, 51}, // 40 - {168, 51}, // 41 - {194, 51}, // 70 - {224, 51}, // 71 - - { 0, 64}, // 72 - { 14, 64}, // 73 - { 28, 64}, // 74 - { 84, 64}, // 75 - {140, 64}, // 76 - {154, 64}, // 77 - {168, 64}, // 78 - {182, 64}, // 80 - {194, 64}, // 81 - {224, 64}, // 82 - - {0, 0}, // 68 LED 1 - {0, 6}, // 69 LED 2 - {0, 13}, // 70 LED 3 - {0, 19}, // 71 LED 4 - {0, 25}, // 72 LED 5 - {0, 32}, // 73 LED 6 - {0, 38}, // 74 LED 7 - {0, 45}, // 75 LED 8 - {0, 51}, // 73 LED 9 - {0, 57}, // 74 LED 10 - {0, 64}, // 75 LED 11 - - {224, 0 }, // 78 LED 12 - {224, 6 }, // 79 LED 13 - {224, 13}, // 80 LED 14 - {224, 19}, // 81 LED 15 - {224, 25}, // 82 LED 16 - {224, 32}, // 83 LED 17 - {224, 38}, // 84 LED 18 - {224, 45}, // 82 LED 19 - {224, 51}, // 83 LED 20 - {224, 57}, // 84 LED 21 - {224, 64} // 85 LED 22 - }, - { - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 - } -}; #endif enum __layers { @@ -290,34 +152,8 @@ enum __layers { MAC_W, MAC_FN }; -enum colors { - WHITE, - RED, - GREEN, - BLUE -}; -enum colors led_color_status = WHITE; // clang-format on -static bool Lkey_flag = false; -static bool reset_glint_flag = false; -static bool while_test_flag = false; -static bool alarm_flag = false; -static uint16_t current_time = 0; -static uint8_t glint_cnt = 0; -static uint16_t scancode = 0; -static uint8_t alarm_cnt = 0; - -#ifndef DISABLE_M1_KEYCODES -static uint8_t RGB_HSV_level; -static bool fn_make_flag = false; -#endif - -HSV hsv; - -void led_test(uint8_t color); -void clear_eeprom(void); - void led_init_ports(void) { // set our LED pings as output setPinOutput(LED_CAPS_LOCK_PIN); // LED1 Num Lock @@ -371,70 +207,14 @@ bool dip_switch_update_kb(uint8_t index, bool active) { return true; } -bool rgb_matrix_indicators_advanced_kb(uint8_t led_min, uint8_t led_max) { - if (!rgb_matrix_indicators_advanced_user(led_min, led_max)) { - return false; - } - keyboard_post_init_user(); - if (pwron_flag == false) { - map_current_time = timer_read(); - if (map_current_time < 3000) { - map_current_time++; - rgb_matrix_set_color_all(150, 150, 150); - } - if (map_current_time >= 3000) { - pwron_flag = true; - if (!rgb_matrix_get_flags()) { - rgb_matrix_set_flags(LED_FLAG_NONE); - rgb_matrix_set_color_all(0, 0, 0); - } else { - rgb_matrix_set_flags(LED_FLAG_ALL); - } - } - } - return true; -} - bool process_record_kb(uint16_t keycode, keyrecord_t *record) { if (!process_record_user(keycode, record)) { return false; } switch (keycode) { #ifndef DISABLE_5075_KEYCODES - case MO(WIN_FN): - case MO(MAC_FN): - fn_make_flag = record->event.pressed; - return true; - case KC_GRV: - if (fn_make_flag && record->event.pressed) { - Lkey_flag = true; - current_time = timer_read(); - scancode = KC_GRV; - return false; - } else { - Lkey_flag = 0; - } - return true; - case KC_LCTL: - if (fn_make_flag && record->event.pressed) { - if (while_test_flag) { - while_test_flag = false; - rgb_matrix_init(); - } else { - Lkey_flag = true; - current_time = timer_read(); - scancode = KC_LCTL; - } - return false; - } else { - Lkey_flag = 0; - } - return true; case TG(WIN_W): - if ((fn_make_flag && record->event.pressed) && (alarm_flag == 0)) { - alarm_flag = true; - rgb_matrix_toggle_noeeprom(); - current_time = timer_read(); + if (record->event.pressed) { if (layer_state_cmp(default_layer_state, WIN_W)) { set_single_persistent_default_layer(WIN_B); layer_off(WIN_W); @@ -445,10 +225,7 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) { } return false; case TG(MAC_W): - if ((fn_make_flag && record->event.pressed) && (alarm_flag == 0)) { - alarm_flag = true; - rgb_matrix_toggle_noeeprom(); - current_time = timer_read(); + if (record->event.pressed) { if (layer_state_cmp(default_layer_state, MAC_W)) { set_single_persistent_default_layer(MAC_B); layer_off(MAC_W); @@ -459,79 +236,10 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) { } return false; case GU_TOGG: - if ((fn_make_flag && record->event.pressed) && (alarm_flag == 0)) { - alarm_flag = true; - rgb_matrix_toggle_noeeprom(); - current_time = timer_read(); + if (record->event.pressed) { writePin(LED_WIN_LOCK_PIN, !keymap_config.no_gui); } return true; - case RGB_HUI: - if ((fn_make_flag && record->event.pressed) && (alarm_flag == 0)) { - RGB_HSV_level = ((uint8_t)rgb_matrix_get_hue() / (UINT8_MAX / 6) + 1) % 7; - rgb_matrix_config.hsv.h = (uint8_t)(UINT8_MAX / 6) * RGB_HSV_level; - } - rgb_matrix_sethsv(rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v); - - return false; - case RGB_VAI: - if ((fn_make_flag && record->event.pressed) && (alarm_flag == 0)) { - if ((RGB_HSV_level = (uint8_t)rgb_matrix_get_val() / (RGB_MATRIX_MAXIMUM_BRIGHTNESS / 4)) < 4) { - alarm_cnt = 2; - RGB_HSV_level++; - rgb_matrix_config.hsv.v = (uint8_t)(RGB_MATRIX_MAXIMUM_BRIGHTNESS / 4) * RGB_HSV_level; - } - rgb_matrix_sethsv(rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v); - } - return false; - case RGB_VAD: - if ((fn_make_flag && record->event.pressed) && (alarm_flag == 0)) { - if ((RGB_HSV_level = (uint8_t)rgb_matrix_get_val() / (RGB_MATRIX_MAXIMUM_BRIGHTNESS / 4)) > 0) { - alarm_cnt = 2; - RGB_HSV_level--; - rgb_matrix_config.hsv.v = (uint8_t)(RGB_MATRIX_MAXIMUM_BRIGHTNESS / 4) * RGB_HSV_level; - } - rgb_matrix_sethsv(rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v); - } - return false; - case RGB_SAI: - if ((fn_make_flag && record->event.pressed) && (alarm_flag == 0)) { - if ((RGB_HSV_level = (uint8_t)rgb_matrix_get_sat() / (UINT8_MAX / 4)) < 4) { - RGB_HSV_level++; - rgb_matrix_config.hsv.s = (uint8_t)(UINT8_MAX / 4) * RGB_HSV_level; - alarm_cnt = 2; - } - rgb_matrix_sethsv(rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v); - } - return false; - case RGB_SAD: - if ((fn_make_flag && record->event.pressed) && (alarm_flag == 0)) { - if ((RGB_HSV_level = (uint8_t)rgb_matrix_get_sat() / (UINT8_MAX / 4)) > 0) { - RGB_HSV_level--; - rgb_matrix_config.hsv.s = (uint8_t)(UINT8_MAX / 4) * RGB_HSV_level; - alarm_cnt = 2; - } - rgb_matrix_sethsv(rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v); - } - return false; - case RGB_SPI: - if ((fn_make_flag && record->event.pressed) && (alarm_flag == 0)) { - if ((RGB_HSV_level = (uint8_t)rgb_matrix_get_speed() / (UINT8_MAX / 4)) < 4) { - alarm_cnt = 2; - RGB_HSV_level++; - rgb_matrix_set_speed((uint8_t)(UINT8_MAX / 4) * RGB_HSV_level); - } - } - return false; - case RGB_SPD: - if ((fn_make_flag && record->event.pressed) && (alarm_flag == 0)) { - if ((RGB_HSV_level = (uint8_t)rgb_matrix_get_speed() / (UINT8_MAX / 4)) > 0) { - alarm_cnt = 2; - RGB_HSV_level--; - rgb_matrix_set_speed((uint8_t)(UINT8_MAX / 4) * RGB_HSV_level); - } - } - return false; case RGB_TOG: if (record->event.pressed) { switch (rgb_matrix_get_flags()) { @@ -553,123 +261,3 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) { return true; } } - -void housekeeping_task_kb(void) { - if (Lkey_flag) { - if (scancode == KC_GRV) { - if (timer_elapsed(current_time) >= 3000) { - Lkey_flag = false; - clear_eeprom(); - - current_time = timer_read(); - reset_glint_flag = true; - glint_cnt = 0; - rgb_matrix_mode_noeeprom(RGB_MATRIX_SOLID_COLOR); - rgb_matrix_sethsv_noeeprom(HSV_OFF); - } - } else if (scancode == KC_LCTL) { - if (timer_elapsed(current_time) >= 3000) { - Lkey_flag = false; - clear_eeprom(); - - while_test_flag = true; - glint_cnt = 0; - rgb_matrix_mode_noeeprom(RGB_MATRIX_SOLID_COLOR); - rgb_matrix_sethsv_noeeprom(HSV_WHITE); - } - } - } else if (reset_glint_flag) { - if ((timer_elapsed(current_time)) >= 300) { - current_time = timer_read(); - if (((glint_cnt++) & 0x01) == 0) { - rgb_matrix_sethsv_noeeprom(HSV_WHITE); - } else { - rgb_matrix_sethsv_noeeprom(HSV_OFF); - } - if (glint_cnt >= 3) { - glint_cnt = 0; - reset_glint_flag = false; - rgb_matrix_init(); - } - } - - } else if (while_test_flag) { - if ((timer_elapsed(current_time)) >= 1000) { - current_time = timer_read(); - if ((glint_cnt % 4) == 0) { - rgb_matrix_sethsv_noeeprom(HSV_RED); - } else if ((glint_cnt % 4) == 1) { - rgb_matrix_sethsv_noeeprom(HSV_GREEN); - } else if ((glint_cnt % 4) == 2) { - rgb_matrix_sethsv_noeeprom(HSV_BLUE); - } else if ((glint_cnt % 4) == 3) { - rgb_matrix_sethsv_noeeprom(HSV_WHITE); - } - glint_cnt++; - if (glint_cnt >= 30) { - glint_cnt = 0; - while_test_flag = false; - rgb_matrix_init(); - } - } - } else if (alarm_cnt != 0) { - alarm_cnt--; - if (alarm_cnt == 0) { - alarm_flag = true; - rgb_matrix_toggle_noeeprom(); - current_time = timer_read(); - } - } else if (alarm_flag) { - if ((timer_elapsed(current_time)) >= 50) { - rgb_matrix_toggle_noeeprom(); - alarm_flag = 0; - } - } -} - -void led_test(uint8_t color) { - rgb_matrix_mode_noeeprom(RGB_MATRIX_SOLID_COLOR); - - switch (color) { - case WHITE: - rgb_matrix_sethsv_noeeprom(HSV_WHITE); - break; - - case RED: - rgb_matrix_sethsv_noeeprom(HSV_RED); - break; - - case GREEN: - rgb_matrix_sethsv_noeeprom(HSV_GREEN); - break; - - case BLUE: - rgb_matrix_sethsv_noeeprom(HSV_BLUE); - break; - } -} - -void clear_eeprom(void) { - if (default_layer_state & ((1<event.pressed){ - if(rgb_matrix_get_val() < RGB_MATRIX_MAXIMUM_BRIGHTNESS){ - rgb_matrix_config.hsv.v = rgb_matrix_get_val() + RGB_MATRIX_VAL_STEP; - rgb_matrix_sethsv(rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v); - } - } - return false; - case ENC_VAD: - if (record->event.pressed){ - if(rgb_matrix_get_val() > 0){ - rgb_matrix_config.hsv.v = rgb_matrix_get_val() - RGB_MATRIX_VAL_STEP; - rgb_matrix_sethsv(rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v); - } - } - return false; - } - return true; -} diff --git a/keyboards/akko/5075/keymaps/via/keymap.c b/keyboards/akko/5075/keymaps/via/keymap.c index 26b1e5fe293..be19d1ecb0e 100644 --- a/keyboards/akko/5075/keymaps/via/keymap.c +++ b/keyboards/akko/5075/keymaps/via/keymap.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2022 jonylee@hfd +/* Copyright (C) 2023 jonylee@hfd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,15 +24,9 @@ enum __layers { MAC_W, MAC_FN }; -enum custom_keycodes { - ENC_VAI = SAFE_RANGE, - ENC_VAD -}; - #define KC_TASK LGUI(KC_TAB) #define KC_FLXP LGUI(KC_E) - const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [WIN_B] = LAYOUT( /* Base */ @@ -89,33 +83,10 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][2] = { [WIN_B] = { ENCODER_CCW_CW(KC_VOLU, KC_VOLD) }, [WIN_W] = { ENCODER_CCW_CW(KC_VOLU, KC_VOLD) }, - [WIN_FN] = { ENCODER_CCW_CW(ENC_VAI, ENC_VAD) }, + [WIN_FN] = { ENCODER_CCW_CW(RGB_VAI, RGB_VAD) }, [MAC_B] = { ENCODER_CCW_CW(KC_VOLU, KC_VOLD) }, [MAC_W] = { ENCODER_CCW_CW(KC_VOLU, KC_VOLD) }, - [MAC_FN] = { ENCODER_CCW_CW(ENC_VAI, ENC_VAD) } + [MAC_FN] = { ENCODER_CCW_CW(RGB_VAI, RGB_VAD) } }; #endif -// clang-format on - -bool process_record_user(uint16_t keycode, keyrecord_t *record) { - switch (keycode) { - case ENC_VAI: - if (record->event.pressed){ - if(rgb_matrix_get_val() < RGB_MATRIX_MAXIMUM_BRIGHTNESS){ - rgb_matrix_config.hsv.v = rgb_matrix_get_val() + RGB_MATRIX_VAL_STEP; - rgb_matrix_sethsv(rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v); - } - } - return false; - case ENC_VAD: - if (record->event.pressed){ - if(rgb_matrix_get_val() > 0){ - rgb_matrix_config.hsv.v = rgb_matrix_get_val() - RGB_MATRIX_VAL_STEP; - rgb_matrix_sethsv(rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v); - } - } - return false; - } - return true; -} diff --git a/keyboards/akko/5075/rules.mk b/keyboards/akko/5075/rules.mk index 1276b73592e..b861fb86dd7 100644 --- a/keyboards/akko/5075/rules.mk +++ b/keyboards/akko/5075/rules.mk @@ -1,9 +1,5 @@ # Build Options # change yes to no to disable # -RGB_MATRIX_DRIVER = IS31FL3733 EEPROM_DRIVER = wear_leveling WEAR_LEVELING_DRIVER = spi_flash -#RGB_MATRIX_CUSTOM_KB = yes #Add turnoff LED - -