Skip to content

Commit 8e2779a

Browse files
committed
update UI for transmit CAN packets
1 parent b6d6f58 commit 8e2779a

File tree

3 files changed

+49
-39
lines changed

3 files changed

+49
-39
lines changed

src/event_handler/debug.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,9 @@ impl<'a> DebugHandler<'a> {
4444
vec_data.insert(
4545
0,
4646
raw_can {
47-
time: SharedString::from(format!(
48-
"{:?}",
49-
Local::now().to_string().replace('"', "")
50-
)),
47+
time: SharedString::from(
48+
Local::now().to_string().replace('"', "").to_string(),
49+
),
5150
data: SharedString::from(format!("{:?}", frame.data())),
5251
id: SharedString::from(format!("0x{:08X}", frame_id)),
5352
len: frame.len() as i32,

ui/debug_page.slint

Lines changed: 43 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

2-
import { ListView, Button } from "std-widgets.slint";
2+
import { ListView, Button, LineEdit, CheckBox } from "std-widgets.slint";
3+
import { MyCheckBox } from "filter_page.slint";
34

45
export struct raw_can {
56
time: string,
@@ -17,6 +18,7 @@ export component StartPauseButton inherits Rectangle {
1718
height: 30px;
1819
states [
1920
pressed when touch-area.pressed : {
21+
background: #ffffff.darker(0.8);
2022
}
2123

2224
hover when touch-area.has-hover: {
@@ -30,13 +32,39 @@ export component StartPauseButton inherits Rectangle {
3032
colorize: white;
3133
}
3234
touch-area := TouchArea {
33-
pointer-event(event) => {
34-
if (event.button == PointerEventButton.left && event.kind == PointerEventKind.down) {
35-
clicked();
35+
clicked => {
36+
clicked();
37+
}
38+
}
39+
}
40+
41+
export component CanTransmitData inherits Rectangle {
42+
callback send(bool, string, string, string);
43+
HorizontalLayout {
44+
is_extended := MyCheckBox {
45+
text: "Extended Frame";
46+
}
47+
can_id := LineEdit {
48+
placeholder-text: "ID (hex)";
49+
input-type: decimal;
50+
}
51+
can_len := LineEdit {
52+
placeholder-text: "length";
53+
input-type: number;
54+
}
55+
can_data := LineEdit {
56+
placeholder-text: "data (hex)";
57+
input-type: decimal;
58+
}
59+
Button {
60+
text: "send";
61+
clicked => {
62+
send(is_extended.checked, can_id.text, can_len.text, can_data.text)
3663
}
3764
}
3865
}
3966
}
67+
4068
export component debugPage inherits Rectangle {
4169
in-out property <bool> en;
4270
in property <string> state;
@@ -153,32 +181,17 @@ export component debugPage inherits Rectangle {
153181
border-width: 1px;
154182
}
155183
VerticalLayout {
156-
ListView {
157-
for raw in raw_data: Rectangle {
158-
HorizontalLayout {
159-
Rectangle {
160-
width: parent.width * 30%;
161-
Text {
162-
text: raw.id;
163-
color: white;
164-
}
165-
}
166-
Rectangle {
167-
width: parent.width * 20%;
168-
Text {
169-
text: raw.len;
170-
color: white;
171-
}
172-
}
173-
Rectangle {
174-
width: parent.width * 50%;
175-
Text {
176-
text: raw.data;
177-
color: white;
178-
}
179-
}
180-
}
181-
}
184+
CanTransmitData {
185+
186+
}
187+
CanTransmitData {
188+
189+
}
190+
CanTransmitData {
191+
192+
}
193+
CanTransmitData {
194+
182195
}
183196
}
184197
}

ui/filter_page.slint

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,9 @@ export component MyCheckBox inherits Rectangle {
4545
}
4646
}
4747
touch-area := TouchArea {
48-
pointer-event(event) => {
49-
if (event.button == PointerEventButton.left && event.kind == PointerEventKind.down && enabled) {
50-
checked = !checked;
51-
toggled(checked);
52-
}
48+
clicked => {
49+
checked = !checked;
50+
toggled(checked);
5351
}
5452
}
5553
}

0 commit comments

Comments
 (0)