From 915112941f89630ef11179cf4ebe29a49a5a117b Mon Sep 17 00:00:00 2001 From: StellaLupus Date: Sat, 10 Aug 2024 13:46:19 +0300 Subject: [PATCH] fix: formatting (python) --- tools/serial_parser.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tools/serial_parser.py b/tools/serial_parser.py index 7248a1f01..115d58e41 100644 --- a/tools/serial_parser.py +++ b/tools/serial_parser.py @@ -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 @@ -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