diff --git a/ctru-rs/examples/camera-image.rs b/ctru-rs/examples/camera-image.rs index 40c5f75..851aa2a 100644 --- a/ctru-rs/examples/camera-image.rs +++ b/ctru-rs/examples/camera-image.rs @@ -61,7 +61,7 @@ fn main() { let mut buf = vec![0u8; BUF_SIZE]; println!("\nPress R to take a new picture"); - println!("\x1b[29;16HPress Start to exit"); + println!("Press Start to exit"); while apt.main_loop() { hid.scan_input(); diff --git a/ctru-rs/examples/gfx-3d-mode.rs b/ctru-rs/examples/gfx-3d-mode.rs index c5b9de8..32d7af1 100644 --- a/ctru-rs/examples/gfx-3d-mode.rs +++ b/ctru-rs/examples/gfx-3d-mode.rs @@ -10,7 +10,6 @@ use ctru::services::gfx::{Flush, Screen, Side, Swap, TopScreen3D}; // // WARNING: this example uses 3D mode in a rather unnatural way, and should // probably not be viewed for too long or at all if you are photosensitive. - const IMAGE: &[u8] = include_bytes!("assets/ferris.rgb"); static ZERO: &[u8] = &[0; IMAGE.len()]; @@ -22,8 +21,9 @@ fn main() { let apt = Apt::new().expect("Couldn't obtain APT controller"); let _console = Console::new(gfx.bottom_screen.borrow_mut()); - println!("Press A to switch sides (be sure to have set the 3D slider correctly)."); - println!("\x1b[29;16HPress Start to exit"); + println!("Press A to switch sides."); + println!("Make sure to have set the 3D slider correctly"); + println!("\x1b[29;12HPress Start to exit"); gfx.top_screen.borrow_mut().set_double_buffering(true); diff --git a/ctru-rs/examples/gfx-bitmap.rs b/ctru-rs/examples/gfx-bitmap.rs index 39634c2..8efb2be 100644 --- a/ctru-rs/examples/gfx-bitmap.rs +++ b/ctru-rs/examples/gfx-bitmap.rs @@ -64,6 +64,15 @@ fn main() { } else { IMAGE }; + + let frame_buffer = bottom_screen.raw_framebuffer(); + + // We render the newly switched image to the framebuffer. + unsafe { + frame_buffer + .ptr + .copy_from(image_bytes.as_ptr(), image_bytes.len()); + } } // Flush framebuffers. Since we're not using double buffering, diff --git a/ctru-rs/examples/network-sockets.rs b/ctru-rs/examples/network-sockets.rs index 0cc70ad..d55e29c 100644 --- a/ctru-rs/examples/network-sockets.rs +++ b/ctru-rs/examples/network-sockets.rs @@ -12,12 +12,9 @@ fn main() { ctru::use_panic_handler(); let gfx = Gfx::new().unwrap(); - let _console = Console::new(gfx.top_screen.borrow_mut()); let mut hid = Hid::new().unwrap(); let apt = Apt::new().unwrap(); - println!("\nlibctru sockets demo\n"); - // Owning a living handle to the `Soc` service is required to use network functionalities. let soc = Soc::new().unwrap(); @@ -25,8 +22,12 @@ fn main() { let server = TcpListener::bind("0.0.0.0:80").unwrap(); server.set_nonblocking(true).unwrap(); - println!("Point your browser to http://{}/\n", soc.host_address()); - println!("\x1b[29;16HPress Start to exit"); + let _bottom_console = Console::new(gfx.bottom_screen.borrow_mut()); + + println!("Point your browser at:\nhttp://{}/\n", soc.host_address()); + println!("\x1b[29;12HPress Start to exit"); + + let _top_console = Console::new(gfx.top_screen.borrow_mut()); while apt.main_loop() { hid.scan_input(); @@ -34,6 +35,7 @@ fn main() { break; }; + // Receive any incoming connections. match server.accept() { Ok((mut stream, socket_addr)) => { println!("Got connection from {socket_addr}"); diff --git a/ctru-rs/examples/software-keyboard.rs b/ctru-rs/examples/software-keyboard.rs index 269ccf0..e754781 100644 --- a/ctru-rs/examples/software-keyboard.rs +++ b/ctru-rs/examples/software-keyboard.rs @@ -13,8 +13,7 @@ fn main() { let gfx = Gfx::new().unwrap(); let _console = Console::new(gfx.top_screen.borrow_mut()); - println!("Press A to enter some text."); - println!("\x1b[29;16HPress Start to exit"); + println!("Press A to enter some text or press Start to exit."); while apt.main_loop() { hid.scan_input(); @@ -23,7 +22,7 @@ fn main() { break; } - // If the user request to write some input. + // Check if the user request to write some input. if hid.keys_down().contains(KeyPad::A) { // Prepares a software keyboard with two buttons: One to cancel input and one // to accept it. You can also use `SoftwareKeyboard::new()` to launch the keyboard in different diff --git a/ctru-rs/examples/time-rtc.rs b/ctru-rs/examples/time-rtc.rs index e8c3a95..ca4709a 100644 --- a/ctru-rs/examples/time-rtc.rs +++ b/ctru-rs/examples/time-rtc.rs @@ -27,8 +27,17 @@ fn main() { // since the 3DS doesn't seem to support timezones. let cur_time = time::OffsetDateTime::now_utc(); - // Display the retrieved information. - println!("\x1b[1;1H{cur_time}"); + let hours = cur_time.hour(); + let minutes = cur_time.minute(); + let seconds = cur_time.second(); + + let weekday = cur_time.weekday().to_string(); + let month = cur_time.month().to_string(); + let day = cur_time.day(); + let year = cur_time.year(); + + println!("\x1b[1;1H{hours:0>2}:{minutes:0>2}:{seconds:0>2}"); + println!("{weekday} {month} {day} {year}"); gfx.wait_for_vblank(); } diff --git a/ctru-rs/examples/title-info.rs b/ctru-rs/examples/title-info.rs index 9cb4db8..d2898ac 100644 --- a/ctru-rs/examples/title-info.rs +++ b/ctru-rs/examples/title-info.rs @@ -88,7 +88,8 @@ fn main() { // Clear the bottom screen and write the properties of selected title to it. bottom_screen.select(); - println!("\x1b[2J"); + bottom_screen.clear(); + println!("Press Start to exit"); // Move cursor to top left. println!("\x1b[1;1"); @@ -97,7 +98,6 @@ fn main() { println!("Version: 0x{:x}", selected_title.version()); println!("Product code: \"{}\"", selected_title.product_code()); - println!("\x1b[29;16HPress Start to exit"); if use_nand { println!("Press SELECT to choose SD Card"); println!("Current medium: NAND"); diff --git a/ctru-rs/examples/touch-screen.rs b/ctru-rs/examples/touch-screen.rs index a785055..135de2b 100644 --- a/ctru-rs/examples/touch-screen.rs +++ b/ctru-rs/examples/touch-screen.rs @@ -32,6 +32,9 @@ fn main() { // We only want to print the position when it's different // from what it was on the previous frame. if touch != old_touch { + // Move the cursor back to the top of the screen and print the coordinates. + print!("\x1b[1;1HTouch Screen position: {:#?}", touch); + // Special case for when the user lifts the stylus/finger from the screen. // This is done to avoid some screen tearing. if touch == (0, 0) { @@ -40,9 +43,6 @@ fn main() { // Print again because we just cleared the screen. println!("\x1b[29;16HPress Start to exit"); } - - // Move the cursor back to the top of the screen and print the coordinates. - print!("\x1b[1;1HTouch Screen position: {:#?}", touch); } // Save our current touch position for the next frame. diff --git a/ctru-rs/src/console.rs b/ctru-rs/src/console.rs index 8eb3ebc..32fbe10 100644 --- a/ctru-rs/src/console.rs +++ b/ctru-rs/src/console.rs @@ -21,7 +21,9 @@ static mut EMPTY_CONSOLE: PrintConsole = unsafe { const_zero::const_zero!(PrintC /// /// # Notes /// -/// The console will take full possession of the screen handed to it as long as it stays alive. It also supports ANSI codes. +/// The [`Console`] will take full possession of the screen handed to it as long as it stays alive. It also supports ANSI codes. +/// The [`Console`]'s window will have a size of 40x30 on the bottom screen, 50x30 on the normal top screen and +/// 100x30 on the top screen when wide mode is enabled. /// /// # Alternatives ///