Advertisement
hakbraley

QMK Flash backlighting 2

Sep 14th, 2021
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.72 KB | None | 0 0
  1. /*  https://www.reddit.com/r/olkb/comments/pohkyr/changing_backlight_level_also_enables_led_any_way/
  2.  *  This goes into keymap.c
  3.  */
  4.  
  5. static uint16_t key_timer;
  6. bool BL_flashing = true;  //backlight flashing mode
  7.  
  8. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  9.     if (BL_flashing && record->event.pressed) {
  10.         backlight_level_noeeprom(255);
  11.         key_timer = timer_read();
  12.     }
  13.  
  14.     switch (keycode) {
  15.         case BL_TOGG:
  16.             if (record->event.pressed)
  17.                 BL_flashing = !BL_flashing;  //toggle this variable
  18.             return false;                    //do nothing else
  19.     }
  20.     return true;
  21. }
  22.  
  23. void matrix_scan_user(void) {
  24.     if (timer_elapsed(key_timer) > 50 && get_backlight_level())
  25.         backlight_level_noeeprom(0);
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement