What is SpaceFN and why you should give it a try
The SpaceFN concept - setting up your space key as a layer switch when held - is probably one of the most useful tweaks in the keyboard hobby. Let me explain how it works. My SpaceFN article on kbd.news made some rounds recently - quite surprisingly given the age of this concept. This piece you're reading is a condensed version of the full post. If you're left with unanswered questions, you'll most likely find the info you're looking for in the original write-up. On my imaginary top list of the most useful keyboard features, tweaks and hacks, SpaceFN would deserve a podium finish for sure. But what makes it so special? In short: SpaceFN is easy to implement, easy to learn, costs nothing, can be used with any keyboard, and can improve your productivity instantly. I will list its benefits below, but can state right at this point that the SpaceFN concept, setting up your space key as a layer switch when held, is clearly one of the most useful tweaks in the keyboard hobby....
Apr 30, 2024
I originally posted the link to it in another comment, but I don't want that comment to turn into a saga because the instructions for said sheet are long-winded.
Why would you want this?
1. Knowing (roughly) how the online configurator works 2. Having more options available to you than the online configurator provides (such as brightness, and caps key LED control) 3. Probably 100 more ideas I can't think of at the moment.
Disclaimer: This deals with quite a bit of math (albeit painfully simple once grok'ed). However, It's been a long time since my CS days, so there's probably a lot of bugs in there, but so far, "works on my machine"
Here's the sheet: https://docs.google.com/spreadsheets/d/1kiBfnmMFix5_T1oD7WCBvGF-wOoa0wvOVLMAP4B00jI/edit?usp=sharing
The idea (once you copy/download it) is that you put the value of the LED into one of the boxes marked LED Number in either one of the tabs and it'll spit out a value that you can put the source code if you've pulled down the MD QMK fork and want to hack.
Oh I'm assuming you've re-pulled down Massdrop's QMK Fork, because currently that's where the key-by-key layout code is living https://github.com/Massdrop/qmk_firmware/
Also, there are a couple of bugs (that the compiler will point out very quickly and are easy to fix, they are in keymap.c) so build the default before investing too much time. It's a nifty demo, I really like what the FN key does (It's not worth PR'ing because I'm sure this will be fixed and eventually wind up in QMK prime)
This was my target/inspiration https://github.com/Massdrop/qmk_firmware/blob/master/keyboards/massdrop/ctrl/keymaps/default/keymap.c#L209
For making your own version, that you'll need to know the LED values, and the SUM of the 2^x values based on the LED's element mapping in their array
Long winded explanation: Skip if you just want to make maps! Sum? Yes, it's not just a simple leds = {1,2,3,4,5} style setup (boy I wish). It uses this techique called 'bitwise' (based on the comments in the code) that I never fully comprehended in my school days and I only did the bare minimum to re-education myself on today. Basically it's like a parity scheme that lets one number represent several addresses. If you look at the "Map" tab in the spreadsheet, you'll see there are 4 arrays, each of 32 elements. So if you want to just do spacebar, that's LED 80. LED 80 is 16th element in array id2. That means it's value is 2^16 😵😵😵. Want to do Spacebar + Alt? That's (2^16 + 2^15). Yes, a sum.
Back to Action So once you've gotten some LED values jotted down, you can go over to the "Values" tab and use the sheet (plus the ample scratch area) to put together your map. You'll need THE SUM of the binary values (probably incorrect term, but it's been over a decade since my CS studies) to put into the code.
Example: If you want "wasd" to be it's own color, you'll need LED's 36, 52, 52, and 54. Luckily these are all in id1. Using the "Values" tab, you can find out that these are elements 4, 20, 21, and 22 in id1. You can then pick any cell (although there's a "sum" cell as a "for instance", but really any will do) , start a `=sum(` function, and then click the values that correspond with elements 4,20,21,22. That will make 7340048.
Take that number and put it into a block of code like https://github.com/Massdrop/qmk_firmware/blob/master/keyboards/massdrop/ctrl/keymaps/default/keymap.c#L209 with `.id1 = 7340048` as the address and you're ready to go. (If you want all of the other keys besides WASD, you can take (4294967295 - 7340048) which will give you 4287627247. Of course, that's only for id1. You'll need to do calculations for all of the other idX arrays)
Helpful snippets:
`.id2 = 4278190080, .id3 = 1073741823`
That's the entire underglow layer.
`.id0 = 4294967295, .id1 = 4294967295, .id2 = 16777215,`
That's all of the key leds.
`.id0 = 4294967295, .id1 = 4294967295, .id2 = 4294967295, .id3 = 4294967295`
That's EVERYTHING.
Edit: I fixed my repo enough to post the changed I made yesterday using the spreadsheet. https://github.com/LastContinue/qmk_firmware/blob/massdrop/keyboards/massdrop/ctrl/keymaps/lastcontinue/keymap.c#L217
Pulling the entire branch and then compiling the `lastcontinue` map will give you a pretty neat color scheme (I think).
(And again, if you don't want to use two keyboards to program this board, let alone two different commands, check out my helper script https://gist.github.com/LastContinue/ad5a526033e8965563e407d8f0b1b09e)