-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdataMaker
executable file
·99 lines (82 loc) · 2.67 KB
/
dataMaker
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/python3
# System modules
import tkinter as tk
import serial
import time
import obd
import socket
from dashSpecs import *
import pickle
from tkinter import ttk
from queue import Queue
from threading import Thread
# Set up some global variables
num_fetch_threads = 1
queue = Queue()
# This is the thread that reads from the Ardino
def getData(app, q):
print("*** Get thread running")
serverMACAddress = 'b8:27:eb:2d:17:5a'
#serverMACAddress = 'b8:27:eb:7b:60:24'
port = 3
s = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM, socket.BTPROTO_RFCOMM)
s.connect((serverMACAddress,port))
while True:
time.sleep(.1)
data = [
int(app.MPH.get()), #data[0]
int(app.RPM.get()), #data[1]
int(app.Temp.get()), #data[2]
int(app.fuelLevel.get()), #etc.
int(app.intakeTemp.get())
]
data = ' '.join(str(e) for e in data)
#data_string = pickle.dumps(data)
s.send(bytes(data, 'UTF-8'))
# Declare a class for the GUI
class Dash(tk.Tk):
def __init__(self):
# Init
tk.Tk.__init__(self)
style = ttk.Style()
style.configure("BW.TLabel", foreground="black")
self.geometry('800x480')
# Set up the different screens
notebook = ttk.Notebook(self)
screen1 = ttk.Frame(notebook)
notebook.add(screen1, text='Screen 1')
notebook.pack()
# TEMP
self.labelTemp = ttk.Label(screen1, text="Engine Temp C", style="BW.TLabel")
self.labelTemp.pack()
self.Temp = ttk.Scale(screen1, from_=0, to=ENGINE_TEMP_MAX, length=800, orient="horizontal")
self.Temp.pack()
# RPM
self.labelRPM = ttk.Label(screen1, text="RPM", style="BW.TLabel")
self.labelRPM.pack()
self.RPM = ttk.Scale(screen1, from_=0, to=RPM_MAX, length=800, orient="horizontal")
self.RPM.pack()
# MPH
self.labelMPH = ttk.Label(screen1, text="MPH", style="BW.TLabel")
self.labelMPH.pack()
self.MPH = ttk.Scale(screen1, from_=0, to=120, length=800, orient="horizontal")
self.MPH.pack()
# Fuel Level
self.labelFuelLevel = ttk.Label(screen1, text="Fuel Level", style="BW.TLabel")
self.labelFuelLevel.pack()
self.fuelLevel = ttk.Scale(screen1, from_=0, to=FUEL_MAX, length=800, orient="horizontal")
self.fuelLevel.pack()
# Intake Temp
self.labelIntakeTemp = ttk.Label(screen1, text="Intake Temp", style="BW.TLabel")
self.labelIntakeTemp.pack()
self.intakeTemp = ttk.Scale(screen1, from_=0, to=200, length=800, orient="horizontal")
self.intakeTemp.pack()
print('*** Main thread running')
app = Dash()
# Set up some threads
getData = Thread(target=getData, args=(app, queue,))
getData.setDaemon(True)
getData.start()
app.mainloop()
queue.join()
print('*** Done')