Skip to content

Commit ec1c165

Browse files
committed
chore: adjust style
1 parent f0432c4 commit ec1c165

File tree

6 files changed

+28
-16
lines changed

6 files changed

+28
-16
lines changed

app/chacon54662/cli.py

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
from .protocol import transmit
66

7+
__all__ = ["main"]
8+
79

810
def parse_args():
911
parser = argparse.ArgumentParser(description="Chacon 54662 remote control")

app/chacon54662/protocol.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import odroid_wiringpi as wiringpi
22

3+
__all__ = ["transmit"]
4+
35
TIME_HIGH_LOCK = 290
46
TIME_LOW_LOCK = 2400
57

@@ -10,7 +12,7 @@
1012
TIME_LOW_1 = 1250
1113

1214

13-
def sendBit(pin: int, b: bool):
15+
def send_bit(pin: int, b: bool):
1416
if b:
1517
wiringpi.digitalWrite(pin, wiringpi.HIGH)
1618
wiringpi.delayMicroseconds(TIME_HIGH_1)
@@ -23,18 +25,18 @@ def sendBit(pin: int, b: bool):
2325
wiringpi.delayMicroseconds(TIME_LOW_0)
2426

2527

26-
def sendWord(pin: int, word: int, bits: int):
28+
def send_word(pin: int, word: int, bits: int):
2729
for bit in reversed(range(bits)):
2830
if word & (1 << bit):
29-
sendBit(pin, True)
31+
send_bit(pin, True)
3032
else:
31-
sendBit(pin, False)
33+
send_bit(pin, False)
3234

3335

3436
def transmit(pin: int, word: int):
3537
for _ in range(4):
3638
# Code word (24 bits)
37-
sendWord(pin, word, 24)
39+
send_word(pin, word, 24)
3840

3941
# End lock
4042
wiringpi.digitalWrite(pin, wiringpi.HIGH)

app/chacon54662/routes.py

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from .protocol import transmit
44

5+
__all__ = ["router"]
6+
57
router = APIRouter(prefix="/chacon54662", tags=["chacon54662"])
68

79

app/chacondio10/cli.py

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
from .protocol import transmit
66

7+
__all__ = ["main"]
8+
79

810
def parse_args():
911
parser = argparse.ArgumentParser(description="Chacon DIO 1.0 remote control")

app/chacondio10/protocol.py

+13-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import odroid_wiringpi as wiringpi
22

3+
__all__ = ["transmit"]
4+
35
TIME_HIGH_LOCK = 275
46
TIME_LOW_LOCK1 = 9900
57
TIME_LOW_LOCK2 = 2675
@@ -9,7 +11,7 @@
911
TIME_LOW_DATA_SHORT = 275 # 310 or 275 or 350
1012

1113

12-
def sendBit(pin: int, b: bool):
14+
def send_bit(pin: int, b: bool):
1315
if b:
1416
wiringpi.digitalWrite(pin, wiringpi.HIGH)
1517
wiringpi.delayMicroseconds(TIME_HIGH_DATA)
@@ -22,17 +24,17 @@ def sendBit(pin: int, b: bool):
2224
wiringpi.delayMicroseconds(TIME_LOW_DATA_SHORT)
2325

2426

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)
2830

2931

30-
def sendWord(pin: int, word: int, bits: int):
32+
def send_word(pin: int, word: int, bits: int):
3133
for bit in reversed(range(bits)):
3234
if word & (1 << bit):
33-
sendPair(pin, True)
35+
send_pair(pin, True)
3436
else:
35-
sendPair(pin, False)
37+
send_pair(pin, False)
3638

3739

3840
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):
4850
wiringpi.digitalWrite(pin, wiringpi.HIGH)
4951

5052
# Sender code (26 bits)
51-
sendWord(pin, sender, 26)
53+
send_word(pin, sender, 26)
5254

5355
# Group bit
54-
sendPair(pin, group)
56+
send_pair(pin, group)
5557

5658
# On/off bit
57-
sendPair(pin, onoff)
59+
send_pair(pin, onoff)
5860

5961
# Button number (4 bits)
60-
sendWord(pin, button, 4)
62+
send_word(pin, button, 4)
6163

6264
# End lock
6365
wiringpi.digitalWrite(pin, wiringpi.HIGH)

app/chacondio10/routes.py

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from .protocol import transmit
44

5+
__all__ = ["router"]
6+
57
router = APIRouter(prefix="/chacondio10", tags=["chacondio10"])
68

79

0 commit comments

Comments
 (0)