Pico RGB Keypad Base Documentation

Hi all !
I’ve just received today my Pico and Pico rgb keypad (I’ve bought them on the day the PICO was announced… Thank you Brexit and PT customs) and was able to run the demo (Micropython).
I really want to explore it a bit further, but I can’t find any documentation whatsoever on the Python functions and libraries of the RGB keypad.

Where does such thing may be ?
Thank you

Hi, not seen any docs, but from the example;
NUM_PADS = keypad.get_num_pads() , returns the number of buttons available - 16
“button_states = keypad.get_button_states()” returns the button pressed, 0 to 15
keypad.illuminate(keyno, red, green, blue), sets button “keyno” to the RGB value eg
keypad.illuminate(0, 255,0,0) = set button 0 to red.
keypad.set_brightness(1.0) = sert to full brightness

Sorry “button_states = keypad.get_button_states()” returns 0 to 32768 ie an integer where each bit represents the buttons is pressed and you have to shift and test to see which buttons are pressed.
0 = button 0 (bit0), 2 = button 1 (bit1), 4 = button 3 (bit3), 8 = button 4(bit4), 16 = button 5(bit5) … 32768 = button 15 (bit15).

Here is another examples that sets all the buttons to a predetermined colour and changes the colour of the pressed button to white and print the button number.

#Very Basic
#Set all keys to a background color
#Illuminate the keys pressed

import time
import picokeypad as keypad
from machine import UART, Pin
keypad.init()
keypad.set_brightness(1.0)






lit = 0
last_button_states = 0
colour_index = 0
color =[[0x05, 0x00,0x00],[0x05, 0x00,0x00],[0x05, 0x00,0x00],[0x05, 0x00,0x00], # red
        [0x00, 0x05,0x00],[0x00, 0x05,0x00],[0x00, 0x05,0x00],[0x00, 0x05,0x00], # green
        [0x00, 0x00,0x05],[0x00, 0x00,0x05],[0x00, 0x00,0x05],[0x00, 0x00,0x05], # blue
        [0x05, 0x05,0x00],[0x05, 0x05,0x00],[0x05, 0x05,0x00],[0x05, 0x05,0x00]] # yellow



NUM_PADS = keypad.get_num_pads()
print("num pads :")
print(NUM_PADS)
color[15][1]=0x05
for find in range (0, NUM_PADS):
    keypad.illuminate(find, color[find][0], color[find][1], color[find][2])
            
global c

while True:

    button_states = keypad.get_button_states()
    if last_button_states != button_states:
        last_button_states = button_states
        print("button states :")
        print(button_states)

        if button_states > 0:
            button = 0
            for find in range (0, NUM_PADS):
                    # check if this button is pressed and no other buttons are pressed
                if button_states & 0x01 > 0:
                    print("Button Pressed is : " + str(find))
                    keypad.illuminate(button, 25, 25, 25)
                button_states >>= 1
                button += 1

        else:
            for find in range (0, NUM_PADS):
                keypad.illuminate(find, color[find][0], color[find][1], color[find][2])
            
    keypad.update()
    time.sleep(0.1)

Hi !
Thank you for the reply. I’ve run the demo and understand it , but I would love to know more about 0x0? values (what they stand ) and the functions (and arguments) available for the keypad.
I’m sure they are working on it ! :D

So 0x00 is hexadecimal representation of numbers. Can make it easier when working with bits and powers of 2 in programming. I could have just used color =[[5,0,0] etc but used to working in hexadecimal.
The RGB values used to set the colors can be in the range 0 to 255 or 0x00 to 0xff in hex.