mirror of
https://github.com/qmk/qmk_firmware
synced 2024-11-18 09:55:48 +00:00
Refactor the crkbd/via keymap and fix OLED bugs
This commit is contained in:
parent
f079dd90ed
commit
dc9db029fc
2 changed files with 37 additions and 110 deletions
|
@ -27,7 +27,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||
//|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
|
||||
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ESC,
|
||||
//|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------|
|
||||
KC_LGUI, FN_MO13, KC_SPC, KC_ENT, FN_MO23, KC_RALT
|
||||
KC_LGUI, MO(1), KC_SPC, KC_ENT, MO(2), KC_RALT
|
||||
//`--------------------------' `--------------------------'
|
||||
|
||||
),
|
||||
|
@ -40,7 +40,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||
//|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
|
||||
KC_LSFT, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
|
||||
//|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------|
|
||||
KC_LGUI, _______, KC_SPC, KC_ENT, _______, KC_RALT\
|
||||
KC_LGUI, XXXXXXX, KC_SPC, KC_ENT, MO(3), KC_RALT
|
||||
//`--------------------------' `--------------------------'
|
||||
),
|
||||
|
||||
|
@ -52,19 +52,19 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||
//|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
|
||||
KC_LSFT, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, KC_TILD,
|
||||
//|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------|
|
||||
KC_LGUI, _______, KC_SPC, KC_ENT, _______, KC_RALT
|
||||
KC_LGUI, MO(3), KC_SPC, KC_ENT, XXXXXXX, KC_RALT
|
||||
//`--------------------------' `--------------------------'
|
||||
),
|
||||
|
||||
[3] = LAYOUT_split_3x6_3( \
|
||||
//,-----------------------------------------------------. ,-----------------------------------------------------.
|
||||
RESET, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,\
|
||||
RESET, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
|
||||
//|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
|
||||
RGB_TOG, RGB_HUI, RGB_SAI, RGB_VAI, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,\
|
||||
RGB_TOG, RGB_HUI, RGB_SAI, RGB_VAI, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
|
||||
//|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
|
||||
RGB_MOD, RGB_HUD, RGB_SAD, RGB_VAD, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,\
|
||||
RGB_MOD, RGB_HUD, RGB_SAD, RGB_VAD, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
|
||||
//|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------|
|
||||
KC_LGUI, _______, KC_SPC, KC_ENT, _______, KC_RALT\
|
||||
KC_LGUI, XXXXXXX, KC_SPC, KC_ENT, XXXXXXX, KC_RALT
|
||||
//`--------------------------' `--------------------------'
|
||||
)
|
||||
};
|
||||
|
@ -77,109 +77,28 @@ oled_rotation_t oled_init_user(oled_rotation_t rotation) {
|
|||
return rotation;
|
||||
}
|
||||
|
||||
#define L_BASE 0
|
||||
#define L_LOWER 2
|
||||
#define L_RAISE 4
|
||||
#define L_ADJUST 8
|
||||
|
||||
void oled_render_layer_state(void) {
|
||||
oled_write_P("Layer: ", false);
|
||||
switch (layer_state) {
|
||||
case L_BASE:
|
||||
oled_write_ln_P("Default", false);
|
||||
break;
|
||||
case L_LOWER:
|
||||
oled_write_ln_P("Lower", false);
|
||||
break;
|
||||
case L_RAISE:
|
||||
oled_write_ln_P("Raise", false);
|
||||
break;
|
||||
case L_ADJUST:
|
||||
case L_ADJUST|L_LOWER:
|
||||
case L_ADJUST|L_RAISE:
|
||||
case L_ADJUST|L_LOWER|L_RAISE:
|
||||
oled_write_ln_P("Adjust", false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
char keylog_str[24] = {};
|
||||
char keylogs_str[21] = {};
|
||||
int keylogs_str_idx = 0;
|
||||
|
||||
const char code_to_name[60] = {
|
||||
' ', ' ', ' ', ' ', 'a', 'b', 'c', 'd', 'e', 'f',
|
||||
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
|
||||
'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
|
||||
'1', '2', '3', '4', '5', '6', '7', '8', '9', '0',
|
||||
'R', 'E', 'B', 'T', '_', '-', '=', '[', ']', '\\',
|
||||
'#', ';', '\'', '`', ',', '.', '/', ' ', ' ', ' '};
|
||||
|
||||
void set_keylog(uint16_t keycode, keyrecord_t *record) {
|
||||
char name = ' ';
|
||||
if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) ||
|
||||
(keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) { keycode = keycode & 0xFF; }
|
||||
if (keycode < 60) {
|
||||
name = code_to_name[keycode];
|
||||
}
|
||||
|
||||
// update keylog
|
||||
snprintf(keylog_str, sizeof(keylog_str), "%dx%d, k%2d : %c",
|
||||
record->event.key.row, record->event.key.col,
|
||||
keycode, name);
|
||||
|
||||
// update keylogs
|
||||
if (keylogs_str_idx == sizeof(keylogs_str) - 1) {
|
||||
keylogs_str_idx = 0;
|
||||
for (int i = 0; i < sizeof(keylogs_str) - 1; i++) {
|
||||
keylogs_str[i] = ' ';
|
||||
}
|
||||
}
|
||||
|
||||
keylogs_str[keylogs_str_idx] = name;
|
||||
keylogs_str_idx++;
|
||||
}
|
||||
|
||||
void oled_render_keylog(void) {
|
||||
oled_write(keylog_str, false);
|
||||
}
|
||||
void oled_render_keylogs(void) {
|
||||
oled_write(keylogs_str, false);
|
||||
}
|
||||
|
||||
void render_bootmagic_status(bool status) {
|
||||
/* Show Ctrl-Gui Swap options */
|
||||
static const char PROGMEM logo[][2][3] = {
|
||||
{{0x97, 0x98, 0}, {0xb7, 0xb8, 0}},
|
||||
{{0x95, 0x96, 0}, {0xb5, 0xb6, 0}},
|
||||
};
|
||||
if (status) {
|
||||
oled_write_ln_P(logo[0][0], false);
|
||||
oled_write_ln_P(logo[0][1], false);
|
||||
} else {
|
||||
oled_write_ln_P(logo[1][0], false);
|
||||
oled_write_ln_P(logo[1][1], false);
|
||||
}
|
||||
}
|
||||
|
||||
void oled_render_logo(void) {
|
||||
static const char PROGMEM crkbd_logo[] = {
|
||||
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94,
|
||||
0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4,
|
||||
0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4,
|
||||
0};
|
||||
oled_write_P(crkbd_logo, false);
|
||||
}
|
||||
// When you add source files to SRC in rules.mk, you can use functions.
|
||||
const char *read_layer_state(void);
|
||||
const char *read_logo(void);
|
||||
void set_keylog(uint16_t keycode, keyrecord_t *record);
|
||||
const char *read_keylog(void);
|
||||
// const char *read_keylogs(void);
|
||||
// const char *read_mode_icon(bool swap);
|
||||
// const char *read_host_led_state(void);
|
||||
// void set_timelog(void);
|
||||
// const char *read_timelog(void);
|
||||
|
||||
void oled_task_user(void) {
|
||||
if (is_master) {
|
||||
oled_render_layer_state();
|
||||
oled_render_keylog();
|
||||
// oled_render_keylogs();
|
||||
// oled_renger_bootmagic_icon(keymap_config.swap_lalt_lgui);
|
||||
if (is_keyboard_master()) {
|
||||
// If you want to change the display of OLED, you need to change here
|
||||
oled_write_ln(read_layer_state(), false);
|
||||
oled_write_ln(read_keylog(), false);
|
||||
//oled_write_ln(read_keylogs(), false);
|
||||
//oled_write_ln(read_mode_icon(keymap_config.swap_lalt_lgui), false);
|
||||
//oled_write_ln(read_host_led_state(), false);
|
||||
//oled_write_ln(read_timelog(), false);
|
||||
} else {
|
||||
oled_render_logo();
|
||||
oled_write(read_logo(), false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
SRC += ./lib/rgb_state_reader.c \
|
||||
./lib/layer_state_reader.c \
|
||||
./lib/logo_reader.c \
|
||||
./lib/keylogger.c \
|
||||
# ./lib/mode_icon_reader.c \
|
||||
# ./lib/host_led_state_reader.c \
|
||||
# ./lib/timelogger.c \
|
||||
|
||||
MOUSEKEY_ENABLE = no # Mouse keys
|
||||
RGBLIGHT_ENABLE = yes # Enable WS2812 RGB underlight.
|
||||
VIA_ENABLE = yes # Enable VIA
|
||||
|
|
Loading…
Reference in a new issue