add code to render sleep screen bitmap

This commit is contained in:
bunnie 2020-10-12 03:23:15 +08:00
parent e414c87414
commit 49db984000
2 changed files with 59 additions and 38 deletions

View file

@ -25,7 +25,7 @@ impl XousDisplay {
((FB_WIDTH_WORDS * FB_LINES * 4) + 4096) & !4095, ((FB_WIDTH_WORDS * FB_LINES * 4) + 4096) & !4095,
xous::MemoryFlags::R | xous::MemoryFlags::W, xous::MemoryFlags::R | xous::MemoryFlags::W,
) )
.expect("couldn't map control port"); .expect("couldn't map frame buffer");
let control = xous::syscall::map_memory( let control = xous::syscall::map_memory(
xous::MemoryAddress::new(utra::HW_MEMLCD_BASE), xous::MemoryAddress::new(utra::HW_MEMLCD_BASE),
@ -49,6 +49,19 @@ impl XousDisplay {
pub fn update(&mut self) {} pub fn update(&mut self) {}
pub fn force_bitmap(&mut self, bmp: [u32; FB_SIZE]) {
let framebuffer = self.fb.as_mut_ptr() as *mut u32;
for words in 0..FB_SIZE {
unsafe {
framebuffer.add(words).write_volatile(bmp[words]);
}
}
self.update_all();
while self.busy() {}
}
/// Beneath this line are pure-HAL layer, and should not be user-visible /// Beneath this line are pure-HAL layer, and should not be user-visible
/// ///

View file

@ -17,7 +17,14 @@ use embedded_graphics::{
use core::convert::TryFrom; use core::convert::TryFrom;
mod logo;
const USE_BOOT_LOGO: bool = true;
fn draw_boot_logo(display: &mut XousDisplay) { fn draw_boot_logo(display: &mut XousDisplay) {
if USE_BOOT_LOGO {
display.force_bitmap(logo::LOGO_MAP);
} else {
// Create styles used by the drawing operations. // Create styles used by the drawing operations.
let thin_stroke = PrimitiveStyle::with_stroke(BinaryColor::On, 1); let thin_stroke = PrimitiveStyle::with_stroke(BinaryColor::On, 1);
let thick_stroke = PrimitiveStyle::with_stroke(BinaryColor::On, 3); let thick_stroke = PrimitiveStyle::with_stroke(BinaryColor::On, 3);
@ -63,6 +70,7 @@ fn draw_boot_logo(display: &mut XousDisplay) {
.draw(display) .draw(display)
.unwrap(); .unwrap();
} }
}
#[xous::xous_main] #[xous::xous_main]
fn xmain() -> ! { fn xmain() -> ! {