mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
Merge branch 'main' of github.com:betrusted-io/xous-core
This commit is contained in:
commit
7ff40a3e42
6 changed files with 60 additions and 14 deletions
|
|
@ -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
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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, _, _, _, {
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in a new issue