Skip to content

Peg OLED Display

To use this you need to make some changes to your as well as you I will break it into two sections for you.

What you can and cant do

Can do

  • Display images
  • Display text
  • Set images or text to react to your layer

Cant do yet / on the way

  • React to battery percentage
  • React to WPM

Required Libraries

You need these frozen into your CircuitPython or in a lib folder at the root of your drive. * Adafruit_CircuitPython_DisplayIO_SSD1306 * Adafruit_CircuitPython_Display_Text * Download .mpy versions from Adafruit_CircuitPython_Bundle

Your chosen board may already have these changes done If not you will need to add them.

You need to add 'SCL' and SDA to your keyboard. The pins the OLED are connected to on your controller may not be called "SCL"and "SDA" they could be "GP21" and "GP13" for example. The best way to find out what they are is look at the boards pinout.

Make this change to your file:


These are the changes that need to be made / added to your


No matter how you are going to use the OLED you need this part (in

    from kmk.extensions.peg_oled_Display import Oled,OledDisplayMode,OledReactionType,OledData
    keyboard = KMKKeyboard()
    # ... Other oled code


So the config for photos is quite simple. Getting the photos maybe not so much. I will explain.

Oled takes 2-3 arguments

  1. OledData
    • OledData can take image or corner_one, corner_two, corner_three and corner_four
    • Every item in OledData has 2 fields
    • 0: This is the reaction type right now it can be OledReactionType.LAYER or OledReactionType.STATIC
    • 1: An array of the items you want to show for the reaction. In this example 4 images to switch on the 4 layers
  2. To display called as toDisplay=OledDisplayMode.TXT this takes a OledDisplayMode TXT or IMG.
    • This tells the extension to load images or text.
  3. Flip called as "flip= Boolean" this will simply flip your display.
oled = Oled(OledData(image={0:OledReactionType.LAYER,1:["1.bmp","2.bmp","1.bmp","2.bmp"]}),toDisplay=OledDisplayMode.IMG,flip=False)

In this code example we are saying to react to the layer change and load a image filed named "1.bmp" for layer one and "2.bmp" for layer two and so on.

Preparing the images

So you need to include all the images in your CircuitPython drive in the root along side

Your images need to be 128x32 pixels and should only be black and white. After you have made your image you can save as a "monochrome bmp" this will save you a lot of space.


OK now we get into something that looks a lot more complicated but we will get though it.

Almost everything is the same We swap toDisplay to TXT and there are more items in the OledData Class, lets get into that.

  1. Top left
  2. Top right
  3. Bottom left
  4. Bottom right

After that is the same as the previous example. Each one has two fields 0:the reaction type. 1:what to display

In this code we will always display the word "layer" in the top left corner of the screen then the other 3 corners will swap depending on the layer.

oled = Oled(


Your OLED data can be a variable as shown below with images.


oled = Oled(oled_display_data,toDisplay=OledDisplayMode.IMG,flip=False)

Text example