Skip to content

Commit 8d6ff7e

Browse files
committed
basic firmware and UI
1 parent 9d82e90 commit 8d6ff7e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+5420
-2
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: PlatformIO CI
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v4
11+
- uses: actions/cache@v4
12+
with:
13+
path: |
14+
~/.cache/pip
15+
~/.platformio/.cache
16+
key: ${{ runner.os }}-pio
17+
- uses: actions/setup-python@v5
18+
with:
19+
python-version: '3.11'
20+
- name: Install PlatformIO Core
21+
run: pip install --upgrade platformio
22+
23+
- name: Build PlatformIO Project
24+
run: pio run

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.pio
2+
.vscode/.browse.c_cpp.db*
3+
.vscode/c_cpp_properties.json
4+
.vscode/launch.json
5+
.vscode/ipch
6+
.venv

.vscode/extensions.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
// See http://go.microsoft.com/fwlink/?LinkId=827846
3+
// for the documentation about the extensions.json format
4+
"recommendations": [
5+
"platformio.platformio-ide"
6+
],
7+
"unwantedRecommendations": [
8+
"ms-vscode.cpptools-extension-pack"
9+
]
10+
}

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
# igniter-daq
2-
UI and firmware for igniter DAQ
1+
# Igniter DAQ

UI/UI.py

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
import TKinterModernThemes as TKMT
2+
from matplotlib.axes._axes import Axes
3+
from matplotlib.figure import Figure
4+
import time
5+
import numpy as np
6+
import random
7+
8+
9+
DO_COUNT = 5
10+
11+
12+
sample_autoseq = [
13+
{"Time": 0, "DO": "DO_1", "State": "On"},
14+
{"Time": 0.5, "DO": "DO_2", "State": "On"},
15+
{"Time": 2, "DO": "DO_1", "State": "Off"}
16+
]
17+
18+
class TKGraph:
19+
def __init__(self, canvas, fig: Figure, ax: Axes, backgroundcolor: str, accentcolor: str, labels):
20+
self.canvas = canvas
21+
self.fig = fig
22+
self.ax = ax
23+
self.backgroundcolor = backgroundcolor
24+
self.accentcolor = accentcolor
25+
self.labels = labels
26+
27+
self.xs = []
28+
self.points_1 = []
29+
self.points_2 = []
30+
self.last_x = 0
31+
self.last_y_1 = 50
32+
self.last_y_2 = 30
33+
34+
self.scatter1 = ax.scatter([], [], c=self.accentcolor)
35+
self.scatter2 = ax.scatter([], [], c='blue')
36+
ax.axhline(y=70, color='r', linestyle='--', label='redline')
37+
self.ax.set_xlabel("Time")
38+
self.ax.set_ylim(0, 100)
39+
self.fig.legend(self.labels)
40+
41+
42+
def update(self):
43+
self.xs.append(self.last_x)
44+
self.points_1.append(self.last_y_1)
45+
self.points_2.append(self.last_y_2)
46+
self.last_x += 1
47+
self.last_y_1 += (random.random() * 5) - 2.4
48+
self.last_y_2 += (random.random() * 5) - 2.4
49+
50+
self.xs = self.xs[-20:]
51+
self.points_1 = self.points_1[-20:]
52+
self.points_2 = self.points_2[-20:]
53+
54+
self.scatter1.set_offsets(np.c_[self.xs, self.points_1])
55+
self.scatter2.set_offsets(np.c_[self.xs, self.points_2])
56+
self.ax.set_xlim(self.last_x - 20, self.last_x)
57+
58+
self.canvas.draw()
59+
60+
61+
class App(TKMT.ThemedTKinterFrame):
62+
def __init__(self):
63+
super().__init__("Igniter DAQ")
64+
self.root.tk.call("source", 'cust_ui.tcl')
65+
#self.root.attributes("-fullscreen", True)
66+
67+
self.control_frame = self.addLabelFrame("Control")
68+
self.control_frame.Button("START", None, style=TKMT.ThemeStyles.ButtonStyles.AccentButton)
69+
self.control_frame.Button("ABORT", None, style='Red_' + TKMT.ThemeStyles.ButtonStyles.AccentButton, col=1)
70+
self.control_frame.Treeview(['Time', 'DO', 'State'], [50, 50, 50], 10, sample_autoseq, '', colspan=2)
71+
72+
self.do_frame = self.control_frame.addFrame("do frame", colspan=2, padx=(0,0), pady=(0,0))
73+
for do_num in range(DO_COUNT):
74+
self.do_frame.ToggleButton(f"DO_{do_num}", None, col=do_num)
75+
76+
self.serial_frame = self.control_frame.addLabelFrame("Serial Command Interface", colspan=2, padx=(5,5), pady=(5,5))
77+
self.serial_frame.Entry(None, widgetkwargs={'width': 50})
78+
self.serial_frame.AccentButton("Send", None, col=1)
79+
80+
self.nextCol()
81+
self.data_frame = self.addLabelFrame("Data")
82+
self.graph_1 = TKGraph(*self.data_frame.matplotlibFrame("Graph 1", figsize=(4,2.5), toolbar=False, padx=0, pady=0), ['PT0', 'PT1'])
83+
self.graph_2 = TKGraph(*self.data_frame.matplotlibFrame("Graph 2", figsize=(4,2.5), toolbar=False, padx=0, pady=0), ['PT2', 'PT3'])
84+
self.graph_3 = TKGraph(*self.data_frame.matplotlibFrame("Graph 3", figsize=(4,2.5), toolbar=False, padx=0, pady=0), ['TC_LOX', 'TC_IPA'])
85+
86+
self.root.after(500, self.periodic)
87+
#self.root.after(2000, self.fullscreen)
88+
89+
self.debugPrint()
90+
self.run(onlyFrames=False)
91+
92+
def periodic(self):
93+
s = time.time()
94+
self.graph_1.update()
95+
self.graph_2.update()
96+
self.graph_3.update()
97+
print('e', time.time() - s)
98+
self.root.after(100, self.periodic) #Call every 0.1 seconds to keep UI updated
99+
100+
def fullscreen(self):
101+
self.root.attributes("-fullscreen", True)
102+
103+
104+
105+
if __name__ == '__main__':
106+
app = App()

UI/cust_ui.tcl

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package require Tk 8.6
2+
3+
namespace eval ttk::theme::cust_ui {
4+
5+
variable version 1.0
6+
package provide ttk::theme::cust_ui $version
7+
variable colors
8+
array set colors {
9+
-fg "#eeeeee"
10+
-bg "#313131"
11+
-disabledfg "#595959"
12+
-disabledbg "#ffffff"
13+
-selectfg "#ffffff"
14+
-selectbg "#217346"
15+
}
16+
17+
proc LoadImages {imgdir} {
18+
variable I
19+
foreach file [glob -directory $imgdir *.png] {
20+
set img [file tail [file rootname $file]]
21+
set I($img) [image create photo -file $file -format png]
22+
}
23+
}
24+
25+
LoadImages [file join [file dirname [info script]] cust_ui_elems]
26+
27+
28+
ttk::style layout Red_Accent.TButton {
29+
Red_AccentButton.button -children {
30+
Red_AccentButton.padding -children {
31+
Red_AccentButton.label -side left -expand true
32+
}
33+
}
34+
}
35+
36+
# Elements
37+
38+
# AccentButton
39+
ttk::style configure Red_Accent.TButton -padding {8 4 8 4} -width -10 -anchor center -foreground #eeeeee
40+
41+
ttk::style element create Red_AccentButton.button image \
42+
[list $I(red-rect-accent) \
43+
{selected disabled} $I(red-rect-accent-hover) \
44+
disabled $I(red-rect-accent-hover) \
45+
selected $I(red-rect-accent) \
46+
pressed $I(red-rect-accent) \
47+
active $I(red-rect-accent-hover) \
48+
] -border 4 -sticky nsew
49+
}
290 Bytes
Loading

UI/cust_ui_elems/rect-accent.png

290 Bytes
Loading
322 Bytes
Loading
322 Bytes
Loading

0 commit comments

Comments
 (0)