コード例 #1
0
def run():
    keypad.init()
    keypad.set_brightness(0.5)
    clear_display()
    while True:
        scroll()
        sleep_ms(250)
コード例 #2
0
import time
import picokeypad as keypad

keypad.init()
keypad.set_brightness(1.0)

lit = 0
last_button_states = 0
colour_index = 0

NUM_PADS = keypad.get_num_pads()
while True:
    button_states = keypad.get_button_states()
    if last_button_states != button_states:
        last_button_states = button_states
        if button_states > 0:
            if lit == 0xffff:
                # all buttons are already lit, reset the test
                lit = 0
                colour_index += 1
                if colour_index >= 6:
                    colour_index = 0
            else:
                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:
                        if not (button_states & (~0x01)) > 0:
                            lit = lit | (1 << button)
                        break
                    button_states >>= 1