Close

2: QMK

A project log for RPDeck

A USB Volume mixer/macro pad

neatloaf7neatloaf7 4 days ago0 Comments

I recently picked up an Adafruit macropad kit and have been learning to use QMK. After reading through the documentation, I learned of the Raw HID feature that allows for two-way HID reporting with the host. I figured QMK is already so feature rich and somewhat easy to create firmware with, so I will be trying to use QMK for this project. 

I will be trying to implement some sort of image-based indicator for the sound level along with its numerical value, sort of like how the windows volume mixer tray icon works. I also hope to incorporate a few application icons such as for spotify or discord. I have decided to switch to the RP2040 as the much larger flash memory should help me avoid any memory issues down the line. My code for the firmware probably not be well optimized given my lack of code experience. 

The way I have been drawing to the Adafruit macropad OLED is using byte arrays, which works  since I only have 2 layers for now. I imagine the volume indicator image will have 4-5 different states depending on volume level and mute status. I'll assume for now about 4 different unique sound icons (spotify, discord, games, and master volume). That is alot of permutations for what images can be shown on the screen and that doesn't include all the text descriptors. I believe QMK allows for writing characters directly to the screen, so hopefully I can populate the images first and then draw the text on after. 

The oled is 128x64, so about a 8200 length byte array. However, HID reports are only 32 bytes in length I believe. Sending a whole byte array to draw to the OLED would take a minimum of 256 reports. I've read that the report rate reaches about 1kHz with the rp2040. It sounds like it could be potentially slow to update if you are quickly switching through apps, so I will probably have all the image arrays baked into the firmware. I am hoping to have arrays for the application logo on the left of the screen and arrays for the volume level image on the right, and combine the two before drawing to the screen. Lastly I will draw the application name and volume level. 

The app switching encoder can either be mapped null in the keymap and instead directly send HID reports, or I could map them to hot keys that the windows application will be listening for. Outgoing HID reports would be pretty simple, probably only needing one or two bytes of information to update the windows application. 

Volume control will be through QMK standard key codes. Switching output devices is taken care of with the windows app called SoundSwitch which I have mapped to a hot key already. 

Incoming HID reports will be a little more complex. The windows app will need to report information on the current volume level, mute status, and selected application. Volume level and mute can be 3 bytes in the report. As for selected application, I can either send the name over, or have a precompiled list of applications in the firmware and just send a number associated with the application. I could also do a combination of the two; on startup, have the windows app report names of all applications configured and store them on the RP2040 and associate each application name to a number. Having a preset list is the simplest, but would require reflashing the board each time a new application (probably a new game) is configured in the windows application.

The windows application will probably give me the most trouble. At the least I need to monitor volume level and mute status for what application is currently selected. There will need to be a way to filter out any applications I don't want to control. I believe windows has an API with this functionality but I'll need to do more research. 

While I wait for the RP2040 to arrive, I am using a pro micro to test out building firmware from scratch. 

It was sort of a headache but I at least got the oled and encoders working. The static image took up a not insignificant amount of memory so I'm glad I ordered the RP2040. ext I will be testing drawing to OLED and the raw HID feature. 

Discussions