Skip to content

Commit

Permalink
orb-ui: increased volume to ask for wifi (#266)
Browse files Browse the repository at this point in the history
"please show wifi qr code" spoken loudly.
  • Loading branch information
fouge authored Oct 23, 2024
1 parent 2f26452 commit b7a84db
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ui/src/engine/diamond.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,10 +345,15 @@ impl EventHandler for Runner<DIAMOND_RING_LED_COUNT, DIAMOND_CENTER_LED_COUNT> {
}
QrScanSchema::Wifi => {
self.operator_idle.no_wlan();

// temporarily increase the volume to ask wifi qr code
let master_volume = self.sound.volume();
self.sound.set_master_volume(40);
self.sound.queue(
sound::Type::Voice(sound::Voice::ShowWifiHotspotQrCode),
Duration::ZERO,
)?;
self.sound.set_master_volume(master_volume);
}
QrScanSchema::User => {
self.operator_signup_phase.user_qr_code_ok();
Expand Down
5 changes: 5 additions & 0 deletions ui/src/engine/pearl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,15 @@ impl EventHandler for Runner<PEARL_RING_LED_COUNT, PEARL_CENTER_LED_COUNT> {
}
QrScanSchema::Wifi => {
self.operator_idle.no_wlan();

// temporarily increase the volume to ask wifi qr code
let master_volume = self.sound.volume();
self.sound.set_master_volume(30);
self.sound.queue(
sound::Type::Voice(sound::Voice::ShowWifiHotspotQrCode),
Duration::ZERO,
)?;
self.sound.set_master_volume(master_volume);
}
QrScanSchema::User => {
self.operator_signup_phase.user_qr_code_ok();
Expand Down
7 changes: 7 additions & 0 deletions ui/src/sound/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ pub trait Player: fmt::Debug + Send {
/// Returns a new handler to the shared queue.
fn clone(&self) -> Box<dyn Player>;

/// Returns the master volume [0, 100].
fn volume(&self) -> u64;

/// Sets the master volume.
fn set_master_volume(&mut self, level: u64);

Expand Down Expand Up @@ -262,6 +265,10 @@ impl Player for Jetson {
})
}

fn volume(&self) -> u64 {
(self.volume * 100.0) as u64
}

fn set_master_volume(&mut self, level: u64) {
self.volume = level as f64 / 100.0;
}
Expand Down

0 comments on commit b7a84db

Please sign in to comment.