forked from 7h30th3r0n3/Raspyjack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgpio_shim.py
More file actions
56 lines (41 loc) · 933 Bytes
/
Copy pathgpio_shim.py
File metadata and controls
56 lines (41 loc) · 933 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"""
gpio_shim – Drop-in replacement for RPi.GPIO on M5Stack CardputerZero.
Translates GPIO.input() calls to evdev key state via evdev_keys module.
GPIO.output/setup/setmode are no-ops (no physical GPIO buttons on this device).
"""
import evdev_keys
# RPi.GPIO constants
BCM = 11
BOARD = 10
IN = 0
OUT = 1
PUD_UP = 22
PUD_DOWN = 21
HIGH = 1
LOW = 0
# Map GPIO pin numbers -> Raspyjack button names
_PIN_TO_BUTTON = {
6: 'KEY_UP_PIN',
19: 'KEY_DOWN_PIN',
5: 'KEY_LEFT_PIN',
26: 'KEY_RIGHT_PIN',
13: 'KEY_PRESS_PIN',
21: 'KEY1_PIN',
20: 'KEY2_PIN',
16: 'KEY3_PIN',
}
def setmode(mode):
pass
def setwarnings(flag):
pass
def setup(pin, direction, pull_up_down=None):
pass
def output(pin, value):
pass
def input(pin):
button = _PIN_TO_BUTTON.get(pin)
if button is None:
return 1
return 0 if evdev_keys.is_pressed(button) else 1
def cleanup():
pass