Display with formatting now works
This commit is contained in:
parent
e324795ab9
commit
0b86eeaf90
14
src/main.rs
14
src/main.rs
|
@ -217,16 +217,16 @@ fn check_display_init() {
|
||||||
display.rect(10, 10, 250, 250, Color::rgb(32, 96, 64));
|
display.rect(10, 10, 250, 250, Color::rgb(32, 96, 64));
|
||||||
display.draw_text(50, 50, "Hello there!", Color::rgb(128, 192, 255));
|
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
|
// 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?
|
// So, some rust runtime things are breaking it, why?
|
||||||
|
|
||||||
// if s.is_err() {
|
if s.is_err() {
|
||||||
// display.draw_text(50, 150, "Error displaying", Color::red())
|
display.draw_text(50, 150, "Error displaying", Color::red())
|
||||||
// } else {
|
} else {
|
||||||
// display.draw_text(50, 150, s.unwrap(), Color::white());
|
display.draw_text(50, 150, s.unwrap(), Color::white());
|
||||||
// }
|
}
|
||||||
|
|
||||||
display.draw_text(150, 50, "RED", Color::red());
|
display.draw_text(150, 50, "RED", Color::red());
|
||||||
display.draw_text(160, 60, "GREEN", Color::green());
|
display.draw_text(160, 60, "GREEN", Color::green());
|
||||||
|
|
|
@ -129,10 +129,6 @@ impl Display {
|
||||||
fn write_pixel_component(&self, x: u32, y: u32, chan: u16, c: u32) {
|
fn write_pixel_component(&self, x: u32, y: u32, chan: u16, c: u32) {
|
||||||
unsafe {
|
unsafe {
|
||||||
*(self.base as *mut u8).offset(
|
*(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,
|
(y * self.pitch + x * (self.depth >> 3) + self.color_component(chan)) as isize,
|
||||||
) = c as u8;
|
) = c as u8;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue