Add clear_screen function

This commit is contained in:
VersBinarii 2022-04-18 18:46:30 +02:00
parent d933649c19
commit 6e8c814156
2 changed files with 10 additions and 1 deletions

View file

@ -1,5 +1,4 @@
use crate::Ili9341; use crate::Ili9341;
use embedded_graphics_core::{ use embedded_graphics_core::{
pixelcolor::{raw::RawU16, Rgb565}, pixelcolor::{raw::RawU16, Rgb565},
prelude::*, prelude::*,
@ -82,4 +81,8 @@ where
Ok(()) Ok(())
} }
} }
fn clear(&mut self, color: Self::Color) -> Result<(), Self::Error> {
self.clear_screen(RawU16::from(color).into_inner())
}
} }

View file

@ -313,6 +313,12 @@ where
self.landscape = mode.is_landscape(); self.landscape = mode.is_landscape();
Ok(()) Ok(())
} }
/// Fill entire screen with specfied color u16 value
pub fn clear_screen(&mut self, color: u16) -> Result {
let color = core::iter::repeat(color).take(self.width * self.height);
self.draw_raw_iter(0, 0, self.width as u16, self.height as u16, color)
}
} }
impl<IFACE, RESET> Ili9341<IFACE, RESET> { impl<IFACE, RESET> Ili9341<IFACE, RESET> {