From ec1c16531eecea15316e223ce6b3a69dfb8b5a66 Mon Sep 17 00:00:00 2001 From: Fabien Crespel Date: Fri, 10 May 2024 00:14:26 +0200 Subject: [PATCH] chore: adjust style --- app/chacon54662/cli.py | 2 ++ app/chacon54662/protocol.py | 12 +++++++----- app/chacon54662/routes.py | 2 ++ app/chacondio10/cli.py | 2 ++ app/chacondio10/protocol.py | 24 +++++++++++++----------- app/chacondio10/routes.py | 2 ++ 6 files changed, 28 insertions(+), 16 deletions(-) diff --git a/app/chacon54662/cli.py b/app/chacon54662/cli.py index f15cca7..9608ede 100644 --- a/app/chacon54662/cli.py +++ b/app/chacon54662/cli.py @@ -4,6 +4,8 @@ from .protocol import transmit +__all__ = ["main"] + def parse_args(): parser = argparse.ArgumentParser(description="Chacon 54662 remote control") diff --git a/app/chacon54662/protocol.py b/app/chacon54662/protocol.py index 8a4e065..e172baa 100644 --- a/app/chacon54662/protocol.py +++ b/app/chacon54662/protocol.py @@ -1,5 +1,7 @@ import odroid_wiringpi as wiringpi +__all__ = ["transmit"] + TIME_HIGH_LOCK = 290 TIME_LOW_LOCK = 2400 @@ -10,7 +12,7 @@ TIME_LOW_1 = 1250 -def sendBit(pin: int, b: bool): +def send_bit(pin: int, b: bool): if b: wiringpi.digitalWrite(pin, wiringpi.HIGH) wiringpi.delayMicroseconds(TIME_HIGH_1) @@ -23,18 +25,18 @@ def sendBit(pin: int, b: bool): wiringpi.delayMicroseconds(TIME_LOW_0) -def sendWord(pin: int, word: int, bits: int): +def send_word(pin: int, word: int, bits: int): for bit in reversed(range(bits)): if word & (1 << bit): - sendBit(pin, True) + send_bit(pin, True) else: - sendBit(pin, False) + send_bit(pin, False) def transmit(pin: int, word: int): for _ in range(4): # Code word (24 bits) - sendWord(pin, word, 24) + send_word(pin, word, 24) # End lock wiringpi.digitalWrite(pin, wiringpi.HIGH) diff --git a/app/chacon54662/routes.py b/app/chacon54662/routes.py index 1aeba47..00cc0a3 100644 --- a/app/chacon54662/routes.py +++ b/app/chacon54662/routes.py @@ -2,6 +2,8 @@ from .protocol import transmit +__all__ = ["router"] + router = APIRouter(prefix="/chacon54662", tags=["chacon54662"]) diff --git a/app/chacondio10/cli.py b/app/chacondio10/cli.py index c8be958..9abb454 100644 --- a/app/chacondio10/cli.py +++ b/app/chacondio10/cli.py @@ -4,6 +4,8 @@ from .protocol import transmit +__all__ = ["main"] + def parse_args(): parser = argparse.ArgumentParser(description="Chacon DIO 1.0 remote control") diff --git a/app/chacondio10/protocol.py b/app/chacondio10/protocol.py index e1641bb..d4c6ac7 100644 --- a/app/chacondio10/protocol.py +++ b/app/chacondio10/protocol.py @@ -1,5 +1,7 @@ import odroid_wiringpi as wiringpi +__all__ = ["transmit"] + TIME_HIGH_LOCK = 275 TIME_LOW_LOCK1 = 9900 TIME_LOW_LOCK2 = 2675 @@ -9,7 +11,7 @@ TIME_LOW_DATA_SHORT = 275 # 310 or 275 or 350 -def sendBit(pin: int, b: bool): +def send_bit(pin: int, b: bool): if b: wiringpi.digitalWrite(pin, wiringpi.HIGH) wiringpi.delayMicroseconds(TIME_HIGH_DATA) @@ -22,17 +24,17 @@ def sendBit(pin: int, b: bool): wiringpi.delayMicroseconds(TIME_LOW_DATA_SHORT) -def sendPair(pin: int, b: bool): - sendBit(pin, b) - sendBit(pin, not b) +def send_pair(pin: int, b: bool): + send_bit(pin, b) + send_bit(pin, not b) -def sendWord(pin: int, word: int, bits: int): +def send_word(pin: int, word: int, bits: int): for bit in reversed(range(bits)): if word & (1 << bit): - sendPair(pin, True) + send_pair(pin, True) else: - sendPair(pin, False) + send_pair(pin, False) 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): wiringpi.digitalWrite(pin, wiringpi.HIGH) # Sender code (26 bits) - sendWord(pin, sender, 26) + send_word(pin, sender, 26) # Group bit - sendPair(pin, group) + send_pair(pin, group) # On/off bit - sendPair(pin, onoff) + send_pair(pin, onoff) # Button number (4 bits) - sendWord(pin, button, 4) + send_word(pin, button, 4) # End lock wiringpi.digitalWrite(pin, wiringpi.HIGH) diff --git a/app/chacondio10/routes.py b/app/chacondio10/routes.py index c0aa5d2..bc15d03 100644 --- a/app/chacondio10/routes.py +++ b/app/chacondio10/routes.py @@ -2,6 +2,8 @@ from .protocol import transmit +__all__ = ["router"] + router = APIRouter(prefix="/chacondio10", tags=["chacondio10"])