Skip to content

Commit

Permalink
WIP still some strange behavior with partial handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
dkm committed Aug 28, 2020
1 parent 7956bf1 commit 129553b
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/epd2in13_v2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ where
Ok(())
}

/// Beware that this does not work well with the screen partial refresh feature.
fn update_partial_frame(
&mut self,
spi: &mut SPI,
Expand All @@ -226,6 +227,8 @@ where
) -> Result<(), SPI::Error> {
assert!((width * height / 8) as usize == buffer.len());

assert!(self.refresh == RefreshLUT::FULL);

self.set_ram_area(spi, x, y, x + width, y + height)?;
self.set_ram_address_counters(spi, x, y)?;

Expand All @@ -249,6 +252,16 @@ where
}
self.command(spi, Command::MASTER_ACTIVATION)?;
self.wait_until_idle();

// If partial refresh, swap the buffer so that the current buffer
// becomes the new base for comparison.
// if self.refresh == RefreshLUT::QUICK {
// // self.set_partial_base_buffer(spi, buffer )?;
// self.set_display_update_control_2(spi, DisplayUpdateControl2::new().swap_ram())?;
// self.command(spi, Command::MASTER_ACTIVATION)?;
// self.wait_until_idle();
// }

Ok(())
}

Expand All @@ -259,15 +272,15 @@ where
// If partial refresh, swap the buffer so that the current buffer
// becomes the new base for comparison.
if self.refresh == RefreshLUT::QUICK {
self.set_display_update_control_2(spi, DisplayUpdateControl2::new().swap_ram())?;
self.set_partial_base_buffer(spi, buffer)?;
//self.set_display_update_control_2(spi, DisplayUpdateControl2::new().swap_ram())?;
self.command(spi, Command::MASTER_ACTIVATION)?;
self.wait_until_idle();

// We still need to do this as current RAM nows holds the previous
// reference. If we use the `update_partial_frame()` then we may
// end-up with old data.
// FIXME: This needs to be tested.
self.update_frame(spi, buffer)?;
// self.update_frame(spi, buffer)?;
}
Ok(())
}
Expand All @@ -278,7 +291,6 @@ where
self.command(spi, Command::WRITE_RAM)?;
self.interface
.data_x_times(spi, color, WIDTH * HEIGHT / 8)?;

Ok(())
}

Expand Down Expand Up @@ -331,8 +343,10 @@ where
spi: &mut SPI,
buffer: &[u8],
) -> Result<(), SPI::Error> {
self.update_frame(spi, buffer)?;
// self.update_frame(spi, buffer)?;
assert!((WIDTH * HEIGHT / 8) as usize == buffer.len());
self.set_ram_area(spi, 0, 0, WIDTH - 1, HEIGHT - 1)?;
self.set_ram_address_counters(spi, 0, 0)?;

self.cmd_with_data(spi, Command::WRITE_RAM_RED, buffer)?;
Ok(())
Expand Down

0 comments on commit 129553b

Please sign in to comment.