Generalise graphics once more

Change u16 positions to u32 to adapt to embedded graphics unsigned coordinates

Furthermore added epd4in2 defaults graphics buffer
This commit is contained in:
Chris
2018-10-19 14:36:43 +02:00
parent 9289d689b7
commit 139096297b
10 changed files with 124 additions and 92 deletions
+13 -13
View File
@@ -19,8 +19,8 @@
//! epd4in2.sleep();
//! ```
const WIDTH: u16 = 200;
const HEIGHT: u16 = 200;
const WIDTH: u32 = 200;
const HEIGHT: u32 = 200;
//const DPI: u16 = 184;
const DEFAULT_BACKGROUND_COLOR: Color = Color::White;
@@ -109,11 +109,11 @@ where
DC: OutputPin,
RST: OutputPin,
{
fn width(&self) -> u16 {
fn width(&self) -> u32 {
WIDTH
}
fn height(&self) -> u16 {
fn height(&self) -> u32 {
HEIGHT
}
@@ -157,10 +157,10 @@ where
&mut self,
spi: &mut SPI,
buffer: &[u8],
x: u16,
y: u16,
width: u16,
height: u16,
x: u32,
y: u32,
width: u32,
height: u32,
) -> Result<(), SPI::Error> {
self.set_ram_area(spi, x, y, x + width, y + height)?;
self.set_ram_counter(spi, x, y)?;
@@ -227,10 +227,10 @@ where
pub(crate) fn set_ram_area(
&mut self,
spi: &mut SPI,
start_x: u16,
start_y: u16,
end_x: u16,
end_y: u16,
start_x: u32,
start_y: u32,
end_x: u32,
end_y: u32,
) -> Result<(), SPI::Error> {
assert!(start_x < end_x);
assert!(start_y < end_y);
@@ -251,7 +251,7 @@ where
)
}
pub(crate) fn set_ram_counter(&mut self, spi: &mut SPI, x: u16, y: u16) -> Result<(), SPI::Error> {
pub(crate) fn set_ram_counter(&mut self, spi: &mut SPI, x: u32, y: u32) -> Result<(), SPI::Error> {
// x is positioned in bytes, so the last 3 bits which show the position inside a byte in the ram
// aren't relevant
self.interface.cmd_with_data(spi, Command::SET_RAM_X_ADDRESS_COUNTER, &[(x >> 3) as u8])?;