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