mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
31 lines
908 B
Rust
31 lines
908 B
Rust
use crate::{ShellCmdApi, CommonEnv};
|
|
use xous_ipc::String;
|
|
|
|
#[derive(Debug)]
|
|
pub struct Accel {
|
|
}
|
|
|
|
impl<'a> ShellCmdApi<'a> for Accel {
|
|
cmd_api!(accel); // inserts boilerplate for command API
|
|
|
|
fn process(&mut self, args: String::<1024>, env: &mut CommonEnv) -> Result<Option<String::<1024>>, xous::Error> {
|
|
use core::fmt::Write;
|
|
let mut ret = String::<1024>::new();
|
|
let helpstring = "accel has no options";
|
|
|
|
let mut tokens = args.as_str().unwrap().split(' ');
|
|
|
|
if let Some(sub_cmd) = tokens.next() {
|
|
match sub_cmd {
|
|
_ => {
|
|
let (x, y, z, id) = env.com.gyro_read_blocking().unwrap();
|
|
write!(ret, "x: {} y: {} z: {}, id: 0x{:x}", x, y, z, id).unwrap();
|
|
}
|
|
}
|
|
|
|
} else {
|
|
write!(ret, "{}", helpstring).unwrap();
|
|
}
|
|
Ok(Some(ret))
|
|
}
|
|
}
|