@@ -50,17 +50,11 @@ use regulators::Regulators;
50
50
use setup_mode:: SetupMode ;
51
51
use system:: System ;
52
52
use temperatures:: Temperatures ;
53
- use ui:: { setup_display, Ui , UiResources } ;
53
+ use ui:: { setup_display, Display , Ui , UiResources } ;
54
54
use usb_hub:: UsbHub ;
55
55
use watchdog:: Watchdog ;
56
56
57
- #[ async_std:: main]
58
- async fn main ( ) -> Result < ( ) > {
59
- env_logger:: init ( ) ;
60
-
61
- // Show a splash screen very early on
62
- let display = setup_display ( ) ;
63
-
57
+ async fn init ( ) -> Result < ( Ui , HttpServer , Option < Watchdog > ) > {
64
58
// The BrokerBuilder collects topics that should be exported via the
65
59
// MQTT/REST APIs.
66
60
// The topics are also used to pass around data inside the tacd.
@@ -122,9 +116,6 @@ async fn main() -> Result<()> {
122
116
// in the web interface.
123
117
journal:: serve ( & mut http_server. server ) ;
124
118
125
- // Expose the display as a .png on the web server
126
- ui:: serve_display ( & mut http_server. server , display. screenshooter ( ) ) ;
127
-
128
119
// Set up the user interface for the hardware display on the TAC.
129
120
// The different screens receive updates via the topics provided in
130
121
// the UiResources struct.
@@ -153,6 +144,18 @@ async fn main() -> Result<()> {
153
144
// and expose the topics via HTTP and MQTT-over-websocket.
154
145
bb. build ( & mut http_server. server ) ;
155
146
147
+ Ok ( ( ui, http_server, watchdog) )
148
+ }
149
+
150
+ async fn run (
151
+ ui : Ui ,
152
+ mut http_server : HttpServer ,
153
+ watchdog : Option < Watchdog > ,
154
+ display : Display ,
155
+ ) -> Result < ( ) > {
156
+ // Expose the display as a .png on the web server
157
+ ui:: serve_display ( & mut http_server. server , display. screenshooter ( ) ) ;
158
+
156
159
log:: info!( "Setup complete. Handling requests" ) ;
157
160
158
161
// Run until the user interface, http server or (if selected) the watchdog
@@ -172,3 +175,14 @@ async fn main() -> Result<()> {
172
175
173
176
Ok ( ( ) )
174
177
}
178
+
179
+ #[ async_std:: main]
180
+ async fn main ( ) -> Result < ( ) > {
181
+ env_logger:: init ( ) ;
182
+
183
+ // Show a splash screen very early on
184
+ let display = setup_display ( ) ;
185
+
186
+ let ( ui, http_server, watchdog) = init ( ) . await ?;
187
+ run ( ui, http_server, watchdog, display) . await
188
+ }
0 commit comments