aboutsummaryrefslogtreecommitdiff
path: root/keyboards/splitkb/zima/zima.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/splitkb/zima/zima.c')
-rw-r--r--keyboards/splitkb/zima/zima.c112
1 files changed, 112 insertions, 0 deletions
diff --git a/keyboards/splitkb/zima/zima.c b/keyboards/splitkb/zima/zima.c
new file mode 100644
index 000000000..3989ebeb2
--- /dev/null
+++ b/keyboards/splitkb/zima/zima.c
@@ -0,0 +1,112 @@
1/* Copyright 2019 Thomas Baart
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 "zima.h"
17#include <stdio.h>
18
19#ifdef HAPTIC_ENABLE
20# include "haptic.h"
21extern haptic_config_t haptic_config;
22#endif
23
24#ifdef OLED_DRIVER_ENABLE
25static bool is_asleep = false;
26static uint32_t oled_timer;
27
28void suspend_power_down_kb(void) {
29 is_asleep = true;
30 suspend_power_down_user();
31}
32
33void suspend_wakeup_init_kb(void) {
34 is_asleep = false;
35 suspend_wakeup_init_user();
36}
37
38__attribute__((weak)) oled_rotation_t oled_init_user(oled_rotation_t rotation) { return OLED_ROTATION_180; }
39
40__attribute__((weak)) void oled_task_user(void) {
41 if (is_asleep) {
42 oled_off();
43 return;
44 }
45
46 if (timer_elapsed32(oled_timer) < 30000) {
47 oled_on();
48 oled_scroll_off();
49 oled_write_P(PSTR("SplitKB's Zima"), false);
50 char layer[2] = {0};
51 snprintf(layer, sizeof(layer), "%d", get_highest_layer(layer_state));
52 oled_write_P(PSTR(" L:"), false);
53 oled_write_ln(layer, false);
54 oled_write_ln_P(PSTR("--------------"), false);
55 if (rgblight_is_enabled()) {
56 oled_write_P(PSTR("HSV: "), false);
57 char rgbs[14];
58 snprintf(rgbs, sizeof(rgbs), "%3d, %3d, %3d", rgblight_get_hue(), rgblight_get_sat(), rgblight_get_val());
59 oled_write_ln(rgbs, false);
60 } else {
61 oled_write_ln_P(PSTR("RGB LIGHT DISABLED"), false);
62 }
63# ifdef AUDIO_ENABLE
64 oled_write_P(PSTR("Audio:"), false);
65 is_audio_on() ? oled_write_P(PSTR(" on"), false) : oled_write_P(PSTR("off"), false);
66# ifdef AUDIO_CLICKY
67 oled_write_P(PSTR(" Clicky:"), false);
68 (is_clicky_on() && is_audio_on()) ? oled_write_P(PSTR(" on"), false) : oled_write_P(PSTR("off"), false);
69# endif
70# endif
71 } else {
72 if (timer_elapsed32(oled_timer) < 120000) {
73 oled_on();
74 // clang-format off
75 static const char PROGMEM qmk_logo[] = {
76 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94,
77 0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0xb4,
78 0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4,0};
79 // clang-format on
80 oled_write_ln_P(qmk_logo, false);
81 oled_scroll_right();
82 } else {
83 oled_off();
84 }
85 }
86}
87
88bool process_record_kb(uint16_t keycode, keyrecord_t* record) {
89 oled_timer = timer_read32();
90
91 return process_record_user(keycode, record);
92}
93#endif
94
95#ifdef ENCODER_ENABLE
96__attribute__((weak)) void encoder_update_user(uint8_t index, bool clockwise) {
97 if (clockwise) {
98 tap_code16(KC_VOLU);
99 } else {
100 tap_code16(KC_VOLD);
101 }
102# ifdef OLED_DRIVER_ENABLE
103 oled_timer = timer_read32();
104# endif
105# if defined(AUDIO_ENABLE) && defined(AUDIO_CLICKY)
106 if (is_audio_on() && is_clicky_on()) clicky_play();
107# endif
108# ifdef HAPTIC_ENABLE
109 if (haptic_config.enable) haptic_play();
110# endif
111}
112#endif