Skip to content

Commit

Permalink
orb-ui: wifi qr animation
Browse files Browse the repository at this point in the history
  • Loading branch information
fouge committed Oct 17, 2024
1 parent 7427509 commit 85c205b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
5 changes: 5 additions & 0 deletions orb-ui/rgb/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ impl Argb {
Argb(Some(Self::DIMMING_MAX_VALUE), 128, 128, 0);
pub const DIAMOND_OPERATOR_VERSIONS_OUTDATED: Argb =
Argb(Some(Self::DIMMING_MAX_VALUE), 255, 0, 0);

/// Outer-ring color during wifi QR scans
pub const DIAMOND_RING_WIFI_QR_SCAN: Argb = Argb(Some(5), 0, 10, 80);
pub const DIAMOND_RING_WIFI_QR_SCAN_SPINNER: Argb = Argb(Some(10), 50, 50, 40);

/// Outer-ring color during operator QR scans
pub const DIAMOND_RING_OPERATOR_QR_SCAN: Argb = Argb(Some(5), 77, 14, 0);
pub const DIAMOND_RING_OPERATOR_QR_SCAN_SPINNER: Argb = Argb(Some(10), 80, 50, 30);
Expand Down
15 changes: 14 additions & 1 deletion orb-ui/src/engine/diamond.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,11 @@ impl EventHandler for Runner<DIAMOND_RING_LED_COUNT, DIAMOND_CENTER_LED_COUNT> {
sound::Type::Melody(sound::Melody::InternetConnectionSuccessful),
Duration::ZERO,
)?;
self.stop_ring(LEVEL_FOREGROUND, Transition::FadeOut(0.5));
self.set_ring(
LEVEL_BACKGROUND,
animations::Static::<DIAMOND_RING_LED_COUNT>::new(Argb::OFF, None),
);
}
Event::BootComplete { api_mode } => {
self.sound.queue(
Expand Down Expand Up @@ -345,7 +350,14 @@ impl EventHandler for Runner<DIAMOND_RING_LED_COUNT, DIAMOND_CENTER_LED_COUNT> {
}
QrScanSchema::Wifi => {
self.operator_idle.no_wlan();

self.set_ring(
LEVEL_FOREGROUND,
animations::SimpleSpinner::new(
Argb::DIAMOND_RING_WIFI_QR_SCAN_SPINNER,
Some(Argb::DIAMOND_RING_WIFI_QR_SCAN),
)
.fade_in(1.5),
);
// temporarily increase the volume to ask wifi qr code
let master_volume = self.sound.volume();
self.sound.set_master_volume(40);
Expand Down Expand Up @@ -488,6 +500,7 @@ impl EventHandler for Runner<DIAMOND_RING_LED_COUNT, DIAMOND_CENTER_LED_COUNT> {
);
}
QrScanSchema::Wifi => {
self.stop_ring(LEVEL_FOREGROUND, Transition::FadeOut(0.5));
self.sound.queue(
sound::Type::Melody(sound::Melody::QrLoadSuccess),
Duration::ZERO,
Expand Down
9 changes: 9 additions & 0 deletions orb-ui/src/simulation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ pub async fn bootup_simulation(ui: &dyn Engine) -> Result<()> {
Ok(())
}

#[expect(dead_code)]
pub async fn wifi_qr_code_simulation(ui: &dyn Engine) {
ui.qr_scan_start(QrScanSchema::Wifi);
time::sleep(Duration::from_secs(6)).await;
ui.qr_scan_capture();
time::sleep(Duration::from_secs(2)).await;
ui.network_connection_success();
}

pub async fn signup_simulation(
ui: &dyn Engine,
hardware: Hardware,
Expand Down

0 comments on commit 85c205b

Please sign in to comment.