Initial commit

This commit is contained in:
2026-04-05 01:03:30 +02:00
commit ff87ebebd9
8 changed files with 175 additions and 0 deletions

10
.gitignore vendored Normal file
View File

@@ -0,0 +1,10 @@
# Python-generated files
__pycache__/
*.py[oc]
build/
dist/
wheels/
*.egg-info
# Virtual environments
.venv

1
.python-version Normal file
View File

@@ -0,0 +1 @@
3.14

BIN
Inter-Regular.ttf Normal file

Binary file not shown.

0
README.md Normal file
View File

116
main.py Normal file
View File

@@ -0,0 +1,116 @@
import dearpygui.dearpygui as dpg
import time
import threading
from serial import Serial
import serial.tools.list_ports
running = True
def quit_app(sender, app_data, user_data):
running = False
dpg.destroy_context()
def serial_worker():
while running:
print(serial_port.read())
serial_port.close()
serial_port = Serial()
serial_thread = threading.Thread(target=serial_worker, daemon=True)
def telemetry_worker():
speed_data_x = [-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0]
speed_data_y = [5,6,7,8,9,10,9,8,7,6,5]
while running:
time.sleep(0.1)
y_val = speed_data_y.pop(0)
speed_data_y.append(y_val)
dpg.set_value("speed_series", [speed_data_x, speed_data_y])
dpg.set_axis_limits("x_axis_speed", speed_data_x[0], speed_data_x[-1])
def show_page(sender, app_data, user_data):
pages = ["page_live_data", "page_lap_recap"]
for page in pages:
dpg.hide_item(page)
dpg.show_item(user_data)
def show_connection_menu(sender, app_data, user_data):
ports = serial.tools.list_ports.comports()
port_names = []
for port in ports:
if port.vid is not None and port.pid is not None:
port_names.append(port.device)
dpg.configure_item("serial_combo", items=port_names)
dpg.show_item("connection_menu")
def connect_to_serial(sender, app_data, user_data):
global serial_port
port = dpg.get_value("serial_combo")
print("Connecting to " + port)
serial_port = Serial(port=port, baudrate=115200)
serial_thread.start()
dpg.create_context()
dpg.create_viewport(title='DataFlux', width=600, height=600)
with dpg.font_registry():
app_font = dpg.add_font("./Inter-Regular.ttf", 18)
dpg.bind_font(app_font)
with dpg.window(label='DataFlux',tag="main_window", no_collapse=True):
with dpg.menu_bar():
with dpg.menu(label='File'):
dpg.add_menu_item(label="Connect", callback=show_connection_menu)
dpg.add_menu_item(label="Quit", callback=quit_app)
with dpg.menu(label='Window'):
dpg.add_menu_item(label="Live Data", callback=show_page, user_data="page_live_data")
dpg.add_menu_item(label="Lap Recap", callback=show_page, user_data="page_lap_recap")
with dpg.child_window(tag="content_area", autosize_x=True, autosize_y=True, border=False):
with dpg.group(tag="page_live_data", show=True):
dpg.add_text("Live Data")
dpg.add_separator()
with dpg.group(horizontal=True):
with dpg.child_window(tag="realtime_stats", width=250, autosize_y=True, border=True):
dpg.add_text("Speed: 25kmh")
with dpg.child_window(tag="data_graphs", autosize_x=True, autosize_y=True, border=True):
with dpg.plot(label="Speed", height=250, width=-1, no_inputs=True):
dpg.add_plot_legend()
dpg.add_plot_axis(dpg.mvXAxis, label="Time", tag="x_axis_speed")
y_axis = dpg.add_plot_axis(dpg.mvYAxis, label="Speed", tag="y_axis_speed")
dpg.set_axis_limits("y_axis_speed", 0, 50)
dpg.add_line_series([], [], parent=y_axis, tag="speed_series")
with dpg.group(tag="page_lap_recap", show=False):
dpg.add_text("Lap Recap")
dpg.add_separator()
with dpg.window(label="Connection Menu", tag="connection_menu", show=False, modal=True, no_collapse=True, width=300):
dpg.add_combo([], tag="serial_combo")
dpg.add_button(label="Connect", callback=connect_to_serial)
worker = threading.Thread(target=telemetry_worker, daemon=True)
worker.start()
dpg.setup_dearpygui()
dpg.show_viewport()
vp_w = dpg.get_viewport_client_width()
vp_h = dpg.get_viewport_client_height()
dpg.configure_item("main_window", pos=(0, 0), width=vp_w, height=vp_h)
dpg.set_primary_window("main_window", True)
dpg.start_dearpygui()
running = False
dpg.destroy_context()

10
pyproject.toml Normal file
View File

@@ -0,0 +1,10 @@
[project]
name = "dataflux"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.14"
dependencies = [
"dearpygui>=2.2",
"pyserial>=3.5",
]

1
telemetry_common Symbolic link
View File

@@ -0,0 +1 @@
/home/hector/projects/Exergie/TelemetryCommon/

37
uv.lock generated Normal file
View File

@@ -0,0 +1,37 @@
version = 1
revision = 3
requires-python = ">=3.14"
[[package]]
name = "dataflux"
version = "0.1.0"
source = { virtual = "." }
dependencies = [
{ name = "dearpygui" },
{ name = "pyserial" },
]
[package.metadata]
requires-dist = [
{ name = "dearpygui", specifier = ">=2.2" },
{ name = "pyserial", specifier = ">=3.5" },
]
[[package]]
name = "dearpygui"
version = "2.2"
source = { registry = "https://pypi.org/simple" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/8b/76/3ccaec465021b647f13c83be42a635043a08255076984a658ed691701498/dearpygui-2.2-cp314-cp314-macosx_13_0_arm64.whl", hash = "sha256:22451146968729429ba37afa2602957dfefc03ff92dcc627dd4d85ba3f93e771", size = 1931385, upload-time = "2026-02-17T14:21:58.193Z" },
{ url = "https://files.pythonhosted.org/packages/52/ac/8e591f33a712563742fe77b0731c1c900fe2fcc3d3e75bd4c7d8e60057a8/dearpygui-2.2-cp314-cp314-manylinux1_x86_64.whl", hash = "sha256:dcc9377d8d9fe27f659ae6b016fe96aa37d8b26b57ce60c47985290e1be7801e", size = 2592691, upload-time = "2026-02-17T14:22:05.191Z" },
{ url = "https://files.pythonhosted.org/packages/f8/03/aeb4ebe09a0240c8c9337018d2ac3e087fd911f6051a3bb0131248fbd942/dearpygui-2.2-cp314-cp314-win_amd64.whl", hash = "sha256:fe3c8dc37be3ddce0356afb0c16721c0e485a4c94a831886935a0692bb9a9966", size = 1889279, upload-time = "2026-02-17T14:21:46.16Z" },
]
[[package]]
name = "pyserial"
version = "3.5"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/1e/7d/ae3f0a63f41e4d2f6cb66a5b57197850f919f59e558159a4dd3a818f5082/pyserial-3.5.tar.gz", hash = "sha256:3c77e014170dfffbd816e6ffc205e9842efb10be9f58ec16d3e8675b4925cddb", size = 159125, upload-time = "2020-11-23T03:59:15.045Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/07/bc/587a445451b253b285629263eb51c2d8e9bcea4fc97826266d186f96f558/pyserial-3.5-py2.py3-none-any.whl", hash = "sha256:c4451db6ba391ca6ca299fb3ec7bae67a5c55dde170964c7a14ceefec02f2cf0", size = 90585, upload-time = "2020-11-23T03:59:13.41Z" },
]