From c4ea096c7f9b216604505a000071648e88b68081 Mon Sep 17 00:00:00 2001 From: Yang Hu Date: Wed, 16 Jun 2021 18:37:14 -0700 Subject: [PATCH] Fix various issues in PR #12993 feedback. * Added copyright in glcdfont, fix include in that file. * Removed `_kc` layout and renamed layout with generic style. * Moved capslock oled update to oled.c inside `oled_task_user()`. --- keyboards/yanghu/unicorne/glcdfont.c | 28 ++++++++++++------- .../yanghu/unicorne/keymaps/default/config.h | 1 + .../yanghu/unicorne/keymaps/default/keymap.c | 18 ++++-------- .../yanghu/unicorne/keymaps/default/oled.c | 14 ++++++---- .../yanghu/unicorne/keymaps/default/oled.h | 1 - keyboards/yanghu/unicorne/readme.md | 5 ++++ keyboards/yanghu/unicorne/unicorne.h | 17 ++--------- 7 files changed, 40 insertions(+), 44 deletions(-) diff --git a/keyboards/yanghu/unicorne/glcdfont.c b/keyboards/yanghu/unicorne/glcdfont.c index 687a95b3cfa7..24c06471ff37 100644 --- a/keyboards/yanghu/unicorne/glcdfont.c +++ b/keyboards/yanghu/unicorne/glcdfont.c @@ -1,14 +1,23 @@ +/* Copyright 2021 Yang Hu + * + * 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 + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #pragma once -#ifdef __AVR__ - #include - #include -#elif defined(ESP8266) - #include -#else - #define PROGMEM -#endif +#include "progmem.h" +// clang-format off const unsigned char font[] PROGMEM = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, 0x00, @@ -235,5 +244,4 @@ const unsigned char font[] PROGMEM = { 0x40, 0x40, 0x40, 0x40, 0x40, 0x43, 0x4F, 0x4E, 0x4C, 0x40, 0x7F, 0x00, }; - - +// clang-format on diff --git a/keyboards/yanghu/unicorne/keymaps/default/config.h b/keyboards/yanghu/unicorne/keymaps/default/config.h index 27d009d65e51..e7ee9814efe6 100644 --- a/keyboards/yanghu/unicorne/keymaps/default/config.h +++ b/keyboards/yanghu/unicorne/keymaps/default/config.h @@ -19,3 +19,4 @@ #define OLED_FONT_H "keyboards/yanghu/unicorne/glcdfont.c" #define ENCODER_RESOLUTION 4 #define RGBLIGHT_DEFAULT_MODE RGBLIGHT_MODE_BREATHING +#define RGBLIGHT_DEFAULT_COLOR HSV_BLUE diff --git a/keyboards/yanghu/unicorne/keymaps/default/keymap.c b/keyboards/yanghu/unicorne/keymaps/default/keymap.c index 1ced3f7e9df3..a3355fe7e2ad 100644 --- a/keyboards/yanghu/unicorne/keymaps/default/keymap.c +++ b/keyboards/yanghu/unicorne/keymaps/default/keymap.c @@ -17,6 +17,7 @@ #include QMK_KEYBOARD_H #include "layers.h" #include "oled.h" +#include "config.h" #define LOWER MO(_LOWER) #define RAISE MO(_RAISE) @@ -24,28 +25,28 @@ // clang-format off const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { - [_BASE] = LAYOUT_unicorne( + [_BASE] = LAYOUT_split_3x6_4( KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, LCTL_T(KC_ESC), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, RSFT_T(KC_ENT), KC_LCTL, KC_LALT, LOWER, KC_ENT, KC_BSPC, KC_SPC, RAISE, KC_RGUI ), - [_LOWER] = LAYOUT_unicorne( + [_LOWER] = LAYOUT_split_3x6_4( _______, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_DEL, _______, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_GRV, KC_TILD, _______, KC_ESC, KC_LGUI, KC_LALT, KC_CAPS, KC_DQUO, KC_HOME, KC_END, KC_PGUP, KC_PGDN, KC_PSCR, RSFT_T(KC_SPC), _______, _______, _______, _______, _______, _______, _______, _______ ), - [_RAISE] = LAYOUT_unicorne( + [_RAISE] = LAYOUT_split_3x6_4( _______, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, _______, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, _______, KC_ESC, KC_RGUI, KC_RALT, KC_CAPS, KC_QUOT, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, _______, _______, _______, _______, _______, _______ ), - [_ADJUST] = LAYOUT_unicorne( + [_ADJUST] = LAYOUT_split_3x6_4( RGB_VAI, RGB_SAI, RGB_HUI, RGB_MOD, XXXXXXX, RGB_TOG, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, RGB_VAD, RGB_SAD, RGB_HUD, RGB_RMOD, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, RESET, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, @@ -55,13 +56,6 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { // clang-format on layer_state_t layer_state_set_user(layer_state_t state) { return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST); } -bool led_update_user(led_t led_state) { -#ifdef OLED_DRIVER_ENABLE - oled_render_capslock(led_state.caps_lock); -#endif - return true; -} - // Left encoder scrolls the mousewheel. Right encoder adjusts underglow hue. void encoder_update_user(uint8_t index, bool clockwise) { if (index == 0) { @@ -96,4 +90,4 @@ void encoder_update_user(uint8_t index, bool clockwise) { } // Set underglow color to blue. -void keyboard_post_init_user(void) { rgblight_sethsv(HSV_BLUE); } +void keyboard_post_init_user(void) { rgblight_sethsv_noeeprom(RGBLIGHT_DEFAULT_COLOR); } diff --git a/keyboards/yanghu/unicorne/keymaps/default/oled.c b/keyboards/yanghu/unicorne/keymaps/default/oled.c index 9935fd5c395b..a5576c05b1a2 100644 --- a/keyboards/yanghu/unicorne/keymaps/default/oled.c +++ b/keyboards/yanghu/unicorne/keymaps/default/oled.c @@ -119,12 +119,6 @@ void oled_render_mods(void) { void oneshot_mods_changed_user(uint8_t mods) { osmods = mods; } -void oled_task_user(void) { - /* oled_render_keylog(); */ - oled_render_layer(); - oled_render_mods(); -} - // Call this from "led_update_user" and use `led_state.caps_lock` to check // the status of capslock. void oled_render_capslock(bool caps_on) { @@ -137,3 +131,11 @@ void oled_render_capslock(bool caps_on) { } } } + +void oled_task_user(void) { + /* oled_render_keylog(); */ + oled_render_layer(); + oled_render_mods(); + led_t led_state = host_keyboard_led_state(); + oled_render_capslock(led_state.caps_lock); +} diff --git a/keyboards/yanghu/unicorne/keymaps/default/oled.h b/keyboards/yanghu/unicorne/keymaps/default/oled.h index ee5b4e1902c8..04f3578d6b77 100644 --- a/keyboards/yanghu/unicorne/keymaps/default/oled.h +++ b/keyboards/yanghu/unicorne/keymaps/default/oled.h @@ -15,4 +15,3 @@ */ #pragma once -void oled_render_capslock(bool caps_on); diff --git a/keyboards/yanghu/unicorne/readme.md b/keyboards/yanghu/unicorne/readme.md index 51c955708b9d..921922fc4b5f 100644 --- a/keyboards/yanghu/unicorne/readme.md +++ b/keyboards/yanghu/unicorne/readme.md @@ -11,10 +11,15 @@ buzzer, RGB LED underglow as well as encoders. * Hardware Availability: Open source design at https://github.com/yanghu/unicorne +To enter bootloader, long press the reset button for 3-5 seconds then release. +More details can be found at [keyboard +wiki](https://github.com/yanghu/unicorne/wiki/Build-guide#testing-the-board). + Make example for this keyboard (after setting up your build environment): qmk compile -kb yanghu/unicorne -km default + See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more diff --git a/keyboards/yanghu/unicorne/unicorne.h b/keyboards/yanghu/unicorne/unicorne.h index da8fe9a3ea56..14c5f4744139 100644 --- a/keyboards/yanghu/unicorne/unicorne.h +++ b/keyboards/yanghu/unicorne/unicorne.h @@ -28,7 +28,7 @@ */ // clang-format off -#define LAYOUT_unicorne( \ +#define LAYOUT_split_3x6_4( \ K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, \ K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, \ K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, \ @@ -40,19 +40,6 @@ { K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B }, \ { KC_NO, KC_NO, K30, K31, K32, K33, K34, K35, K36, K37, KC_NO, KC_NO} \ } - -#define LAYOUT_kc( \ - K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, \ - K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, \ - K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, \ - K30, K31, K32, K33, K34, K35, K36, K37 \ -) \ -LAYOUT_unicorne( \ - KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, \ - KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, \ - KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, \ - KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37 \ -) // clang-format on -#define LAYOUT LAYOUT_unicorne +#define LAYOUT LAYOUT_split_3x6_4