mirror of
https://github.com/LegitCamper/picocalc-os-rs.git
synced 2025-12-27 07:45:28 +00:00
clippy
This commit is contained in:
@@ -83,7 +83,7 @@ pub fn main() {
|
||||
.align_to(&display.bounding_box(), horizontal::Left, vertical::Center);
|
||||
|
||||
let result = if let Ok(result) = evaluate(&input[input_min..]) {
|
||||
&format!(" = {}", result)
|
||||
&format!(" = {result}")
|
||||
} else {
|
||||
" = Error"
|
||||
};
|
||||
|
||||
@@ -51,9 +51,9 @@ pub fn main() {
|
||||
|
||||
println!("file: {}", file);
|
||||
if file.extension().unwrap_or("") == "bmp" || file.extension().unwrap_or("") == "BMP" {
|
||||
let file_path = format!("/images/{}", file);
|
||||
let file_path = format!("/images/{file}");
|
||||
|
||||
let read = read_file(&file_path, 0, &mut &mut bmp_buf[..]);
|
||||
let read = read_file(&file_path, 0, &mut bmp_buf[..]);
|
||||
if read > 0 {
|
||||
let bmp = Bmp::from_slice(&bmp_buf).expect("failed to parse bmp");
|
||||
|
||||
@@ -74,7 +74,7 @@ pub fn main() {
|
||||
|
||||
let text_style = MonoTextStyle::new(&FONT_6X10, Rgb565::WHITE);
|
||||
let text_y = y + bmp_h + 2; // 2px gap under image
|
||||
Text::new(&file.base(), Point::new(cell_x + 2, text_y), text_style)
|
||||
Text::new(file.base(), Point::new(cell_x + 2, text_y), text_style)
|
||||
.draw(&mut display)
|
||||
.unwrap();
|
||||
|
||||
@@ -85,11 +85,8 @@ pub fn main() {
|
||||
|
||||
loop {
|
||||
let event = get_key();
|
||||
if event.state != KeyState::Idle {
|
||||
match event.key {
|
||||
KeyCode::Esc => return,
|
||||
_ => (),
|
||||
}
|
||||
};
|
||||
if event.state != KeyState::Idle && event.key == KeyCode::Esc {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,16 +6,16 @@ use alloc::{format, vec, vec::Vec};
|
||||
use core::panic::PanicInfo;
|
||||
use embedded_graphics::{
|
||||
image::ImageDrawable,
|
||||
mono_font::{ascii::FONT_6X10, MonoTextStyle},
|
||||
mono_font::{MonoTextStyle, ascii::FONT_6X10},
|
||||
pixelcolor::Rgb565,
|
||||
prelude::{Point, RgbColor},
|
||||
transform::Transform,
|
||||
};
|
||||
use selection_ui::{draw_text_center, SelectionUi, SelectionUiError};
|
||||
use selection_ui::{SelectionUi, SelectionUiError, draw_text_center};
|
||||
use tinygif::Gif;
|
||||
use userlib::{
|
||||
display::{Display, SCREEN_HEIGHT, SCREEN_WIDTH},
|
||||
fs::{file_len, list_dir, read_file, Entries},
|
||||
fs::{Entries, file_len, list_dir, read_file},
|
||||
get_key, get_ms,
|
||||
keyboard::{KeyCode, KeyState},
|
||||
println, sleep,
|
||||
@@ -44,7 +44,7 @@ pub fn main() {
|
||||
let mut gifs = files.iter().map(|e| e.full_name()).collect::<Vec<&str>>();
|
||||
gifs.sort();
|
||||
|
||||
let mut selection_ui = SelectionUi::new(&mut gifs);
|
||||
let mut selection_ui = SelectionUi::new(&gifs);
|
||||
let selection = match selection_ui.run_selection_ui(&mut display) {
|
||||
Ok(maybe_sel) => maybe_sel,
|
||||
Err(e) => match e {
|
||||
@@ -87,14 +87,9 @@ pub fn main() {
|
||||
|
||||
if frame_num % 5 == 0 {
|
||||
let event = get_key();
|
||||
if event.state != KeyState::Idle {
|
||||
match event.key {
|
||||
KeyCode::Esc => {
|
||||
drop(buf);
|
||||
return;
|
||||
}
|
||||
_ => (),
|
||||
};
|
||||
if event.state != KeyState::Idle && event.key == KeyCode::Esc {
|
||||
drop(buf);
|
||||
return;
|
||||
};
|
||||
}
|
||||
sleep(((frame.delay_centis as u64) * 10).saturating_sub(start));
|
||||
|
||||
@@ -4,18 +4,18 @@
|
||||
extern crate alloc;
|
||||
use alloc::{string::String, vec::Vec};
|
||||
use core::panic::PanicInfo;
|
||||
use embedded_audio::{wav::Wav, AudioFile, PlatformFile, PlatformFileError};
|
||||
use embedded_audio::{AudioFile, PlatformFile, PlatformFileError, wav::Wav};
|
||||
use embedded_graphics::{
|
||||
mono_font::{ascii::FONT_6X10, MonoTextStyle},
|
||||
mono_font::{MonoTextStyle, ascii::FONT_6X10},
|
||||
pixelcolor::Rgb565,
|
||||
prelude::RgbColor,
|
||||
};
|
||||
use selection_ui::{draw_text_center, SelectionUi, SelectionUiError};
|
||||
use selection_ui::{SelectionUi, SelectionUiError, draw_text_center};
|
||||
use userlib::{
|
||||
audio::{audio_buffer_ready, send_audio_buffer, AUDIO_BUFFER_LEN},
|
||||
audio::{AUDIO_BUFFER_LEN, audio_buffer_ready, send_audio_buffer},
|
||||
display::Display,
|
||||
format,
|
||||
fs::{file_len, list_dir, read_file, Entries},
|
||||
fs::{Entries, file_len, list_dir, read_file},
|
||||
get_key,
|
||||
keyboard::{KeyCode, KeyState},
|
||||
println,
|
||||
@@ -45,7 +45,7 @@ pub fn main() {
|
||||
let mut wavs = files.iter().map(|e| e.full_name()).collect::<Vec<&str>>();
|
||||
wavs.sort();
|
||||
|
||||
let mut selection_ui = SelectionUi::new(&mut wavs);
|
||||
let mut selection_ui = SelectionUi::new(&wavs);
|
||||
let selection = match selection_ui.run_selection_ui(&mut display) {
|
||||
Ok(maybe_sel) => maybe_sel,
|
||||
Err(e) => match e {
|
||||
@@ -72,7 +72,7 @@ pub fn main() {
|
||||
.expect("Display Error");
|
||||
|
||||
let file_name = format!("/music/{}", wavs[selection.unwrap()]);
|
||||
let file = File::new(String::from(file_name));
|
||||
let file = File::new(file_name);
|
||||
let mut wav = Wav::new(file).unwrap();
|
||||
println!("sample rate: {}", wav.sample_rate());
|
||||
println!("channels: {:?}", wav.channels() as u8);
|
||||
@@ -90,11 +90,8 @@ pub fn main() {
|
||||
}
|
||||
|
||||
let event = get_key();
|
||||
if event.state == KeyState::Released {
|
||||
match event.key {
|
||||
KeyCode::Esc => return,
|
||||
_ => (),
|
||||
}
|
||||
if event.state == KeyState::Released && event.key == KeyCode::Esc {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user