diff options
Diffstat (limited to 'keyboards/lily58/keymaps/yuchi/keymap.c')
-rw-r--r-- | keyboards/lily58/keymaps/yuchi/keymap.c | 125 |
1 files changed, 108 insertions, 17 deletions
diff --git a/keyboards/lily58/keymaps/yuchi/keymap.c b/keyboards/lily58/keymaps/yuchi/keymap.c index d708dbec7..13b6cb168 100644 --- a/keyboards/lily58/keymaps/yuchi/keymap.c +++ b/keyboards/lily58/keymaps/yuchi/keymap.c @@ -1,7 +1,23 @@ #include QMK_KEYBOARD_H +#ifdef PROTOCOL_LUFA + #include "lufa.h" + #include "split_util.h" +#endif +#ifdef SSD1306OLED + #include "ssd1306.h" +#endif + + extern keymap_config_t keymap_config; +#ifdef RGBLIGHT_ENABLE +//Following line allows macro to read current RGB settings +extern rgblight_config_t rgblight_config; +#endif + +extern uint8_t is_master; + #define _QWERTY 0 #define _LOWER 1 #define _RAISE 2 @@ -89,28 +105,103 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * |------+------+------+------+------+------| |------+------+------+------+------+------| * | | | | | | | | | | | | | | * |------+------+------+------+------+------| |------+------+------+------+------+------| - * | | | | | | |-------. ,-------| | | | | | | + * | | | | | | |-------. ,-------| | |RGB ON| HUE+ | SAT+ | VAL+ | * |------+------+------+------+------+------| | | |------+------+------+------+------+------| - * | | | | | | |-------| |-------| | | | | | | + * | | | | | | |-------| |-------| | | MODE | HUE- | SAT- | VAL- | * `-----------------------------------------/ / \ \-----------------------------------------' * |LOWER | LGUI | Alt | /Space / \Enter \ |BackSP| RGUI |RAISE | * | | | |/ / \ \ | | | | - * `-------------------''-------' '------''--------------------' + * `----------------------------' '------''--------------------' */ [_ADJUST] = LAYOUT( \ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \ - XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \ - XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, 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, XXXXXXX, XXXXXXX, RGB_MOD, RGB_HUD, RGB_SAD, RGB_VAD,\ _______, _______, _______, _______, _______, _______, _______, _______ \ ) }; +int RGB_current_mode; + +// Setting ADJUST layer RGB back to default +void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) { + if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) { + layer_on(layer3); + } else { + layer_off(layer3); + } +} + +void matrix_init_user(void) { + #ifdef RGBLIGHT_ENABLE + RGB_current_mode = rgblight_config.mode; + #endif + //SSD1306 OLED init, make sure to add #define SSD1306OLED in config.h + #ifdef SSD1306OLED + iota_gfx_init(!has_usb()); // turns on the display + #endif +} + +//SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h +#ifdef SSD1306OLED + +// When 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 matrix_scan_user(void) { + iota_gfx_task(); +} + +void matrix_render_user(struct CharacterMatrix *matrix) { + if (is_master) { + // If you want to change the display of OLED, you need to change here + matrix_write_ln(matrix, read_layer_state()); + matrix_write_ln(matrix, read_keylog()); + matrix_write_ln(matrix, read_keylogs()); + //matrix_write_ln(matrix, read_mode_icon(keymap_config.swap_lalt_lgui)); + //matrix_write_ln(matrix, read_host_led_state()); + //matrix_write_ln(matrix, read_timelog()); + } else { + matrix_write(matrix, read_logo()); + } +} + +void matrix_update(struct CharacterMatrix *dest, const struct CharacterMatrix *source) { + if (memcmp(dest->display, source->display, sizeof(dest->display))) { + memcpy(dest->display, source->display, sizeof(dest->display)); + dest->dirty = true; + } +} + +void iota_gfx_task_user(void) { + struct CharacterMatrix matrix; + matrix_clear(&matrix); + matrix_render_user(&matrix); + matrix_update(&display, &matrix); +} +#endif//SSD1306OLED bool process_record_user(uint16_t keycode, keyrecord_t *record) { + if (record->event.pressed) { +#ifdef SSD1306OLED + set_keylog(keycode, record); +#endif + // set_timelog(); + } + switch (keycode) { case QWERTY: - if (record->event.pressed) { + if (record->event.pressed) { set_single_persistent_default_layer(_QWERTY); } return false; @@ -118,31 +209,31 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { case LOWER: if (record->event.pressed) { layer_on(_LOWER); - update_tri_layer(_LOWER, _RAISE, _ADJUST); + update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST); } else { layer_off(_LOWER); - update_tri_layer(_LOWER, _RAISE, _ADJUST); + update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST); } return false; break; case RAISE: if (record->event.pressed) { layer_on(_RAISE); - update_tri_layer(_LOWER, _RAISE, _ADJUST); + update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST); } else { layer_off(_RAISE); - update_tri_layer(_LOWER, _RAISE, _ADJUST); + update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST); } return false; break; case ADJUST: - if (record->event.pressed) { - layer_on(_ADJUST); - } else { - layer_off(_ADJUST); - } - return false; - break; + if (record->event.pressed) { + layer_on(_ADJUST); + } else { + layer_off(_ADJUST); + } + return false; + break; } return true; }
\ No newline at end of file |