How to get to point you can have per key RGB control for keyboard and macropad?

@Cory_Galloway if you paste your whole files here, please also wrap it in a colapsed block to save the thread from being hard to scroll.
Like this:

[details="/framework/ansi/keymaps/default/keymap.c"]

```c
(keymap.c file code)
```
[/details]

example:

/framework/ansi/keymaps/default/keymap.c
// Copyright 2022 Framework Computer
// SPDX-License-Identifier: GPL-2.0-or-later

#include QMK_KEYBOARD_H
#include "framework.h"

enum _layers {
  _BASE,
  _FN,
  _FN_LOCK,
  _FM
};


const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
     /*
     *         β”Œβ”€β”€β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”€β”
     * 14 keys β”‚ESC  β”‚Mutβ”‚vDnβ”‚vUpβ”‚Prvβ”‚Plyβ”‚Nxtβ”‚bDnβ”‚bUpβ”‚Scnβ”‚Airβ”‚Prtβ”‚Appβ”‚Del β”‚
     *         β”œβ”€β”€β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”€β”€β”€β”€
     * 14 keys β”‚ ` β”‚ 1 β”‚ 2 β”‚ 3 β”‚ 4 β”‚ 5 β”‚ 6 β”‚ 7 β”‚ 8 β”‚ 9 β”‚ 0 β”‚ - β”‚ = β”‚Backspβ”‚
     *         β”œβ”€β”€β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”€β”€β”€β”€
     * 14 keys β”‚ Tab β”‚ Q β”‚ W β”‚ E β”‚ R β”‚ T β”‚ Y β”‚ U β”‚ I β”‚ O β”‚ P β”‚ [ β”‚ ] β”‚ \  β”‚
     *         β”œβ”€β”€β”€β”€β”€β”΄β”¬β”€β”€β”΄β”¬β”€β”€β”΄β”¬β”€β”€β”΄β”¬β”€β”€β”΄β”¬β”€β”€β”΄β”¬β”€β”€β”΄β”¬β”€β”€β”΄β”¬β”€β”€β”΄β”¬β”€β”€β”΄β”¬β”€β”€β”΄β”¬β”€β”€β”΄β”¬β”€β”€β”΄β”€β”€β”€β”€β”€
     * 13 keys β”‚ Caps β”‚ A β”‚ S β”‚ D β”‚ F β”‚ G β”‚ H β”‚ J β”‚ K β”‚ L β”‚ ; β”‚ ' β”‚ Enter β”‚
     *         β”œβ”€β”€β”€β”€β”€β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€
     * 12 keys β”‚ Shift  β”‚ Z β”‚ X β”‚ C β”‚ V β”‚ B β”‚ N β”‚ M β”‚ , β”‚ . β”‚ / β”‚  Shift  β”‚
     *         β”œβ”€β”€β”€β”€β”¬β”€β”€β”€β”Όβ”€β”€β”€β”Όβ”€β”€β”€β”Όβ”€β”€β”€β”΄β”€β”€β”€β”΄β”€β”€β”€β”΄β”€β”€β”€β”΄β”€β”€β”€β”Όβ”€β”€β”€β”Όβ”€β”€β”€β”Όβ”€β”€β”€β”΄β”¬β”€β”€β”€β”¬β”€β”€β”€β”€β”€
     *         β”‚    β”‚   β”‚   β”‚   β”‚                   β”‚   β”‚   β”‚    │↑  β”‚    β”‚
     * 11 keys β”‚Ctrlβ”‚FN β”‚GUIβ”‚Altβ”‚                   β”‚Altβ”‚Ctlβ”‚ ←  β”œβ”€β”€β”€β”€  β†’ β”‚
     *         β”‚    β”‚   β”‚   β”‚   β”‚                   β”‚   β”‚   β”‚    β”‚  ↓│    β”‚
     *         β””β”€β”€β”€β”€β”΄β”€β”€β”€β”΄β”€β”€β”€β”΄β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”΄β”€β”€β”€β”΄β”€β”€β”€β”€β”΄β”€β”€β”€β”΄β”€β”€β”€β”€β”˜
     * 78 total
     */
    [_BASE] = LAYOUT(
        KC_ESC,  KC_MUTE, KC_VOLD, KC_VOLU, KC_MPRV, KC_MPLY, KC_MNXT, KC_BRID, KC_BRIU, KC_SCRN, KC_AIRP, KC_PSCR, KC_MSEL, KC_DEL,
        KC_GRV,  KC_1,    KC_2,    KC_3,    KC_4,    KC_5,    KC_6,    KC_7,    KC_8,    KC_9,    KC_0,    KC_MINS, KC_EQL,  KC_BSPC,
        KC_TAB,  KC_Q,    KC_W,    KC_E,    KC_R,    KC_T,    KC_Y,    KC_U,    KC_I,    KC_O,    KC_P,    KC_LBRC, KC_RBRC, KC_BSLS,
        KC_CAPS, KC_A,    KC_S,    KC_D,    KC_F,    KC_G,    KC_H,    KC_J,    KC_K,    KC_L,    KC_SCLN, KC_QUOT,          KC_ENT,
        KC_LSFT,          KC_Z,    KC_X,    KC_C,    KC_V,    KC_B,    KC_N,    KC_M,    KC_COMM, KC_DOT,  KC_SLSH,          KC_RSFT,
        KC_LCTL, MO(_FN), KC_LGUI, KC_LALT,          KC_SPC,                    KC_RALT, KC_RCTL, KC_LEFT,   KC_UP, KC_DOWN, KC_RGHT
    ),
     /*
     * Function layer
     *         β”Œβ”€β”€β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”€β”
     * 14 keys β”‚FN lkβ”‚F1 β”‚F2 β”‚F3 β”‚F4 β”‚F5 β”‚F6 β”‚F7 β”‚F8 β”‚F9 β”‚F10β”‚F11β”‚F12β”‚Ins β”‚
     *         β”œβ”€β”€β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”€β”€β”€β”€
     * 14 keys β”‚   β”‚   β”‚   β”‚   β”‚   β”‚   β”‚   β”‚   β”‚   β”‚   β”‚   β”‚   β”‚   β”‚      β”‚
     *         β”œβ”€β”€β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”€β”€β”€β”€
     * 14 keys β”‚     β”‚   β”‚RGBβ”‚Nxtβ”‚Hueβ”‚Satβ”‚Spdβ”‚Brtβ”‚   β”‚   β”‚Pauβ”‚   β”‚   β”‚    β”‚
     *         β”œβ”€β”€β”€β”€β”€β”΄β”¬β”€β”€β”΄β”¬β”€β”€β”΄β”¬β”€β”€β”΄β”¬β”€β”€β”΄β”¬β”€β”€β”΄β”¬β”€β”€β”΄β”¬β”€β”€β”΄β”¬β”€β”€β”΄β”¬β”€β”€β”΄β”¬β”€β”€β”΄β”¬β”€β”€β”΄β”¬β”€β”€β”΄β”€β”€β”€β”€β”€
     * 13 keys β”‚      β”‚   β”‚SRqβ”‚Prvβ”‚Hueβ”‚Satβ”‚Spdβ”‚Brtβ”‚ScLβ”‚   β”‚   β”‚   β”‚       β”‚
     *         β”œβ”€β”€β”€β”€β”€β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€
     * 12 keys β”‚        β”‚   β”‚   β”‚   β”‚   β”‚   β”‚Brkβ”‚   β”‚   β”‚   β”‚   β”‚         β”‚
     *         β”œβ”€β”€β”€β”€β”¬β”€β”€β”€β”Όβ”€β”€β”€β”Όβ”€β”€β”€β”Όβ”€β”€β”€β”΄β”€β”€β”€β”΄β”€β”€β”€β”΄β”€β”€β”€β”΄β”€β”€β”€β”Όβ”€β”€β”€β”Όβ”€β”€β”€β”Όβ”€β”€β”€β”΄β”¬β”€β”€β”€β”¬β”€β”€β”€β”€β”€
     *         β”‚    β”‚   β”‚   β”‚   β”‚                   β”‚   β”‚   β”‚    β”‚PgUβ”‚    β”‚
     * 11 keys β”‚    β”‚   β”‚   β”‚   β”‚ Toggle Backlight  β”‚   β”‚   β”‚Homeβ”œβ”€β”€β”€β”€End β”‚
     *         β”‚    β”‚   β”‚   β”‚   β”‚                   β”‚   β”‚   β”‚    β”‚PgDβ”‚    β”‚
     *         β””β”€β”€β”€β”€β”΄β”€β”€β”€β”΄β”€β”€β”€β”΄β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”΄β”€β”€β”€β”΄β”€β”€β”€β”€β”΄β”€β”€β”€β”΄β”€β”€β”€β”€β”˜
     * 78 total
     */
    [_FN] = LAYOUT(
        FN_LOCK, KC_F1,   KC_F2,   KC_F3,   KC_F4,   KC_F5,   KC_F6,   KC_F7,   KC_F8,   KC_F9,   KC_F10,  KC_F11,  KC_F12,  KC_INS,
        _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
        _______, _______, RGB_TOG, RGB_MOD, RGB_HUI, RGB_SAI, RGB_SPI, RGB_VAI, _______, _______, KC_PAUS, _______, _______, _______,
        _______, _______, KC_SYRQ, RGB_RMOD,RGB_HUD, RGB_SAD, RGB_SPD, RGB_VAD, KC_SCRL, _______, _______, _______,          _______,
        _______,          _______, _______, BL_BRTG, _______, KC_BRK,  _______, _______, _______, _______, _______,          _______,
        _______, _______, _______, _______,          BL_STEP,                   _______, _______, KC_HOME, KC_PGUP, KC_PGDN, KC_END
    ),
    // Function lock layer
    // Everything on F-row locked to function layer, except ESC and DEL
    [_FN_LOCK] = LAYOUT(
        _______, KC_F1,   KC_F2,   KC_F3,   KC_F4,   KC_F5,   KC_F6,   KC_F7,   KC_F8,   KC_F9,   KC_F10,  KC_F11,  KC_F12,  _______,
        _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
        _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
        _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,          _______,
        _______,          _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,          _______,
        _______, MO(_FM), _______, _______,          _______,                   _______, _______, _______, _______, _______, _______
    ),
    // Locked+temporary FN (back to base plus extra keys)
    [_FM] = LAYOUT(
        FN_LOCK, KC_MUTE, KC_VOLD, KC_VOLU, KC_MPRV, KC_MPLY, KC_MNXT, KC_BRID, KC_BRIU, KC_SCRN, KC_AIRP, KC_PSCR, KC_MSEL,  KC_INS,
        _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
        _______, _______, RGB_TOG, RGB_MOD, RGB_HUI, RGB_SAI, RGB_SPI, RGB_VAI, _______, _______, KC_PAUS, _______, _______, _______,
        _______, _______, KC_SYRQ, RGB_RMOD,RGB_HUD, RGB_SAD, RGB_SPD, RGB_VAD, KC_SCRL, _______, _______, _______,          _______,
        _______,          _______, _______, BL_BRTG, _______, KC_BRK,  _______, _______, _______, _______, _______,          _______,
        _______, _______, _______, _______,          BL_STEP,                   _______, _______, KC_HOME, KC_PGUP, KC_PGDN, KC_END
    ),
};

// Make sure to keep FN Lock even after reset
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
    switch (keycode) {
        case FN_LOCK:
            if (record->event.pressed) {
                if (layer_state_is(_FN)) {
                    set_single_persistent_default_layer(_FN_LOCK);
                }
                if (layer_state_is(_FM)) {
                    set_single_persistent_default_layer(_BASE);
                }
            }
            return false;
            break;
        default:
            break;
    }
    return true;
}

The option is under the gear icon in the post editor.

2 Likes

thanks for info. i didnt want to paste the whole file and not sure how to add my files to github so i can give a link. i really want to let you see my keymap and other keyboard files i changed. i have only touched the files inside the keyboard folder. nothing higher than that folder was changed only referenced to find any errors inside my keyboard files. i just have to see if i can clean up the matrix without breaking it. i already cleaned up the rgb id’s so it starts at 0 in top left corner and goes in reading order in reading down the keyboard. so i think i can use rgb matrix with a bool setup that i input the start and end led to create segments so dont have to specify each rgb individually unless its just for a key not in a range specified. it will take me a minute to code those options but after trial and error and reading everything on qmk i can as reference i think i am good to go as long as i can find the commands and keycodes in the quantum and other folders that is where the commands were created to see how to use them correctly. which helps way more than some of the documentation on the websites that is kinda light on details.

While creating a proper fork of the Framework repo is the best way to store and share code, there is also the option of a gist. You can put multiple files in a single gist.
What is a GitHub gist? A Beginner’s Guide to GitHub gists

The RP2040 has so much memory that it isn’t any problem just specifying the keys you want individually. Of course, the color you wish to set can be a variable, so you don’t have to repeat that, and so you can change colors easily. But I get that it looks neater if you can condense specifying the keys.

There are two 21’s and no 10 here. I think the row 6 key 2 is LED 10 for K110, correct?

1 Like

Yep, looks like it’s LED index 10 for that key. Thanks for the correction! I updated the map. Maybe I looked at K101 instead of K110.

1 Like

I have been working on 6 versions of the per key RGB keymaps but this is the only one that is sorta polished and have not found any conflicts so far. ANYONE please take a look and if you got any changes that would increase speed or use less data for same tasks it would be appreciated. I also have ones for the macropad that work for me but i need to polish those too before uploading. you can see my macropad in the images on the README file.

I worked out how to change the RGB’s brightness like how backlight step works for animation brightness. and also now you can have per key RGB or turn off the RGB brightness and the animation colors will be active and you can configure in the RGB layer.

2 Likes

I was only able to take a quick glance at the code right now, but I can say the results are sure are nice. Are you seeing any problems in use?

When you’re satisfied with its functioning, you should consider creating a thread to make it more visible to others who might like it. A video would be nice to show it off.

Also, it’s just great to see more of the keyboard’s potential being used.

it took me a long time to condense the code while keeping functionality. today i got it to point i was not seeing any conflicts or unwanted actions taking place. wanted to post here so those that were working on similar could try it and give review or use the file and change the colors used.

I am not sure if anyone is checking the readme file in main. It has pictures of how the layers look. i will be creating a video of how it looks for changing layers and how to get to animations if anyone is interested.

1 Like

Video of Keymap Navigation

https://www.dropbox.com/scl/fi/vc1fssw52lvtmzqev77db/Vid-of-CORY6-Keymap-1.mp4?rlkey=hmqnncffqd1t3c9e7mv3kijuq&st=l40ogbw0&dl=0

3 Likes

possibly easier to look at on reddit

Your work so far looks awesome, keep us updated on your project, I cant wait to get my macro pad to have per key RGB!

i have been working on a program that will allow anyone to create a firmware personal to them without needing coding knowledge. but needed to create other apps first. i got the firmware down to a really small size but i need to finish adding hooks so the app can easily work with the slim firmware. and flesh out the app. i already added logic for they keys to consider the location of the led’s and relation to the icon the light will shine through. also understanding the shifted keys so the cross animation for key press will look more like a line than wavy due to keys not lining up.

Thank you @Mj1,
after reading this a couple of times and looking at the existing keymap.c finally figured out how to make a super simple version that has some keys mapped and individual colours

My Super simple keymap.c
#include QMK_KEYBOARD_H

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

/*  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
     */

const uint8_t led_colors[24][3] = {
     [7] = {255,   0,   0},  // Red
     [1] = {255, 165,   0},  // Orange (leaning towards yellow)
    [21] = {255,   0,   0},  // Red
     [6] = {255,  69,   0},  // Orange
     [3] = {  0, 255,   0},  // 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_NO,
        KC_A,     KC_S,     KC_D,     KC_NO,
        KC_LSFT,  KC_NO,    KC_NO,    KC_NO,
        KC_LCTL,  KC_NO,    KC_NO,    KC_SPACE
    )
};

bool rgb_matrix_indicators_user(void) {
    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);
    }
    return true;
}

Seems to work.. but probably not the best way to do it :slight_smile:
just wanted to say Thank you!
now I just want to figure out how to make it so I can increase the brightness using couple of keys on there.. and then layers… lol so manythings.

1 Like

That will be awesome.. even awesomer(yup that’s a word now…) if it also works for macropad.
(purly because thats the only one I have lol) :slight_smile: