now passing the linter

This commit is contained in:
Sam Chin 2025-06-09 16:27:34 +08:00
parent e5cdeaf2ca
commit c291b6a11f
4 changed files with 58 additions and 54 deletions

View file

@ -142,8 +142,8 @@ impl CmdEnv {
let mut echo_cmd = Echo {}; // this command has no persistent storage, so we can "create" it every time we call dispatch (but it's a zero-cost absraction so this doesn't actually create any instructions)
let mut ver_cmd = Ver {};
let mut console_cmd = Test {};
let mut i2cdetect_cmd = I2cDetect{};
let mut cute_cmd = Cute{};
let mut i2cdetect_cmd = I2cDetect {};
let mut cute_cmd = Cute {};
let commands: &mut [&mut dyn ShellCmdApi] = &mut [
///// 4. add your command to this array, so that it can be looked up and dispatched

View file

@ -9,19 +9,19 @@ impl<'a> ShellCmdApi<'a> for Cute {
cmd_api!(cute);
fn process(&mut self, args: String, _env: &mut CommonEnv) -> Result<Option<String>, xous::Error> {
use core::fmt::Write;
let mut ret = String::new();
let helpstring = "Usage:
use core::fmt::Write;
let mut ret = String::new();
let helpstring = "Usage:
cute cat - prints cat ascii art
cute bread - prints bread ascii art
cute breadcat - prints breadcat ascii art";
let mut tokens = args.split_whitespace();
let mut tokens = args.split_whitespace();
if let Some(sub_cmd) = tokens.next() {
match sub_cmd {
"cat" => {
let cat_art = r#"
if let Some(sub_cmd) = tokens.next() {
match sub_cmd {
"cat" => {
let cat_art = r#"
⠀⠀⠀⠀⢀⠠⠤⠀⢀⣿⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠐⠀⠐⠀⠀⢀⣾⣿⡇⠀⠀⠀⠀⠀⢀⣼⡇⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣸⣿⣿⣿⠀⠀⠀⠀⣴⣿⣿⠇⠀⠀⠀⠀
@ -34,10 +34,10 @@ impl<'a> ShellCmdApi<'a> for Cute {
⠨⠠⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠑⠀⠀⠀⠀⠀⠀
⠁⠃⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
"#;
write!(ret, "{}", cat_art).unwrap();
}
"bread" => {
let bread_art = r#"
write!(ret, "{}", cat_art).unwrap();
}
"bread" => {
let bread_art = r#"
⠀⠀⠀⠀⣀⣠⣤⣤⣤⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⣴⣿⣿⠿⠛⣉⣁⣠⣤⣤⣤⣬⣀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⢸⣿⣿⣿⣿⣿⣿⡿⠛⣉⣁⣠⣤⣤⣤⣬⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
@ -54,10 +54,10 @@ impl<'a> ShellCmdApi<'a> for Cute {
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠛⠛⠛⠛⠻⠶⣶⣤⣈⣉⣉⣉⣁⣤⣴⠾⠛⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠙⠛⠉⠉⠉⠀⠀⠀⠀
"#;
write!(ret, "{}", bread_art).unwrap();
}
"breadcat" => {
let breadcat_art = r#"
write!(ret, "{}", bread_art).unwrap();
}
"breadcat" => {
let breadcat_art = r#"
⠀⠀⠀⠰⣦⣤⣤⣀⠀⠀⡀⠀⠀⠀⠀⣀⣀⠀⠠⢤⣶⣶⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⢿⣿⢋⣵⣾⣿⣿⡿⣥⣮⢻⣿⣿⣿⣿⣶⣌⢿⣿⢰⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣦⣤⡀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠘⢡⣿⣿⣿⣿⣿⣷⡹⠟⣵⣿⣿⣿⣿⣿⣿⣦⢃⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀
@ -75,18 +75,16 @@ impl<'a> ShellCmdApi<'a> for Cute {
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢿⣿⣿⣿⣿⣿⠿⠟⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠉⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
"#;
write!(ret, "{}", breadcat_art).unwrap();
}
_ => {
write!(ret, "{}\n", helpstring).unwrap();
write!(ret, "{}", breadcat_art).unwrap();
}
_ => {
write!(ret, "{}\n", helpstring).unwrap();
}
}
} else {
write!(ret, "{}\n", helpstring).unwrap();
}
} else {
write!(ret, "{}\n", helpstring).unwrap();
Ok(Some(ret))
}
Ok(Some(ret))
}
}

View file

@ -1,7 +1,7 @@
use String;
use cram_hal_service::I2c;
use cramium_api::I2cApi;
use cramium_api::I2cResult;
use cram_hal_service::I2c;
use crate::{CommonEnv, ShellCmdApi};
@ -23,37 +23,46 @@ fn probe_address(i2c: &mut I2c, addr: u8) -> ProbeStatus {
}
}
pub struct I2cDetect {}
impl<'a> ShellCmdApi<'a> for I2cDetect {
cmd_api!(i2cdetect);
fn process(&mut self, args: String, _env: &mut CommonEnv) -> Result<Option<String>, xous::Error> {
use core::fmt::Write;
let mut ret = String::new();
let helpstring = "Usage:
use core::fmt::Write;
let mut ret = String::new();
let helpstring = "Usage:
i2cdetect probe <hex> - probes a single I2C address (e.g. 34)
i2cdetect scan - reads
i2cdetect bmp180_temp - reads raw temperature from BMP180";
let mut tokens = args.split_whitespace();
let mut tokens = args.split_whitespace();
if let Some(sub_cmd) = tokens.next() {
match sub_cmd {
"probe" => {
if let Some(sub_cmd) = tokens.next() {
match sub_cmd {
"probe" => {
if let Some(addr_str) = tokens.next() {
match u8::from_str_radix(addr_str, 16) {
Ok(addr) => {
let mut i2c = I2c::new();
let status = probe_address(&mut i2c, addr);
match status {
ProbeStatus::Ack => write!(ret, "Device found at address {:02X}\n", addr).unwrap(),
ProbeStatus::Nack => write!(ret, "Device at address {:02X} responded with NACK\n", addr).unwrap(),
ProbeStatus::Ack => {
write!(ret, "Device found at address {:02X}\n", addr).unwrap()
}
ProbeStatus::Nack => {
write!(ret, "Device at address {:02X} responded with NACK\n", addr)
.unwrap()
}
};
}
Err(_) => {
write!(ret, "Invalid hex address '{}'. Example: i2cdetect probe 3C\n", addr_str).unwrap();
write!(
ret,
"Invalid hex address '{}'. Example: i2cdetect probe 3C\n",
addr_str
)
.unwrap();
}
}
} else {
@ -82,18 +91,14 @@ impl<'a> ShellCmdApi<'a> for I2cDetect {
}
}
_ => {
write!(ret, "{}\n", helpstring).unwrap();
_ => {
write!(ret, "{}\n", helpstring).unwrap();
}
}
} else {
write!(ret, "{}\n", helpstring).unwrap();
}
} else {
write!(ret, "{}\n", helpstring).unwrap();
Ok(Some(ret))
}
Ok(Some(ret))
}
}
}

View file

@ -612,7 +612,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// - [planned] vault application
let bao_rram_pkgs =
["xous-ticktimer", "xous-log", "xous-names", "keystore" /* "usb-cramium" */].to_vec(); /* "usb-cramium" */
let bao_swap_pkgs = ["cram-hal-service", "bao-console", /*"modals", "pddb", "bao-video"*/].to_vec(); /* "bao-video" */
let bao_swap_pkgs =
["cram-hal-service", "bao-console" /* "modals", "pddb", "bao-video" */].to_vec(); /* "bao-video" */
if !builder.is_swap_set() {
builder.set_swap(0, 8 * 1024 * 1024);
}