mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
add code to render sleep screen bitmap
This commit is contained in:
parent
e414c87414
commit
49db984000
2 changed files with 59 additions and 38 deletions
|
|
@ -25,7 +25,7 @@ impl XousDisplay {
|
|||
((FB_WIDTH_WORDS * FB_LINES * 4) + 4096) & !4095,
|
||||
xous::MemoryFlags::R | xous::MemoryFlags::W,
|
||||
)
|
||||
.expect("couldn't map control port");
|
||||
.expect("couldn't map frame buffer");
|
||||
|
||||
let control = xous::syscall::map_memory(
|
||||
xous::MemoryAddress::new(utra::HW_MEMLCD_BASE),
|
||||
|
|
@ -49,6 +49,19 @@ impl XousDisplay {
|
|||
|
||||
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
|
||||
|
||||
///
|
||||
|
|
|
|||
|
|
@ -17,51 +17,59 @@ use embedded_graphics::{
|
|||
|
||||
use core::convert::TryFrom;
|
||||
|
||||
mod logo;
|
||||
const USE_BOOT_LOGO: bool = true;
|
||||
|
||||
fn draw_boot_logo(display: &mut XousDisplay) {
|
||||
// Create styles used by the drawing operations.
|
||||
let thin_stroke = PrimitiveStyle::with_stroke(BinaryColor::On, 1);
|
||||
let thick_stroke = PrimitiveStyle::with_stroke(BinaryColor::On, 3);
|
||||
let fill = PrimitiveStyle::with_fill(BinaryColor::On);
|
||||
let text_style = TextStyle::new(Font6x8, BinaryColor::On);
|
||||
|
||||
let yoffset = 10;
|
||||
if USE_BOOT_LOGO {
|
||||
display.force_bitmap(logo::LOGO_MAP);
|
||||
} else {
|
||||
// Create styles used by the drawing operations.
|
||||
let thin_stroke = PrimitiveStyle::with_stroke(BinaryColor::On, 1);
|
||||
let thick_stroke = PrimitiveStyle::with_stroke(BinaryColor::On, 3);
|
||||
let fill = PrimitiveStyle::with_fill(BinaryColor::On);
|
||||
let text_style = TextStyle::new(Font6x8, BinaryColor::On);
|
||||
|
||||
// Draw a 3px wide outline around the display.
|
||||
let bottom_right = Point::zero() + display.size() - Point::new(1, 1);
|
||||
Rectangle::new(Point::zero(), bottom_right)
|
||||
.into_styled(thick_stroke)
|
||||
let yoffset = 10;
|
||||
|
||||
// Draw a 3px wide outline around the display.
|
||||
let bottom_right = Point::zero() + display.size() - Point::new(1, 1);
|
||||
Rectangle::new(Point::zero(), bottom_right)
|
||||
.into_styled(thick_stroke)
|
||||
.draw(display)
|
||||
.unwrap();
|
||||
|
||||
// Draw a triangle.
|
||||
Triangle::new(
|
||||
Point::new(16, 16 + yoffset),
|
||||
Point::new(16 + 16, 16 + yoffset),
|
||||
Point::new(16 + 8, yoffset),
|
||||
)
|
||||
.into_styled(thin_stroke)
|
||||
.draw(display)
|
||||
.unwrap();
|
||||
|
||||
// Draw a triangle.
|
||||
Triangle::new(
|
||||
Point::new(16, 16 + yoffset),
|
||||
Point::new(16 + 16, 16 + yoffset),
|
||||
Point::new(16 + 8, yoffset),
|
||||
)
|
||||
.into_styled(thin_stroke)
|
||||
.draw(display)
|
||||
.unwrap();
|
||||
// Draw a filled square
|
||||
Rectangle::new(Point::new(52, yoffset), Point::new(52 + 16, 16 + yoffset))
|
||||
.into_styled(fill)
|
||||
.draw(display)
|
||||
.unwrap();
|
||||
|
||||
// Draw a filled square
|
||||
Rectangle::new(Point::new(52, yoffset), Point::new(52 + 16, 16 + yoffset))
|
||||
.into_styled(fill)
|
||||
.draw(display)
|
||||
.unwrap();
|
||||
// Draw a circle with a 3px wide stroke.
|
||||
Circle::new(Point::new(96, yoffset + 8), 8)
|
||||
.into_styled(thick_stroke)
|
||||
.draw(display)
|
||||
.unwrap();
|
||||
|
||||
// Draw a circle with a 3px wide stroke.
|
||||
Circle::new(Point::new(96, yoffset + 8), 8)
|
||||
.into_styled(thick_stroke)
|
||||
.draw(display)
|
||||
.unwrap();
|
||||
|
||||
// Draw centered text.
|
||||
let text = "embedded-graphics";
|
||||
let width = text.len() as i32 * 6;
|
||||
Text::new(text, Point::new(64 - width / 2, 40))
|
||||
.into_styled(text_style)
|
||||
.draw(display)
|
||||
.unwrap();
|
||||
// Draw centered text.
|
||||
let text = "embedded-graphics";
|
||||
let width = text.len() as i32 * 6;
|
||||
Text::new(text, Point::new(64 - width / 2, 40))
|
||||
.into_styled(text_style)
|
||||
.draw(display)
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
#[xous::xous_main]
|
||||
|
|
|
|||
Loading…
Reference in a new issue