Browse Source

Fixed small issues and an older bug

pull/94/head
Andrea Ciliberti 2 years ago
parent
commit
6a937a58e3
  1. 14
      ctru-rs/examples/camera-image.rs
  2. 2
      ctru-rs/src/services/cam.rs

14
ctru-rs/examples/camera-image.rs

@ -9,7 +9,7 @@ const WIDTH: usize = 400; @@ -9,7 +9,7 @@ const WIDTH: usize = 400;
const HEIGHT: usize = 240;
// The screen size is the width and height multiplied by 2 (RGB565 store pixels in 2 bytes)
const BUF_SIZE: usize = WIDTH * HEIGHT * 2;
// const BUF_SIZE: usize = WIDTH * HEIGHT * 2;
const WAIT_TIMEOUT: Duration = Duration::from_micros(300);
@ -55,9 +55,8 @@ fn main() { @@ -55,9 +55,8 @@ fn main() {
.set_trimming(false)
.expect("Failed to disable trimming");
}
let mut buf = vec![128u8; BUF_SIZE / 2];
let mut lol = vec![255u8; BUF_SIZE / 2];
buf.append(&mut lol);
let mut buf;
println!("\nPress R to take a new picture");
println!("Press Start to exit to Homebrew Launcher");
@ -72,8 +71,6 @@ fn main() { @@ -72,8 +71,6 @@ fn main() {
if keys_down.contains(KeyPad::KEY_R) {
println!("Capturing new image");
cam.play_shutter_sound(CamShutterSoundType::NORMAL)
.expect("Failed to play shutter sound");
let camera = &mut cam.outer_right_cam;
@ -84,7 +81,9 @@ fn main() { @@ -84,7 +81,9 @@ fn main() {
WAIT_TIMEOUT,
)
.expect("Failed to take picture");
}
cam.play_shutter_sound(CamShutterSoundType::NORMAL)
.expect("Failed to play shutter sound");
let img = rotate_image(&buf, WIDTH, HEIGHT);
@ -100,6 +99,7 @@ fn main() { @@ -100,6 +99,7 @@ fn main() {
gfx.swap_buffers();
gfx.wait_for_vblank();
}
}
}
// The 3DS' screens are 2 vertical LCD panels rotated by 90 degrees.

2
ctru-rs/src/services/cam.rs

@ -731,7 +731,7 @@ pub trait Camera { @@ -731,7 +731,7 @@ pub trait Camera {
Ok::<u32, i32>(buf_size)
}?;
let screen_size = u32::from(width) * u32::from(width) * 2;
let screen_size = u32::from(width) * u32::from(height) * 2;
let mut buf = vec![0u8; usize::try_from(screen_size).unwrap()];

Loading…
Cancel
Save