Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* https://www.reddit.com/r/olkb/comments/po9skn/how_do_i_flash_the_leds_on_the_dz60_on_every/
- * Code to briefly flash backlighting on every keypress.
- * Every keypress will turn backlighting on.
- * The backlighting will turn off BACKLIGHT_FLASH_TIME milliseconds after the most recent keypress.
- * This goes in keymap.c
- *
- * *Note 1: the number of backlight levels is defined in config.h, or defaults to 3. 31 is the max allowed number of levels.
- * Change '31' to below this value to flash the LEDs at a lower brightness.
- */
- #define BACKLIGHT_FLASH_TIME 200 //configure flash time in milliseconds
- uint16_t last_keydown_time = 0; //marks the time of last keydown event
- bool process_record_user(uint16_t keycode, keyrecord_t *record) {
- if (record->event.pressed) { //when any key is pressed
- last_keydown_time = timer_read(); //update last_keydown_time to now
- backlight_level_noeeprom(31); //set backlight level to 31 (max possible) *Note 1
- }
- switch (keycode) {
- //macro code
- }
- return true;
- }
- void matrix_scan_user(void) {
- if (get_backlight_level()) { //if backlight is on (level is not zero)
- if (timer_elapsed(last_keydown_time) > BACKLIGHT_FLASH_TIME) { //if last keydown was more than BACKLIGHT_FLASH_TIME ms ago
- backlight_level_noeeprom(0); //turn backlight off
- }
- }
- }
Add Comment
Please, Sign In to add comment