This commit is contained in:
2025-11-10 11:35:21 -07:00
parent f0d9f41fea
commit d9886fdea1
10 changed files with 256 additions and 276 deletions

View File

@@ -39,7 +39,7 @@ pub extern "Rust" fn _start() {
pub fn main() {
print!("Starting Calculator app");
let mut display = Display;
let mut display = Display::take().unwrap();
let mut input = vec!['e', 'x', 'p', 'r', ':', ' '];
let input_min = input.len();

View File

@@ -32,7 +32,7 @@ pub extern "Rust" fn _start() {
pub fn main() {
print!("Starting Gallery app");
let mut bmp_buf = vec![0_u8; 100_000];
let mut display = Display;
let mut display = Display::take().unwrap();
let grid_cols = 3;
let grid_rows = 3;

View File

@@ -12,9 +12,13 @@ use abi::{
use alloc::{format, vec, vec::Vec};
use core::panic::PanicInfo;
use embedded_graphics::{
image::ImageDrawable, pixelcolor::Rgb565, prelude::Point, transform::Transform,
image::ImageDrawable,
mono_font::{MonoTextStyle, ascii::FONT_6X10},
pixelcolor::Rgb565,
prelude::{Point, RgbColor},
transform::Transform,
};
use selection_ui::SelectionUi;
use selection_ui::{SelectionUi, SelectionUiError, draw_text_center};
use tinygif::Gif;
#[panic_handler]
@@ -30,7 +34,7 @@ pub extern "Rust" fn _start() {
pub fn main() {
print!("Starting Gif app");
let mut display = Display;
let mut display = Display::take().unwrap();
let mut entries = Entries::new();
list_dir("/gifs", &mut entries);
@@ -39,13 +43,26 @@ pub fn main() {
files.retain(|e| e.extension().unwrap_or("") == "gif");
let gifs = &files.iter().map(|e| e.full_name()).collect::<Vec<&str>>();
let mut selection_ui = SelectionUi::new(&gifs, "No Gif files found in /gifs");
let selection = selection_ui
.run_selection_ui(&mut display)
.expect("failed to draw")
.expect("Failed to get user selection");
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 {
SelectionUiError::SelectionListEmpty => {
draw_text_center(
&mut display,
"No Gifs were found in /gifs",
MonoTextStyle::new(&FONT_6X10, Rgb565::RED),
)
.expect("Display Error");
None
}
SelectionUiError::DisplayError(_) => panic!("Display Error"),
},
};
let file_name = format!("/gifs/{}", gifs[selection]);
assert!(selection.is_some());
let file_name = format!("/gifs/{}", gifs[selection.unwrap()]);
let size = file_len(&file_name);
let mut buf = vec![0_u8; size];
let read = read_file(&file_name, 0, &mut buf);

View File

@@ -28,7 +28,7 @@ const CELL_SIZE: usize = 8;
pub fn main() {
print!("Starting Snake app");
let mut display = Display;
let mut display = Display::take().unwrap();
let mut game = SnakeGame::<100, Rgb565, Rng>::new(
SCREEN_WIDTH as u16,