Add display clear
This commit is contained in:
parent
79218ff2dd
commit
abafec12c6
|
@ -56,6 +56,7 @@ fn kmain() -> ! {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(mut display) = VC::init_fb(Size2d { x: 800, y: 600 } /*, &mut uart*/) {
|
if let Some(mut display) = VC::init_fb(Size2d { x: 800, y: 600 } /*, &mut uart*/) {
|
||||||
|
display.clear(Color::black());
|
||||||
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));
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,10 @@ impl Color {
|
||||||
Color(u32::from(b) << 16 | u32::from(g) << 8 | u32::from(r))
|
Color(u32::from(b) << 16 | u32::from(g) << 8 | u32::from(r))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn black() -> Color {
|
||||||
|
Color::rgb(0, 0, 0)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn white() -> Color {
|
pub fn white() -> Color {
|
||||||
Color::rgb(255, 255, 255)
|
Color::rgb(255, 255, 255)
|
||||||
}
|
}
|
||||||
|
@ -150,6 +154,10 @@ impl Display {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn clear(&mut self, color: Color) {
|
||||||
|
self.rect(0, 0, self.width, self.height, color)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn draw_text(&mut self, x: u32, y: u32, text: &str, color: Color) {
|
pub fn draw_text(&mut self, x: u32, y: u32, text: &str, color: Color) {
|
||||||
for i in 0..8 {
|
for i in 0..8 {
|
||||||
// Take an 8 bit slice from each array value.
|
// Take an 8 bit slice from each array value.
|
||||||
|
|
Loading…
Reference in New Issue