mirror of
https://github.com/LegitCamper/picocalc-os-rs.git
synced 2025-12-28 00:05:28 +00:00
Merge branch 'main' into nes
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
extern crate alloc;
|
||||
use abi::{
|
||||
display::Display,
|
||||
display::{Display, SCREEN_HEIGHT, SCREEN_WIDTH},
|
||||
fs::{Entries, file_len, list_dir, read_file},
|
||||
get_key, get_ms,
|
||||
keyboard::{KeyCode, KeyState},
|
||||
@@ -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);
|
||||
@@ -53,17 +70,18 @@ pub fn main() {
|
||||
assert!(read == size);
|
||||
|
||||
let gif = Gif::<Rgb565>::from_slice(&buf).expect("Failed to parse gif");
|
||||
let height = gif.height();
|
||||
|
||||
let translation = Point::new(
|
||||
(SCREEN_WIDTH as i32 - gif.width() as i32) / 2,
|
||||
(SCREEN_HEIGHT as i32 - gif.height() as i32) / 2,
|
||||
);
|
||||
|
||||
let mut frame_num = 0;
|
||||
loop {
|
||||
for mut frame in gif.frames() {
|
||||
let start = get_ms();
|
||||
|
||||
frame
|
||||
.translate_mut(Point::new(0, (320 - height as i32) / 2))
|
||||
.draw(&mut display)
|
||||
.unwrap();
|
||||
frame.translate_mut(translation).draw(&mut display).unwrap();
|
||||
frame_num += 1;
|
||||
|
||||
if frame_num % 5 == 0 {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user