diff --git a/services/codec/src/backend/tlv320aic3100.rs b/services/codec/src/backend/tlv320aic3100.rs index 5f98a6c85..48ded9bfb 100644 --- a/services/codec/src/backend/tlv320aic3100.rs +++ b/services/codec/src/backend/tlv320aic3100.rs @@ -28,6 +28,10 @@ pub struct Codec { live: bool, conn: xous::CID, drain: bool, + // to recall values through suspend/resume + speaker_gain: f32, + headphone_left_gain: f32, + headphone_right_gain: f32, } static SILENCE: [u32; FIFO_DEPTH] = [ZERO_PCM as u32 | (ZERO_PCM as u32) << 16; FIFO_DEPTH]; @@ -138,6 +142,9 @@ impl Codec { tx_stat_errors: 0, rx_stat_errors: 0, drain: false, + speaker_gain: -6.0, + headphone_left_gain: -15.0, + headphone_right_gain: -15.0, }; xous::claim_interrupt( @@ -182,6 +189,8 @@ impl Codec { } } self.susres_manager.resume(); + self.set_speaker_gain_db(self.speaker_gain); + self.set_headphone_gain_db(self.headphone_left_gain, self.headphone_right_gain); } pub fn init(&mut self) { @@ -191,6 +200,9 @@ impl Codec { self.audio_ports(); log::trace!("audio_mixer"); self.audio_mixer(); + // this restores the user state of gain, which is overriden during the audio_mixer() reset sequence + self.set_speaker_gain_db(self.speaker_gain); + self.set_headphone_gain_db(self.headphone_left_gain, self.headphone_right_gain); log::trace!("audio initialized!"); self.initialized = true; } @@ -233,6 +245,7 @@ impl Codec { } pub fn set_speaker_gain_db(&mut self, gain_db: f32) { + self.speaker_gain = gain_db; if gain_db <= -79.0 { // mute self.w(0, &[1]); // select page 1 @@ -247,18 +260,21 @@ impl Codec { } } - pub fn set_headphone_gain_db(&mut self, gain_db: f32) { - if gain_db <= -79.0 { + pub fn set_headphone_gain_db(&mut self, gain_db_left: f32, gain_db_right: f32) { + self.headphone_left_gain = gain_db_left; + self.headphone_right_gain = gain_db_right; + if gain_db_left <= -79.0 && gain_db_right <= -79.0 { // mute self.w(0, &[1]); // select page 1 self.w(31, &[0b0_0_0_10_1_0_0]); // headphones powered down } else { - let code = analog_volume_db_to_code(gain_db); + let code_left = analog_volume_db_to_code(gain_db_left); + let code_right = analog_volume_db_to_code(gain_db_right); self.w(0, &[1]); // select page 1 self.w(31, &[0b1_1_00011_0]); // headphones powered up self.w(36, &[ - 0b1_000_0000 | code, // HPL - 0b1_000_0000 | code, // HPR + 0b1_000_0000 | code_left, // HPL + 0b1_000_0000 | code_right, // HPR ]); } } diff --git a/services/codec/src/main.rs b/services/codec/src/main.rs index 1eefd3504..62f480f58 100644 --- a/services/codec/src/main.rs +++ b/services/codec/src/main.rs @@ -217,7 +217,7 @@ fn xmain() -> ! { }, _ => log::error!("got speaker volume primitive that we don't recognize, ignoring!"), }; - codec.set_headphone_gain_db(headphone_analog_gain_db); + codec.set_headphone_gain_db(headphone_analog_gain_db, headphone_analog_gain_db); }), None => { log::error!("couldn't convert opcode"); diff --git a/services/keyboard/src/main.rs b/services/keyboard/src/main.rs index 91f08a7d0..b69a6cf1e 100644 --- a/services/keyboard/src/main.rs +++ b/services/keyboard/src/main.rs @@ -325,6 +325,7 @@ mod implementation { */ let was_idle = self.chord_active == 0; for rc in krs.keydowns.iter() { + log::info!("keydown r: {} c: {}", rc.r, rc.c); self.chord[rc.r as usize][rc.c as usize] = true; self.chord_active += 1; } @@ -349,13 +350,20 @@ mod implementation { 1 4 2 5 */ + /* + 7/5 0/1 1/2 5/7 4/8 8/6 + 2/3 2/3 + 8/0 6/4 3/9 + 8/3 5/2 3/6 + 8/2 + */ let keys: [bool; 6] = [ - self.chord[5][7], - self.chord[4][8], - self.chord[3][9], self.chord[1][2], self.chord[0][1], - self.chord[8][0], + self.chord[7][5], + self.chord[5][7], + self.chord[4][8], + self.chord[8][6], ]; let mut keycode: usize = 0; for i in 0..keys.len() { @@ -418,15 +426,15 @@ mod implementation { let space = self.chord[2][3]; if space { keystates.push(' '); } - let esc = self.chord[8][6]; + let esc = self.chord[8][0]; let bs: char = 0x8_u8.into(); // back space if esc { keystates.push(bs); } - let func = self.chord[7][5]; + let func = self.chord[3][9]; let cr: char = 0xd_u8.into(); // carriage return if func { keystates.push(cr); } - log::trace!("up {}, left {}, right {}, down, {}, center, {}, space {}, esc {}, func {}", + log::debug!("up {}, left {}, right {}, down, {}, center, {}, space {}, esc {}, func {}", up, left, right, down, center, space, esc, func); } for rc in krs.keyups.iter() { diff --git a/services/llio/Cargo.toml b/services/llio/Cargo.toml index e25dbe4a2..8b4acac67 100644 --- a/services/llio/Cargo.toml +++ b/services/llio/Cargo.toml @@ -32,5 +32,6 @@ chrono = "0.4" [features] debugprint = [] wfi_off = [] # useful for serial port debugging, forces power on so the UART characters can finish printing +tts = [] default = [] # "debugprint" #default = ["debugprint"] # , "fccagent" diff --git a/services/llio/src/main.rs b/services/llio/src/main.rs index 6a5e72c4d..d6e8cc65c 100644 --- a/services/llio/src/main.rs +++ b/services/llio/src/main.rs @@ -443,6 +443,10 @@ mod implementation { }, } } + /// this vibrates until the device sleeps + pub fn tts_sleep_indicate(&mut self) { + self.power_csr.wfo(utra::power::VIBE_VIBE, 1); + } pub fn xadc_vbus(&self) -> u16 { self.xadc_csr.rf(utra::trng::XADC_VBUS_XADC_VBUS) as u16 } @@ -597,7 +601,8 @@ mod implementation { pub fn set_usb_disable(&mut self, state: bool) { self.usb_disable = state; } - + pub fn tts_sleep_indicate(&mut self) { + } } } @@ -761,8 +766,12 @@ fn xmain() -> ! { match FromPrimitive::from_usize(msg.body.id()) { Some(Opcode::SuspendResume) => xous::msg_scalar_unpack!(msg, token, _, _, _, { llio.suspend(); + #[cfg(feature="tts")] + llio.tts_sleep_indicate(); // this happens after the suspend call because we don't want the sleep indicator to be restored on resume susres.suspend_until_resume(token).expect("couldn't execute suspend/resume"); llio.resume(); + #[cfg(feature="tts")] + llio.vibe(VibePattern::Double); lockstatus_force_update = true; // notify the status bar that yes, it does need to redraw the lock status, even if the value hasn't changed since the last read }), Some(Opcode::CrgMode) => msg_scalar_unpack!(msg, _mode, _, _, _, { diff --git a/services/status/src/main.rs b/services/status/src/main.rs index 2a65a8837..bc4ac6b40 100644 --- a/services/status/src/main.rs +++ b/services/status/src/main.rs @@ -363,6 +363,18 @@ fn xmain() -> ! { log::debug!("subscribe to wifi updates"); netmgr.wifi_state_subscribe(cb_cid, StatusOpcode::WifiStats.to_u32().unwrap()).unwrap(); let mut wifi_status: WlanStatus = WlanStatus::from_ipc(WlanStatusIpc::default()); + + #[cfg(feature="tts")] + thread::spawn({ + move || { + // indicator of boot-up for blind users + let tt = ticktimer_server::Ticktimer::new().unwrap(); + tt.sleep_ms(1500).unwrap(); + let xns = xous_names::XousNames::new().unwrap(); + let llio = llio::Llio::new(&xns); + llio.vibe(llio::VibePattern::Double).unwrap(); + } + }); log::info!("|status: starting main loop"); // don't change this -- factory test looks for this exact string loop { let msg = xous::receive_message(status_sid).unwrap();