Skip to content

Commit 6fd10fc

Browse files
updated ui and added new data to get
1 parent 7bb7dbc commit 6fd10fc

File tree

2 files changed

+56
-18
lines changed

2 files changed

+56
-18
lines changed

client/index.html

+31-9
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@
3030
padding: .7em 1em;
3131
}
3232

33+
main #addition {
34+
display: flex;
35+
justify-content: center;
36+
align-items: center;
37+
}
38+
3339
main #dashboard {
3440
display: -ms-grid;
3541
display: grid;
@@ -38,17 +44,19 @@
3844
}
3945

4046
main #dashboard .meter {
41-
display: -webkit-box;
42-
display: -ms-flexbox;
4347
display: flex;
44-
-webkit-box-orient: vertical;
45-
-webkit-box-direction: normal;
46-
-ms-flex-direction: column;
4748
flex-direction: column;
48-
-webkit-box-align: center;
49-
-ms-flex-align: center;
5049
align-items: center;
5150
}
51+
52+
main #dashboard .meter #rpm, #spd {
53+
background-color: #333;
54+
width: 250px;
55+
color: whitesmoke;
56+
position:fixed;
57+
bottom:0;
58+
59+
}
5260
</style>
5361
</head>
5462
<body>
@@ -59,14 +67,20 @@ <h1>OBD Client</h1>
5967
<p id="error"></p>
6068
<button onclick="location.reload()">Retry</button>
6169
</section>
70+
<section id="addition">
71+
<div class="meter">
72+
<h2>MAF</h2>
73+
<div id="maf"></div>
74+
</div>
75+
</section>
6276
<section id="dashboard">
6377
<div class="meter">
6478
<h2>Speed</h2>
65-
<h3 id="spd"></h3>
79+
<div id="spd"></div>
6680
</div>
6781
<div class="meter">
6882
<h2>RPM</h2>
69-
<h3 id="rpm"></h3>
83+
<div id="rpm"></div>
7084
</div>
7185
</section>
7286
</main>
@@ -78,6 +92,7 @@ <h3 id="rpm"></h3>
7892
var error = document.querySelector('#error');
7993
var spd = document.getElementById('spd');
8094
var rpm = document.getElementById('rpm');
95+
var maf = document.getElementById('maf');
8196

8297
const errors = [];
8398

@@ -86,9 +101,16 @@ <h3 id="rpm"></h3>
86101
console.log(msg);
87102
if(msg['speed'] !== undefined){
88103
spd.innerText = msg['speed'];
104+
105+
spd.style.height = `${(parseInt(msg['speed']))*10}px`
89106
}
90107
if(msg['rpm'] !== undefined){
91108
rpm.innerText = msg['rpm'];
109+
110+
rpm.style.height = `${(parseInt(msg['rpm']))/3}px`
111+
}
112+
if(msg['maf'] !== undefined){
113+
maf.innerText = msg['maf'];
92114
}
93115
errors = [];
94116
});

main.py

+25-9
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,45 @@
88

99
def new_spd(s):
1010
string = str(s.value.to('mph'))
11-
data = {
12-
"speed" : string
13-
}
11+
data = {"speed" : string}
1412
print(json.dumps(data))
1513
sys.stdout.flush()
1614

1715
def new_rpm(r):
1816
string = str(r.value)
19-
data = {
20-
"rpm": string
21-
}
17+
data = {"rpm" : string}
2218
print(json.dumps(data))
2319
sys.stdout.flush()
2420

21+
def new_maf(r):
22+
string = str(r.value)
23+
data = {"maf" : string}
24+
print(json.dumps(data))
25+
sys.stdout.flush()
26+
27+
def new_fuel(r):
28+
string = str(r.value)
29+
data = {"fuel" : string}
30+
print(json.dumps(data))
31+
sys.stdout.flush()
32+
33+
def new_temp(r):
34+
string = str(r.value)
35+
data = {"temp" : string}
36+
print(json.dumps(data))
37+
sys.stdout.flush()
2538

2639
# commands to watch
2740
connection.watch(obd.commands.SPEED, callback=new_spd)
2841
connection.watch(obd.commands.RPM, callback=new_rpm)
29-
# connection.watch(obd.commands.FUEL_PRESSURE)
42+
connection.watch(obd.commands.MAF, callback=new_maf)
43+
connection.watch(obd.commands.FUEL_LEVEL, callback=new_fuel)
44+
connection.watch(obd.commands.COOLANT_TEMP, callback=new_temp)
3045

3146
# start the connection
3247
connection.start()
3348

34-
time.sleep(60)
35-
connection.stop()
49+
while True:
50+
3651

52+
connection.stop()

0 commit comments

Comments
 (0)