Browse Source

added fast partial update to embedded_linux example

embedded-hal-1.0
Chris 8 years ago
parent
commit
d4abd54b56
  1. 24
      examples/embedded_linux/src/main.rs
  2. 3
      src/epd4in2/mod.rs

24
examples/embedded_linux/src/main.rs

@ -111,7 +111,7 @@ fn main() {
graphics.draw_line(&mut buffer, 0,0,400,300, &Color::Black);
graphics.draw_filled_rectangle(&mut buffer, 200,200, 230, 230, &Color::Black);
graphics.draw_line(&mut buffer, 200,200,200,230, &Color::White);
graphics.draw_line(&mut buffer, 202,202,218,228, &Color::White);
graphics.draw_circle(&mut buffer, 200, 150, 130, &Color::Black);
@ -125,6 +125,28 @@ fn main() {
epd4in2.delay_ms(3000);
epd4in2.clear_frame(None).expect("clear frame error");
let mut small_buffer = [0xff; 128];
let circle_graphics = Graphics::new(32,32);
graphics.draw_circle(&mut small_buffer, 16,16, 10, &Color::Black);
epd4in2.set_partial_window(&small_buffer, 16,16, 32,32, 2, false);
epd4in2.display_frame_quick();
epd4in2.set_partial_window(&small_buffer, 128,64, 32,32, 2, false);
epd4in2.display_frame_quick();
epd4in2.set_partial_window(&small_buffer, 320,24, 32,32, 2, false);
epd4in2.display_frame_quick();
epd4in2.set_partial_window(&small_buffer, 160,240, 32,32, 2, false);
epd4in2.display_frame_quick();
epd4in2.delay_ms(3000);
epd4in2.clear_frame(None).expect("clear frame error");
epd4in2.sleep().expect("sleeping error");

3
src/epd4in2/mod.rs

@ -211,6 +211,9 @@ where
/// Transmit partial data to the SRAM of the EPD,
/// the final parameter dtm chooses between the 2
/// internal buffers
///
/// Normally it should be dtm2, so use false
///
/// BUFFER needs to be of size: w / 8 * l !
pub fn set_partial_window(&mut self, buffer: &[u8], x: u16, y: u16, w: u16, l: u16, is_dtm1: bool) -> Result<(), E> {
if buffer.len() as u16 != w / 8 * l {

Loading…
Cancel
Save