added code for timer pushbutton

This commit is contained in:
2024-02-27 21:07:09 +01:00
parent 51d19ac1f5
commit acb098e183
7 changed files with 290 additions and 2 deletions

100
SW/PC/Alkator.json Normal file
View File

@@ -0,0 +1,100 @@
{
"1": {
"name": "Michal_Dolezal",
"time": 59686.214496,
"laps": 3,
"lap_time": {
"0": 1570.6283019999973,
"1": 1714.182087000001,
"2": 1446.9299450000035
}
},
"2": {
"name": "David_Hubalek",
"time": 61285.385381,
"laps": 3,
"lap_time": {
"0": 1378.498722999997,
"1": 1902.1900959999984,
"2": 2436.201885000002
}
},
"9": {
"name": "Lucie_Ponocna",
"time": 60148.765882,
"laps": 3,
"lap_time": {
"0": 1481.6570529999954,
"1": 1371.9764339999965,
"2": 1392.5671650000004
}
},
"8": {
"name": "Jan_Cada",
"time": 60218.945151,
"laps": 3,
"lap_time": {
"0": 1293.8216450000036,
"1": 1341.646053000004,
"2": 1402.6441269999996
}
},
"10": {
"name": "Jenda",
"time": 61880.872883,
"laps": 3,
"lap_time": {
"0": 1365.9300070000027,
"1": 1959.2283549999993,
"2": 1957.2417010000063
}
},
"4": {
"name": "Vojta_Flekr",
"time": 61567.55196,
"laps": 3,
"lap_time": {
"0": 1447.2361820000006,
"1": 1654.6209919999965,
"2": 1696.5821589999978
}
},
"7": {
"name": "Lukas_Bouchal",
"time": 61356.658114,
"laps": 3,
"lap_time": {
"0": 1456.207137999998,
"1": 1405.8979709999985,
"2": 1365.8517150000043
}
},
"3": {
"name": "Adam_Krejsa",
"time": 61475.209162,
"laps": 3,
"lap_time": {
"0": 1313.4791200000036,
"1": 1358.869869999995,
"2": 1402.3635040000008
}
},
"6": {
"name": "David_Bedrnicek",
"time": 62894.44809,
"laps": 3,
"lap_time": {
"0": 1480.398721999998,
"1": 1721.0690019999965,
"2": 1939.8222899999964
}
},
"11": {
"name": "Nacelnik",
"time": 64679.27699,
"laps": 1,
"lap_time": {
"0": 2533.054164000001
}
}
}

View File

@@ -0,0 +1,37 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Oct 21 17:19:11 2023
@author: angoosh
"""
import json
FILE = './Alkator.json'
data_dict = ''
results = {}
with open(FILE,'r') as f:
file_content = f.read()
data_dict = json.loads(file_content)
for id in data_dict:
laps = int(data_dict[id]['laps'])
time = 0
for i in range(0,laps):
time += float(data_dict[id]['lap_time'][str(i)])
time = (time - (600*laps)) / 60
print(data_dict[id]['name'],time)
data_dict[id]['total_time'] = time
results[data_dict[id]['name']] = time
print(results)
dict(sorted(results.items(), key=lambda item: item[0]))
print(results)

View File

@@ -75,7 +75,7 @@ def write(ser):
break
def main():
s = serial.Serial(port="/dev/ttyACM0", parity=serial.PARITY_EVEN, stopbits=serial.STOPBITS_ONE, timeout=1)
s = serial.Serial(port="/dev/ttyACM3", parity=serial.PARITY_EVEN, stopbits=serial.STOPBITS_ONE, timeout=1)
s.flush()
rw = input('Read or Write tags? [R/w]')
@@ -98,4 +98,4 @@ def main():
if __name__ == "__main__":
main()
main()