aboutsummaryrefslogtreecommitdiff
path: root/users/snowe/oled_setup.c
diff options
context:
space:
mode:
authorTyler Thrailkill <tylerbthrailkill@gmail.com>2021-06-23 20:21:40 -0600
committerGitHub <noreply@github.com>2021-06-24 12:21:40 +1000
commit4a15eb593d0d1447bf9bca87ef966f84b8077a4f (patch)
tree8b4bf29238334d71eca22d4687451f8c0430dab4 /users/snowe/oled_setup.c
parent6e1ed1c9d3f083e7dbb7b17375e437963cd70771 (diff)
downloadqmk_firmware-4a15eb593d0d1447bf9bca87ef966f84b8077a4f.tar.gz
qmk_firmware-4a15eb593d0d1447bf9bca87ef966f84b8077a4f.zip
snowe keymap/userspace and Ocean Dream animation (#12477)
* Add snowe keymap/userspace & Ocean Dream animation * Add snowe userspace with keymap wrappers and two animations * Add crkbd keymap * Add Ocean Dream animation, a cool full screen animation with: * * twinkling stars * * meteor showers * * ocean waves * * island with palm tree * * moon with phases * Disable Luna so travis build succeeds. * Add more copyrights * Add pragma once to keycode_aliases.h Co-authored-by: Drashna Jaelre <drashna@live.com> Co-authored-by: Drashna Jaelre <drashna@live.com>
Diffstat (limited to 'users/snowe/oled_setup.c')
-rw-r--r--users/snowe/oled_setup.c141
1 files changed, 141 insertions, 0 deletions
diff --git a/users/snowe/oled_setup.c b/users/snowe/oled_setup.c
new file mode 100644
index 000000000..b3e04df45
--- /dev/null
+++ b/users/snowe/oled_setup.c
@@ -0,0 +1,141 @@
1/*
2 * Copyright QMK Community
3 * Copyright 2021 Tyler Thrailkill (@snowe/@snowe2010) <tyler.b.thrailkill@gmail.com>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifdef OLED_DRIVER_ENABLE
20
21# include QMK_KEYBOARD_H
22# include "quantum.h"
23# include "snowe.h"
24
25# include <stdio.h> // for keylog?
26
27oled_rotation_t oled_init_user(oled_rotation_t rotation) {
28 if (!is_master) {
29 return OLED_ROTATION_270; // flips the display 180 degrees if offhand
30 }
31 return OLED_ROTATION_270;
32}
33
34# define L_BASE 0
35# define L_LOWER 2
36# define L_RAISE 4
37# define L_ADJUST 8
38
39void oled_render_layer_state(void) {
40 oled_write_P(PSTR("Layer"), false);
41 switch (layer_state) {
42 case L_BASE:
43 oled_write_ln_P(PSTR("Main"), false);
44 break;
45 case L_LOWER:
46 oled_write_ln_P(PSTR("Bot"), false);
47 break;
48 case L_RAISE:
49 oled_write_ln_P(PSTR("Top"), false);
50 break;
51 case L_ADJUST:
52 case L_ADJUST | L_LOWER:
53 case L_ADJUST | L_RAISE:
54 case L_ADJUST | L_LOWER | L_RAISE:
55 oled_write_ln_P(PSTR("Comb"), false);
56 break;
57 }
58}
59
60char keylog_str[24] = {};
61
62const char code_to_name[60] = {
63 ' ', ' ', ' ', ' ', 'a', 'b', 'c', 'd', 'e', 'f',
64 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
65 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
66 '1', '2', '3', '4', '5', '6', '7', '8', '9', '0',
67 'R', 'E', 'B', 'T', '_', '-', '=', '[', ']', '\\',
68 '#', ';', '\'', '`', ',', '.', '/', ' ', ' ', ' '};
69
70void set_keylog(uint16_t keycode, keyrecord_t *record) {
71 char name = ' ';
72 if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) {
73 keycode = keycode & 0xFF;
74 }
75 if (keycode < 60) {
76 name = code_to_name[keycode];
77 }
78
79 // update keylog
80 snprintf(keylog_str, sizeof(keylog_str), "%dx%d, k%2d : %c", record->event.key.row, record->event.key.col, keycode, name);
81}
82
83void oled_render_keylog(void) { oled_write(keylog_str, false); }
84
85// void render_bootmagic_status(bool status) {
86// /* Show Ctrl-Gui Swap options */
87// static const char PROGMEM logo[][2][3] = {
88// {{0x97, 0x98, 0}, {0xb7, 0xb8, 0}},
89// {{0x95, 0x96, 0}, {0xb5, 0xb6, 0}},
90// };
91// if (status) {
92// oled_write_ln_P(logo[0][0], false);
93// oled_write_ln_P(logo[0][1], false);
94// } else {
95// oled_write_ln_P(logo[1][0], false);
96// oled_write_ln_P(logo[1][1], false);
97// }
98//}
99void render_bootmagic_status(void) {
100 /* Show Ctrl-Gui Swap options */
101 static const char PROGMEM logo[][2][3] = {
102 {{0x97, 0x98, 0}, {0xb7, 0xb8, 0}},
103 {{0x95, 0x96, 0}, {0xb5, 0xb6, 0}},
104 };
105 oled_write_P(PSTR("BTMGK"), false);
106 oled_write_P(PSTR(""), false);
107 if (!keymap_config.swap_lctl_lgui) {
108 oled_write_P(logo[1][0], false);
109 oled_write_P(PSTR(" "), false);
110 oled_write_P(logo[1][1], false);
111 } else {
112 oled_write_P(logo[0][0], false);
113 oled_write_P(PSTR(" "), false);
114 oled_write_P(logo[0][1], false);
115 }
116 oled_write_P(PSTR(" NKRO "), keymap_config.nkro);
117 oled_write_P(PSTR("WPM: "), false);
118
119 char wpm[6];
120 itoa(get_current_wpm(), wpm, 10);
121 oled_write_ln(wpm, false);
122}
123
124void oled_task_user(void) {
125 if (is_master) {
126 oled_render_layer_state();
127 oled_render_keylog();
128 render_bootmagic_status();
129
130# ifdef LUNA_ENABLE
131 led_usb_state = host_keyboard_led_state();
132 render_luna(0, 13);
133# endif
134 } else {
135# ifdef OCEAN_DREAM_ENABLE
136 render_stars();
137# endif
138 }
139}
140
141#endif // OLED_DRIVER_ENABLE