mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-21 09:14:34 +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,
|
((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
|
||||||
|
|
||||||
///
|
///
|
||||||
|
|
|
||||||
|
|
@ -17,51 +17,59 @@ 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) {
|
||||||
// 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 yoffset = 10;
|
||||||
let bottom_right = Point::zero() + display.size() - Point::new(1, 1);
|
|
||||||
Rectangle::new(Point::zero(), bottom_right)
|
// Draw a 3px wide outline around the display.
|
||||||
.into_styled(thick_stroke)
|
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)
|
.draw(display)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
// Draw a triangle.
|
// Draw a filled square
|
||||||
Triangle::new(
|
Rectangle::new(Point::new(52, yoffset), Point::new(52 + 16, 16 + yoffset))
|
||||||
Point::new(16, 16 + yoffset),
|
.into_styled(fill)
|
||||||
Point::new(16 + 16, 16 + yoffset),
|
.draw(display)
|
||||||
Point::new(16 + 8, yoffset),
|
.unwrap();
|
||||||
)
|
|
||||||
.into_styled(thin_stroke)
|
|
||||||
.draw(display)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
// Draw a filled square
|
// Draw a circle with a 3px wide stroke.
|
||||||
Rectangle::new(Point::new(52, yoffset), Point::new(52 + 16, 16 + yoffset))
|
Circle::new(Point::new(96, yoffset + 8), 8)
|
||||||
.into_styled(fill)
|
.into_styled(thick_stroke)
|
||||||
.draw(display)
|
.draw(display)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
// Draw a circle with a 3px wide stroke.
|
// Draw centered text.
|
||||||
Circle::new(Point::new(96, yoffset + 8), 8)
|
let text = "embedded-graphics";
|
||||||
.into_styled(thick_stroke)
|
let width = text.len() as i32 * 6;
|
||||||
.draw(display)
|
Text::new(text, Point::new(64 - width / 2, 40))
|
||||||
.unwrap();
|
.into_styled(text_style)
|
||||||
|
.draw(display)
|
||||||
// Draw centered text.
|
.unwrap();
|
||||||
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]
|
#[xous::xous_main]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue