Pico RGB Keypad Base support in CircuitPython

Hello!

Just letting anyone interested now that I’ve forked Kebow 2040 library so it supports both Keybow 2040 and Pico RGB Keypad Base:

Feel free to comment with suggestions (-:

2 Likes

I assume you meant to post a link to your actual fork that has ready-to-use files, instead of to the upstream PR that’s more troublesome to use.

1 Like

Nice, I have plans to use one of those keybow like as a hid device.

Finally had a chance to have a go at this but didn’t get far. I got as far as the Hardware independent part.

“Finally, drop the lib contents ( keybow2040.py file and keybow_hardware folder) from this library into the lib folder on your CIRCUITPY drive also, and you’re all set!”

Where do I get those from?

EDIT: Never mind i think I figured it out, its on your github page.

EDIT2: not working for me, renamed the reactive.press.py file code.py, and made the RGB Keypad base edit, but nothing happens? What’s supposed to happen? No errors in thonny?

I’ve just tested this file and it seems to be working - buttons are dark on startup and each button lights up cyan when being pressed (turns back off on release).

Ok, I’ll try holding the button down for a second or two. I was just momentarily pressing them.

1 Like

Not lighting up, must have done something wrong? I’m going to nuke it and try again latter on today.

OK, I flash nuked it back to factory condition.
Flashed it with the adafruit-circuitpython-raspberry_pi_pico-en_US-6.3.0.uf2 file.
Downloaded the Adafruit_CircuitPython_DotStar-main.
Copied the adafruit_dotstar.py to the PICO lib folder.
Copied the keybow2040.py` file and keybow_hardware folder from your library into the
lib folder.
Commented out the line:
from keybow_hardware.pim56x import PIM56X as Hardware
and uncommented the line:
from keybow_hardware.pim551 import PIM551 as Hardware
Saved the reative_press.py as code.py and nada?
No errors in Thonny but no buttons light up?

Everything you did sounds right, so it’s indeed strange that it’s not working.

Not much more comes to my mind, so sorry if some of the following questions seem dumb:

  • Is code.py (renamed example) in root directory of your CIRCUITPYTHON drive?
  • Are you able to access REPL (interactive python console)?
  • Have you tried reloading from REPL (ctrl+c, ctrl+d)?
  • Have you tried different examples?
1 Like

My code.py is where the original was, in the root directory.
Thonny shows the following in Shell
Adafruit CircuitPython 6.3.0 on 2021-06-01; Raspberry Pi Pico with rp2040
Its set to CircuitPython Generic.
ctrl c ctrl d gets me this

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.

code.py output:
Traceback (most recent call last):
  File "code.py", line 16, in <module>
  File "/lib/keybow_hardware/pim551.py", line 22, in __init__
RuntimeError: No pull up found on SDA or SCL; check your wiring

Code done running.

Press Ctrl-C to enter the REPL. Use CTRL-D to reload.

I’ve only tried the one example.

EDIT: Found this, not sure what it means exactly? 4:30 AM here though and only just got up, lol.
Pico RGB Keypad i2c pullup error - Discussion / Raspberry Pi - Pimoroni Buccaneers

It looks like I have a defective RGB Keypad Base. I have two here, one had a defective LED, and the replacement they sent for that defective one.
I just swapped the replacement for the original and your setup is working. Thankyou for sticking with it, greatly appreciated. I’ll put up with the one bum LED for now. Just lucky I hadn’t recycled the other one at the enviro center.
I have one base with a bum LED and the other with an i2c issue. It’s only a Circuit Python issue it seems though? It runs the Micro python demo just fine.

1 Like

It’s indeed weird that it works for MP and not in CP. Maybe some timing issue? For workaround / diagnosis you can add in lib/keybow_hardware/pim551.py in function __init__(self) following lines:

import time
time.sleep(0.5)
# if it works, you can try lowering timeout above

before line

self._i2c = busio.I2C(board.GP5, board.GP4)

If you click the link I posted above, i2c pullup error, you’ll see that I’m not alone.

Fixed my not working one. I soldered two 4.7 K pull up resistors on, one on GP4 to 3.3v and one on GP5 to 3.3v. Working now. =)

1 Like

New replacement PICO RGB Keypad circuit board on the way to fix my issue.
They were going to send me the full kit, but I said all I needed was the circuit board. I can reuse all the rest. =)

@matemaciek
EDIT: it won’t let me post again do to a 3 posts in a row max rule, so I have to do an edit.

Saved hid-keys-simple.py as code.py and now I get a

code.py output:
Traceback (most recent call last):
  File "code.py", line 20, in <module>
ImportError: no module named 'adafruit_hid'

Code done running.

The offending code is as follows.

import usb_hid
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS
from adafruit_hid.keycode import Keycode

A Google search didn’t turn up much?

It does show up as USB HID Keyboard in Windows Device manager though?

EDIT2: Fixed it by downloading the Adafruit Circuit Python Library for version 6.
CircuitPython Libraries | Welcome to CircuitPython! | Adafruit Learning System
And then copying the adafruit_hid folder to the CIRCUITPY lib folder.

EDIT3: lol, The key assignments are messed up but in a good way IMHO.
Turn it so the layout is like this, PICO on the right side instead of at the top.

C840
D951
EA62
FB73

And when you press the keys you will get

0123
4567
89AB
CDEF

All you have to do is turn the top cover 90 degrees so they match up. I was wanting to do this anyway to get the USB cable going out the top instead of to the left. =)

1 Like

Hm, question about running same code.py on two different boards got me thinking - maybe instead of choosing hardware by (un)commenting line in each example it would be better to encapsulate it in separate file (device.py?), so trying out all examples will be easier on both boards? I guess I’ll try to change this in my fork.

(Too bad there seem to be no interest in merging it upstream.)

I think if it was me, I’d edit them to run on the RGB Keypad. I’d just make the required edits to your fork so the default is the RGB Keypad. Most of those using a Keybow will be using the official GitHub page, that has the original examples.

I have been quietly prodding / hinting to Pimoroni that they need to do something in the way of a “how to” for the PICO RGB Keypad base, IE, how to actually use it as a HID device in Micro Python.
@hel @gadgetoid

Adafruit is likely who would have to step up for this to happen in Circuit Python. I don’t have near the presence on their forum as I do here. Or on their GitHub page.