add dtc and fixed some things
This commit is contained in:
@@ -14,6 +14,10 @@ def index():
|
|||||||
print("hello "+account.name)
|
print("hello "+account.name)
|
||||||
return render_template('index.html', account = account)
|
return render_template('index.html', account = account)
|
||||||
|
|
||||||
|
@app.route('/dtc')
|
||||||
|
def dtc():
|
||||||
|
return render_template('dtc.html')
|
||||||
|
|
||||||
# not sure if im gonna use this
|
# not sure if im gonna use this
|
||||||
@app.route('/api/obd_speed/')
|
@app.route('/api/obd_speed/')
|
||||||
def data():
|
def data():
|
||||||
|
|||||||
+38
-8
@@ -15,6 +15,7 @@ class OBD:
|
|||||||
|
|
||||||
obd_status = ["Disconnected", "Connected", "Connection...", "wtf"]
|
obd_status = ["Disconnected", "Connected", "Connection...", "wtf"]
|
||||||
obd_speed_lock = threading.Lock()
|
obd_speed_lock = threading.Lock()
|
||||||
|
obd_speed_rpm = threading.Lock()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
print(obd_status[2])
|
print(obd_status[2])
|
||||||
@@ -31,24 +32,30 @@ def get_speedtime():
|
|||||||
return [str(time_now), speed]
|
return [str(time_now), speed]
|
||||||
|
|
||||||
@socketio.on('obd')
|
@socketio.on('obd')
|
||||||
def obd_connection():
|
def obd_connection():
|
||||||
|
|
||||||
if connection.is_connected():
|
if connection.is_connected():
|
||||||
print(obd_status[1])
|
print(obd_status[1])
|
||||||
socketio.emit('obd_status', obd_status[1])
|
socketio.emit('obd_status', obd_status[1])
|
||||||
print("OBD connection established.")
|
print("OBD connection established.")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
print("OBD connection failed.")
|
||||||
print(obd_status[0])
|
print(obd_status[0])
|
||||||
|
|
||||||
socketio.emit('obd_status', obd_status[0])
|
socketio.emit('obd_status', obd_status[0])
|
||||||
socketio.emit('obd_speed', "-")
|
socketio.emit('obd_speed', "-")
|
||||||
socketio.emit('obd_error', "-")
|
socketio.emit('obm_error', "-")
|
||||||
|
socketio.emit('obd_rpm', "-")
|
||||||
|
|
||||||
# test speed while offline
|
# debug speed for testing
|
||||||
print("OBD connection failed.")
|
thread_speed = Thread(target=obd_speed)
|
||||||
thread = Thread(target=obd_speed)
|
thread_speed.daemon = True
|
||||||
thread.daemon = True
|
thread_speed.start()
|
||||||
thread.start()
|
|
||||||
|
# debug rpm for testing
|
||||||
|
thread_rpm = Thread(target=obd_rpm)
|
||||||
|
thread_rpm.daemon = True
|
||||||
|
thread_rpm.start()
|
||||||
|
|
||||||
def obd_speed():
|
def obd_speed():
|
||||||
obd_speed_lock.acquire()
|
obd_speed_lock.acquire()
|
||||||
@@ -70,4 +77,27 @@ def obd_speed():
|
|||||||
finally:
|
finally:
|
||||||
obd_speed_lock.release()
|
obd_speed_lock.release()
|
||||||
|
|
||||||
|
def obd_rpm():
|
||||||
|
obd_speed_lock.acquire()
|
||||||
|
cmd = obd.commands.RPM # select an OBD command (sensor)
|
||||||
|
response = connection.query(cmd) # send the command and parse the response
|
||||||
|
loop = True
|
||||||
|
try:
|
||||||
|
while loop == True:
|
||||||
|
global rpm
|
||||||
|
speed = speed + 1
|
||||||
|
time.sleep(1)
|
||||||
|
if response.is_null():
|
||||||
|
print("No data received. #"+ str(get_speedtime()))
|
||||||
|
socketio.emit('obd_speed', get_speedtime())
|
||||||
|
else:
|
||||||
|
print("RPM:", response.value)
|
||||||
|
socketio.emit('obd_speed', response.value.to("kph"))
|
||||||
|
finally:
|
||||||
|
obd_rpm_lock.release()
|
||||||
|
|
||||||
|
def kill_obd(obd_type):
|
||||||
|
if obd_type == "speed":
|
||||||
|
obd_speed.loop = False
|
||||||
|
elif obd_type == "rpm":
|
||||||
|
obd_rpm.loop = False
|
||||||
|
|||||||
+8
-2
@@ -13,6 +13,7 @@ chart = new Chart(ctx, {
|
|||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
options: {
|
options: {
|
||||||
|
responsive: true,
|
||||||
scales: {
|
scales: {
|
||||||
x: {
|
x: {
|
||||||
reverse: true,
|
reverse: true,
|
||||||
@@ -64,13 +65,18 @@ socket.on('obd_speed', function(data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update the chart
|
// Update the chart
|
||||||
|
|
||||||
chart.update();
|
chart.update();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
socket.on('obd_rpm', function(data) {
|
||||||
|
console.log("obd rpm "+data);
|
||||||
|
const status = document.getElementById('obd-rpm');
|
||||||
|
status.innerHTML = data;
|
||||||
|
});
|
||||||
|
|
||||||
socket.on('obd_error', function(data) {
|
socket.on('obd_error', function(data) {
|
||||||
console.log(data);
|
console.log("obd errors "+data);
|
||||||
const status = document.getElementById('obd-error');
|
const status = document.getElementById('obd-error');
|
||||||
status.innerHTML = data;
|
status.innerHTML = data;
|
||||||
});
|
});
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
#map { height: 460px; }
|
#map { height: 20rem; }
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html data-bs-theme="light" lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
|
||||||
|
<title>Table - yaris vroom vroom de course</title>
|
||||||
|
<link rel="stylesheet" href="{{ url_for('static', filename='bootstrap/css/bootstrap.min.css') }}">
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i&display=swap">
|
||||||
|
<link rel="stylesheet" href="{{ url_for('static', filename='fonts/fontawesome-all.min.css') }}">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body id="page-top">
|
||||||
|
<div id="wrapper">
|
||||||
|
<nav class="navbar align-items-start sidebar sidebar-dark accordion bg-gradient-primary p-0 navbar-dark" style="color: var(--bs-accordion-btn-focus-border-color);background: rgb(0,0,0);filter: blur(0px);backdrop-filter: blur(0px) hue-rotate(0deg);">
|
||||||
|
<div class="container-fluid d-flex flex-column p-0"><a class="navbar-brand d-flex justify-content-center align-items-center sidebar-brand m-0" href="#">
|
||||||
|
<div class="sidebar-brand-icon rotate-n-15"><i class="fas fa-car"></i></div>
|
||||||
|
<div class="sidebar-brand-text mx-3"><span>yaris </span></div>
|
||||||
|
</a>
|
||||||
|
<hr class="sidebar-divider my-0">
|
||||||
|
<ul class="navbar-nav text-light" id="accordionSidebar">
|
||||||
|
<li class="nav-item"><a class="nav-link" href="/"><i class="fas fa-tachometer-alt"></i><span>Dashboard</span></a></li>
|
||||||
|
<li class="nav-item"></li>
|
||||||
|
<li class="nav-item"><a class="nav-link active" href="/dtc"><i class="fas fa-table"></i><span>DTC </span></a></li>
|
||||||
|
</ul>
|
||||||
|
<div class="text-center d-none d-md-inline"><button class="btn rounded-circle border-0" id="sidebarToggle" type="button"></button></div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
<div class="d-flex flex-column" id="content-wrapper">
|
||||||
|
<div id="content">
|
||||||
|
<nav class="navbar navbar-expand bg-white shadow mb-4 topbar static-top navbar-light">
|
||||||
|
<div class="container-fluid"><button class="btn btn-link d-md-none rounded-circle me-3" id="sidebarToggleTop" type="button"><i class="fas fa-bars"></i></button>
|
||||||
|
<form class="d-none d-sm-inline-block me-auto ms-md-3 my-2 my-md-0 mw-100 navbar-search">
|
||||||
|
<div class="input-group"></div>
|
||||||
|
</form>
|
||||||
|
<ul class="navbar-nav flex-nowrap ms-auto">
|
||||||
|
<li class="nav-item dropdown d-sm-none no-arrow"><a class="dropdown-toggle nav-link" aria-expanded="false" data-bs-toggle="dropdown" href="#"><i class="fas fa-search"></i></a>
|
||||||
|
<div class="dropdown-menu dropdown-menu-end p-3 animated--grow-in" aria-labelledby="searchDropdown">
|
||||||
|
<form class="me-auto navbar-search w-100">
|
||||||
|
<div class="input-group"><input class="bg-light form-control border-0 small" type="text" placeholder="Search for ...">
|
||||||
|
<div class="input-group-append"><button class="btn btn-primary py-0" type="button"><i class="fas fa-search"></i></button></div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item dropdown no-arrow mx-1">
|
||||||
|
<div class="nav-item dropdown no-arrow"><a class="dropdown-toggle nav-link" aria-expanded="false" data-bs-toggle="dropdown" href="#"><span class="badge bg-danger badge-counter"></span></a>
|
||||||
|
</div>
|
||||||
|
<div class="shadow dropdown-list dropdown-menu dropdown-menu-end" aria-labelledby="alertsDropdown"></div>
|
||||||
|
</li>
|
||||||
|
<div class="d-none d-sm-block topbar-divider"></div>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
<div class="container-fluid">
|
||||||
|
<h3 class="text-dark mb-4">DTC Codes</h3>
|
||||||
|
<div class="card shadow">
|
||||||
|
<div class="card-header py-3">
|
||||||
|
<p class="text-primary m-0 fw-bold">Output</p>
|
||||||
|
</div>
|
||||||
|
<div class="card-body"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<footer class="bg-white sticky-footer">
|
||||||
|
<div class="container my-auto">
|
||||||
|
<div class="text-center my-auto copyright"><span>Copyright © yaris vroom vroom de course 2023</span></div>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
</div><a class="border rounded d-inline scroll-to-top" href="#page-top"><i class="fas fa-angle-up"></i></a>
|
||||||
|
</div>
|
||||||
|
<script src="{{ url_for('static', filename='js/yaris.js') }}"></script>
|
||||||
|
<script src="{{ url_for('static', filename='bootstrap/js/bootstrap.min.js') }}"></script>
|
||||||
|
<script src="{{ url_for('static', filename='js/bs-init.js') }}"></script>
|
||||||
|
<script src="{{ url_for('static', filename='js/theme.js') }}"></script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
+26
-10
@@ -17,15 +17,13 @@
|
|||||||
<nav class="navbar align-items-start sidebar sidebar-dark accordion bg-gradient-primary p-0 navbar-dark" style="color: var(--bs-accordion-btn-focus-border-color);background: rgb(0,0,0);filter: blur(0px);backdrop-filter: blur(0px) hue-rotate(0deg);">
|
<nav class="navbar align-items-start sidebar sidebar-dark accordion bg-gradient-primary p-0 navbar-dark" style="color: var(--bs-accordion-btn-focus-border-color);background: rgb(0,0,0);filter: blur(0px);backdrop-filter: blur(0px) hue-rotate(0deg);">
|
||||||
<div class="container-fluid d-flex flex-column p-0"><a class="navbar-brand d-flex justify-content-center align-items-center sidebar-brand m-0" href="#">
|
<div class="container-fluid d-flex flex-column p-0"><a class="navbar-brand d-flex justify-content-center align-items-center sidebar-brand m-0" href="#">
|
||||||
<div class="sidebar-brand-icon rotate-n-15"><i class="fas fa-car"></i></div>
|
<div class="sidebar-brand-icon rotate-n-15"><i class="fas fa-car"></i></div>
|
||||||
<div class="sidebar-brand-text mx-3"><span>CAR MODEL</span></div>
|
<div id="index-car-model" class="sidebar-brand-text mx-3"><span>CAR MODEL</span></div>
|
||||||
</a>
|
</a>
|
||||||
<hr class="sidebar-divider my-0">
|
<hr class="sidebar-divider my-0">
|
||||||
<ul class="navbar-nav text-light" id="accordionSidebar">
|
<ul class="navbar-nav text-light" id="accordionSidebar">
|
||||||
<li class="nav-item"><a class="nav-link active" href="/"><i class="fas fa-tachometer-alt"></i><span>Dashboard</span></a></li>
|
<li class="nav-item"><a class="nav-link active" href="/"><i class="fas fa-tachometer-alt"></i><span>Dashboard</span></a></li>
|
||||||
<li class="nav-item"><a class="nav-link" href="#"><i class="fas fa-user"></i><span>Profile</span></a></li>
|
<li class="nav-item"></li>
|
||||||
<li class="nav-item"><a class="nav-link" href="#"><i class="fas fa-table"></i><span>Table</span></a></li>
|
<li class="nav-item"><a class="nav-link" href="/dtc"><i class="fas fa-table"></i><span>DTC </span></a></li>
|
||||||
<li class="nav-item"><a class="nav-link" href="#"><i class="far fa-user-circle"></i><span>Login</span></a></li>
|
|
||||||
<li class="nav-item"><a class="nav-link" href="#"><i class="fas fa-user-circle"></i><span>Register</span></a></li>
|
|
||||||
</ul>
|
</ul>
|
||||||
<div class="text-center d-none d-md-inline"><button class="btn rounded-circle border-0" id="sidebarToggle" type="button"></button></div>
|
<div class="text-center d-none d-md-inline"><button class="btn rounded-circle border-0" id="sidebarToggle" type="button"></button></div>
|
||||||
</div>
|
</div>
|
||||||
@@ -94,8 +92,8 @@
|
|||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="row align-items-center no-gutters">
|
<div class="row align-items-center no-gutters">
|
||||||
<div class="col me-2">
|
<div class="col me-2">
|
||||||
<div class="text-uppercase text-warning fw-bold text-xs mb-1" style="color: rgb(246,62,62);"><span style="color: rgb(246,62,62);">ERRORS</span></div>
|
<div class="text-uppercase text-warning fw-bold text-xs mb-1" style="color: rgb(246,62,62);"><span style="color: rgb(246,62,62);">RPM</span></div>
|
||||||
<div id="obd-error" class="text-dark fw-bold h5 mb-0"><span>unknown</span></div>
|
<div id="obd-rpm" class="text-dark fw-bold h5 mb-0"><span>unknown</span></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-auto"><i class="fas fa-comments fa-2x text-gray-300"></i></div>
|
<div class="col-auto"><i class="fas fa-comments fa-2x text-gray-300"></i></div>
|
||||||
</div>
|
</div>
|
||||||
@@ -133,7 +131,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<canvas id="speedGraph" width="400" height="200"></canvas>
|
<div class="chart-container" style="position: relative; height:40vh; text-align: center;">
|
||||||
|
<canvas id="speedGraph"></canvas>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -152,6 +152,21 @@
|
|||||||
<div id="map"></div>
|
<div id="map"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="card shadow mb-4">
|
||||||
|
<div class="card-header d-flex justify-content-between align-items-center">
|
||||||
|
<h6 class="text-primary fw-bold m-0">GPS Info</h6>
|
||||||
|
<div class="dropdown no-arrow"><button class="btn btn-link btn-sm dropdown-toggle" aria-expanded="false" data-bs-toggle="dropdown" type="button"><i class="fas fa-ellipsis-v text-gray-400"></i></button>
|
||||||
|
<div class="dropdown-menu shadow dropdown-menu-end animated--fade-in">
|
||||||
|
<p class="text-center dropdown-header">dropdown header:</p><a class="dropdown-item" href="#"> Action</a><a class="dropdown-item" href="#"> Another action</a>
|
||||||
|
<div class="dropdown-divider"></div><a class="dropdown-item" href="#"> Something else here</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<p>GPS X:</p>
|
||||||
|
<p>GPS Y:</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -163,11 +178,12 @@
|
|||||||
</footer>
|
</footer>
|
||||||
</div><a class="border rounded d-inline scroll-to-top" href="#page-top"><i class="fas fa-angle-up"></i></a>
|
</div><a class="border rounded d-inline scroll-to-top" href="#page-top"><i class="fas fa-angle-up"></i></a>
|
||||||
</div>
|
</div>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.0.1/socket.io.js" integrity="sha512-q/dWJ3kcmjBLU4Qc47E4A9kTB4m3wuTY7vkFJDTZKjTs8jhyGQnaUrxa0Ytd0ssMZhbNua9hE+E7Qv1j+DyZwA==" crossorigin="anonymous"></script>
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.2.0/socket.io.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.2.0/socket.io.js"></script>
|
||||||
<script src="{{ url_for('static', filename='js/yaris.js') }}"></script>
|
<script src="{{ url_for('static', filename='js/yaris.js') }}"></script>
|
||||||
|
<script src="{{ url_for('static', filename='bootstrap/js/bootstrap.min.js') }}"></script>
|
||||||
|
<script src="{{ url_for('static', filename='js/bs-init.js') }}"></script>
|
||||||
|
<script src="{{ url_for('static', filename='js/theme.js') }}"></script>
|
||||||
<script src="https://unpkg.com/[email protected]/dist/leaflet.js" integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" crossorigin=""></script>
|
<script src="https://unpkg.com/[email protected]/dist/leaflet.js" integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" crossorigin=""></script>
|
||||||
<script>var map = L.map('map').setView([48.505, -0.09], 13);
|
<script>var map = L.map('map').setView([48.505, -0.09], 13);
|
||||||
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||||
|
|||||||
Reference in New Issue
Block a user