Display with formatting now works

This commit is contained in:
Berkus Decker 2019-03-10 16:19:58 +02:00
parent e324795ab9
commit 0b86eeaf90
2 changed files with 7 additions and 11 deletions

View File

@ -217,16 +217,16 @@ fn check_display_init() {
display.rect(10, 10, 250, 250, Color::rgb(32, 96, 64));
display.draw_text(50, 50, "Hello there!", Color::rgb(128, 192, 255));
// let mut buf = [0u8; 64];
let mut buf = [0u8; 64];
// Crashes if uncommenting next line: vvv
// let s = write_to::show(&mut buf, format_args!("Display width {}", display.width));
let s = write_to::show(&mut buf, format_args!("Display width {}", display.width));
// So, some rust runtime things are breaking it, why?
// if s.is_err() {
// display.draw_text(50, 150, "Error displaying", Color::red())
// } else {
// display.draw_text(50, 150, s.unwrap(), Color::white());
// }
if s.is_err() {
display.draw_text(50, 150, "Error displaying", Color::red())
} else {
display.draw_text(50, 150, s.unwrap(), Color::white());
}
display.draw_text(150, 50, "RED", Color::red());
display.draw_text(160, 60, "GREEN", Color::green());

View File

@ -129,10 +129,6 @@ impl Display {
fn write_pixel_component(&self, x: u32, y: u32, chan: u16, c: u32) {
unsafe {
*(self.base as *mut u8).offset(
// This is still a problem!
// 1. Fix display output so we can print some values
// 2. Print display info
// 3. Go from there.
(y * self.pitch + x * (self.depth >> 3) + self.color_component(chan)) as isize,
) = c as u8;
}