Custom QMK Firmware for Macropad

I have created a custom firmware for the macro pad (simplified version below).
I have issues with getting the firmware to work properly. It seems there is still some remnance from the original firmware interacting with it.

keymap.c

// Copyright 2022 Framework Computer
// SPDX-License-Identifier: GPL-2.0-or-later

#include QMK_KEYBOARD_H
#include "factory.h"


const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    [0] = LAYOUT(
        TO(0),    TO(1),      TO(2),       KC_NO,
        KC_TAB,   KC_MINS,    KC_PLUS,     KC_BSPC,
        KC_7,     KC_8,       KC_9,        KC_EQL,
        KC_4,     KC_5,       KC_6,        KC_ASTR,
        KC_1,     KC_2,       KC_3,        KC_SLSH,
        KC_COMM,  KC_0,       KC_DOT,      KC_ENT
    ),
    [1] = LAYOUT(
        _______, _______,    _______,    _______,
        KC_PSCR, KC_SCRL,    KC_PAUSE,   KC_ESC,
        KC_INS,  KC_HOME,    KC_PGUP,    C(KC_HOME),
        KC_DEL,  KC_END,     KC_PGDN,    C(KC_END),
        KC_NO,   KC_UP,      KC_NO,      KC_NO, 
        KC_LEFT, KC_DOWN,    KC_RIGHT,   KC_ENTER
    ),
    [2] = LAYOUT(
        _______, _______, _______, _______,
        KC_E,    KC_F,    KC_G,    KC_H,
        KC_I,    KC_J,    KC_K,    KC_L,
        KC_M,    KC_N,    KC_O,    KC_P,
        KC_Q,    KC_R,    KC_S,    KC_T,
        KC_U,    KC_V,    KC_W,    KC_X
    ),
};

I compile the code with no issues like this

qmk compile -kb framework/macropad -km darkcruix

Then Flash it to the macropad (attaching it with 2 + 6) held down, so it is in bootloader mode while attaching:

qmk flash -kb framework/macropad -km darkcruix

All seems to work fine, but I can’t toggle the layers at all. It stays at layer 0 whatever layer button I press.

Any help is much appreciated.

SOLVED

If someone else looks for a solution, edit the rules.mk (./keyboards/framework/rules.mk) and change these lines:

VIA_ENABLE = no
RAW_ENABLE = yes

Here’s my modified macropad (keycaps and QMK firmware). The macropad changes colors depending on the function of the respective layer.

https://youtu.be/_tV2mSwzBRE

Did you clear persistent memory / EEPROM after flashing your new firmware? Via keymaps are stored there. Parts of it or all of it will remain, and it will take precedence after flashing new firmware.

Disabling Via will have a similar effect, since any persistent memory will just not be used.

1 Like

By Request, here are is the SCAD file for the keycaps (3D printed):
Key_Cap_Cover.scad (3.2 KB)

keycap with cutout:

module key_cap_cover(){
difference(){          
linear_extrude(layer_height*4,scale=0.9)r_square([width,length],1.2,center=true);
translate([-width/20+margin_1[0],length/4-margin_1[1],layer_height-0.2])linear_extrude(layer_height*3+0.2,scale=1.1)text(key_1, font = font,halign="center",valign="center",size=font_size+font_deviation_1);
translate([-width/4+margin_2[0],-length/4+margin_2[1],layer_height])linear_extrude(layer_height*3,scale=1.1)text(key_2, font = font,halign="center",valign="center",size=font_size+font_deviation_2);
translate([width/4-margin_3[0],length/4-margin_3[1],layer_height])linear_extrude(layer_height*3,scale=1.1)text(key_3, font = font,halign="center",valign="center",size=font_size+font_deviation_3);
translate([width/20-margin_4[0],-length/4+margin_4[1],layer_height-0.2])linear_extrude(layer_height*3+0.2,scale=1.1)text(key_4, font = font,halign="center",valign="center",size=font_size+font_deviation_4);
translate([0+center_offset[0],0+center_offset[1],layer_height])linear_extrude(layer_height*3,scale=1.1)text(key_center, font = font,halign="center",valign="center",size=font_size+font_deviation_center);

}
}

Just the legend:

module key_cap_cover(){
union(){          
linear_extrude(layer_height*4,scale=0.9)r_square([width,length],1.2,center=true);
translate([-width/20+margin_1[0],length/4-margin_1[1],layer_height-0.2])linear_extrude(layer_height*3+0.2,scale=1.1)text(key_1, font = font,halign="center",valign="center",size=font_size+font_deviation_1);
translate([-width/4+margin_2[0],-length/4+margin_2[1],layer_height])linear_extrude(layer_height*3,scale=1.1)text(key_2, font = font,halign="center",valign="center",size=font_size+font_deviation_2);
translate([width/4-margin_3[0],length/4-margin_3[1],layer_height])linear_extrude(layer_height*3,scale=1.1)text(key_3, font = font,halign="center",valign="center",size=font_size+font_deviation_3);
translate([width/20-margin_4[0],-length/4+margin_4[1],layer_height-0.2])linear_extrude(layer_height*3+0.2,scale=1.1)text(key_4, font = font,halign="center",valign="center",size=font_size+font_deviation_4);
translate([0+center_offset[0],0+center_offset[1],layer_height])linear_extrude(layer_height*3,scale=1.1)text(key_center, font = font,halign="center",valign="center",size=font_size+font_deviation_center);

}
}

QMK code for the MacroPad:

// Copyright 2022 Framework Computer
// SPDX-License-Identifier: GPL-2.0-or-later

#include QMK_KEYBOARD_H
#include "factory.h"


const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    [0] = LAYOUT(
        TO(0),    TO(1),      TO(2),       TO(3),
        KC_TAB,   KC_MINS,    KC_PLUS,     KC_BSPC,
        KC_7,     KC_8,       KC_9,        KC_EQL,
        KC_4,     KC_5,       KC_6,        KC_ASTR,
        KC_1,     KC_2,       KC_3,        KC_SLSH,
        KC_COMM,  KC_0,       KC_DOT,      KC_ENT
    ),
    [1] = LAYOUT(
        _______, _______,    _______,    _______,
        KC_PSCR, KC_SCRL,    KC_PAUSE,   KC_ESC,
        KC_INS,  KC_HOME,    KC_PGUP,    C(KC_HOME),
        KC_DEL,  KC_END,     KC_PGDN,    C(KC_END),
        KC_NO,   KC_UP,      KC_NO,      KC_NO,
        KC_LEFT, KC_DOWN,    KC_RIGHT,   KC_ENTER
    ),
    [2] = LAYOUT(
        _______, _______, _______, _______,
        KC_E,    KC_F,    KC_G,    KC_H,
        KC_I,    KC_J,    KC_K,    KC_L,
        KC_M,    KC_N,    KC_O,    KC_P,
        KC_Q,    KC_R,    KC_S,    KC_T,
        KC_U,    KC_V,    KC_W,    KC_X
    ),
    [3] = LAYOUT(
        _______, _______, _______, _______,
        KC_E,    KC_F,    KC_G,    KC_H,
        KC_I,    KC_J,    KC_K,    KC_L,
        KC_M,    KC_N,    KC_O,    KC_P,
        KC_Q,    KC_R,    KC_S,    KC_T,
        KC_U,    KC_V,    KC_W,    KC_X
    ),

};

bool rgb_matrix_indicators_user(void) {
  if (rgb_matrix_config.enable == 1) {
    if (layer_state_cmp(layer_state, 0)) {
        // Highlight Number Keys 
        rgb_matrix_set_color(4, 147, 112, 219); // tab		C1 R2
        rgb_matrix_set_color(7, 128, 0, 128); // 7 ins	C1 R3
        rgb_matrix_set_color(6, 128, 0, 128); // 4 del	C1 R4
        rgb_matrix_set_color(9, 128, 0, 128); // 1 		C1 R5
        rgb_matrix_set_color(0, 147, 112, 219); // -		C2 R2
        rgb_matrix_set_color(1, 128, 0, 128); // 8 hom	C2 R3
        rgb_matrix_set_color(3, 128, 0, 128); // 5 end	C2 R4
        rgb_matrix_set_color(11, 128, 0, 128); // 2 		C2 R5
        rgb_matrix_set_color(8, 147, 112, 219); // ,		C1 R6
        rgb_matrix_set_color(20, 147, 112, 219); // + 		C3 R2
        rgb_matrix_set_color(21, 128, 0, 128); // 9		C3 R3
        rgb_matrix_set_color(23, 128, 0, 128); // 6		C3 R4
        rgb_matrix_set_color(15, 128, 0, 128); // 3		C3 R5
        rgb_matrix_set_color(14, 147, 112, 219); // .		C3 R6 
        rgb_matrix_set_color(18, 147, 112, 219); // bckspc	C4 R2
        rgb_matrix_set_color(19, 147, 112, 219); // *		C4 R4 
    rgb_matrix_set_color(12, 147, 112, 219); // enter	C4 R6
        rgb_matrix_set_color(5, 128, 0, 128); // mod1         C1 R1
        rgb_matrix_set_color(2, 255, 255, 0); // mod2		C2 R1
        rgb_matrix_set_color(17, 128, 128, 128); // mod4 	C4 R1
        rgb_matrix_set_color(16, 147, 112, 219); // =		C4 R3
        rgb_matrix_set_color(13, 147, 112, 219); // /		C4 R5
        rgb_matrix_set_color(10, 128, 0, 128); // 0		C2 R6
    rgb_matrix_set_color(22, 0, 0, 255); // mod3	C3 R1
    }
    if (layer_state_cmp(layer_state, 1)) {
        // Highlight Number Keys 
        rgb_matrix_set_color(4, 255, 255, 204); // tab		C1 R2
        rgb_matrix_set_color(7, 255, 255, 0); // 7 ins	C1 R3
        rgb_matrix_set_color(6, 255, 255, 0); // 4 del	C1 R4
        rgb_matrix_set_color(9, 0, 0, 0); // 1 		C1 R5
        rgb_matrix_set_color(0, 255, 255, 204); // -		C2 R2
        rgb_matrix_set_color(1, 255, 255, 0); // 8 hom	C2 R3
        rgb_matrix_set_color(3, 255, 255, 0); // 5 end	C2 R4
        rgb_matrix_set_color(11, 255, 255, 0); // 2 		C2 R5
        rgb_matrix_set_color(8, 255, 255, 0); // ,		C1 R6
        rgb_matrix_set_color(20, 255, 255, 204); // + 		C3 R2
        rgb_matrix_set_color(21, 255, 255, 0); // 9		C3 R3
        rgb_matrix_set_color(23, 255, 255, 0); // 6		C3 R4
        rgb_matrix_set_color(15, 0, 0, 0); // 3		C3 R5
        rgb_matrix_set_color(14, 255, 255, 0); // .		C3 R6 
        rgb_matrix_set_color(18, 255, 255, 204); // bckspc	C4 R2
        rgb_matrix_set_color(19, 255, 255, 204); // *		C4 R4 
    rgb_matrix_set_color(12, 255, 255, 204); // enter	C4 R6
        rgb_matrix_set_color(5, 128, 0, 128); // mod1         C1 R1
        rgb_matrix_set_color(2, 255, 255, 0); // mod2		C2 R1
        rgb_matrix_set_color(17, 128, 128, 128); // mod4 	C4 R1
        rgb_matrix_set_color(16, 255, 255, 204); // =		C4 R3
        rgb_matrix_set_color(13, 255, 255, 204); // /		C4 R5
        rgb_matrix_set_color(10, 255, 255, 0); // 0		C2 R6
    rgb_matrix_set_color(22, 0, 0, 255); // mod3	C3 R1
    }
    if (layer_state_cmp(layer_state, 2)) {
        // Highlight Number Keys 
        rgb_matrix_set_color(4, 30, 144, 255); // tab		C1 R2
        rgb_matrix_set_color(7, 30, 144, 255); // 7 ins	C1 R3
        rgb_matrix_set_color(6, 30, 144, 255); // 4 del	C1 R4
        rgb_matrix_set_color(9, 30, 144, 255); // 1 		C1 R5
        rgb_matrix_set_color(0, 30, 144, 255); // -		C2 R2
        rgb_matrix_set_color(1, 30, 144, 255); // 8 hom	C2 R3
        rgb_matrix_set_color(3, 30, 144, 255); // 5 end	C2 R4
        rgb_matrix_set_color(11, 30, 144, 255); // 2 		C2 R5
        rgb_matrix_set_color(8, 30, 144, 255); // ,		C1 R6
        rgb_matrix_set_color(20, 30, 144, 255); // + 		C3 R2
        rgb_matrix_set_color(21, 30, 144, 255); // 9		C3 R3
        rgb_matrix_set_color(23, 30, 144, 255); // 6		C3 R4
        rgb_matrix_set_color(15, 30, 144, 255); // 3		C3 R5
        rgb_matrix_set_color(14, 30, 144, 255); // .		C3 R6 
        rgb_matrix_set_color(18, 30, 144, 255); // bckspc	C4 R2
        rgb_matrix_set_color(19, 30, 144, 255); // *		C4 R4 
    rgb_matrix_set_color(12, 30, 144, 255); // enter	C4 R6
        rgb_matrix_set_color(5, 128, 0, 128); // mod1         C1 R1
        rgb_matrix_set_color(2, 255, 255, 0); // mod2		C2 R1
        rgb_matrix_set_color(17, 128, 128, 128); // mod4 	C4 R1
        rgb_matrix_set_color(16, 30, 144, 255); // =		C4 R3
        rgb_matrix_set_color(13, 30, 144, 255); // /		C4 R5
        rgb_matrix_set_color(10, 30, 144, 255); // 0		C2 R6
    rgb_matrix_set_color(22, 0, 0, 255); // mod3	C3 R1
    }
    if (layer_state_cmp(layer_state, 3)) {
        // Highlight Number Keys 
        rgb_matrix_set_color(4, 8, 8, 8); // tab		C1 R2
        rgb_matrix_set_color(7, 8, 8, 8); // 7 ins	C1 R3
        rgb_matrix_set_color(6, 8, 8, 8); // 4 del	C1 R4
        rgb_matrix_set_color(9, 8, 8, 8); // 1 		C1 R5
        rgb_matrix_set_color(0, 8, 8, 8); // -		C2 R2
        rgb_matrix_set_color(1, 8, 8, 8); // 8 hom	C2 R3
        rgb_matrix_set_color(3, 8, 8, 8); // 5 end	C2 R4
        rgb_matrix_set_color(11, 8, 8, 8); // 2 		C2 R5
        rgb_matrix_set_color(8, 8, 8, 8); // ,		C1 R6
        rgb_matrix_set_color(20, 8, 8, 8); // + 		C3 R2
        rgb_matrix_set_color(21, 8, 8, 8); // 9		C3 R3
        rgb_matrix_set_color(23, 8, 8, 8); // 6		C3 R4
        rgb_matrix_set_color(15, 8, 8, 8); // 3		C3 R5
        rgb_matrix_set_color(14, 8, 8, 8); // .		C3 R6 
        rgb_matrix_set_color(18, 8, 8, 8); // bckspc	C4 R2
        rgb_matrix_set_color(19, 8, 8, 8); // *		C4 R4 
    rgb_matrix_set_color(12, 8, 8, 8); // enter	C4 R6
        rgb_matrix_set_color(5, 8, 0, 8); // mod1         C1 R1
        rgb_matrix_set_color(2, 8, 8, 0); // mod2		C2 R1
        rgb_matrix_set_color(17, 8, 8, 8); // mod4 	C4 R1
        rgb_matrix_set_color(16, 8, 8, 8); // =		C4 R3
        rgb_matrix_set_color(13, 8, 8, 8); // /		C4 R5
        rgb_matrix_set_color(10, 8, 8, 8); // 0		C2 R6
    rgb_matrix_set_color(22, 0, 0, 8); // mod3	C3 R1
    }




  }
  return true;
}