Per Layer RGB control

Hi everyone,

this is my first post here and i’m not sure if this is the right category, but this is what seemed right to me.
Also, English is not my first language, so please forgive me all my mistakes
:wink:

I finally came around to configure the Macropad of my Framework 16 which was not as straight-forward as I imagined it to be as I had to manually edit my udev-rules.

But now, that I have multiple Layers of keybindings, I have the issue that I never know on which Layer I currently am.

My preferred solution would be to have different RGB colours or Patterns for each Layer, which would include the following functions:

  • the Effect changes when a Layer is changed
  • a Layer always has the same Effect
  • Keys should have individual Colours to indicate their function (optional)
  • I only have to press one key to change Layer and Colour, not multiple

has anyone already achieved something like this?

I already tried to create a marco that does that, but i cant attach a layerchange to a macro.

Also, the Lighting Settings are global and independant of the active layer

Is something like I proposed even possible with standard firmware?

If not:

Could Framework integrate such functionality, as I think this could be beneficial to many users?

I am not a software developer, but I think it wouldn’t be that hard to add an option to configure individual lighting modes per layer.

Thank you!

Welcome Guest478 :slight_smile:

this is the thread that I used to make my macro pad behave the way I wanted it to :slight_smile:

if I remember right @MJ1 was the one who had done a lot of work and explained how it works so if this is helpfull then all credits go to him :slight_smile:

but yeah in that thread you can see my super simple keymap.c and yeah it does what I need.. so thats good enough for me for now :slight_smile:

FrameworkDeck was another project someone else doing..
https://github.com/enkode/FrameworkDeck
to be honest I can’t remember why I’m not using that one instead of my custom built thing..

as for your english, seems perfectly fine to me :slight_smile:

in that thread, you said that you also wanted to Layers in the Future.

Have you already done that or do you know how I could modify your Keymap to achieve that?

Regarding the FrameworkDeck, I dont trust it as much as it seems to be mainly vibecoded.

So if can i achieve it with your version (+ some modifications), i would prefer that.

Ahh here I was thinking that thread had the latest bit I had done…
its not perfection by any means or probably even the best way to do things, might even be the worst.. but seems to work :slight_smile:

#include QMK_KEYBOARD_H
#define MAX_BRIGHTNESS 255
#define MIN_BRIGHTNESS 10

enum custom_keycodes {
    MACRO_BRIGHT_UP = SAFE_RANGE,
    MACRO_BRIGHT_DOWN
};

static uint8_t ledbright = 20; // Start at 20% brightness

bool increasing = true; // Tracks the direction of the color shift
uint8_t green = 255;
uint8_t blue = 0;

/*  Macropad key location to LED Index
     *         β”Œβ”€β”€β”€β”€β”¬β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”
     *  row 1  β”‚  5 β”‚  2 β”‚ 22 β”‚ 17 β”‚
     *         β”œβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€
     *  row 2  β”‚  4 β”‚  0 β”‚ 20 β”‚ 18 β”‚
     *         β”œβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€
     *  row 3  β”‚  7 β”‚  1 β”‚ 21 β”‚ 16 β”‚
     *         β”œβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€
     *  row 4  β”‚  6 β”‚  3 β”‚ 23 β”‚ 19 β”‚
     *         β”œβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€
     *  row 5  β”‚  9 β”‚ 11 β”‚ 15 β”‚ 13 β”‚
     *         β”œβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€
     *  row 6  β”‚  8 β”‚ 10 β”‚ 14 β”‚ 12 β”‚
     *         β””β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”˜
     *        24 keys and LEDs total
     */

     // Hold down 2 and 6 to flash firmware to macro pad


uint8_t led_colors[24][3] = {
     [5] = { 64,  64,  64},  // Shurly this must be grey now.
     [2] = { 64,  64,  64},  // Shurly this must be grey now.
    [22] = { 64,  64,  64},  // light blue
    [17] = { 64,  64,  64},  // DeepDarkBlue
     [7] = {255,   0,   0},  // Red
     [1] = {255, 165,   0},  // Orange (leaning towards yellow)
    [21] = {255,   0,   0},  // Red
    [19] = {128, 128,  32},  // Red
     [6] = {255,  69,   0},  // Orange
     [3]  ={234, 255,   0},  // Yellowish with a hint of green
    [23] = {255,  69,   0},  // Orange
    [12] = {  0, 140, 139},  // Teal
     [8] = {  0, 220, 139},  // Teal
     [9] = {140,   0, 139},  // Purpleish
     [4] = {255, 255, 255},  // White
     [0] = {191, 191, 191},  // Dimmer white
    [20] = {128, 128, 128},  // can we call it grey yet ?
    [18] = { 64,  64,  64}   // Shurly this must be grey now.

};

// Default color for all other keys (Dark Blue)
#define DEFAULT_R 0
#define DEFAULT_G 0
#define DEFAULT_B 139

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    [0] = LAYOUT(
        KC_NO,    KC_NO,    KC_NO,    KC_NO,
        KC_1,     KC_2,     KC_3,     KC_4,
        KC_Q,     KC_W,     KC_E,     KC_TAB,
        KC_A,     KC_S,     KC_D,     KC_F,
        KC_LSFT,  KC_NO,    KC_NO,    TO(1),
        KC_LCTL,  KC_NO,    KC_NO,    KC_SPACE
    ),
    [1] = LAYOUT(
        KC_NO,    KC_NO,    KC_NO,    KC_NO,
        KC_NO,    KC_NO,    KC_NO,    KC_NO,
         KC_7,     KC_8,     KC_9,    KC_NO,
         KC_4,     KC_5,     KC_6,    KC_NO,
         KC_1,     KC_2,     KC_3,    TO(2),
        KC_NO,     KC_0,     KC_NO,    KC_NO
    ),
    [2] = LAYOUT(
        KC_NO,    KC_NO,    KC_NO,    KC_NO,
        KC_F1,    KC_F2,    KC_F3,    KC_F4,
        KC_Q,     KC_W,     KC_E,     KC_TAB,
        KC_A,     KC_S,     KC_D,     KC_F,
        KC_LSFT,  KC_NO,    KC_NO,    TO(3),
        KC_LCTL,  KC_NO,    KC_NO,    KC_SPACE
    ),
    [3] = LAYOUT(
        KC_NO,    KC_NO,    KC_NO,    KC_NO,
        KC_F1,    KC_F2,    KC_F3,    KC_F4,
        KC_HOME,  KC_UP,    KC_PGUP,  KC_TAB,
        KC_LEFT,  KC_DOWN,  KC_RIGHT, KC_F,
        KC_LSFT,  KC_NO,    KC_NO,    TO(0),
        KC_LCTL,  KC_NO,    KC_NO,    KC_SPACE
    )
};

void cycle_tab_color(void) {
    if (increasing) {
        green--;
        blue++;
        if (green == 0 && blue == 255) {
            increasing = false; // Reverse direction
        }
    } else {
        green++;
        blue--;
        if (green == 255 && blue == 0) {
            increasing = true; // Switch back
        }
    }
    led_colors[16][0]=0;
    led_colors[16][1]=green;
    led_colors[16][2]=blue;

    //rgb_matrix_set_color(16, 0, green, blue);// Update RGB lighting
}

bool rgb_matrix_indicators_user(void) {
    if (layer_state_is(0)) 
    {
        led_colors[13][0]=0;
        led_colors[13][1]=255;
        led_colors[13][2]=0; 
    }

    if (layer_state_is(1)) 
    {
        led_colors[13][0]=255;
        led_colors[13][1]=0;
        led_colors[13][2]=0; 
    }      

    if (layer_state_is(2)) 
    {
        led_colors[13][0]=0;
        led_colors[13][1]=0;
        led_colors[13][2]=255; 
    }      

    if (layer_state_is(3)) 
    {
        led_colors[13][0]=255;
        led_colors[13][1]=0;
        led_colors[13][2]=255; 
    }      
    
    
    for (int i = 0; i < 24; i++) {
        uint8_t r = DEFAULT_R, g = DEFAULT_G, b = DEFAULT_B;
        
        if (led_colors[i][0] || led_colors[i][1] || led_colors[i][2]) {
            r = (led_colors[i][0] * ledbright) / MAX_BRIGHTNESS;
            g = (led_colors[i][1] * ledbright) / MAX_BRIGHTNESS;
            b = (led_colors[i][2] * ledbright) / MAX_BRIGHTNESS;
        } else {
            r = (DEFAULT_R * ledbright) / MAX_BRIGHTNESS;
            g = (DEFAULT_G * ledbright) / MAX_BRIGHTNESS;
            b = (DEFAULT_B * ledbright) / MAX_BRIGHTNESS;
        }
        rgb_matrix_set_color(i, r, g, b);
    }
    cycle_tab_color();
    return true;
}


bool process_record_user(uint16_t keycode, keyrecord_t *record) {
    if (record->event.pressed) {
        if (keycode == MACRO_BRIGHT_DOWN) { 
            if (ledbright > MIN_BRIGHTNESS) {
                ledbright -= 1;
            }
        } else if (keycode == MACRO_BRIGHT_UP) { 
            if (ledbright < MAX_BRIGHTNESS) {
                ledbright += 1;
            }
        }
    }
    return false;
}


so here is where I basically just set the colour of one of the keys to indicate the layer i’m on :slight_smile:

bool rgb_matrix_indicators_user(void) {
    if (layer_state_is(0)) 
    {
        led_colors[13][0]=0;
        led_colors[13][1]=255;
        led_colors[13][2]=0; 
    }

    if (layer_state_is(1)) 
    {
        led_colors[13][0]=255;
        led_colors[13][1]=0;
        led_colors[13][2]=0; 
    }      

    if (layer_state_is(2)) 
    {
        led_colors[13][0]=0;
        led_colors[13][1]=0;
        led_colors[13][2]=255; 
    }      

    if (layer_state_is(3)) 
    {
        led_colors[13][0]=255;
        led_colors[13][1]=0;
        led_colors[13][2]=255; 
    }      
    
    
    for (int i = 0; i < 24; i++) {
        uint8_t r = DEFAULT_R, g = DEFAULT_G, b = DEFAULT_B;
        
        if (led_colors[i][0] || led_colors[i][1] || led_colors[i][2]) {
            r = (led_colors[i][0] * ledbright) / MAX_BRIGHTNESS;
            g = (led_colors[i][1] * ledbright) / MAX_BRIGHTNESS;
            b = (led_colors[i][2] * ledbright) / MAX_BRIGHTNESS;
        } else {
            r = (DEFAULT_R * ledbright) / MAX_BRIGHTNESS;
            g = (DEFAULT_G * ledbright) / MAX_BRIGHTNESS;
            b = (DEFAULT_B * ledbright) / MAX_BRIGHTNESS;
        }
        rgb_matrix_set_color(i, r, g, b);
    }
    cycle_tab_color();
    return true;
}

hopefully this helps somewhat.. Colour cycling I was just curious if I could do it and was messing around..

1 Like

Tahnk you very much!

This is the keymap as i modified it, if anyone is interested:

#include QMK_KEYBOARD_H
#define MAX_BRIGHTNESS 255
#define MIN_BRIGHTNESS 10

enum custom_keycodes {
    MACRO_BRIGHT_UP = SAFE_RANGE,
    MACRO_BRIGHT_DOWN
};

static uint8_t ledbright = 100; // Start at 20% brightness

bool increasing = true; // Tracks the direction of the color shift
uint8_t green = 255;
uint8_t blue = 0;

/*  Macropad key location to LED Index
 *         β”Œβ”€β”€β”€β”€β”¬β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”
 *  row 1  β”‚  5 β”‚  2 β”‚ 22 β”‚ 17 β”‚
 *         β”œβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€
 *  row 2  β”‚  4 β”‚  0 β”‚ 20 β”‚ 18 β”‚
 *         β”œβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€
 *  row 3  β”‚  7 β”‚  1 β”‚ 21 β”‚ 16 β”‚
 *         β”œβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€
 *  row 4  β”‚  6 β”‚  3 β”‚ 23 β”‚ 19 β”‚
 *         β”œβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€
 *  row 5  β”‚  9 β”‚ 11 β”‚ 15 β”‚ 13 β”‚
 *         β”œβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€
 *  row 6  β”‚  8 β”‚ 10 β”‚ 14 β”‚ 12 β”‚
 *         β””β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”˜
 *        24 keys and LEDs total
 */

// Hold down 2 and 6 to flash firmware to macro pad


uint8_t led_colors[24][3] = {

};

// Default color for all other keys (Dark Blue)
#define DEFAULT_R 64
#define DEFAULT_G 64
#define DEFAULT_B 64

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    [0] = LAYOUT(
        KC_ESC,  KC_CALC, KC_EQL,  KC_NO,
        TO(1),  KC_PSLS, KC_PAST, KC_BSPC,
        KC_7,   KC_8,   KC_9,   KC_PMNS,
        KC_4,   KC_5,   KC_6,   KC_PPLS,
        KC_1,   KC_2,   KC_3,   KC_ENT,
        TO(1),   KC_0,   KC_DOT, KC_ENT

    ),
    [1] = LAYOUT(
        QK_CLEAR_EEPROM,    QK_BOOT,    MACRO_BRIGHT_UP,    MACRO_BRIGHT_DOWN,
        TO(0),    KC_NO,    KC_NO,    BL_STEP,
        KC_NO,     KC_UP,     KC_PAGE_UP,    KC_NO,
        KC_LEFT,     KC_ENT,     KC_RIGHT,    KC_NO,
        KC_NO,     KC_DOWN,     KC_PAGE_DOWN,    KC_NO,
        TO(2),     KC_CUT,     KC_COPY,    KC_PASTE
    ),
    [2] = LAYOUT(
        KC_NO,    KC_NO,    KC_NO,    KC_NO,
        KC_NO,    KC_1,    KC_2,    KC_3,
        KC_TAB,     KC_Q,     KC_W,     KC_E,
        KC_LSFT,     KC_A,     KC_S,     KC_D,
        KC_LSFT,  KC_NO,    KC_NO,    KC_NO,
        TO(0),  KC_NO,    KC_NO,    KC_SPACE
    ),
    [3] = LAYOUT(
        KC_F21,    KC_F22,    KC_F23,    KC_F24,
        KC_F1,    KC_F2,    KC_F3,    KC_F4,
        KC_HOME,  KC_UP,    KC_PGUP,  KC_TAB,
        KC_LEFT,  KC_DOWN,  KC_RIGHT, KC_F,
        KC_LSFT,  KC_NO,    KC_NO,    TO(0),
        KC_LCTL,  KC_NO,    KC_NO,    KC_SPACE
    )
};
/*
void cycle_tab_color(void) {
    if (increasing) {
        green--;
        blue++;
        if (green == 0 && blue == 255) {
            increasing = false; // Reverse direction
        }
    } else {
        green++;
        blue--;
        if (green == 255 && blue == 0) {
            increasing = true; // Switch back
        }
    }
    led_colors[16][0]=0;
    led_colors[16][1]=green;
    led_colors[16][2]=blue;

    //rgb_matrix_set_color(16, 0, green, blue);// Update RGB lighting
}
*/
#define NUMPAD_R 20
#define NUMPAD_G 60
#define NUMPAD_B 255
bool rgb_matrix_indicators_user(void) {
    if (layer_state_is(0))
    {
        //2nd row
        led_colors[4][0]=0;
        led_colors[4][1]=0;
        led_colors[4][2]=255;
        led_colors[0][0]=200;
        led_colors[0][1]=0;
        led_colors[0][2]=200;
        led_colors[20][0]=150;
        led_colors[20][1]=200;
        led_colors[20][2]=0;
        //right column
        led_colors[18][0]=255;
        led_colors[18][1]=70;
        led_colors[18][2]=0;
        led_colors[16][0]=255;
        led_colors[16][1]=0;
        led_colors[16][2]=0;
        led_colors[19][0]=0;
        led_colors[19][1]=255;
        led_colors[19][2]=0;
        led_colors[13][0]=255;
        led_colors[13][1]=255;
        led_colors[13][2]=255;

        //cross
        led_colors[1][0]=NUMPAD_R;
        led_colors[1][1]=NUMPAD_G;
        led_colors[1][2]=NUMPAD_B;
        led_colors[6][0]=NUMPAD_R;
        led_colors[6][1]=NUMPAD_G;
        led_colors[6][2]=NUMPAD_B;
        led_colors[11][0]=NUMPAD_R;
        led_colors[11][1]=NUMPAD_G;
        led_colors[11][2]=NUMPAD_B;
        led_colors[23][0]=NUMPAD_R;
        led_colors[23][1]=NUMPAD_G;
        led_colors[23][2]=NUMPAD_B;
        //center
        led_colors[3][0]=NUMPAD_R;
        led_colors[3][1]=NUMPAD_G;
        led_colors[3][2]=NUMPAD_B;
        //cross_bg
        led_colors[7][0]=NUMPAD_R;
        led_colors[7][1]=NUMPAD_G;
        led_colors[7][2]=NUMPAD_B;
        led_colors[21][0]=NUMPAD_R;
        led_colors[21][1]=NUMPAD_G;
        led_colors[21][2]=NUMPAD_B;
        led_colors[9][0]=NUMPAD_R;
        led_colors[9][1]=NUMPAD_G;
        led_colors[9][2]=NUMPAD_B;
        led_colors[15][0]=NUMPAD_R;
        led_colors[15][1]=NUMPAD_G;
        led_colors[15][2]=NUMPAD_B;
        //bottom row
        led_colors[10][0]=NUMPAD_R;
        led_colors[10][1]=NUMPAD_G;
        led_colors[10][2]=NUMPAD_B;
        led_colors[14][0]=DEFAULT_R;
        led_colors[14][1]=DEFAULT_G;
        led_colors[14][2]=DEFAULT_B;
    }

    if (layer_state_is(1))
    {
        //2nd row
        led_colors[4][0]=0;
        led_colors[4][1]=0;
        led_colors[4][2]=255;
        led_colors[0][0]=DEFAULT_R;
        led_colors[0][1]=DEFAULT_G;
        led_colors[0][2]=DEFAULT_B;
        led_colors[20][0]=DEFAULT_R;
        led_colors[20][1]=DEFAULT_G;
        led_colors[20][2]=DEFAULT_B;
        //right column
        led_colors[18][0]=DEFAULT_R;
        led_colors[18][1]=DEFAULT_G;
        led_colors[18][2]=DEFAULT_B;
        led_colors[16][0]=DEFAULT_R;
        led_colors[16][1]=DEFAULT_G;
        led_colors[16][2]=DEFAULT_B;
        led_colors[19][0]=DEFAULT_R;
        led_colors[19][1]=DEFAULT_G;
        led_colors[19][2]=DEFAULT_B;
        led_colors[13][0]=255;
        led_colors[13][1]=0;
        led_colors[13][2]=0;
        led_colors[12][0]=0;
        led_colors[12][1]=255;
        led_colors[12][2]=0;
        //cross
        led_colors[1][0]=0;
        led_colors[1][1]=255;
        led_colors[1][2]=0;
        led_colors[6][0]=0;
        led_colors[6][1]=255;
        led_colors[6][2]=0;
        led_colors[11][0]=0;
        led_colors[11][1]=255;
        led_colors[11][2]=0;
        led_colors[23][0]=0;
        led_colors[23][1]=255;
        led_colors[23][2]=0;
        //center
        led_colors[3][0]=0;
        led_colors[3][1]=255;
        led_colors[3][2]=0;
        //cross_bg
        led_colors[7][0]=DEFAULT_R;
        led_colors[7][1]=DEFAULT_G;
        led_colors[7][2]=DEFAULT_B;
        led_colors[21][0]=255;
        led_colors[21][1]=50;
        led_colors[21][2]=0;
        led_colors[9][0]=DEFAULT_R;
        led_colors[9][1]=DEFAULT_G;
        led_colors[9][2]=DEFAULT_B;
        led_colors[15][0]=255;
        led_colors[15][1]=50;
        led_colors[15][2]=0;
        //bottom row
        led_colors[10][0]=255;
        led_colors[10][1]=0;
        led_colors[10][2]=0;
        led_colors[14][0]=150;
        led_colors[14][1]=150;
        led_colors[14][2]=0;
        led_colors[12][0]=255;
        led_colors[12][1]=255;
        led_colors[12][2]=255;

    }

    if (layer_state_is(2))
    {
        //2nd row
        led_colors[4][0]=DEFAULT_R;
        led_colors[4][1]=DEFAULT_G;
        led_colors[4][2]=DEFAULT_B;
        led_colors[0][0]=DEFAULT_R;
        led_colors[0][1]=DEFAULT_G;
        led_colors[0][2]=DEFAULT_B;
        led_colors[20][0]=DEFAULT_R;
        led_colors[20][1]=DEFAULT_G;
        led_colors[20][2]=DEFAULT_B;
        //right column
        led_colors[18][0]=DEFAULT_R;
        led_colors[18][1]=DEFAULT_G;
        led_colors[18][2]=DEFAULT_B;
        led_colors[16][0]=DEFAULT_R;
        led_colors[16][1]=DEFAULT_G;
        led_colors[16][2]=DEFAULT_B;
        led_colors[19][0]=DEFAULT_R;
        led_colors[19][1]=DEFAULT_G;
        led_colors[19][2]=DEFAULT_B;
        led_colors[13][0]=0;
        led_colors[13][1]=0;
        led_colors[13][2]=255;
        led_colors[12][0]=0;
        led_colors[12][1]=0;
        led_colors[12][2]=255;
        //cross
        led_colors[1][0]=DEFAULT_R;
        led_colors[1][1]=DEFAULT_G;
        led_colors[1][2]=DEFAULT_B;
        led_colors[6][0]=DEFAULT_R;
        led_colors[6][1]=DEFAULT_G;
        led_colors[6][2]=DEFAULT_B;
        led_colors[11][0]=DEFAULT_R;
        led_colors[11][1]=DEFAULT_G;
        led_colors[11][2]=DEFAULT_B;
        led_colors[23][0]=DEFAULT_R;
        led_colors[23][1]=DEFAULT_G;
        led_colors[23][2]=DEFAULT_B;
        led_colors[3][0]=DEFAULT_R;
        led_colors[3][1]=DEFAULT_G;
        led_colors[3][2]=DEFAULT_B;
        //center
        led_colors[3][0]=DEFAULT_R;
        led_colors[3][1]=DEFAULT_G;
        led_colors[3][2]=DEFAULT_B;
        //cross_bg
        led_colors[7][0]=DEFAULT_R;
        led_colors[7][1]=DEFAULT_G;
        led_colors[7][2]=DEFAULT_B;
        led_colors[21][0]=DEFAULT_R;
        led_colors[21][1]=DEFAULT_G;
        led_colors[21][2]=DEFAULT_B;
        led_colors[9][0]=DEFAULT_R;
        led_colors[9][1]=DEFAULT_G;
        led_colors[9][2]=DEFAULT_B;
        led_colors[15][0]=DEFAULT_R;
        led_colors[15][1]=DEFAULT_G;
        led_colors[15][2]=DEFAULT_B;
        //bottom row
        led_colors[10][0]=DEFAULT_R;
        led_colors[10][1]=DEFAULT_G;
        led_colors[10][2]=DEFAULT_B;
        led_colors[14][0]=DEFAULT_R;
        led_colors[14][1]=DEFAULT_G;
        led_colors[14][2]=DEFAULT_B;
        led_colors[12][0]=DEFAULT_R;
        led_colors[12][1]=DEFAULT_G;
        led_colors[12][2]=DEFAULT_B;

    }

    if (layer_state_is(3))
    {
        led_colors[13][0]=0;
        led_colors[13][1]=0;
        led_colors[13][2]=0;
        led_colors[12][0]=0;
        led_colors[12][1]=0;
        led_colors[12][2]=0;
    }


    for (int i = 0; i < 24; i++) {
        uint8_t r = DEFAULT_R, g = DEFAULT_G, b = DEFAULT_B;

        if (led_colors[i][0] || led_colors[i][1] || led_colors[i][2]) {
            r = (led_colors[i][0] * ledbright) / MAX_BRIGHTNESS;
            g = (led_colors[i][1] * ledbright) / MAX_BRIGHTNESS;
            b = (led_colors[i][2] * ledbright) / MAX_BRIGHTNESS;
        } else {
            r = (DEFAULT_R * ledbright) / MAX_BRIGHTNESS;
            g = (DEFAULT_G * ledbright) / MAX_BRIGHTNESS;
            b = (DEFAULT_B * ledbright) / MAX_BRIGHTNESS;
        }
        rgb_matrix_set_color(i, r, g, b);
    }
    /*
    cycle_tab_color();
    */
    return true;
}


bool process_record_user(uint16_t keycode, keyrecord_t *record) {
    if (record->event.pressed) {
        if (keycode == MACRO_BRIGHT_DOWN) {
            if (ledbright > MIN_BRIGHTNESS) {
                ledbright -= 1;
            }
        } else if (keycode == MACRO_BRIGHT_UP) {
            if (ledbright < MAX_BRIGHTNESS) {
                ledbright += 1;
            }
        }
    }
    return false;
}

the only thing I did not get to work was the brightness control.

Did it work with your setup? and how did you assign the macros?

yeah pretty sure it did…but found that the value of 20 was just right…

enum custom_keycodes {
MACRO_BRIGHT_UP = SAFE_RANGE,
MACRO_BRIGHT_DOWN
};

so this bit should make the keycode a unused code

so then thats the key code to use in the layout.

1 Like

just tested it and yeah it works…
(what ever weird thing I have done it also acts as if I click the function of what ever is on F9)
but yeah it increases and decreases the brightness…

[3] = LAYOUT(

    KC_NO,    KC_NO,    MACRO_BRIGHT_UP,    MACRO_BRIGHT_DOWN,

    KC_F1,    KC_F2,    KC_F3,    KC_F4,
1 Like