aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYang Hu <hueyhy@gmail.com>2021-11-05 02:10:15 -0700
committerGitHub <noreply@github.com>2021-11-05 20:10:15 +1100
commitad6d85ef5a77f0fb810f5c850c24499a4886e458 (patch)
treef3909737414bb25f9fed6301a6f837189c0c4b04
parent8f2ffea656c3abcfd0150bb67fa01e5d4cbafd14 (diff)
downloadqmk_firmware-ad6d85ef5a77f0fb810f5c850c24499a4886e458.tar.gz
qmk_firmware-ad6d85ef5a77f0fb810f5c850c24499a4886e458.zip
Add a new keyboard "Unicorne" (#12993)
* Add keyboards/yanghu/unicorne initial files. * add default keymap to yanghu/unicorne * use slow i2c and enable internal pullup resistor * add oled to default keymaps * fix unicorne default keymap * fix encoder pad direction * fix marauder * add led matrix configs. * add encoder code to default keymap. * fix encoder direction * add readme, info.json and update copyright for c files. * fix build error by clean up include in unicorne.c * fix images in readme files * 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()`. * Update keyboards/yanghu/unicorne/keymaps/default/rules.mk Always include oled.c Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/keymaps/default/oled.c Wrap `oled.c` with ifdef. Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/keymaps/default/oled.c Co-authored-by: Drashna Jaelre <drashna@live.com> * move oled code to unicorne.c, and set weakly. * Update keyboards/yanghu/unicorne/config.h Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/keymaps/default/keymap.c Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/keymaps/default/keymap.c Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/keymaps/default/keymap.c Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/unicorne.c Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/readme.md Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/readme.md Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/readme.md Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/readme.md Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/keymaps/default/oled.c Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/f411/rules.mk Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/rules.mk Co-authored-by: Ryan <fauxpark@gmail.com> * remove oled.h * remove include of oled.h after the file is deleted. * Apply suggestions from code review: remove redundant macros and reformat. Co-authored-by: Drashna Jaelre <drashna@live.com> Co-authored-by: Ryan <fauxpark@gmail.com> * Apply suggestions from code review: change OLED driver macro. Use `OLED_ENABLE` instead of `OLED_DRIVER_ENABLE`. Co-authored-by: Jonathan Rascher <jon@bcat.name> Co-authored-by: Drashna Jaelre <drashna@live.com> Co-authored-by: Ryan <fauxpark@gmail.com> Co-authored-by: Jonathan Rascher <jon@bcat.name>
-rw-r--r--keyboards/yanghu/unicorne/config.h76
-rw-r--r--keyboards/yanghu/unicorne/f411/halconf.h27
-rw-r--r--keyboards/yanghu/unicorne/f411/mcuconf.h34
-rw-r--r--keyboards/yanghu/unicorne/f411/rules.mk5
-rw-r--r--keyboards/yanghu/unicorne/glcdfont.c247
-rw-r--r--keyboards/yanghu/unicorne/info.json62
-rw-r--r--keyboards/yanghu/unicorne/keymaps/default/config.h22
-rw-r--r--keyboards/yanghu/unicorne/keymaps/default/keymap.c92
-rw-r--r--keyboards/yanghu/unicorne/keymaps/default/layers.h24
-rw-r--r--keyboards/yanghu/unicorne/keymaps/default/oled.c67
-rw-r--r--keyboards/yanghu/unicorne/keymaps/default/readme.md10
-rw-r--r--keyboards/yanghu/unicorne/keymaps/default/rules.mk1
-rw-r--r--keyboards/yanghu/unicorne/readme.md17
-rw-r--r--keyboards/yanghu/unicorne/rules.mk26
-rw-r--r--keyboards/yanghu/unicorne/unicorne.c148
-rw-r--r--keyboards/yanghu/unicorne/unicorne.h50
16 files changed, 908 insertions, 0 deletions
diff --git a/keyboards/yanghu/unicorne/config.h b/keyboards/yanghu/unicorne/config.h
new file mode 100644
index 000000000..652afeb3b
--- /dev/null
+++ b/keyboards/yanghu/unicorne/config.h
@@ -0,0 +1,76 @@
1/* Copyright 2021 Yang Hu
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#pragma once
18
19#include "config_common.h"
20
21/* USB Device descriptor parameter */
22#define VENDOR_ID 0xFEED
23#define PRODUCT_ID 0x0204
24#define DEVICE_VER 0x0001
25#define MANUFACTURER yanghu
26#define PRODUCT unicorne
27
28/* key matrix size */
29#define MATRIX_ROWS 4
30#define MATRIX_COLS 12
31
32#define MATRIX_COL_PINS \
33 { A14, A15, B13, B14, B15, A13, A0, A1, A2, A3, A6, A7 }
34#define MATRIX_ROW_PINS \
35 { B9, B8, A10, A9 }
36
37/* COL2ROW, ROW2COL*/
38#define DIODE_DIRECTION COL2ROW
39
40#define ENCODERS_PAD_A \
41 { B10, B2 }
42#define ENCODERS_PAD_B \
43 { B12, B0 }
44
45/* Audio */
46#define AUDIO_PIN A8
47#define AUDIO_PWM_PAL_MODE 1
48#define AUDIO_PWM_DRIVER PWMD1
49#define AUDIO_PWM_CHANNEL 1
50#define AUDIO_STATE_TIMER GPTD4
51
52/* RGB LED */
53#define RGB_DI_PIN B1
54#define RGBLED_NUM 8
55#define DRIVER_LED_TOTAL RGBLED_NUM
56#define RGBLIGHT_EFFECT_BREATHING
57#define RGBLIGHT_EFFECT_RAINBOW_MOOD
58#define RGBLIGHT_EFFECT_RAINBOW_SWIRL
59#define RGBLIGHT_EFFECT_SNAKE
60#define RGBLIGHT_EFFECT_KNIGHT
61#define RGBLIGHT_EFFECT_CHRISTMAS
62#define RGBLIGHT_EFFECT_STATIC_GRADIENT
63#define RGBLIGHT_EFFECT_RGB_TEST
64#define RGBLIGHT_EFFECT_ALTERNATING
65#define RGBLIGHT_EFFECT_TWINKLE
66
67#define WS2812_PWM_DRIVER PWMD3
68#define WS2812_PWM_CHANNEL 4
69#define WS2812_PWM_PAL_MODE 2
70#define WS2812_DMA_STREAM STM32_DMA1_STREAM2
71#define WS2812_DMA_CHANNEL 5
72#define WS2812_EXTERNAL_PULLUP
73
74
75/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
76#define DEBOUNCE 5
diff --git a/keyboards/yanghu/unicorne/f411/halconf.h b/keyboards/yanghu/unicorne/f411/halconf.h
new file mode 100644
index 000000000..d28ae12fd
--- /dev/null
+++ b/keyboards/yanghu/unicorne/f411/halconf.h
@@ -0,0 +1,27 @@
1/* Copyright 2020 QMK
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#pragma once
18
19/* PWM for AUDIO and RGB LED */
20#define HAL_USE_PWM TRUE
21/* GPT and PAL for Audio */
22#define HAL_USE_GPT TRUE
23#define HAL_USE_PAL TRUE
24/* I2C for OLED display */
25#define HAL_USE_I2C TRUE
26
27#include_next <halconf.h>
diff --git a/keyboards/yanghu/unicorne/f411/mcuconf.h b/keyboards/yanghu/unicorne/f411/mcuconf.h
new file mode 100644
index 000000000..f4dc31bff
--- /dev/null
+++ b/keyboards/yanghu/unicorne/f411/mcuconf.h
@@ -0,0 +1,34 @@
1/* Copyright 2020 QMK
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#pragma once
18
19#include_next <mcuconf.h>
20
21/* TIM1 PWM used for audio driver */
22#undef STM32_PWM_USE_TIM1
23#define STM32_PWM_USE_TIM1 TRUE
24/* TIM5 GPT used for audio driver */
25#undef STM32_GPT_USE_TIM4
26#define STM32_GPT_USE_TIM4 TRUE
27
28/* TIM3 used for WS2812 driver */
29#undef STM32_PWM_USE_TIM3
30#define STM32_PWM_USE_TIM3 TRUE
31
32/* I2C used for OLED display */
33#undef STM32_I2C_USE_I2C1
34#define STM32_I2C_USE_I2C1 TRUE
diff --git a/keyboards/yanghu/unicorne/f411/rules.mk b/keyboards/yanghu/unicorne/f411/rules.mk
new file mode 100644
index 000000000..b32a8b7f5
--- /dev/null
+++ b/keyboards/yanghu/unicorne/f411/rules.mk
@@ -0,0 +1,5 @@
1# MCU name
2MCU = STM32F411
3
4# Bootloader selection
5BOOTLOADER = stm32-dfu
diff --git a/keyboards/yanghu/unicorne/glcdfont.c b/keyboards/yanghu/unicorne/glcdfont.c
new file mode 100644
index 000000000..24c06471f
--- /dev/null
+++ b/keyboards/yanghu/unicorne/glcdfont.c
@@ -0,0 +1,247 @@
1/* Copyright 2021 Yang Hu
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#pragma once
17
18#include "progmem.h"
19
20// clang-format off
21const unsigned char font[] PROGMEM = {
22 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, 0x00,
24 0x3E, 0x6B, 0x4F, 0x6B, 0x3E, 0x00,
25 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, 0x00,
26 0x18, 0x3C, 0x7E, 0x3C, 0x18, 0x00,
27 0x1C, 0x57, 0x7D, 0x57, 0x1C, 0x00,
28 0x1C, 0x5E, 0x7F, 0x5E, 0x1C, 0x00,
29 0x00, 0x18, 0x3C, 0x18, 0x00, 0x00,
30 0xFF, 0xE7, 0xC3, 0xE7, 0xFF, 0x00,
31 0x00, 0x18, 0x24, 0x18, 0x00, 0x00,
32 0xFF, 0xE7, 0xDB, 0xE7, 0xFF, 0x00,
33 0x30, 0x48, 0x3A, 0x06, 0x0E, 0x00,
34 0x26, 0x29, 0x79, 0x29, 0x26, 0x00,
35 0x40, 0x7F, 0x05, 0x05, 0x07, 0x00,
36 0x40, 0x7F, 0x05, 0x25, 0x3F, 0x00,
37 0x5A, 0x3C, 0xE7, 0x3C, 0x5A, 0x00,
38 0x7F, 0x3E, 0x1C, 0x1C, 0x08, 0x00,
39 0x08, 0x1C, 0x1C, 0x3E, 0x7F, 0x00,
40 0x14, 0x22, 0x7F, 0x22, 0x14, 0x00,
41 0x5F, 0x5F, 0x00, 0x5F, 0x5F, 0x00,
42 0x06, 0x09, 0x7F, 0x01, 0x7F, 0x00,
43 0x00, 0x66, 0x89, 0x95, 0x6A, 0x00,
44 0x60, 0x60, 0x60, 0x60, 0x60, 0x00,
45 0x94, 0xA2, 0xFF, 0xA2, 0x94, 0x00,
46 0x08, 0x04, 0x7E, 0x04, 0x08, 0x00,
47 0x10, 0x20, 0x7E, 0x20, 0x10, 0x00,
48 0x08, 0x08, 0x2A, 0x1C, 0x08, 0x00,
49 0x08, 0x1C, 0x2A, 0x08, 0x08, 0x00,
50 0x1E, 0x10, 0x10, 0x10, 0x10, 0x00,
51 0x0C, 0x1E, 0x0C, 0x1E, 0x0C, 0x00,
52 0x30, 0x38, 0x3E, 0x38, 0x30, 0x00,
53 0x06, 0x0E, 0x3E, 0x0E, 0x06, 0x00,
54 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
55 0x00, 0x00, 0x5F, 0x00, 0x00, 0x00,
56 0x00, 0x07, 0x00, 0x07, 0x00, 0x00,
57 0x14, 0x7F, 0x14, 0x7F, 0x14, 0x00,
58 0x24, 0x2A, 0x7F, 0x2A, 0x12, 0x00,
59 0x23, 0x13, 0x08, 0x64, 0x62, 0x00,
60 0x36, 0x49, 0x56, 0x20, 0x50, 0x00,
61 0x00, 0x08, 0x07, 0x03, 0x00, 0x00,
62 0x00, 0x1C, 0x22, 0x41, 0x00, 0x00,
63 0x00, 0x41, 0x22, 0x1C, 0x00, 0x00,
64 0x2A, 0x1C, 0x7F, 0x1C, 0x2A, 0x00,
65 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00,
66 0x00, 0x80, 0x70, 0x30, 0x00, 0x00,
67 0x08, 0x08, 0x08, 0x08, 0x08, 0x00,
68 0x00, 0x00, 0x60, 0x60, 0x00, 0x00,
69 0x20, 0x10, 0x08, 0x04, 0x02, 0x00,
70 0x3E, 0x51, 0x49, 0x45, 0x3E, 0x00,
71 0x00, 0x42, 0x7F, 0x40, 0x00, 0x00,
72 0x72, 0x49, 0x49, 0x49, 0x46, 0x00,
73 0x21, 0x41, 0x49, 0x4D, 0x33, 0x00,
74 0x18, 0x14, 0x12, 0x7F, 0x10, 0x00,
75 0x27, 0x45, 0x45, 0x45, 0x39, 0x00,
76 0x3C, 0x4A, 0x49, 0x49, 0x31, 0x00,
77 0x41, 0x21, 0x11, 0x09, 0x07, 0x00,
78 0x36, 0x49, 0x49, 0x49, 0x36, 0x00,
79 0x46, 0x49, 0x49, 0x29, 0x1E, 0x00,
80 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
81 0x00, 0x40, 0x34, 0x00, 0x00, 0x00,
82 0x00, 0x08, 0x14, 0x22, 0x41, 0x00,
83 0x14, 0x14, 0x14, 0x14, 0x14, 0x00,
84 0x00, 0x41, 0x22, 0x14, 0x08, 0x00,
85 0x02, 0x01, 0x59, 0x09, 0x06, 0x00,
86 0x3E, 0x41, 0x5D, 0x59, 0x4E, 0x00,
87 0x7C, 0x12, 0x11, 0x12, 0x7C, 0x00,
88 0x7F, 0x49, 0x49, 0x49, 0x36, 0x00,
89 0x3E, 0x41, 0x41, 0x41, 0x22, 0x00,
90 0x7F, 0x41, 0x41, 0x41, 0x3E, 0x00,
91 0x7F, 0x49, 0x49, 0x49, 0x41, 0x00,
92 0x7F, 0x09, 0x09, 0x09, 0x01, 0x00,
93 0x3E, 0x41, 0x41, 0x51, 0x73, 0x00,
94 0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00,
95 0x00, 0x41, 0x7F, 0x41, 0x00, 0x00,
96 0x20, 0x40, 0x41, 0x3F, 0x01, 0x00,
97 0x7F, 0x08, 0x14, 0x22, 0x41, 0x00,
98 0x7F, 0x40, 0x40, 0x40, 0x40, 0x00,
99 0x7F, 0x02, 0x1C, 0x02, 0x7F, 0x00,
100 0x7F, 0x04, 0x08, 0x10, 0x7F, 0x00,
101 0x3E, 0x41, 0x41, 0x41, 0x3E, 0x00,
102 0x7F, 0x09, 0x09, 0x09, 0x06, 0x00,
103 0x3E, 0x41, 0x51, 0x21, 0x5E, 0x00,
104 0x7F, 0x09, 0x19, 0x29, 0x46, 0x00,
105 0x26, 0x49, 0x49, 0x49, 0x32, 0x00,
106 0x03, 0x01, 0x7F, 0x01, 0x03, 0x00,
107 0x3F, 0x40, 0x40, 0x40, 0x3F, 0x00,
108 0x1F, 0x20, 0x40, 0x20, 0x1F, 0x00,
109 0x3F, 0x40, 0x38, 0x40, 0x3F, 0x00,
110 0x63, 0x14, 0x08, 0x14, 0x63, 0x00,
111 0x03, 0x04, 0x78, 0x04, 0x03, 0x00,
112 0x61, 0x59, 0x49, 0x4D, 0x43, 0x00,
113 0x00, 0x7F, 0x41, 0x41, 0x41, 0x00,
114 0x02, 0x04, 0x08, 0x10, 0x20, 0x00,
115 0x00, 0x41, 0x41, 0x41, 0x7F, 0x00,
116 0x04, 0x02, 0x01, 0x02, 0x04, 0x00,
117 0x40, 0x40, 0x40, 0x40, 0x40, 0x00,
118 0x00, 0x03, 0x07, 0x08, 0x00, 0x00,
119 0x20, 0x54, 0x54, 0x78, 0x40, 0x00,
120 0x7F, 0x28, 0x44, 0x44, 0x38, 0x00,
121 0x38, 0x44, 0x44, 0x44, 0x28, 0x00,
122 0x38, 0x44, 0x44, 0x28, 0x7F, 0x00,
123 0x38, 0x54, 0x54, 0x54, 0x18, 0x00,
124 0x00, 0x08, 0x7E, 0x09, 0x02, 0x00,
125 0x58, 0xA4, 0xA4, 0x9C, 0x78, 0x00,
126 0x7F, 0x08, 0x04, 0x04, 0x78, 0x00,
127 0x00, 0x44, 0x7D, 0x40, 0x00, 0x00,
128 0x20, 0x40, 0x40, 0x3D, 0x00, 0x00,
129 0x7F, 0x10, 0x28, 0x44, 0x00, 0x00,
130 0x00, 0x41, 0x7F, 0x40, 0x00, 0x00,
131 0x7C, 0x04, 0x78, 0x04, 0x78, 0x00,
132 0x7C, 0x08, 0x04, 0x04, 0x78, 0x00,
133 0x38, 0x44, 0x44, 0x44, 0x38, 0x00,
134 0xFC, 0x18, 0x24, 0x24, 0x18, 0x00,
135 0x18, 0x24, 0x24, 0x18, 0xFC, 0x00,
136 0x7C, 0x08, 0x04, 0x04, 0x08, 0x00,
137 0x48, 0x54, 0x54, 0x54, 0x24, 0x00,
138 0x04, 0x04, 0x3F, 0x44, 0x24, 0x00,
139 0x3C, 0x40, 0x40, 0x20, 0x7C, 0x00,
140 0x1C, 0x20, 0x40, 0x20, 0x1C, 0x00,
141 0x3C, 0x40, 0x30, 0x40, 0x3C, 0x00,
142 0x44, 0x28, 0x10, 0x28, 0x44, 0x00,
143 0x4C, 0x10, 0x10, 0x10, 0x7C, 0x00,
144 0x44, 0x64, 0x54, 0x4C, 0x44, 0x00,
145 0x00, 0x08, 0x36, 0x41, 0x00, 0x00,
146 0x00, 0x00, 0x77, 0x00, 0x00, 0x00,
147 0x00, 0x41, 0x36, 0x08, 0x00, 0x00,
148 0x02, 0x01, 0x02, 0x04, 0x02, 0x00,
149 0x3C, 0x26, 0x23, 0x26, 0x3C, 0x00,
150 0x00, 0x00, 0xF0, 0xF8, 0x9C, 0x0C,
151 0x0C, 0x1C, 0xF8, 0xE0, 0x00, 0x00,
152 0x00, 0xE0, 0xF8, 0x1C, 0x0C, 0x0C,
153 0x9C, 0xF8, 0x60, 0x00, 0x00, 0x00,
154 0x00, 0x0C, 0x0C, 0x0C, 0x3C, 0xF8,
155 0xC0, 0x00, 0x00, 0x00, 0x00, 0x0C,
156 0x0C, 0x0C, 0x0C, 0x0C, 0x00, 0x00,
157 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0,
158 0xF0, 0xF8, 0xFC, 0xFC, 0xF8, 0xF0,
159 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00,
160 0x00, 0x00, 0xC0, 0xE0, 0x70, 0x38,
161 0x1C, 0x0C, 0x06, 0x86, 0x86, 0x86,
162 0x86, 0x86, 0xC6, 0xC6, 0x0C, 0x1C,
163 0x38, 0xF0, 0xE0, 0xC0, 0x00, 0x00,
164 0x00, 0x60, 0xF8, 0x0C, 0x24, 0xE6,
165 0xE6, 0x24, 0x06, 0x06, 0x24, 0xE6,
166 0xE6, 0x24, 0x06, 0x06, 0x24, 0xE6,
167 0xE6, 0x24, 0x0C, 0xF8, 0x60, 0x00,
168 0x00, 0xE0, 0xF0, 0x18, 0x0C, 0x04,
169 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
170 0x86, 0x86, 0xC6, 0x46, 0xE6, 0x66,
171 0x04, 0x0C, 0x18, 0xF0, 0xE0, 0x00,
172 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
173 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
174 0x00, 0xFE, 0x8A, 0x92, 0xA2, 0xC2,
175 0xFE, 0xC2, 0xA2, 0x92, 0x0A, 0x02,
176 0x82, 0xE2, 0x7A, 0x5A, 0x42, 0x42,
177 0x42, 0xC2, 0xC2, 0x42, 0xFE, 0x00,
178 0xFE, 0x02, 0x02, 0x02, 0x02, 0x02,
179 0x02, 0x02, 0x82, 0xE2, 0xFA, 0x7A,
180 0xFA, 0xE2, 0x82, 0x02, 0x02, 0x02,
181 0x02, 0x02, 0x02, 0x02, 0xFE, 0x00,
182 0x00, 0x00, 0x00, 0x81, 0x81, 0xC3,
183 0xC3, 0xC3, 0xFF, 0xFF, 0xC3, 0xC3,
184 0xC3, 0xFF, 0xFF, 0xC3, 0xC3, 0xC3,
185 0x81, 0x81, 0x00, 0x00, 0x00, 0x00,
186 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
187 0x03, 0x0F, 0x3C, 0xF0, 0xC0, 0x00,
188 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
189 0x00, 0x06, 0x07, 0x07, 0x07, 0xFF,
190 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
191 0xFF, 0x07, 0x07, 0x07, 0x06, 0x00,
192 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00,
193 0x00, 0x00, 0x7F, 0xFF, 0xC1, 0xC1,
194 0xC1, 0xC1, 0xFF, 0x7F, 0xE0, 0x80,
195 0x80, 0xC0, 0xFF, 0x7F, 0x00, 0x00,
196 0x00, 0xDB, 0xFF, 0x00, 0x00, 0x1F,
197 0x3F, 0x70, 0xE0, 0xC0, 0xC0, 0xFF,
198 0xFF, 0xC0, 0xC0, 0xE0, 0x70, 0x3F,
199 0x1F, 0x00, 0x00, 0xFF, 0xDB, 0x00,
200 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00,
201 0xC0, 0xF8, 0xFE, 0xFF, 0xF9, 0xF1,
202 0x61, 0x60, 0x3C, 0x07, 0x01, 0x00,
203 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00,
204 0x00, 0x00, 0xC0, 0xF0, 0x3C, 0x0E,
205 0x0E, 0x3C, 0xF0, 0xC0, 0x00, 0x00,
206 0x00, 0xFF, 0x48, 0x44, 0xC2, 0xE1,
207 0x7F, 0x51, 0xC2, 0xC4, 0x4C, 0x06,
208 0x03, 0x0F, 0x38, 0x60, 0xC0, 0xE0,
209 0x38, 0x0F, 0x00, 0x00, 0xFF, 0x00,
210 0xFF, 0x00, 0x00, 0x00, 0x80, 0xE0,
211 0xF8, 0x7E, 0x67, 0x63, 0x60, 0x60,
212 0x60, 0x63, 0x67, 0x7E, 0xF8, 0xE0,
213 0x80, 0x00, 0x00, 0x00, 0xFF, 0x00,
214 0x00, 0x00, 0x0F, 0x1F, 0x39, 0x30,
215 0x30, 0x18, 0x1F, 0x07, 0x00, 0x00,
216 0x00, 0x07, 0x1F, 0x38, 0x30, 0x30,
217 0x39, 0x1F, 0x06, 0x00, 0x00, 0x00,
218 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
219 0x00, 0x00, 0x00, 0x00, 0x03, 0x0F,
220 0x3C, 0x30, 0x30, 0x30, 0x00, 0x00,
221 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F,
222 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F,
223 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00,
224 0x00, 0x00, 0x00, 0x03, 0x07, 0x0E,
225 0x1C, 0x38, 0x30, 0x30, 0x30, 0x30,
226 0x30, 0x30, 0x38, 0x18, 0x18, 0x01,
227 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
228 0x00, 0x06, 0x1F, 0x30, 0x20, 0x60,
229 0x60, 0x20, 0x64, 0x64, 0x26, 0x67,
230 0x67, 0x26, 0x64, 0x64, 0x20, 0x60,
231 0x60, 0x20, 0x30, 0x1F, 0x06, 0x00,
232 0x00, 0x07, 0x0F, 0x18, 0x30, 0x23,
233 0x63, 0x61, 0x61, 0x60, 0x60, 0x60,
234 0x60, 0x60, 0x60, 0x60, 0x60, 0x60,
235 0x20, 0x30, 0x18, 0x0F, 0x07, 0x00,
236 0x0C, 0x0F, 0x03, 0x00, 0x00, 0x00,
237 0x00, 0x00, 0x00, 0x03, 0x0F, 0x0C,
238 0x00, 0x7F, 0x60, 0x71, 0x53, 0x5E,
239 0x4C, 0x4E, 0x5B, 0x50, 0x60, 0x70,
240 0x58, 0x4C, 0x46, 0x43, 0x41, 0x43,
241 0x4E, 0x78, 0x70, 0x60, 0x7F, 0x00,
242 0x7F, 0x40, 0x4C, 0x4E, 0x4F, 0x43,
243 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
244 0x40, 0x40, 0x40, 0x40, 0x40, 0x43,
245 0x4F, 0x4E, 0x4C, 0x40, 0x7F, 0x00,
246};
247// clang-format on
diff --git a/keyboards/yanghu/unicorne/info.json b/keyboards/yanghu/unicorne/info.json
new file mode 100644
index 000000000..995bed8a0
--- /dev/null
+++ b/keyboards/yanghu/unicorne/info.json
@@ -0,0 +1,62 @@
1{
2 "keyboard_name": "Unicorne",
3 "url": "https://github.com/yanghu/unicorne",
4 "maintainer": "yanghu",
5 "layouts": {
6 "LAYOUT_unicorne": {
7 "layout": [
8 {"label":"Tab", "x":0, "y":0.8},
9 {"label":"Q", "x":1, "y":0.8},
10 {"label":"W", "x":2, "y":0.1},
11 {"label":"E", "x":3, "y":0},
12 {"label":"R", "x":4, "y":0.1},
13 {"label":"T", "x":5, "y":0.2},
14
15 {"label":"Y", "x":9, "y":0.2},
16 {"label":"U", "x":10, "y":0.1},
17 {"label":"I", "x":11, "y":0},
18 {"label":"O", "x":12, "y":0.1},
19 {"label":"P", "x":13, "y":0.8},
20 {"label":"Back Space", "x":14, "y":0.8},
21
22 {"label":"Ctrl / Esc", "x":0, "y":1.8},
23 {"label":"A", "x":1, "y":1.8},
24 {"label":"S", "x":2, "y":1.1},
25 {"label":"D", "x":3, "y":1},
26 {"label":"F", "x":4, "y":1.1},
27 {"label":"G", "x":5, "y":1.2},
28
29 {"label":"H", "x":9, "y":1.2},
30 {"label":"J", "x":10, "y":1.1},
31 {"label":"K", "x":11, "y":1},
32 {"label":"L", "x":12, "y":1.1},
33 {"label":";", "x":13, "y":1.8},
34 {"label":"'", "x":14, "y":1.8},
35
36 {"label":"Shift", "x":0, "y":2.8},
37 {"label":"Z", "x":1, "y":2.8},
38 {"label":"X", "x":2, "y":2.1},
39 {"label":"C", "x":3, "y":2},
40 {"label":"V", "x":4, "y":2.1},
41 {"label":"B", "x":5, "y":2.2},
42
43 {"label":"N", "x":9, "y":2.2},
44 {"label":"M", "x":10, "y":2.1},
45 {"label":",", "x":11, "y":2},
46 {"label":".", "x":12, "y":2.1},
47 {"label":"/", "x":13, "y":2.8},
48 {"label":"Shift / Enter", "x":14, "y":2.8},
49
50 {"label":"Ctrl", "x":3, "y":3.7},
51 {"label":"Alt", "x":4, "y":3.7},
52 {"label":"Lower", "x":5, "y":3.7},
53 {"label":"Enter", "x":6, "y":3.2, "h":1.5},
54
55 {"label":"Backspace", "x":8, "y":3.2, "h":1.5},
56 {"label":"Space", "x":9, "y":3.7},
57 {"label":"Raise", "x":10, "y":3.7},
58 {"label":"RGUI", "x":11, "y":3.7}
59 ]
60 }
61 }
62}
diff --git a/keyboards/yanghu/unicorne/keymaps/default/config.h b/keyboards/yanghu/unicorne/keymaps/default/config.h
new file mode 100644
index 000000000..e7ee9814e
--- /dev/null
+++ b/keyboards/yanghu/unicorne/keymaps/default/config.h
@@ -0,0 +1,22 @@
1/* Copyright 2021 Yang Hu
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#pragma once
18
19#define OLED_FONT_H "keyboards/yanghu/unicorne/glcdfont.c"
20#define ENCODER_RESOLUTION 4
21#define RGBLIGHT_DEFAULT_MODE RGBLIGHT_MODE_BREATHING
22#define RGBLIGHT_DEFAULT_COLOR HSV_BLUE
diff --git a/keyboards/yanghu/unicorne/keymaps/default/keymap.c b/keyboards/yanghu/unicorne/keymaps/default/keymap.c
new file mode 100644
index 000000000..26fb01426
--- /dev/null
+++ b/keyboards/yanghu/unicorne/keymaps/default/keymap.c
@@ -0,0 +1,92 @@
1/* Copyright 2021 Yang Hu
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include QMK_KEYBOARD_H
18#include "layers.h"
19
20#define LOWER MO(_LOWER)
21#define RAISE MO(_RAISE)
22#define ADJUST MO(_ADJUST)
23
24// clang-format off
25const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
26 [_BASE] = LAYOUT_split_3x6_4(
27 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC,
28 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,
29 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),
30 KC_LCTL, KC_LALT, LOWER, KC_ENT, KC_BSPC, KC_SPC, RAISE, KC_RGUI
31 ),
32
33 [_LOWER] = LAYOUT_split_3x6_4(
34 _______, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_DEL,
35 _______, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_GRV, KC_TILD,
36 _______, KC_ESC, KC_LGUI, KC_LALT, KC_CAPS, KC_DQUO, KC_HOME, KC_END, KC_PGUP, KC_PGDN, KC_PSCR, RSFT_T(KC_SPC),
37 _______, _______, _______, _______, _______, _______, _______, _______
38 ),
39
40 [_RAISE] = LAYOUT_split_3x6_4(
41 _______, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL,
42 _______, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6,
43 _______, KC_ESC, KC_RGUI, KC_RALT, KC_CAPS, KC_QUOT, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12,
44 _______, _______, _______, _______, _______, _______, _______, _______
45 ),
46
47 [_ADJUST] = LAYOUT_split_3x6_4(
48 RGB_VAI, RGB_SAI, RGB_HUI, RGB_MOD, XXXXXXX, RGB_TOG, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
49 RGB_VAD, RGB_SAD, RGB_HUD, RGB_RMOD, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
50 XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, RESET, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
51 _______, _______, _______, _______, _______, _______, _______, _______
52 ),
53};
54// clang-format on
55layer_state_t layer_state_set_user(layer_state_t state) { return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST); }
56
57// Left encoder scrolls the mousewheel. Right encoder adjusts underglow hue.
58bool encoder_update_user(uint8_t index, bool clockwise) {
59 if (index == 0) {
60 if (clockwise) {
61#ifdef MOUSEKEY_ENABLE
62 tap_code(KC_MS_WH_DOWN);
63#else
64 tap_code(KC_PGDN);
65#endif
66 } else {
67#ifdef MOUSEKEY_ENABLE
68 tap_code(KC_MS_WH_UP);
69#else
70 tap_code(KC_PGUP);
71#endif
72 }
73 } else { // index = 1: right encoder
74 if (clockwise) {
75#ifdef RGB_MATRIX_ENABLE
76 rgb_matrix_step();
77#else
78 rgblight_increase_hue_noeeprom();
79#endif
80 } else {
81#ifdef RGB_MATRIX_ENABLE
82 rgb_matrix_step_reverse();
83#else
84 rgblight_decrease_hue_noeeprom();
85#endif
86 }
87 }
88 return false;
89}
90
91// Set underglow color to blue.
92void keyboard_post_init_user(void) { rgblight_sethsv_noeeprom(RGBLIGHT_DEFAULT_COLOR); }
diff --git a/keyboards/yanghu/unicorne/keymaps/default/layers.h b/keyboards/yanghu/unicorne/keymaps/default/layers.h
new file mode 100644
index 000000000..0505d4956
--- /dev/null
+++ b/keyboards/yanghu/unicorne/keymaps/default/layers.h
@@ -0,0 +1,24 @@
1/* Copyright 2021 Yang Hu
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#pragma once
18// Defines names for use in layer keycodes and the keymap
19enum layer_names {
20 _BASE,
21 _LOWER,
22 _RAISE,
23 _ADJUST,
24};
diff --git a/keyboards/yanghu/unicorne/keymaps/default/oled.c b/keyboards/yanghu/unicorne/keymaps/default/oled.c
new file mode 100644
index 000000000..417f573ff
--- /dev/null
+++ b/keyboards/yanghu/unicorne/keymaps/default/oled.c
@@ -0,0 +1,67 @@
1/* Copyright 2021 Yang Hu
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#ifdef OLED_ENABLE
17# include QMK_KEYBOARD_H
18# include "layers.h"
19
20// Some characters position:
21// alt: 84 85 86/a..../c...
22// shift:87 88 89/a.../c...
23// ctrl: b6 b6/d.../
24// capslock: 9c-9f/b.../d...
25// numlock: 98-9b/b.../d...
26// navigation logo: 92-95/b2.../d2...
27// symbol logo: 8a-8d/aa..../ca....
28// qmk logos; 8e-91/ae..../ce....
29void oled_render_layer(void) {
30 /* static const char PROGMEM cmd_logo[] = { */
31 /* 0x80, 0x81, 0x82, 0x83, 10, */
32 /* 0xa0, 0xa1, 0xa2, 0xa3, 10, */
33 /* 0xc0, 0xc1, 0xc2, 0xc3, 10, */
34 /* 0}; */
35 // clang-format off
36 static const char PROGMEM numlock_logo[] = {
37 0x98, 0x99, 0x9a, 0x9b, 10,
38 0xb8, 0xb9, 0xba, 0xbb, 10,
39 0xd8, 0xd9, 0xda, 0xdb, 10, 0};
40 static const char PROGMEM symbol_logo[] = {
41 0x8a, 0x8b, 0x8c, 0x8d, 10,
42 0xaa, 0xab, 0xac, 0xad, 10,
43 0xca, 0xcb, 0xcc, 0xcd, 10, 0};
44 static const char PROGMEM qmk_logo[] = {
45 0x8e, 0x8f, 0x90, 0x91, 10,
46 0xae, 0xaf, 0xb0, 0xb1, 10,
47 0xce, 0xcf, 0xd0, 0xd1, 10, 0};
48 // clang-format on
49 if (IS_LAYER_ON(_LOWER)) {
50 oled_write_P(symbol_logo, false);
51 } else if (IS_LAYER_ON(_RAISE)) {
52 oled_write_P(numlock_logo, false);
53 } else if (IS_LAYER_ON(_BASE)) {
54 oled_write_P(qmk_logo, false);
55 } else {
56 if (IS_LAYER_ON(_ADJUST)) {
57 oled_write_ln("ADJ", false);
58 } else {
59 oled_write_ln("?????", false);
60 }
61 oled_write_ln(" ", false);
62 oled_write_ln(" ", false);
63 oled_write_ln(" ", false);
64 }
65}
66
67#endif
diff --git a/keyboards/yanghu/unicorne/keymaps/default/readme.md b/keyboards/yanghu/unicorne/keymaps/default/readme.md
new file mode 100644
index 000000000..b6ce9e423
--- /dev/null
+++ b/keyboards/yanghu/unicorne/keymaps/default/readme.md
@@ -0,0 +1,10 @@
1![keymap](https://imgur.com/48cFzA5.jpg)
2
3# Default Unicorne Layout
4
5This is the default layout for Unicorne. The "lower" layer consists of symbols
6and navigation, while "raises' has numbers, some other symbols and function
7keys.
8
9Press `lower` and `raise` together activates `adjust` layer, with RGB controls,
10as well as access to reset/bootloader.
diff --git a/keyboards/yanghu/unicorne/keymaps/default/rules.mk b/keyboards/yanghu/unicorne/keymaps/default/rules.mk
new file mode 100644
index 000000000..dbfa81b6c
--- /dev/null
+++ b/keyboards/yanghu/unicorne/keymaps/default/rules.mk
@@ -0,0 +1 @@
SRC += oled.c
diff --git a/keyboards/yanghu/unicorne/readme.md b/keyboards/yanghu/unicorne/readme.md
new file mode 100644
index 000000000..3da5e97bf
--- /dev/null
+++ b/keyboards/yanghu/unicorne/readme.md
@@ -0,0 +1,17 @@
1# Unicorne
2
3![Unicorne](https://imgur.com/g1nN3b4h.jpg)
4
5A compact 40% (3x6\_4) single-piece angled ortholinear ergo keyboard kit inspired by crkbd, Kyria, Ferris and Reviung41. Features OLED display, audio buzzer, RGB LED underglow as well as encoders.
6
7* Keyboard Maintainer: [Yang Hu](https://github.com/yanghu)
8* Hardware Supported: Unicorne PCB 1.0
9* Hardware Availability: Open source design at https://github.com/yanghu/unicorne
10
11To 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).
12
13Make example for this keyboard (after setting up your build environment):
14
15 make yanghu/unicorne:default
16
17See 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 information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs).
diff --git a/keyboards/yanghu/unicorne/rules.mk b/keyboards/yanghu/unicorne/rules.mk
new file mode 100644
index 000000000..17296a9bc
--- /dev/null
+++ b/keyboards/yanghu/unicorne/rules.mk
@@ -0,0 +1,26 @@
1# Build Options
2# change yes to no to disable
3#
4BOOTMAGIC_ENABLE = no # Enable Bootmagic Lite
5MOUSEKEY_ENABLE = yes # Mouse keys
6EXTRAKEY_ENABLE = yes # Audio control and System control
7CONSOLE_ENABLE = no # Console for debug
8COMMAND_ENABLE = no # Commands for debug and configuration
9# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
10SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
11# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
12NKRO_ENABLE = yes # USB Nkey Rollover
13BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
14RGBLIGHT_ENABLE = yes # Enable keyboard RGB underglow
15AUDIO_ENABLE = yes # Audio output
16ENCODER_ENABLE = yes
17OLED_ENABLE = yes
18OLED_DRIVER = SSD1306
19
20WS2812_DRIVER = pwm
21AUDIO_DRIVER = pwm_hardware
22
23RGB_MATRIX_ENABLE = no # Do not enable with RGBLIGHT
24RGB_MATRIX_DRIVER = WS2812
25
26DEFAULT_FOLDER = yanghu/unicorne/f411
diff --git a/keyboards/yanghu/unicorne/unicorne.c b/keyboards/yanghu/unicorne/unicorne.c
new file mode 100644
index 000000000..27b87253d
--- /dev/null
+++ b/keyboards/yanghu/unicorne/unicorne.c
@@ -0,0 +1,148 @@
1/* Copyright 2021 Yang Hu
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#include "unicorne.h"
17
18
19// Custom i2c init to enable internal pull up resistor for i2c.
20void i2c_init(void) {
21 static bool is_initialised = false;
22 if (!is_initialised) {
23 is_initialised = true;
24
25 // Try releasing special pins for a short time
26 palSetPadMode(I2C1_SCL_BANK, I2C1_SCL, PAL_MODE_INPUT);
27 palSetPadMode(I2C1_SDA_BANK, I2C1_SDA, PAL_MODE_INPUT);
28
29 chThdSleepMilliseconds(10);
30 // Use internal pull up since we do not have pull up on i2c pins in v1 design.
31 palSetPadMode(I2C1_SCL_BANK, I2C1_SCL, PAL_MODE_ALTERNATE(I2C1_SCL_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN | PAL_STM32_PUPDR_PULLUP);
32 palSetPadMode(I2C1_SDA_BANK, I2C1_SDA, PAL_MODE_ALTERNATE(I2C1_SDA_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN | PAL_STM32_PUPDR_PULLUP);
33 }
34}
35
36// LED matrix
37// physical location
38// 2 3 4 5
39//
40// 1 6
41// 0 7
42#ifdef RGB_MATRIX_ENABLE
43// clang-format off
44led_config_t g_led_config = {{
45 // Key Matrix to LED Index
46 // Since we only have 8 LEDs, map the keys near them to the same LED.
47 {2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5},
48 {2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5},
49 {1, 1, 1, 0, 0, 0, 7, 7, 7, 6, 6, 6},
50 {NO_LED, NO_LED, NO_LED, 0, 0, 0, 7, 7, 7, NO_LED, NO_LED, NO_LED},
51}, {// LED Index to Physical Position
52 {94, 60},
53 {18, 44},
54 {8, 10},
55 {94, 10},
56 {130,10},
57 {216, 10},
58 {208, 44},
59 {130, 60}
60}, {// LED Index to Flag
61 LED_FLAG_ALL, LED_FLAG_ALL, LED_FLAG_ALL, LED_FLAG_ALL, LED_FLAG_ALL,
62 LED_FLAG_ALL, LED_FLAG_ALL, LED_FLAG_ALL
63}};
64// clang-format on
65#endif
66
67#ifdef OLED_ENABLE
68// OLED shared code
69// The oled is vertical. Need to rotate 270 degrees.
70__attribute__((weak)) oled_rotation_t oled_init_user(oled_rotation_t rotation) { return OLED_ROTATION_270; }
71
72// Render layer status on OLED. To be re-implemented by keymaps since layers are
73// defined there.
74__attribute__((weak)) void oled_render_layer(void) { return; }
75
76// Oneshot mods status
77uint8_t osmods;
78
79__attribute__((weak)) void oled_render_mods(void) {
80 static const char PROGMEM ctrl[] = {0xb6, 0xb7, 10, 0xd6, 0xd7, 10, 0x20, 0x20, 10, 0};
81 static const char PROGMEM shift[] = {0x87, 0x88, 0x89, 10, 0xa7, 0xa8, 0xa9, 10, 0xc7, 0xc8, 0xc9, 10, 0};
82 static const char PROGMEM alt[] = {0x84, 0x85, 0x86, 10, 0xa4, 0xa5, 0xa6, 10, 0xc4, 0xc5, 0xc6, 10, 0};
83 static const char PROGMEM ctrl_alt[] = {0xb6, 0xb7, 0x84, 0x85, 0x86, 0xd6, 0xd7, 0xa4, 0xa5, 0xa6, 0x20, 0x20, 0xc4, 0xc5, 0xc6, 0};
84
85 static const char PROGMEM ctrl_shift[] = {0xb6, 0xb7, 0x87, 0x88, 0x89, 0xd6, 0xd7, 0xa7, 0xa8, 0xa9, 0x20, 0x20, 0xc7, 0xc8, 0xc9, 0};
86 static const char PROGMEM c_a_shift[] = {0xb6, 0xb7, 0x84, 0x85, 0x86, 0xd6, 0xd7, 0xa4, 0xa5, 0xa6, 0x20, 0x20, 0xc4, 0xc5, 0xc6, 0x87, 0x88, 0x89, 10, 0xa7, 0xa8, 0xa9, 10, 0xc7, 0xc8, 0xc9, 10, 0};
87 // Now check mod status and render.
88 static uint8_t mods;
89 mods = get_mods() | osmods;
90 if ((mods & MOD_MASK_CTRL) && (mods & MOD_MASK_ALT) && (mods & MOD_MASK_SHIFT)) {
91 oled_write_P(c_a_shift, false);
92 } else if ((mods & MOD_MASK_CTRL) && (mods & MOD_MASK_ALT)) {
93 oled_write_P(ctrl_alt, false);
94 } else if ((mods & MOD_MASK_CTRL) && (mods & MOD_MASK_SHIFT)) {
95 oled_write_P(ctrl_shift, false);
96 } else if ((mods & MOD_MASK_SHIFT) && (mods & MOD_MASK_ALT)) {
97 oled_write_P(alt, false);
98 oled_write_P(shift, false);
99 } else if (mods & MOD_MASK_CTRL) {
100 oled_write_P(ctrl, false);
101 } else if (mods & MOD_MASK_ALT) {
102 oled_write_P(alt, false);
103 } else if (mods & MOD_MASK_SHIFT) {
104 oled_write_P(shift, false);
105 } else {
106 for (int i = 0; i < 6; ++i) {
107 oled_write_ln(" ", false);
108 }
109 }
110 return;
111}
112
113void oneshot_mods_changed_user(uint8_t mods) { osmods = mods; }
114
115// Call this from "led_update_user" and use `led_state.caps_lock` to check
116// the status of capslock.
117__attribute__((weak)) void oled_render_capslock(bool caps_on) {
118 static const char PROGMEM capslock_logo[] = {0x9c, 0x9d, 0x9e, 0x9f, 10, 0xbc, 0xbd, 0xbe, 0xbf, 10, 0xdc, 0xdd, 0xde, 0xdf, 10, 0};
119 if (caps_on) {
120 oled_write_P(capslock_logo, false);
121 } else {
122 for (int i = 0; i < 3; ++i) {
123 oled_write_ln(" ", false);
124 }
125 }
126}
127
128char keylog_str[24] = {};
129
130const 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', '_', '-', '=', '[', ']', '\\', '#', ';', '\'', '`', ',', '.', '/', ' ', ' ', ' '};
131
132void set_keylog(uint16_t keycode, keyrecord_t *record) {
133 if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) {
134 keycode = keycode & 0xFF;
135 }
136}
137
138__attribute__((weak)) void oled_render_keylog(void) { oled_write(keylog_str, false); }
139
140// Keymaps can override this function
141__attribute__((weak)) void oled_task_user(void) {
142 /* oled_render_keylog(); */
143 oled_render_layer();
144 oled_render_mods();
145 led_t led_state = host_keyboard_led_state();
146 oled_render_capslock(led_state.caps_lock);
147}
148#endif
diff --git a/keyboards/yanghu/unicorne/unicorne.h b/keyboards/yanghu/unicorne/unicorne.h
new file mode 100644
index 000000000..f0b5685f1
--- /dev/null
+++ b/keyboards/yanghu/unicorne/unicorne.h
@@ -0,0 +1,50 @@
1/* Copyright 2021 Yang Hu
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#pragma once
18
19#include "quantum.h"
20
21#ifdef OLED_ENABLE
22void oled_render_capslock(bool caps_on);
23void oled_render_mods(void);
24void oled_render_keylog(void);
25#endif
26/* This a shortcut to help you visually see your layout.
27 *
28 * The first section contains all of the arguments representing the physical
29 * layout of the board and position of the keys.
30 *
31 * The second converts the arguments into a two-dimensional array which
32 * represents the switch matrix.
33 */
34
35// clang-format off
36#define LAYOUT_split_3x6_4( \
37 K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, \
38 K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, \
39 K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, \
40 K30, K31, K32, K33, K34, K35, K36, K37 \
41) \
42{ \
43 { K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B }, \
44 { K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B }, \
45 { K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B }, \
46 { KC_NO, KC_NO, K30, K31, K32, K33, K34, K35, K36, K37, KC_NO, KC_NO} \
47}
48// clang-format on
49
50#define LAYOUT LAYOUT_split_3x6_4