Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* https://www.reddit.com/r/olkb/comments/yeojrc/qmk_help_my_keyboard_freezes_after_running_this/
- * Code to create a toggleable LED that continually shifts color when active.
- * You can work with RGB values directly instead of HSV, if you prefer.
- * Change "HSV ind_HSV" to "RGB ind_RGB" and delete the line with "hsv_to_rgb(ind_HSV);"
- * This can go into keymap.c
- */
- #define INDICATOR_LED_INDEX 15 // set the index of the LED you want to shift color
- #define INDICATOR_UPDATE_TIME 10 // set how often the indicator will change hue, in milliseconds
- bool indicator_active = true; // turns the indicator LED color shifting on and off
- HSV ind_HSV = {HSV_BLUE}; // HSV variable to keep track of what color to set the LED to
- uint16_t last_ind_update = 0; // timer to keep track of the last time the indicator was updated
- void rgb_matrix_indicators_user() {
- if (indicator_active) {
- if (timer_elapsed(last_ind_update) > INDICATOR_UPDATE_TIME) { // if it's time for the next LED update
- last_ind_update = timer_read(); // update the LED timer
- // play with how you want to change the color each time here
- ind_HSV.h++; // increment h, the hue portion of ind_HSV for the indicator
- RGB ind_RGB = hsv_to_rgb(ind_HSV); // convert to RGB
- rgb_matrix_set_color(15, ind_RGB.r, ind_RGB.g, ind_RGB.b); // set color of indicator LED
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement