Skip to content

Commit

Permalink
ran black on print_dets.py
Browse files Browse the repository at this point in the history
  • Loading branch information
2bndy5 committed Feb 14, 2022
1 parent f9e5075 commit aaf0f53
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions examples/encodeRadioDetails/print_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ def hex_str_to_bytes(s_in: str) -> bytes:


argparser = argparse.ArgumentParser(
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter,
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter,
)
argparser.add_argument(
"buffer",
Expand All @@ -40,6 +41,7 @@ def address_repr(buf, reverse: bool = True, delimit: str = "") -> str:
return delimit.join(["%02X" % buf[byte] for byte in order])


# pylint: disable=too-many-locals,too-many-statements
def print_details(encoded_buf: bytearray):
"""This debuggung function outputs all details about the nRF24L01."""
# declare sequences
Expand Down Expand Up @@ -81,17 +83,16 @@ def print_details(encoded_buf: bytearray):
) = struct.unpack("9B", encoded_buf[29:38])
ce_pin, csn_pin, spi_speed = struct.unpack(">2H1B", encoded_buf[38:44])


# do some deciphering arithmetic
addr_len += 2
crc = (2 if config & 4 else 1) if auto_ack else max(0, ((config & 0x0C) >> 2) - 1)
d_rate = rf_setup & 0x28
d_rate = (2 if d_rate == 8 else 250) if d_rate else 1
pa_level = (3 - ((rf_setup & 6) >> 1)) * -6
pa_level = (
"MIN" if pa_level == -18 else (
"LOW" if pa_level == -12 else ("HIGH" if pa_level == -6 else "MAX")
)
"MIN"
if pa_level == -18
else ("LOW" if pa_level == -12 else ("HIGH" if pa_level == -6 else "MAX"))
)
dyn_p = (
("_Enabled" if dyn_pl else "Disabled")
Expand Down Expand Up @@ -187,6 +188,9 @@ def print_details(encoded_buf: bytearray):
print("\t\texpecting {} byte static payloads".format(pl_len[i]))


# pylint: enable=too-many-locals,too-many-statements


if __name__ == "__main__":
args = argparser.parse_args()
print_details(args.buffer)

0 comments on commit aaf0f53

Please sign in to comment.