1
1
import odroid_wiringpi as wiringpi
2
2
3
+ __all__ = ["transmit" ]
4
+
3
5
TIME_HIGH_LOCK = 275
4
6
TIME_LOW_LOCK1 = 9900
5
7
TIME_LOW_LOCK2 = 2675
9
11
TIME_LOW_DATA_SHORT = 275 # 310 or 275 or 350
10
12
11
13
12
- def sendBit (pin : int , b : bool ):
14
+ def send_bit (pin : int , b : bool ):
13
15
if b :
14
16
wiringpi .digitalWrite (pin , wiringpi .HIGH )
15
17
wiringpi .delayMicroseconds (TIME_HIGH_DATA )
@@ -22,17 +24,17 @@ def sendBit(pin: int, b: bool):
22
24
wiringpi .delayMicroseconds (TIME_LOW_DATA_SHORT )
23
25
24
26
25
- def sendPair (pin : int , b : bool ):
26
- sendBit (pin , b )
27
- sendBit (pin , not b )
27
+ def send_pair (pin : int , b : bool ):
28
+ send_bit (pin , b )
29
+ send_bit (pin , not b )
28
30
29
31
30
- def sendWord (pin : int , word : int , bits : int ):
32
+ def send_word (pin : int , word : int , bits : int ):
31
33
for bit in reversed (range (bits )):
32
34
if word & (1 << bit ):
33
- sendPair (pin , True )
35
+ send_pair (pin , True )
34
36
else :
35
- sendPair (pin , False )
37
+ send_pair (pin , False )
36
38
37
39
38
40
def transmit (pin : int , sender : int , group : bool , button : int , onoff : bool ):
@@ -48,16 +50,16 @@ def transmit(pin: int, sender: int, group: bool, button: int, onoff: bool):
48
50
wiringpi .digitalWrite (pin , wiringpi .HIGH )
49
51
50
52
# Sender code (26 bits)
51
- sendWord (pin , sender , 26 )
53
+ send_word (pin , sender , 26 )
52
54
53
55
# Group bit
54
- sendPair (pin , group )
56
+ send_pair (pin , group )
55
57
56
58
# On/off bit
57
- sendPair (pin , onoff )
59
+ send_pair (pin , onoff )
58
60
59
61
# Button number (4 bits)
60
- sendWord (pin , button , 4 )
62
+ send_word (pin , button , 4 )
61
63
62
64
# End lock
63
65
wiringpi .digitalWrite (pin , wiringpi .HIGH )
0 commit comments