-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple_test.py
More file actions
31 lines (23 loc) · 757 Bytes
/
simple_test.py
File metadata and controls
31 lines (23 loc) · 757 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""
Minimal PS/2 keyboard test - prints raw scancodes
Upload ps2_pio.py first, then run this file
"""
import uasyncio as asyncio
from ps2_pio import PS2Keyboard
# === UPDATE THESE PINS ===
CLK_PIN = 0
DATA_PIN = 1
# =========================
def on_key(scancode, pressed, extended):
"""Simple callback - just print the event"""
print(f"{'▼' if pressed else '▲'} 0x{scancode:02X} {'[EXT]' if extended else ''}")
async def main():
print("PS/2 Keyboard Test")
print(f"CLK=GPIO{CLK_PIN}, DATA=GPIO{DATA_PIN}")
print("-" * 40)
kb = PS2Keyboard(CLK_PIN, DATA_PIN, on_key)
asyncio.create_task(kb.read_loop())
print("Ready - press keys!\n")
while True:
await asyncio.sleep(60)
asyncio.run(main())