Skip to content

Instantly share code, notes, and snippets.

@damonism
Created February 12, 2023 03:21
Show Gist options
  • Save damonism/a0a4ce61bb2ee6feffc8baf0fbc62f6b to your computer and use it in GitHub Desktop.
Save damonism/a0a4ce61bb2ee6feffc8baf0fbc62f6b to your computer and use it in GitHub Desktop.

Lulu keyboard logos and default layers

I use my Lulu split keyboard with both Mac and Windows, and use a separate default layer for each OS. My default Mac/Windows layers setup was based on this blog post.

I wanted to get the Lulu OLEDs to show me whether the keyboard was in Mac (default layer 0) or Windows mode (default layer 3) mode. Showing the other layers was a bonus (you tend to know when you're hitting a layer key, but it's useful for debugging your keymap).

I couldn't get my head around writing text to the OLED so I hand-drew a set of OLED screens using PixilArt. These showed the Mac or Windows default layer and any additional layer (they don't make great use of the whole screen, but I'm not very artistic and they work).

I set PixilArt to use a 32 x 128 canvas, drew the white-on-black images, and exported them to PNG. I then used Preview.app on macOS to rotate them 270º (although I think QMK can actually handle rotating them in code).

I used the QMK Logo Editor to turn the PNGs into code (using the 'Raw' tab) and copied and pasted the resulting code into keymap.c using the same framework as the OLED code in lulu.c (I found that I had to delete the duplicated code from lulu.c to make it work). I kept the original Lulu render_logo because I couldn't think of anything better to display on the right OLED.

One quirk is that the code in lulu.c doesn't check default_layer_state, only layer_state. The following worked for me:

void process_layer_state(void) {
    switch (get_highest_layer(layer_state|default_layer_state)) {
        case 0:
            render_layer_qw_mac();
            break;
        case 1:
            render_layer_ra_mac();
            break;
        case 2:
            render_layer_lo_mac();
            break;
        case 3:
            render_layer_qw_win();
            break;
        case 4:
            render_layer_ra_win();
            break;
        case 5:
            render_layer_lo_win();
            break;
        case 6:
            render_layer_ad();
            break;
    }
}

This is all probably not very efficient, but it has been working well for me. The resulting keymap.c is available here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment