Skip to content

Commit 355083e

Browse files
Get file screen kind of working
1 parent 171ff34 commit 355083e

7 files changed

Lines changed: 138 additions & 17 deletions

File tree

.github/workflows/build.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: build
2+
on:
3+
push:
4+
branches:
5+
- main
6+
7+
jobs:
8+
release:
9+
name: Release - ${{ matrix.platform.os-name }}
10+
strategy:
11+
matrix:
12+
platform:
13+
- os-name: Linux-armv7
14+
runs-on: ubuntu-24.04
15+
target: armv7-unknown-linux-musleabihf
16+
17+
runs-on: ${{ matrix.platform.runs-on }}
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Build container
23+
runs: docker build -t cross-armv7:latest -f armv7.dockerfile .
24+
25+
- name: Build binary
26+
uses: houseabsolute/actions-rust-cross@v1
27+
with:
28+
command: build
29+
target: ${{ matrix.platform.target }}
30+
args: "--locked --release"
31+
strip: true
32+
33+
- name: Upload binary
34+
uses: actions/upload-artifact@v4
35+
with:
36+
name: ${{ matrix.platform.os-name }}
37+
path: target/${{ matrix.platform.target }}/release/atomscreen

example_configs/simulator.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
[display.default]
22
width = 480
33
height = 272
4+
5+
[moonraker]
6+
host = "localhost"
7+
port = 7125

src/config/config.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
use serde::{Deserialize, Serialize};
1+
use serde::{Deserialize};
2+
use crate::config::MoonrakerConfig;
3+
24
use super::{DisplayConfig};
35

4-
#[derive(Serialize, Deserialize)]
6+
#[derive(Deserialize)]
57
pub struct Config {
68
pub display: DisplayConfig,
9+
pub moonraker: Option<MoonrakerConfig>
710
}

src/config/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ pub mod display_default;
44
pub mod display_fb;
55
pub mod cli;
66
pub mod config;
7+
pub mod moonraker;
78

89
pub use display::*;
910
pub use display_default::*;
1011
#[cfg(unix)]
1112
pub use display_fb::*;
1213
pub use cli::*;
13-
pub use config::*;
14+
pub use config::*;
15+
pub use moonraker::*;

src/config/moonraker.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
use serde::Deserialize;
2+
3+
4+
#[derive(Deserialize, Debug)]
5+
pub struct MoonrakerConfig
6+
{
7+
pub host: String,
8+
pub port: u16
9+
}
10+
11+
impl Default for MoonrakerConfig
12+
{
13+
fn default() -> Self {
14+
Self { host: "127.0.0.1".into(), port: 7125u16 }
15+
}
16+
}

src/main.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use moonraker_rs::moonraker_connection::{GeneralEvent, MoonrakerEvent, PrinterEv
88
use slint::{Image, Model, ModelRc, PlatformError, Rgb8Pixel, Rgba8Pixel, SharedPixelBuffer, SharedString, VecModel};
99
use tokio::sync::Mutex;
1010

11-
use crate::{application_error::ApplicationError, hardware::init_display};
11+
use crate::{application_error::ApplicationError, config::MoonrakerConfig, hardware::init_display};
1212

1313

1414
mod config;
@@ -29,8 +29,9 @@ async fn main() -> Result<(), Box<dyn Error>> {
2929

3030
let config_str = fs::read_to_string(&config_path).unwrap();
3131
let config = toml::from_str::<config::Config>(&config_str).unwrap();
32+
let moonraker_config = config.moonraker.unwrap_or(MoonrakerConfig::default());
3233

33-
let moonraker_connection = Arc::new(moonraker_rs::moonraker_connection::MoonrakerConnection::new("localhost", 7125));
34+
let moonraker_connection = Arc::new(moonraker_rs::moonraker_connection::MoonrakerConnection::new(&moonraker_config.host, moonraker_config.port));
3435
let moonraker_connection_clone = moonraker_connection.clone();
3536
let moonraker_connection_clone_2 = moonraker_connection.clone();
3637

@@ -53,7 +54,15 @@ async fn main() -> Result<(), Box<dyn Error>> {
5354
//println!("Received Moonraker event: {:?}", event);
5455
//connection_ref.get_listener();
5556

56-
if let GeneralEvent::MoonrakerEvent(moonraker_event) = &*event
57+
if let GeneralEvent::Connected = &*event
58+
{
59+
ui_weak.upgrade_in_event_loop(move |ui| ui.global::<AppState>().set_moonraker_connected(true)).unwrap();
60+
}
61+
else if let GeneralEvent::Disconnected = &*event
62+
{
63+
ui_weak.upgrade_in_event_loop(move |ui| ui.global::<AppState>().set_moonraker_connected(false)).unwrap();
64+
}
65+
else if let GeneralEvent::MoonrakerEvent(moonraker_event) = &*event
5766
{
5867
if let MoonrakerEvent::NotifyStatusUpdate(status_update) = moonraker_event
5968
{
@@ -222,6 +231,8 @@ async fn main() -> Result<(), Box<dyn Error>> {
222231
SharedString::from(format!("{:.2} {}", value, units[idx]))
223232
});
224233

234+
ui.global::<AppState>().set_moonraker_connected(false);
235+
225236
tokio::task::block_in_place(|| {
226237
ui.run().unwrap();
227238
});

ui/main.slint

Lines changed: 59 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,10 @@ export struct MoonrakerFileTest
188188
thumbnail: image,
189189
}
190190

191+
export global AppState
192+
{
193+
in-out property <bool> moonraker_connected: false;
194+
}
191195

192196
export global Filesystem
193197
{
@@ -212,6 +216,10 @@ component FileListView inherits Rectangle
212216
property <MoonrakerFileTest> selected_file;
213217
property <int> thumbnail_index: 0;
214218

219+
init() => {
220+
Filesystem.list_files();
221+
}
222+
215223
if Filesystem.loading: ProgressIndicator {
216224
indeterminate: true;
217225
width: 200px;
@@ -283,16 +291,10 @@ component BottomBar inherits Rectangle {
283291
}
284292
}
285293

286-
export component AppWindow inherits Window {
294+
component MainView
295+
{
287296
in-out property <int> current-page: 0;
288297

289-
//width: 480px;
290-
//height: 272px;
291-
292-
// The buttons to switch pages
293-
294-
default-font-family: "Figtree";
295-
296298
VerticalLayout {
297299
TopBar {
298300

@@ -306,16 +308,16 @@ export component AppWindow inherits Window {
306308
IconButton { icon: @image-url("assets/print.svg"); checked: root.current-page == 0; clicked => { root.current-page = 0; } }
307309
IconButton { icon: @image-url("assets/temperature.svg"); checked: root.current-page == 1; clicked => { root.current-page = 1; } }
308310
IconButton { icon: @image-url("assets/move.svg"); checked: root.current-page == 2; clicked => { root.current-page = 2; } }
309-
IconButton { icon: @image-url("assets/emergency.svg"); checked: root.current-page == 3; clicked => { root.current-page = 3; Filesystem.list_files(); } foreground: red; }
311+
IconButton { icon: @image-url("assets/emergency.svg"); checked: root.current-page == 3; clicked => { root.current-page = 3; } foreground: red; }
310312
}
311313

312314
Rectangle {
313315
horizontal-stretch: 1;
314316

315-
PageOne { visible: root.current-page == 0; }
317+
//PageOne { visible: root.current-page == 0; }
316318
PageTwo { visible: root.current-page == 1; }
317319
PageThree { visible: root.current-page == 2; }
318-
if root.current-page == 3: PageFour { }
320+
if root.current-page == 0: PageFour { }
319321
}
320322

321323
VerticalLayout {
@@ -333,6 +335,52 @@ export component AppWindow inherits Window {
333335

334336
}
335337
}
338+
}
339+
340+
export component AppWindow inherits Window {
341+
342+
343+
width: 480px;
344+
height: 272px;
345+
346+
// The buttons to switch pages
347+
348+
default-font-family: "Figtree";
349+
350+
if AppState.moonraker_connected: MainView {
351+
width: 100%;
352+
height: 100%;
353+
}
354+
355+
if !AppState.moonraker_connected: VerticalLayout
356+
{
357+
VerticalLayout {
358+
width: 100%;
359+
spacing: 20px;
360+
Rectangle {
361+
362+
}
363+
Rectangle {
364+
VerticalLayout {
365+
width: 200px;
366+
spacing: 20px;
367+
alignment: center;
368+
Text {
369+
text: "Connecting to moonraker...";
370+
horizontal-alignment: center;
371+
}
372+
ProgressIndicator {
373+
width: 100%;
374+
indeterminate: true;
375+
}
376+
}
377+
}
378+
Rectangle {
379+
380+
}
381+
}
382+
}
383+
336384
/*
337385
keyboard := VirtualKeyboard {
338386
y: parent.height - self.height;

0 commit comments

Comments
 (0)