blob: f008e4857a1dd9d557bd3e9d74e8aff878791bad (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
// Copyright 2022 zzeneg (@zzeneg)
// SPDX-License-Identifier: GPL-2.0-or-later
#include "rev1.h"
#ifdef PICA40_RGBLIGHT_TIMEOUT
uint16_t check_rgblight_timer = 0;
uint16_t idle_timer = 0;
uint8_t counter = 0;
void housekeeping_task_kb(void) {
if (timer_elapsed(check_rgblight_timer) > 1000) {
check_rgblight_timer = timer_read();
if (rgblight_is_enabled() && timer_elapsed(idle_timer) > 10000) {
idle_timer = timer_read();
counter++;
}
if (rgblight_is_enabled() && counter > PICA40_RGBLIGHT_TIMEOUT * 6) {
counter = 0;
rgblight_disable_noeeprom();
}
}
housekeeping_task_user();
}
bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed && timer_elapsed(idle_timer) > 1000) {
idle_timer = timer_read();
counter = 0;
if (!rgblight_is_enabled()) {
rgblight_enable_noeeprom();
}
}
return process_record_user(keycode, record);
}
void keyboard_post_init_kb(void) {
check_rgblight_timer = timer_read();
idle_timer = timer_read();
rgblight_enable_noeeprom();
keyboard_post_init_user();
}
#endif // PICA40_RGBLIGHT_TIMEOUT
#ifdef OLED_ENABLE
oled_rotation_t oled_init_kb(oled_rotation_t rotation) {
return OLED_ROTATION_270;
}
void render_mods(uint8_t modifiers) {
oled_write_ln_P((modifiers & MOD_MASK_CTRL) ? PSTR("Ctrl") : PSTR(" "), false);
oled_write_ln_P((modifiers & MOD_MASK_ALT) ? PSTR("Alt") : PSTR(" "), false);
oled_write_ln_P((modifiers & MOD_MASK_SHIFT) ? PSTR("Shft") : PSTR(" "), false);
oled_write_ln_P((modifiers & MOD_MASK_GUI) ? PSTR("GUI") : PSTR(" "), false);
}
bool oled_task_kb(void) {
// display's top is hidden by cover
oled_write_ln_P(PSTR(" "), false);
oled_write_ln_P(PSTR(" "), false);
oled_write_ln_P(PSTR(" "), false);
if (!oled_task_user()) return false;
render_mods(get_mods());
return true;
}
#endif // OLED_ENABLE
#ifdef ENCODER_ENABLE
bool encoder_update_kb(uint8_t index, bool clockwise) {
if (!encoder_update_user(index, clockwise)) return false;
tap_code(clockwise ? KC_VOLU : KC_VOLD);
return false;
}
#endif // ENCODER_ENABLE
|