Adding macros to atreus via chrysalis?

I just got my Atreus and am trying to configure it via Chrysalis, rather than compiling code directly the way I do in my Model01. I see how I can assign macros to keys, but how do I build the macros themselves? I found some old docs that say this is not possible – is that still true?

Not at the moment :cry:

Chrysalis is not aware (yet !) of the plugins embedded in the firmware. All the application provides is a way to assign macro#1 macro#2 macro#3 … where you want them.

For now, you must write your macros in Kaleidoscope, compile and flash the keyboard, and do this each time you change one.

By chance (and thanx to a lot of works from Algernon, Jesse and others) the layers are stored in a different part of the memory than the firmware, so flashing you keyboard preserve your layers :tada:

It is pretty cool that I can use both chrysalis and kaleidoscope together.

Are there any examples out there of how to map macros to numbers in Kaleidoscope? I know how to define macros but don’t know how to give them numbers.

Macro numbers are usually assigned by listing the macro key values in an enum in the sketch. The first one is 0, the next is 1, and so on.

I found the stock Atreus firmware sketch but I’m a little nervous about ripping all the keymaps out, writing some macros, and pushing it to the keyboard. Do you have a sample sketch to be used for macros, which can coexist with using Chrysalis for the things it can do? I can write the actual macros, it’s just the coexistence that has me confused.

Chrysalis only knows about the Key values in the keymap (i.e. M(0), M(1), et cetera). Everything else is in the sketch, just like it is in the Model01 sketch in the Model01-Firmware repository.

Well, I tried it and I bricked my Atreyus. I think I took the stock .ino and stripped too much out of it.
No big deal – use Chrysalis, reset firmware, reprogram the few key mods I’d made. Didn’t work. Tried Chrysalis on both Mac and Windows. In both cases, when I held down Esc and told it to reprogram the firmware, it didn’t give me that 1-2-3-4 count thing I saw earlier, it just sat there. Tried that a few times, no change.

No big deal – pull down https://github.com/keyboardio/Chrysalis-Firmware-Bundle.git, update the board package to keyboardio 1.98.0-beta, build Atreus.ino from source, and flash.
Set the board to Keyboardio Atreus.

When I tried compiling that, Arduino errored out. The whole error message is pretty long but I’ve pasted it below. Now I have a bricked keyboard and am out of ways to recover it. What next?

eric

Looks like the entire error message didn’t come through in my email reply. Here’s the meat of it, I can find a way to upload the entire thing if you need.

It starts with

In file included from /Users/eosborne/Library/Arduino15/packages/keyboardio/hardware/avr/1.98.0-beta/libraries/Kaleidoscope/src/Kaleidoscope.h:59:0,
                 from /Users/eosborne/tmp/Chrysalis-Firmware-Bundle/Keyboardio/Atreus/default/Atreus/Atreus.ino:24:
/Users/eosborne/tmp/Chrysalis-Firmware-Bundle/Keyboardio/Atreus/default/Atreus/Atreus.ino: In static member function 'static kaleidoscope::EventHandlerResult kaleidoscope_internal::EventDispatcher::apply(Args__&& ...)':
/Users/eosborne/Library/Arduino15/packages/keyboardio/hardware/avr/1.98.0-beta/libraries/Kaleidoscope/src/kaleidoscope_internal/event_dispatch.h:167:40: error: expected primary-expression before ',' token
    result = EventHandler__::call(PLUGIN, hook_args...);              __NL__ \
                                        ^
/Users/eosborne/Library/Arduino15/packages/keyboardio/hardware/avr/1.98.0-beta/libraries/Kaleidoscope/src/kaleidoscope/macro_map.h:31:20: note: in definition of macro 'EVAL0'
 #define EVAL0(...) __VA_ARGS__
                    ^~~~~~~~~~~
/Users/eosborne/Library/Arduino15/packages/keyboardio/hardware/avr/1.98.0-beta/libraries/Kaleidoscope/src/kaleidoscope/macro_map.h:32:26: note: in expansion of macro 'EVAL0'
 #define EVAL1(...) EVAL0(EVAL0(EVAL0(__VA_ARGS__)))

and has a whole bunch of complaints around #define EVAL stuff.
The compilation errors end with

/Users/eosborne/Library/Arduino15/packages/keyboardio/hardware/avr/1.98.0-beta/libraries/Kaleidoscope/src/kaleidoscope/macro_map.h:61:21: note: in expansion of macro 'EVAL'
 #define MAP(f, ...) EVAL(MAP1(f, __VA_ARGS__, ()()(), ()()(), ()()(), 0))
                     ^~~~
/Users/eosborne/Library/Arduino15/packages/keyboardio/hardware/avr/1.98.0-beta/libraries/Kaleidoscope/src/kaleidoscope/macro_map.h:61:26: note: in expansion of macro 'MAP1'
 #define MAP(f, ...) EVAL(MAP1(f, __VA_ARGS__, ()()(), ()()(), ()()(), 0))
                          ^~~~
/Users/eosborne/Library/Arduino15/packages/keyboardio/hardware/avr/1.98.0-beta/libraries/Kaleidoscope/src/kaleidoscope_internal/LEDModeManager.h:475:15: note: in expansion of macro 'MAP'
               MAP(                                                      __NL__ \
               ^~~
/Users/eosborne/Library/Arduino15/packages/keyboardio/hardware/avr/1.98.0-beta/libraries/Kaleidoscope/src/kaleidoscope_internal/event_dispatch.h:217:3: note: in expansion of macro '_INIT_LED_MODE_MANAGER'
   _INIT_LED_MODE_MANAGER(__VA_ARGS__)                                         __NL__ \
   ^~~~~~~~~~~~~~~~~~~~~~
/Users/eosborne/Library/Arduino15/packages/keyboardio/hardware/avr/1.98.0-beta/libraries/Kaleidoscope/src/Kaleidoscope.h:106:40: note: in expansion of macro '_KALEIDOSCOPE_INIT_PLUGINS'
 #define KALEIDOSCOPE_INIT_PLUGINS(...) _KALEIDOSCOPE_INIT_PLUGINS(__VA_ARGS__)
                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/eosborne/tmp/Chrysalis-Firmware-Bundle/Keyboardio/Atreus/default/Atreus/Atreus.ino:103:1: note: in expansion of macro 'KALEIDOSCOPE_INIT_PLUGINS'
 KALEIDOSCOPE_INIT_PLUGINS(
 ^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /Users/eosborne/Library/Arduino15/packages/keyboardio/hardware/avr/1.98.0-beta/libraries/Kaleidoscope/src/kaleidoscope_internal/sketch_exploration/sketch_exploration.h:20:0,
                 from /Users/eosborne/Library/Arduino15/packages/keyboardio/hardware/avr/1.98.0-beta/libraries/Kaleidoscope/src/kaleidoscope/layers.h:24,
                 from /Users/eosborne/Library/Arduino15/packages/keyboardio/hardware/avr/1.98.0-beta/libraries/Kaleidoscope/src/Kaleidoscope.h:57,
                 from /Users/eosborne/tmp/Chrysalis-Firmware-Bundle/Keyboardio/Atreus/default/Atreus/Atreus.ino:24:
/Users/eosborne/tmp/Chrysalis-Firmware-Bundle/Keyboardio/Atreus/default/Atreus/Atreus.ino: At global scope:
/Users/eosborne/Library/Arduino15/packages/keyboardio/hardware/avr/1.98.0-beta/libraries/Kaleidoscope/src/kaleidoscope_internal/sketch_exploration/plugin_exploration.h:167:70: error: expected primary-expression before ')' token
     kaleidoscope::sketch_exploration::makePluginTypeList( __VA_ARGS__)         \
                                                                      ^
/Users/eosborne/Library/Arduino15/packages/keyboardio/hardware/avr/1.98.0-beta/libraries/Kaleidoscope/src/kaleidoscope_internal/event_dispatch.h:219:3: note: in expansion of macro '_INIT_PLUGIN_EXPLORATION'
   _INIT_PLUGIN_EXPLORATION(__VA_ARGS__)
   ^~~~~~~~~~~~~~~~~~~~~~~~
/Users/eosborne/Library/Arduino15/packages/keyboardio/hardware/avr/1.98.0-beta/libraries/Kaleidoscope/src/Kaleidoscope.h:106:40: note: in expansion of macro '_KALEIDOSCOPE_INIT_PLUGINS'
 #define KALEIDOSCOPE_INIT_PLUGINS(...) _KALEIDOSCOPE_INIT_PLUGINS(__VA_ARGS__)
                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/eosborne/tmp/Chrysalis-Firmware-Bundle/Keyboardio/Atreus/default/Atreus/Atreus.ino:103:1: note: in expansion of macro 'KALEIDOSCOPE_INIT_PLUGINS'
 KALEIDOSCOPE_INIT_PLUGINS(
 ^~~~~~~~~~~~~~~~~~~~~~~~~
exit status 1
Error compiling for board Keyboardio Atreus.

I managed to get Chrysalis to flash the firmware. I had been setting ‘Restore to factory defaults’ in an effort to wipe the whole thing clean, but that didn’t work. Unselecting that option let me recover the keyboard. I would still like an example sketch which I can use to push macros to the Atreus, though, as I don’t want to go through that whole dance again. I’d even take a sketch which would control all the keymaps and forego Chrysalis if I had to.