Skip to content

Commit

Permalink
Rename some functions
Browse files Browse the repository at this point in the history
  • Loading branch information
avsaase committed Jun 11, 2024
1 parent b1d704e commit 240ed20
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 25 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ Unofficial Rust driver for WeAct Studio e-paper displays.

[^2]: Refresh the screen without flickering the screen a few times.

## Features
## Examples

- `graphics`: Enables `embedded-graphics` support. Enabled by default.
See the `examples` folder for complete usage examples.

## Examples
## Features

See the `examples` folder for usage examples.
- `graphics`: Enables `embedded-graphics` support. Enabled by default.

## Credits

Expand Down
4 changes: 2 additions & 2 deletions examples/rp2040/src/bin/290_bw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ async fn main(_spawner: Spawner) {
.unwrap();
string_buf.clear();

driver.full_update_from_display(&display).unwrap();
driver.full_update(&display).unwrap();

let text_style = TextStyleBuilder::new().alignment(Alignment::Right).build();
loop {
Expand All @@ -82,7 +82,7 @@ async fn main(_spawner: Spawner) {
string_buf.clear();

driver
.fast_partial_update_from_display(&partial_display_bw, 56, 156)
.fast_partial_update(&partial_display_bw, 56, 156)
.unwrap();

partial_display_bw.clear(Color::White);
Expand Down
4 changes: 2 additions & 2 deletions examples/stm32g431/src/bin/290_bw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ async fn main(_spawner: Spawner) {
.unwrap();
string_buf.clear();

driver.full_update_from_display(&display).unwrap();
driver.full_update(&display).unwrap();

let text_style = TextStyleBuilder::new().alignment(Alignment::Right).build();
loop {
Expand All @@ -102,7 +102,7 @@ async fn main(_spawner: Spawner) {
string_buf.clear();

driver
.fast_partial_update_from_display(&partial_display_bw, 56, 156)
.fast_partial_update(&partial_display_bw, 56, 156)
.unwrap();

partial_display_bw.clear(Color::White);
Expand Down
30 changes: 13 additions & 17 deletions src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ where
}

/// Update the screen with the provided full frame buffer using a full refresh.
pub fn full_update(&mut self, buffer: &[u8]) -> Result<()> {
pub fn full_update_from_buffer(&mut self, buffer: &[u8]) -> Result<()> {
self.write_red_buffer(buffer)?;
self.write_bw_buffer(buffer)?;
self.full_refresh()?;
Expand All @@ -310,7 +310,7 @@ where
}

/// Update the screen with the provided full frame buffer using a fast refresh.
pub fn fast_update(&mut self, buffer: &[u8]) -> Result<()> {
pub fn fast_update_from_buffer(&mut self, buffer: &[u8]) -> Result<()> {
self.write_red_buffer(buffer)?;
self.fast_refresh()?;
self.write_red_buffer(buffer)?;
Expand All @@ -321,7 +321,7 @@ where
/// Update the screen with the provided partial frame buffer at the given position using a fast refresh.
///
/// `x`, and `width` must be multiples of 8.
pub fn fast_partial_update(
pub fn fast_partial_update_from_buffer(
&mut self,
buffer: &[u8],
x: u32,
Expand All @@ -339,39 +339,35 @@ where
/// Update the screen with the provided [`Display`] using a full refresh.
#[cfg_attr(docsrs, doc(cfg(feature = "graphics")))]
#[cfg(feature = "graphics")]
pub fn full_update_from_display<const BUFFER_SIZE: usize>(
pub fn full_update<const BUFFER_SIZE: usize>(
&mut self,
display: &Display<WIDTH, HEIGHT, BUFFER_SIZE, crate::color::Color>,
) -> Result<()> {
self.full_update(display.buffer())
self.full_update_from_buffer(display.buffer())
}

/// Update the screen with the provided [`Display`] using a fast refresh.
#[cfg_attr(docsrs, doc(cfg(feature = "graphics")))]
#[cfg(feature = "graphics")]
pub fn fast_update_from_display<const BUFFER_SIZE: usize>(
pub fn fast_update<const BUFFER_SIZE: usize>(
&mut self,
display: &Display<WIDTH, HEIGHT, BUFFER_SIZE, crate::color::Color>,
) -> Result<()> {
self.fast_update(display.buffer())
self.fast_update_from_buffer(display.buffer())
}

/// Update the screen with the provided partial [`Display`] at the given position using a fast refresh.
///
/// `x` and the display width `W` must be multiples of 8.
#[cfg_attr(docsrs, doc(cfg(feature = "graphics")))]
#[cfg(feature = "graphics")]
pub fn fast_partial_update_from_display<
const W: u32,
const H: u32,
const BUFFER_SIZE: usize,
>(
pub fn fast_partial_update<const W: u32, const H: u32, const BUFFER_SIZE: usize>(
&mut self,
display: &Display<W, H, BUFFER_SIZE, crate::color::Color>,
x: u32,
y: u32,
) -> Result<()> {
self.fast_partial_update(display.buffer(), x, y, W, H)
self.fast_partial_update_from_buffer(display.buffer(), x, y, W, H)
}
}

Expand All @@ -385,7 +381,7 @@ where
DELAY: DelayNs,
{
/// Update the screen with the provided full frame buffers using a full refresh.
pub fn full_update(&mut self, bw_buffer: &[u8], red_buffer: &[u8]) -> Result<()> {
pub fn full_update_from_buffer(&mut self, bw_buffer: &[u8], red_buffer: &[u8]) -> Result<()> {
self.write_red_buffer(red_buffer)?;
self.write_bw_buffer(bw_buffer)?;
self.full_refresh()?;
Expand All @@ -395,12 +391,12 @@ where
/// Update the screen with the provided [`Display`] using a full refresh.
#[cfg_attr(docsrs, doc(cfg(feature = "graphics")))]
#[cfg(feature = "graphics")]
pub fn full_update_from_display<const BUFFER_SIZE: usize>(
pub fn full_update<const BUFFER_SIZE: usize>(
&mut self,
display: Display<WIDTH, HEIGHT, BUFFER_SIZE, crate::color::TriColor>,
) -> Result<()> {
self.full_update(display.bw_buffer(), display.red_buffer())
self.full_update_from_buffer(display.bw_buffer(), display.red_buffer())
}

// TODO: check if partial updates
// TODO: check if partial updates with full refresh are supported
}

0 comments on commit 240ed20

Please sign in to comment.