1
|
1 from machine import Pin
|
|
2 class Keys:
|
|
3 def __init__(self):
|
|
4
|
|
5 self.rows = [
|
|
6 Pin(23, Pin.OUT),
|
|
7 Pin(22, Pin.OUT),
|
|
8 ]
|
|
9 self.cols = [
|
|
10 Pin(36, Pin.IN, pull=-1), # these don't have internal pullups
|
|
11 Pin(39, Pin.IN, pull=-1),
|
|
12 Pin(34, Pin.IN, pull=-1),
|
|
13 Pin(35, Pin.IN, pull=-1)
|
|
14 ]
|
|
15 self.prev = ''
|
|
16
|
|
17 def newKeysDown(self):
|
|
18 res = ''
|
|
19 for r, rp in enumerate(self.rows):
|
|
20 rp.value(0)
|
|
21 for c, cp in enumerate(self.cols):
|
|
22 res += str(1 - cp())
|
|
23 rp.value(1)
|
|
24 if res != self.prev:
|
|
25 self.prev = res
|
|
26 return res |