aboutsummaryrefslogtreecommitdiff
path: root/keyboards/halfcliff/halfcliff.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/halfcliff/halfcliff.c')
-rw-r--r--keyboards/halfcliff/halfcliff.c92
1 files changed, 92 insertions, 0 deletions
diff --git a/keyboards/halfcliff/halfcliff.c b/keyboards/halfcliff/halfcliff.c
new file mode 100644
index 000000000..999e9036d
--- /dev/null
+++ b/keyboards/halfcliff/halfcliff.c
@@ -0,0 +1,92 @@
1/* Copyright 2021 n2
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 "halfcliff.h"
18
19#ifdef OLED_DRIVER_ENABLE
20
21// Defines names for use in layer keycodes and the keymap
22enum layer_names {
23 _DEFAULT = 0,
24 _RAISE,
25 _LOWER,
26 _ADJUST
27/* _FN */
28};
29
30__attribute__((weak)) oled_rotation_t oled_init_user(oled_rotation_t rotation) {
31 if (!is_keyboard_master()) {
32 return OLED_ROTATION_180; // flips the display 180 degrees if offhand
33 }
34 return rotation;
35}
36
37__attribute__((weak)) void oled_task_user(void) {
38 if (!is_keyboard_master()) {
39 static const char PROGMEM qmk_logo[] = {
40 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94,
41 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3, 0xB4,
42 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0x00
43 };
44 oled_write_P(qmk_logo, false);
45 } else {
46 // Host Keyboard Layer Status
47 oled_write_P(PSTR("Layer: "), false);
48 switch (get_highest_layer(layer_state)) {
49 case _DEFAULT:
50 oled_write_P(PSTR("DEFAULT\n"), false);
51 break;
52 case _RAISE:
53 oled_write_P(PSTR("RAISE\n"), false);
54 break;
55 case _LOWER:
56 oled_write_P(PSTR("LOWER\n"), false);
57 break;
58 case _ADJUST:
59 oled_write_P(PSTR("ADJUST\n"), false);
60 break;
61 default:
62 // Or use the write_ln shortcut over adding '\n' to the end of your string
63 oled_write_ln_P(PSTR("Undefined"), false);
64 };
65 // Host Keyboard LED Status
66 led_t led_state = host_keyboard_led_state();
67 oled_write_P(led_state.num_lock ? PSTR("NUMLCK ") : PSTR(" "), false);
68 oled_write_P(led_state.caps_lock ? PSTR("CAPLCK ") : PSTR(" "), false);
69 oled_write_P(led_state.scroll_lock ? PSTR("SCRLCK\n") : PSTR(" \n"), false);
70 }
71}
72#endif
73
74#ifdef ENCODER_ENABLE
75bool encoder_update_kb(uint8_t index, bool clockwise) {
76 if (!encoder_update_user(index, clockwise)) { return false; }
77 if (index == 0) { /* Left side encoder */
78 if (clockwise) {
79 tap_code(KC_WH_U);
80 } else {
81 tap_code(KC_WH_D);
82 }
83 } else if (index == 1) { /* Right side encoder */
84 if (clockwise) {
85 tap_code(KC_WH_U);
86 } else {
87 tap_code(KC_WH_D);
88 }
89 }
90 return true;
91}
92#endif