Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enum custom_keycodes {
- TOG_STAT = SAFE_RANGE, //first macro key always starts at SAFE_RANGE
- //MACRO1, //other macros
- //MACRO2,
- //...
- };
- //configure the colors you want for each layer
- void set_layer_color() {
- switch(get_highest_layer(layer_state)) {
- case 0: //layer 0
- rgb_matrix_sethsv_noeeprom(HSV_ORANGE);
- break;
- case 1: //layer 1
- rgb_matrix_sethsv_noeeprom(HSV_CORAL);
- break;
- //other layers
- default: //for any layer not listed in this function
- rgb_matrix_sethsv_noeeprom(HSV_GREEN);
- break;
- }
- }
- //configure the animations you want for each layer
- void set_layer_anim(void) {
- switch(get_highest_layer(layer_state)) {
- case 0: //layer 0
- rgb_matrix_mode_noeeprom(RGB_MATRIX_BREATHING);
- break;
- case 1: //layer 1
- rgb_matrix_mode_noeeprom(RGB_MATRIX_SOLID_REACTIVE_MULTICROSS); //needs RGB_MATRIX_KEYPRESSES in config.h
- break;
- //other layers
- default: //for any layer not listed in this function
- rgb_matrix_mode_noeeprom(RGB_MATRIX_CYCLE_LEFT_RIGHT); //rainbow wave
- break;
- }
- }
- void set_rgb_layers(void) {
- if (!rgb_matrix_is_enabled()) return; //if LEDs are turned off, exit the function
- set_layer_color(); //set color based on current layer
- if (static_color_mode) { //if static color mode is active
- rgb_matrix_mode_noeeprom(RGB_MATRIX_SOLID_COLOR); //set LEDs to solid color mode
- } else {
- set_layer_anim(); //set animation based on current layer
- }
- }
- //this function is called automatically every time there's a layer change
- layer_state_t layer_state_set_user(layer_state_t state) {
- set_rgb_layers();
- return state;
- }
- //this will set the LEDs to static color mode when true
- bool static_color_mode = false;
- bool process_record_user(uint16_t keycode, keyrecord_t *record) {
- case TOG_STAT:
- if (record->event.pressed) { //when TOG_STAT is pressed
- static_color_mode = !static_color_mode; //flip this variable
- set_rgb_layers();
- }
- break;
- //change this key's functionality a bit to set color/animation when LEDs are toggled on
- case RGB_TOG:
- if (record->event.pressed) { //when RGB_TOG is pressed
- rgb_matrix_toggle_noeeprom(); //toggle RGB
- if (rgb_matrix_is_enabled) {
- set_rgb_layers();
- }
- return false; //do nothing else with this key
- }
- return true;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement