Skip to content

Commit

Permalink
Fix various issues in PR #12993 feedback.
Browse files Browse the repository at this point in the history
* 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()`.
  • Loading branch information
yanghu committed Jun 17, 2021
1 parent 14e2138 commit c4ea096
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 44 deletions.
28 changes: 18 additions & 10 deletions keyboards/yanghu/unicorne/glcdfont.c
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/
#pragma once

#ifdef __AVR__
#include <avr/io.h>
#include <avr/pgmspace.h>
#elif defined(ESP8266)
#include <pgmspace.h>
#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,
Expand Down Expand Up @@ -235,5 +244,4 @@ const unsigned char font[] PROGMEM = {
0x40, 0x40, 0x40, 0x40, 0x40, 0x43,
0x4F, 0x4E, 0x4C, 0x40, 0x7F, 0x00,
};


// clang-format on
1 change: 1 addition & 0 deletions keyboards/yanghu/unicorne/keymaps/default/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 6 additions & 12 deletions keyboards/yanghu/unicorne/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,36 @@
#include QMK_KEYBOARD_H
#include "layers.h"
#include "oled.h"
#include "config.h"

#define LOWER MO(_LOWER)
#define RAISE MO(_RAISE)
#define ADJUST MO(_ADJUST)

// 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,
Expand All @@ -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) {
Expand Down Expand Up @@ -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); }
14 changes: 8 additions & 6 deletions keyboards/yanghu/unicorne/keymaps/default/oled.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
}
1 change: 0 additions & 1 deletion keyboards/yanghu/unicorne/keymaps/default/oled.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@
*/

#pragma once
void oled_render_capslock(bool caps_on);
5 changes: 5 additions & 0 deletions keyboards/yanghu/unicorne/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 2 additions & 15 deletions keyboards/yanghu/unicorne/unicorne.h
Original file line number Diff line number Diff line change
Expand Up @@ -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, \
Expand All @@ -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

0 comments on commit c4ea096

Please sign in to comment.