Custom QMK firmware?

Yes, I want to create a “band val pendulum” animation - a band that goes back and forth across the keyboard. I found the source for band_sat, band_val, and hue_pendulum, and have mocked something up.

In my happy place I could test this on some sort of web app or standalone app. I have no idea if such a thing exists.

For now, I’m trying to figure out if there is a way to load a config into via and test it or upload it to the keyboard from there. Presumably yes, but heck if I can figure it out. I will try to dig back into the documentation. I was able use the examples for the led matrix modules to put something together that pulls the current outside temperature and displays it in the led matrix modules. I have not yet dug into if I can update the led matrix modules separately. I have some rudimentary competence at tweaking things, but it helps me greatly to have an initial guide to follow.

Just to check, you want to do this on the keyboard, right? Not the led matrix modules. It’s different for each.

Yes, sorry, I should have been clear. I mentioned the LED matrix modules probably to make myself feel better that I could get something working.

Here, I am looking to customize the keyboard. Thanks for your engagement!

It sounds like yes, you want to create an entirely new custom animation.
In that case.

Second question: No, it can not be done through the Via front end / keyboard.frame.work. I’m afraid you would need to write code for your animation. Most QMK code is written in C.

Third question: I’m not certain, but really don’t think there is a tool available for testing qmk firmware outside of a real keyboard.

For step-by-steps, I do have a couple I’ve been kicking around. Getting the right files to build / compile firmware for the keyboard. And basic flashing firmware. But mostly aimed at flashing precompiled firmware, since once you’re compiling your own, you probably don’t need help there.

I’m comfortable writing the code, believe it or not. I wasn’t sure if, once I write said code, I could load it using via. I’m pretty clearly over my head here in terms of what it takes to do this from start to finish. I was hoping for a simulator of sorts to work out any kinks with the code prior to loading it onto the actual keyboard.

I was about to say that if I ever get this figured out, I would be happy to write something up. If you are willing to share your step-by-step, I would be happy to try it out, and note where I run into issues.

Preamble
For normal use, you can configure your keyboard by going to keyboard.frame.work. Flashing or building firmware is not necessary, and it does carry risk. If you kill your keyboard, I presume it’s not covered by warranty.

• Keyboard QMK firmware, getting the right files to build.

This is only for the Framework 16. The Framework 13 does not use QMK.
I’ve seen a couple people unsure where to get the right branch to compile the firmware.

It’s presumed that you already have your QMK build environment setup. If not, follow this docs.qmk.fm/#/newbs_getting_started Running qmk doctor should say that QMK is ready to go.

Download the Framework Firmware repo

  1. Check the version number of the latest release https://github.com/FrameworkComputer/qmk_firmware/releases
  2. Click the “tags” button on that page to confirm that a branch corresponding to the latest release is there github.com/FrameworkComputer/qmk_firmware/tags
  3. Clone that particular branch with git clone -b <branchname> <remote-repo-url>
    For example:
git clone -b v0.2.9 https://github.com/FrameworkComputer/qmk_firmware.git

QMK compiles from its home directory. See it’s current home directory with

qmk config user.qmk_home

If the Framework firmware repo got downloaded to a different location, you can either move the folder, or just point QMK to it

To point QMK to it / change QMK’s home directory

qmk config user.qmk_home=/[Path-To-The-Downloaded-Firmware]/



• Flashing / reflashing the Framework 16 keyboard firmware.

Be sure you have an external keyboard. Your keyboard won’t work if the wrong file or a bad file is flashed.

To flash firmware, you need to restart your keyboard or numpad into bootloader mode. Here are 3 options:

  • On Framework Laptop 16 Keyboard: Hold down left ALT and right ALT while
    installing the module
  • On Framework Laptop 16 Numpad: Hold down keys for 2 and 6 while installing the
    module
  • Bootmagic reset: Hold down the key at (0,0) in the matrix (usually the top left key or Escape) and plug in the keyboard
  • Keycode in layout: Press the key mapped to QK_BOOT if it is available

The QK_BOOT key is named Reset in Via (https://keyboard.frame.work). It’s found in the “Special” section. Just place it on any key, then press the key.

When your keyboard enters bootloader mode, it will appear to your computer as a flash drive.

To flash or reflash a .uf2 firmware file, open the drive just like you would a real flash drive. Then just drag-and-drop the appropriate .uf2 file over to it. For example, framework_ansi_default_v0.2.9.uf2 for the ANSI (American) layout keyboard. Your keyboard will restart automatically and run the new firmware.

Which layout do I want? ANSI, ISO or JIS

ANSI (American) layout. Note the shape of the enter key.

ISO layout. British is shown, but this layout is valid for many languages.

JIS (Japanese) layout.

Official Framework .uf2 firmware files are here github.com/FrameworkComputer/qmk_firmware/releases

If you’re flashing firmware that you complied yourself, you would usually just do that by command line, rather than dragging-and-dropping the file.




• Compile and flashing commands.

First, cleanup any files from previous builds. It saves you from problems. I always do this by just adding it in front of flashing or compile commands with &&. For example: qmk clean && qmk flash -kb framework/macropad -km default

qmk clean

Compile, creating a .uf2 file in your current directory. For example: qmk compile -kb framework/macropad -km default

qmk compile -kb framework/[KEYBOARD] -km [KEYMAP]

Compile and flash straight over. If your keyboard isn’t already in bootloader mode, QMK will kindly wait for you to do that at the end of the compiling process. A .uf2 file will also still be created in your current directory.

qmk flash -kb framework/[KEYBOARD] -km [KEYMAP]


Also, here is a Per-key color step-by-step

How to get to point you can have per key RGB control for keyboard and macropad? - #2 by MJ1

9 Likes

I would be thankful if you could let me know how it seems, if it’s simple and understandable enough. Maybe if you see something that could be better. I was thinking of creating a thread if it’s good.

1 Like

I absolutely will follow up. Thank you so much for sharing this!

2 Likes

@MJ1 - thank you! I have been able to load a custom animation. It generally works, but it only looks somewhat right at high brightness (fn + space to get there), so I have something not quite right that I need to figure out. It also does not show up in the via gui, but I can get to it with fn + e or fn + d, presumably I need to adjust something with via, but that’s for another day as well.

I will reply tomorrow with notes on the steps, noting where I adjusted things. I could not have gotten this going without your help, and I cannot thank you enough. This community is fantastic, and it’s people like you who make it that way. Thank you, thank you, thank you.

Have a great evening!


For anyone curious:

  1. Follow MJ1’s guide

  2. I added this to keyboards/framework/config.h

#define ENABLE_RGB_MATRIX_VALUE_PENDULUM
  1. I added this the end of quantum/rgb_matrix/animations/rgb_matrix_effects.inc
#include "colorband_val_pendulum_anim.h"
  1. I created quantum/rgb_matrix/animations/colorband_val_pendulum_anim.h with the following contents:
#ifdef ENABLE_RGB_MATRIX_VALUE_PENDULUM
RGB_MATRIX_EFFECT(VALUE_PENDULUM)
#    ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS

// Change valuedelta to adjust range of value change. 0-255.
// Looks better with a low value and slow speed for subtle change.
// Value Pendulum - color moves in a wave to the right before reversing direction
static HSV VALUE_PENDULUM_math(HSV hsv, uint8_t i, uint8_t time) {
    uint8_t valuedelta = 9;
    int16_t v            = hsv.v + scale8(abs8(sin8(time) + (g_led_config.point[i].x) - 239) * 2, valuedelta); // 255 is too much overlaps on the left, 192 too little
    if ((v < 0) || ( v > 255)) {
    	v = 0;
    }
    hsv.v = scale8(v, hsv.v);
    return hsv;
}

bool VALUE_PENDULUM(effect_params_t* params) {
    return effect_runner_i(params, &VALUE_PENDULUM_math);
}

#    endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
#endif     // ENABLE_RGB_MATRIX_VALUE_PENDULUM

  1. Grin like an idiot at being able to tweak things like this.

On a totally separate note, here’s what I am using to put the temp and conditons on the led matrix spacers. Warning, it’s hacky and at the moment hard codes cloud because that has been the weather here today. My regex is awful so go easy there too. Suggestions always welcome.

./inputmodule-control_cli_linux led-matrix --brightness 15 --symbols `inxi -w --wu i | sed -En 's/.*temperature:\s{1,1}([0-9]{1})([0-9]{0,1})([0-9]{0,1})\s{1,1}[CcFf]{1,1}\s{1,1}conditions:\s{1,1}([A-Za-z]*)\s([A-Za-z]*)/\1 \2 \3 /p'` degF ' ' cloud

3 Likes

Some updates to my prior post. @MJ1, I still owe you feedback on your steps. I will get that to by the weekend if not before.

Update to my steps in the prior post. I finally rtfm a little more. Not completely, but a little more.

Undo the changes to config.h and rgb_matrix_effects.inc

  1. Add the following lines to the keyboard rules.mk file. For me that was keyboards/framework/ansi/rules.mk
RGB_MATRIX_CUSTOM_USER = yes
USER_NAME := mycooluser
  1. Create a folder under the users directory with a name relevant for you (the qmk directions give better guidance here, but let’s say it is called mycooluser, as noted in the prior step

  2. create users/mycooluser/rgb_matrix_user.inc, adding the customizations there. Here is my current version of the file. The "band_val_backforth works better than value_pendulum in my opinion

RGB_MATRIX_EFFECT(VALUE_PENDULUM)
RGB_MATRIX_EFFECT(BAND_VAL_BACKFORTH)
RGB_MATRIX_EFFECT(BAND_SAT_BACKFORTH)

#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS

// Change valuedelta to adjust range of value change. 0-255.
// Looks better with a low value and slow speed for subtle change.
// Value Pendulum - color moves in a wave to the right before reversing direction
static HSV VALUE_PENDULUM_math(HSV hsv, uint8_t i, uint8_t time) {
    uint8_t valuedelta = 9; //12;
    int16_t v            = hsv.v + scale8(abs8(sin8(time) + (g_led_config.point[i].x) - 239) * 2, valuedelta);
    if ((v < 0) || ( v > 255)) {
    	v = 0;
    }
    hsv.v = scale8(v, hsv.v);
    return hsv;
}

bool VALUE_PENDULUM(effect_params_t* params) {
    return effect_runner_i(params, &VALUE_PENDULUM_math);
}


//////


static HSV BAND_VAL_BACKFORTH_math(HSV hsv, uint8_t i, uint8_t time) {
    int16_t v = hsv.v - abs(scale8(g_led_config.point[i].x, 228) + 28 - sin8(time)) * 8;
    hsv.v     = scale8(v < 0 ? 0 : v, hsv.v);
    return hsv;
}

bool BAND_VAL_BACKFORTH(effect_params_t* params) {
    return effect_runner_i(params, &BAND_VAL_BACKFORTH_math);
}


//////


static HSV BAND_SAT_BACKFORTH_math(HSV hsv, uint8_t i, uint8_t time) {
    int16_t s = hsv.s - abs(scale8(g_led_config.point[i].x, 228) + 28 - sin8(time)) * 8;
    hsv.s     = scale8(s < 0 ? 0 : s, hsv.s);
    return hsv;
}

bool BAND_SAT_BACKFORTH(effect_params_t* params) {
    return effect_runner_i(params, &BAND_SAT_BACKFORTH_math);
}

#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS

Edit to add: this computer is this nerd’s dream machine. I hadn’t fiddled with qmk before, but with assistance from people like MJ1 (not @'ing you here to try not to spam you), I have been able to modify some existing animations to create ones customized for me. Thank you to everyone at Framework for creating this computer.

3 Likes

No worries, no rush.

2 Likes

Ok, very belatedly getting to this.

I am not very good with git, so I followed the basic qmk setup steps, then cloned the framework-specific one per your instructions. I then ran

qmk config user.qmk_home=/home/mycooluser/restofthepath/qmk_firmware

to point qmk to the framework repo that I set up following your steps. I then deleted the repo that had been set up as part of the qmk newbs getting started process.

To load the firmware onto the keyboard, I set one of the keys as the reset key, then drag and dropped the file onto the “usb” drive that the keyboard shows up as when reset. After loading the firmware I go back and turn off the reset function for the key.

I managed to forget to do that one time after I had loaded firmware, and dragging it again to the “usb” keyboard drive didn’t work, presumably since it was not an updated version. Removing and reinstalling the touchpad module and keyboard did reset the keyboard and get things working again.

Thank you again for the help, as I don’t know that I would have succeeded without your guidance. I’ve got at least one more original animation in mind, but I have to sit down and design it then code it up. If I ever get really motivated and find the time, I would love to put together a simulator for the animations. To be honest, my doing so likely is a pipe dream, due to time and ability constraints.

Note for anyone who comes across this later - I initially mistyped the command above, then fixed it after I saw MJ1’s reply below, which has my original incorrect command quoted.

1 Like

Ah, thanks. I forgot about that. I do need to add something about either cloning the repo where qmk expects it or changing it after.

For others (until I add it in):

To show qmk’s home directory, the location where it will compile firmware from

qmk config user.qmk_home

To change the location, add = and the fullpath

qmk config user.qmk_home=/[FULL-PATH-TO-REPO]/
1 Like

You can also choose to specify the Framework GitHub repo when you use the qmk setup command. Right now, though, if the process is new for someone, it’s probably better to pull from the official repo to make sure your environment is setup correctly, since the Framework fork has an old bug in the qmk doctor check.

2 Likes

i found after having to reinstall my OS a few times and setting up QMK each time that when you start to setup all you need to do is create the folders leading to where you want the firmware located and input this in the terminal:

qmk setup -H ‘{your drive letter here}:/Program Files/{all subfolders}/{empty firmware folder}’

this will link your empty folder as the location to look for firmware. then you can copy the firmware into that folder. you can always clone it with the directions previously stated by MJ1 and move it to the folder you want used.

after the setup accepts your home folder location it will run the rest of setup. if the home folder is empty it it will ask to clone qmk/qmk_firmware to the home folder. if the firmware version you need is already inside the folder before setup it detects the files then it just asks to confirm home folder location with no requests for clone. you can do the setup first then go back and do the git clone command with an addition to make sure it doesnt go into a default C drive location:

git clone -b v0.2.9 https://github.com/FrameworkComputer/qmk_firmware.git '{YOUR PATH TO FOLDER LOCATION}'

you can clone first then run setup so it detects the firmware and doesnt ask to clone again. i have to use the single quotation marks because it doesnt work with spaces in folder names unless the quotation marks are added to read the spaces and not think its a seperate portion of the syntax for the command.

you can also have different branches and tell it which branch you want to use. like i have the untouched clone of the firmware and then have a copy that i removed all the other keyboard and macropad or numpad files and only have my keyboard folder so when you compile it doesnt look at any other keyboards.

i had to do this because compile would not work for me. i had to use ‘make’ instead and did not like specifying the keyboard folder to look at. you have to look at what directory you are in by using ‘dir’ and will show all the folders under the directory you are currently in. use ‘cd …’ to go up a folder and 'cd {next folders here} if you need to change the drive you are looking at just put the drive letter like this A:/…/firmware_folder and add whatever folders you need to go down to get the main firmware folder. i used VIA to add the QK_BOOT which is called Reset on the special keycodes tab to the FN layer so i use ‘make’ when ready and when complete go to .build in the main folder and if you only used ‘make’ on one keymap it will be the only one to show there. just copy the .uf2 file and hit the QK_BOOT/Reset key and a new drive will show in file explorer just paste the file in there and the drive will disappear. when you hit the Reset key only the keyboard or numpad or macropad the key is registered on will go into bootloader mode. this means you need to put a reset key on whatever keypad you want to update. After you copy the file and if the keyboard has not turned back on by itself then all you need to do is slide the mousepad out until all the modules turn off and when slide it back the keyboard and other modules will initialize and start working.

with the terminal open and the file explorer waiting i can ‘make’ and reinitialize the keyboard in 3 minutes max. now if there are errors it is another story. lol

Do you mean that the keyboard gets reflashed on every boot? That seems odd… I would expect to be able to flash it once and have that persist indefinitely.

1 Like

i mean every time you hit the key with QK_BOOT assigned to it. in VIA its not called QK_BOOT but instead Reset. so you can use VIA to give you the assigned keycode to go into the bootloader process where the keyboard uninitializes and makes the storage visible to the computer where you copy the .uf2 into the drive main folder. not any subfolders. then it automatically tries to reinitialize but if it removes the keyboard drive and still not initialized you can remove the mousepad until its not connected to the midplate pins. this will unpower every module you have attached even if they are still in place so then push the mousepad back in and when it connects fully every module initializes and your new setup should be active.

1 Like

Ahh got it. Yeah that’s a pretty good trick then :slight_smile:

I wanted to remap the right alt and right ctrl to left mouse click and right mouse click, since there are no physical trackpad buttons and it was driving me nuts trying to select text, only to have the cursor jump a little as I was trying to lift my finger off.

Turns out “mousekey” is disabled in the firmware by default - easy enough to switch to “true”, but then I had a whole adventure with the keyboard in bootloader mode - systemd kept unmounting the disk device that the keyboard exposed, immediately after it had just mounted it, so I had to disable udisks2 and manually mount the device - thankfully I didn’t have to figure out specifically WHERE to mount the device, my default /media/$USER dir got picked up right away by qmk flash

Just thought I’d toss the idea out there! This trackpad really is not good enough to not have physical mouse buttons, but at least I could hack this in to help a little.