PaulW / rp2040-keyboard-converter

Raspberry Pi Pico RP2040 powered AT, XT and PS2 Keyboard Converter, originally a project specifically for the IBM Model F PC/AT keyboard, it is now being expanded to support multiple keyboards and protocols.
GNU General Public License v3.0
5 stars 1 forks source link

Add LED Support #4

Closed PaulW closed 6 months ago

PaulW commented 6 months ago

This adds support for displaying the Status of the converter, as well as Lock Lights to display state of CapsLock, NumLock and ScrollLock, using a strip of WS2812 (NeoPixel) LEDs.

Different types of LED are also supported. For development, I've used 4 x WS2812 NeoPixel LED's from Adafruit. You can use any other type of WS2812-compatible NeoPixel, but please ensure you set the correct LED Type. As part of this commit, only the following types are supported:

RGB (Red Green Blue) RBG (Red Blue Green) GRB (Green Red Blue) GBR (Green Blue Red) BRG (Blue Red Green) BGR (Blue Green Red)

Please refer to common/lib/types.h for available options, this can be set within config.h by adjusting the following option

CONVERTER_LEDS_TYPE

I've not added support for 4-color NeoPixels (RGBW) as I don't have any to test, however this may come in a later update (or feel free to contribute).

LED Support can be toggled by commenting or uncommenting the following options within config.h

CONVERTER_LEDS (Enable LED Support) CONVERTER_LOCK_LEDS (Enable Lock Light LED Support)

By default, the following colours are set:

Converter Not Ready - Orange Converter Ready - Green Lock LEDs - Green Entering Bootloader - Purple

PIO Code for driving the WS2812 NeoPixel LED was taken from the Pico-SDK pico-examples repository, and as such contains the original copyright header.

To support multiple PIO Code being applied to various State Machines, a new PIO Helper function has been defined to check each PIO for available space to apply the relevant PIO Program, and as such, will automatically choose either PIO 0 or PIO 1 depending where there is enough available space for the instructions (each PIO is limited to 32 total instructions, spread across a maximum of 4 State Machines per PIO). Currently, all current PIO Code will safely sit within a single PIO instance, however, as more functionality is added, this will allow scaling.