I had been using CapsLock from donfeduardo, and it came with the ability to set an LED color when capslock was toggled. I pulled the newest Keyboardio firmware, and I see that it comes with CapsLock in there by default. That’s cool, but is there any way to set an LED color for my capslock key without installing donfeduardo’s capslock? Or more generally, how would I build a macro to both send a keystroke and set a color, either temporarily or toggle?
Something along these lines. You’ll need to adjust the coordinates of your capslock key, and the color. Keep in mind that this example is completely untested, but should work, hopefully.
In file included from C:\Users\eric\Documents\Arduino\hardware\keyboardio\avr\libraries\Kaleidoscope\src/kaleidoscope/plugin/Macros.h:22:0,
from C:\Users\eric\Documents\Arduino\hardware\keyboardio\avr\libraries\Kaleidoscope\src/Kaleidoscope-Macros.h:19,
from C:\Users\eric\Documents\Arduino\Model01-Firmware\Model01-Firmware.ino:30:
C:\Users\eric\Documents\Arduino\Model01-Firmware\Model01-Firmware.ino: In function 'const macro_t toggleCapsLock(uint8_t)':
C:\Users\eric\Documents\Arduino\hardware\keyboardio\avr\libraries\Kaleidoscope\src/kaleidoscope/plugin/Macros/MacroSteps.h:41:101: error: invalid conversion from 'const macro_t* {aka const unsigned char*}' to 'macro_t {aka unsigned char}' [-fpermissive]
#define MACRO(...) ({static const macro_t __m[] PROGMEM = { __VA_ARGS__, MACRO_ACTION_END }; &__m[0]; })
^
C:\Users\eric\Documents\Arduino\Model01-Firmware\Model01-Firmware.ino:340:10: note: in expansion of macro 'MACRO'
return MACRO(T(CapsLock));
^
Multiple libraries were found for "HID.h"
Used: C:\Users\eric\Documents\Arduino\hardware\keyboardio\avr\libraries\HID
Not used: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\HID
exit status 1
Error compiling for board Keyboardio Model 01.
My example had a small bug: the type of toggleCapsLock should be const macro_t *, not const macro_t. That star is important, and the compiler is complaining about that.
I’m triggering it the way I trigger all other macros:
case MACRO_CAPSLOCK:
toggleCapsLock(keyState);
break;
but it seems like I should be doing something with the return from toggleCapsLock(). What’s the magic bit I put in the MACRO_CAPSLOCK case statement to call whatever toggleCapsLock() returns?
(also useful to note: 0,6 is the RxCy coordinate of the key you want to toggle)
It’s a little touchy - if I try to toggle caps lock immediately after the keyboard comes up, it gets confused and sets the LED when capslock is off. I think this might be interacting with the code which sets the LED-key LED to blue when the keyboard first comes on. If I don’t touch capslock for a few seconds after keyboard bootup, it works fine.