-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathStraightKeyer.py
46 lines (37 loc) · 930 Bytes
/
StraightKeyer.py
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
# StraightKeyer - logic for a straight key
import InputOutputPort as port
import KeyingControl as key
import TextKeyer as txt
# callback function
#
def action(state):
global pressing
# almost pass-through
#
if state==key.PRESSED:
key.mark()
key.abort_request() # request to abort text keyer
pressing=True
elif state==key.RELEASED:
key.space()
pressing=False
# callback function to do nothing
#
def null_action(state):
if state==key.PRESSED:
key.abort_request()
# initialization
#
def getaction():
return not not actstat # to make return value to bool
def setaction(newact):
global actstat
if actstat != newact:
actstat = not not newact
if actstat:
port.bind(port.In_C, action)
else:
port.bind(port.In_C, null_action)
actstat=False # current status
setaction(True)
pressing=False