logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

rev1.c (1989B)


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