Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
dkm committed Sep 27, 2020
1 parent 0d1bd6b commit 8c9245f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/epd2in13_v2/graphics.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::buffer_len;
use crate::epd2in13_v2::{DEFAULT_BACKGROUND_COLOR, HEIGHT, WIDTH};
use crate::graphics::{buffer_len, Display, DisplayRotation};
use crate::graphics::{Display, DisplayRotation};
use embedded_graphics::pixelcolor::BinaryColor;
use embedded_graphics::prelude::*;

Expand Down
19 changes: 13 additions & 6 deletions src/epd2in13_v2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use embedded_hal::{
digital::v2::{InputPin, OutputPin},
};

use crate::buffer_len;
use crate::color::Color;
use crate::interface::DisplayInterface;
use crate::traits::{InternalWiAdditions, RefreshLUT, WaveshareDisplay};
Expand Down Expand Up @@ -211,7 +212,7 @@ where
}

fn update_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> {
assert!(buffer.len() == (WIDTH + 7) as usize / 8 * HEIGHT as usize);
assert!(buffer.len() == buffer_len(WIDTH as usize, HEIGHT as usize));
self.set_ram_area(spi, 0, 0, WIDTH - 1, HEIGHT - 1)?;
self.set_ram_address_counters(spi, 0, 0)?;

Expand Down Expand Up @@ -304,17 +305,23 @@ where
self.set_ram_address_counters(spi, 0, 0)?;

self.command(spi, Command::WRITE_RAM)?;
self.interface
.data_x_times(spi, color, WIDTH * HEIGHT / 8)?;
self.interface.data_x_times(
spi,
color,
buffer_len(WIDTH as usize, HEIGHT as usize) as u32,
)?;

// Always keep the base buffer equals to current if not doing partial refresh.
if self.refresh == RefreshLUT::FULL {
self.set_ram_area(spi, 0, 0, WIDTH - 1, HEIGHT - 1)?;
self.set_ram_address_counters(spi, 0, 0)?;

self.command(spi, Command::WRITE_RAM_RED)?;
self.interface
.data_x_times(spi, color, WIDTH * HEIGHT / 8)?;
self.interface.data_x_times(
spi,
color,
buffer_len(WIDTH as usize, HEIGHT as usize) as u32,
)?;
}
Ok(())
}
Expand Down Expand Up @@ -368,7 +375,7 @@ where
spi: &mut SPI,
buffer: &[u8],
) -> Result<(), SPI::Error> {
assert!((WIDTH * HEIGHT / 8) as usize == buffer.len());
assert!(buffer_len(WIDTH as usize, HEIGHT as usize) == buffer.len());
self.set_ram_area(spi, 0, 0, WIDTH - 1, HEIGHT - 1)?;
self.set_ram_address_counters(spi, 0, 0)?;

Expand Down

0 comments on commit 8c9245f

Please sign in to comment.