@@ -9,15 +9,15 @@ use eframe::egui::{self, FontData, FontDefinitions, FontFamily, IconData};
9
9
use log:: info;
10
10
use serialport:: available_ports;
11
11
use ui:: {
12
- AppUI ,
13
12
altitude:: AltitudeUI ,
14
13
// flight_menu::FlightMenu,
15
14
gps:: Gps ,
16
15
imu:: IMUUI ,
17
16
pitot:: PitotUI ,
18
17
servo:: ServoUI ,
19
18
tachometer:: TachUI ,
20
- vane:: VaneUI
19
+ vane:: VaneUI ,
20
+ AppUI ,
21
21
} ;
22
22
23
23
use crate :: parse:: Parser ;
@@ -35,7 +35,7 @@ fn main() -> Result<(), eframe::Error> {
35
35
eframe:: run_native (
36
36
"Meister App" ,
37
37
options,
38
- Box :: new ( |cc|{
38
+ Box :: new ( |cc| {
39
39
egui_extras:: install_image_loaders ( & cc. egui_ctx ) ;
40
40
Box :: < MeisterApp > :: default ( )
41
41
} ) ,
@@ -74,6 +74,7 @@ impl Default for MeisterApp {
74
74
servo : ServoUI :: new ( ) ,
75
75
tach : TachUI :: new ( ) ,
76
76
vane : VaneUI :: new ( ) ,
77
+
77
78
// menu: FlightMenu::new(),
78
79
}
79
80
}
@@ -102,7 +103,7 @@ impl eframe::App for MeisterApp {
102
103
self . parser . parse ( ) ;
103
104
egui:: CentralPanel :: default ( ) . show ( ctx, |ui| {
104
105
ctx. request_repaint_after ( std:: time:: Duration :: from_millis ( 25 ) ) ;
105
-
106
+
106
107
// self.menu.update(&mut self.parser, ctx);
107
108
108
109
match self . parser . get_port ( ) {
@@ -125,6 +126,114 @@ impl eframe::App for MeisterApp {
125
126
self . tach . update ( & mut self . parser , ctx) ;
126
127
self . vane . update ( & mut self . parser , ctx) ;
127
128
129
+ // 生存確認
130
+ let t = chrono:: Utc :: now ( ) . timestamp_millis ( ) ;
131
+
132
+ if let Some ( ( _, timestamp) ) = self . parser . get_servo_data ( ) . last ( ) {
133
+ if t < ( * timestamp + 1000 ) {
134
+ ui. colored_label ( egui:: Color32 :: GREEN , "0x10:Servo" ) ;
135
+ } else {
136
+ ui. colored_label ( egui:: Color32 :: RED , "0x10:Servo" ) ;
137
+ }
138
+ }
139
+ ui. horizontal ( |ui| {
140
+ if let Some ( ( _, timestamp) ) = self . parser . get_tach_data ( 0 ) . last ( ) {
141
+ if t < * timestamp + 1000 {
142
+ ui. colored_label ( egui:: Color32 :: GREEN , "0x20:Thrust" ) ;
143
+ } else {
144
+ ui. colored_label ( egui:: Color32 :: RED , "0x20:Thrust" ) ;
145
+ }
146
+ }
147
+ if let Some ( ( _, timestamp) ) = self . parser . get_tach_data ( 1 ) . last ( ) {
148
+ if t < * timestamp + 1000 {
149
+ ui. colored_label ( egui:: Color32 :: GREEN , "0x21:Tachometer" ) ;
150
+ } else {
151
+ ui. colored_label ( egui:: Color32 :: RED , "0x21:Tachometer" ) ;
152
+ }
153
+ }
154
+ } ) ;
155
+ if let Some ( ( pitot, timestamp) ) = self . parser . get_pitot_data ( ) . last ( ) {
156
+ if t < * timestamp + 1000 {
157
+ ui. colored_label ( egui:: Color32 :: GREEN , format ! ( "0x{:02x}:Pitot" , pitot. id) ) ;
158
+ } else {
159
+ ui. colored_label ( egui:: Color32 :: RED , format ! ( "0x{:02x}:Pitot" , pitot. id) ) ;
160
+ }
161
+ }
162
+
163
+ ui. horizontal ( |ui| {
164
+ if let Some ( ( _, timestamp) ) = self . parser . get_imu ( 0 ) . last ( ) {
165
+ if t < ( * timestamp + 1000 ) {
166
+ ui. colored_label ( egui:: Color32 :: GREEN , "0x40:IMU(B)" ) ;
167
+ } else {
168
+ ui. colored_label ( egui:: Color32 :: RED , "0x40:IMU(B)" ) ;
169
+ }
170
+ }
171
+ if let Some ( ( _, timestamp) ) = self . parser . get_imu ( 1 ) . last ( ) {
172
+ if t < * timestamp + 1000 {
173
+ ui. colored_label ( egui:: Color32 :: GREEN , "0x41:IMU(L)" ) ;
174
+ } else {
175
+ ui. colored_label ( egui:: Color32 :: RED , "0x41:IMU(L)" ) ;
176
+ }
177
+ }
178
+ if let Some ( ( _, timestamp) ) = self . parser . get_imu ( 2 ) . last ( ) {
179
+ if t < * timestamp + 1000 {
180
+ ui. colored_label ( egui:: Color32 :: GREEN , "0x42:IMU(R)" ) ;
181
+ } else {
182
+ ui. colored_label ( egui:: Color32 :: RED , "0x42:IMU(R)" ) ;
183
+ }
184
+ }
185
+ if let Some ( ( _, timestamp) ) = self . parser . get_imu ( 3 ) . last ( ) {
186
+ if t < * timestamp + 1000 {
187
+ ui. colored_label ( egui:: Color32 :: GREEN , "0x43:IMU(A)" ) ;
188
+ } else {
189
+ ui. colored_label ( egui:: Color32 :: RED , "0x43:IMU(A)" ) ;
190
+ }
191
+ }
192
+ } ) ;
193
+
194
+ if let Some ( ( alt, timestamp) ) = self . parser . get_ultra_sonic_data ( ) . last ( ) {
195
+ if t < * timestamp + 1000 {
196
+ ui. colored_label ( egui:: Color32 :: GREEN , format ! ( "0x{:02x}:UltraSonic" , alt. id) ) ;
197
+ } else {
198
+ ui. colored_label (
199
+ egui:: Color32 :: RED ,
200
+ format ! ( "0x{:02x}:UltraSonic" , alt. id) ,
201
+ ) ;
202
+ }
203
+ }
204
+
205
+ if let Some ( ( gps, timestamp) ) = self . parser . get_gps_data ( ) . last ( ) {
206
+ if t < * timestamp + 3000 {
207
+ ui. colored_label ( egui:: Color32 :: GREEN , format ! ( "0x{:02x}:GPS" , gps. id) ) ;
208
+ } else {
209
+ ui. colored_label ( egui:: Color32 :: RED , format ! ( "0x{:02x}:GPS" , gps. id) ) ;
210
+ }
211
+ }
212
+
213
+ if let Some ( ( vane, timestamp) ) = self . parser . get_vane_data ( ) . last ( ) {
214
+ if t < * timestamp + 1000 {
215
+ ui. colored_label ( egui:: Color32 :: GREEN , format ! ( "0x{:02x}:Vane" , vane. id) ) ;
216
+ } else {
217
+ ui. colored_label ( egui:: Color32 :: RED , format ! ( "0x{:02x}:Vane" , vane. id) ) ;
218
+ }
219
+ }
220
+
221
+ ui. horizontal ( |ui| {
222
+ if let Some ( ( _, timestamp) ) = self . parser . get_barometer_data ( 0 ) . last ( ) {
223
+ if t < * timestamp + 1000 {
224
+ ui. colored_label ( egui:: Color32 :: GREEN , "0x90:Barometer (On-board)" ) ;
225
+ } else {
226
+ ui. colored_label ( egui:: Color32 :: RED , "0x90:Barometer (On-board)" ) ;
227
+ }
228
+ }
229
+ if let Some ( ( _, timestamp) ) = self . parser . get_barometer_data ( 1 ) . last ( ) {
230
+ if t < * timestamp + 1000 {
231
+ ui. colored_label ( egui:: Color32 :: GREEN , "0x91:Barometer (ground)" ) ;
232
+ } else {
233
+ ui. colored_label ( egui:: Color32 :: GREEN , "0x91:Barometer (ground)" ) ;
234
+ }
235
+ }
236
+ } ) ;
128
237
}
129
238
None => {
130
239
ui. horizontal ( |ui| match available_ports ( ) {
0 commit comments