Skip to content

Commit

Permalink
fix: formatting (python)
Browse files Browse the repository at this point in the history
  • Loading branch information
StellaLupus committed Aug 10, 2024
1 parent 33bcc85 commit 9151129
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions tools/serial_parser.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#!/usr/bin/python3
"""Automaticly get data from ESP8266's Raw data output and calculating average time for zero, one and space"""
#
# Copyright 2024 Andrey Kravchenko (StellaLupus)
import serial
import serial.tools
import serial.tools.list_ports
Expand All @@ -20,17 +24,17 @@ def get_port():
return get_port()


zero = 756
one = 2149
space = 752
interv = 0.25
ZERO_T = 756
ONE_T = 2149
SPACE_T = 752
PRECISION = 0.25


def get_bit_from_interv(value: int):
"""Returning zero or one from value or 2 if not recognized"""
if value > zero - zero * interv and value < zero + zero * interv:
if value > ZERO_T - ZERO_T * PRECISION and value < ZERO_T + ZERO_T * PRECISION:
return 0
elif value > one - one * interv and value < one + one * interv:
elif value > ONE_T - ONE_T * PRECISION and value < ONE_T + ONE_T * PRECISION:
return 1
else:
return 2
Expand Down

0 comments on commit 9151129

Please sign in to comment.