diff options
| author | feurig <don@suspectdevices.com> | 2021-06-20 21:26:56 -0700 |
|---|---|---|
| committer | feurig <don@suspectdevices.com> | 2021-06-20 21:26:56 -0700 |
| commit | 538f296696e50470f2db12bdc7a853a470acd82e (patch) | |
| tree | 29a16f9f971f68845205923c3be4f680ec30ae52 | |
| parent | cce3b296372ef676b4c4a5a7f4374f16e6271368 (diff) | |
start debounce code
| -rw-r--r-- | PiTerm.py | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -1,3 +1,4 @@ +import time import board import busio import adafruit_character_lcd.character_lcd_rgb_i2c as character_lcd @@ -32,11 +33,21 @@ old_row=0; for pin in row_pins: pin.value=1 +switch_state = [[0,0,0,0,0,0,0,0,0,0,0,0], + [0,0,0,0,0,0,0,0,0,0,0,0], + [0,0,0,0,0,0,0,0,0,0,0,0], + [0,0,0,0,0,0,0,0,0,0,0,0] + ] while True: for r in range(4): row_pins[old_row].value=1 row_pins[r].value=0 old_row=r for c in range(12): - if (col_pins[c].value==0): + if (col_pins[c].value==0 and switch_state[r][c]==1): + switch_state[r][c]=0 print(keymap[r][c]) + lcd.message+=keymap[r][c] + if (col_pins[c].value==1 and switch_state[r][c]==0): + switch_state[r][c]=1 + time.sleep(0.01) # debounce |
