cargo fmt
parent
ba1b90e2f3
commit
9d95eeb64b
|
|
@ -112,11 +112,8 @@ where
|
||||||
// 1 .. B[6:0] = 0xCE | 0xD6
|
// 1 .. B[6:0] = 0xCE | 0xD6
|
||||||
// 1 .. C[6:0] = 0x8D | 0x9D
|
// 1 .. C[6:0] = 0x8D | 0x9D
|
||||||
//TODO: test
|
//TODO: test
|
||||||
self.interface.cmd_with_data(
|
self.interface
|
||||||
spi,
|
.cmd_with_data(spi, Command::BoosterSoftStartControl, &[0xD7, 0xD6, 0x9D])?;
|
||||||
Command::BoosterSoftStartControl,
|
|
||||||
&[0xD7, 0xD6, 0x9D],
|
|
||||||
)?;
|
|
||||||
|
|
||||||
// One Databyte with value 0xA8 for 7V VCOM
|
// One Databyte with value 0xA8 for 7V VCOM
|
||||||
self.interface
|
self.interface
|
||||||
|
|
|
||||||
|
|
@ -111,8 +111,7 @@ where
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.send_resolution(spi)?;
|
self.send_resolution(spi)?;
|
||||||
|
|
||||||
self.interface
|
self.interface.cmd(spi, Command::DataStartTransmission1)?;
|
||||||
.cmd(spi, Command::DataStartTransmission1)?;
|
|
||||||
|
|
||||||
for b in black {
|
for b in black {
|
||||||
let expanded = expand_bits(*b);
|
let expanded = expand_bits(*b);
|
||||||
|
|
@ -126,8 +125,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
chromatic: &[u8],
|
chromatic: &[u8],
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), SPI::Error> {
|
||||||
self.interface
|
self.interface.cmd(spi, Command::DataStartTransmission2)?;
|
||||||
.cmd(spi, Command::DataStartTransmission2)?;
|
|
||||||
self.interface.data(spi, chromatic)?;
|
self.interface.data(spi, chromatic)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -209,8 +207,7 @@ where
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.send_resolution(spi)?;
|
self.send_resolution(spi)?;
|
||||||
|
|
||||||
self.interface
|
self.interface.cmd(spi, Command::DataStartTransmission1)?;
|
||||||
.cmd(spi, Command::DataStartTransmission1)?;
|
|
||||||
|
|
||||||
for b in buffer {
|
for b in buffer {
|
||||||
// Two bits per pixel
|
// Two bits per pixel
|
||||||
|
|
@ -224,8 +221,7 @@ where
|
||||||
let color = self.color.get_byte_value();
|
let color = self.color.get_byte_value();
|
||||||
let nbits = WIDTH * (HEIGHT / 8);
|
let nbits = WIDTH * (HEIGHT / 8);
|
||||||
|
|
||||||
self.interface
|
self.interface.cmd(spi, Command::DataStartTransmission2)?;
|
||||||
.cmd(spi, Command::DataStartTransmission2)?;
|
|
||||||
self.interface.data_x_times(spi, color, nbits)?;
|
self.interface.data_x_times(spi, color, nbits)?;
|
||||||
|
|
||||||
//NOTE: Example code has a delay here
|
//NOTE: Example code has a delay here
|
||||||
|
|
@ -264,16 +260,14 @@ where
|
||||||
let color = DEFAULT_BACKGROUND_COLOR.get_byte_value();
|
let color = DEFAULT_BACKGROUND_COLOR.get_byte_value();
|
||||||
|
|
||||||
// Clear the black
|
// Clear the black
|
||||||
self.interface
|
self.interface.cmd(spi, Command::DataStartTransmission1)?;
|
||||||
.cmd(spi, Command::DataStartTransmission1)?;
|
|
||||||
|
|
||||||
// Uses 2 bits per pixel
|
// Uses 2 bits per pixel
|
||||||
self.interface
|
self.interface
|
||||||
.data_x_times(spi, color, 2 * (WIDTH * HEIGHT / 8))?;
|
.data_x_times(spi, color, 2 * (WIDTH * HEIGHT / 8))?;
|
||||||
|
|
||||||
// Clear the red
|
// Clear the red
|
||||||
self.interface
|
self.interface.cmd(spi, Command::DataStartTransmission2)?;
|
||||||
.cmd(spi, Command::DataStartTransmission2)?;
|
|
||||||
self.interface
|
self.interface
|
||||||
.data_x_times(spi, color, WIDTH * HEIGHT / 8)?;
|
.data_x_times(spi, color, WIDTH * HEIGHT / 8)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
||||||
|
|
@ -160,13 +160,11 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> {
|
fn update_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> {
|
||||||
self.interface
|
self.interface.cmd(spi, Command::DataStartTransmission1)?;
|
||||||
.cmd(spi, Command::DataStartTransmission1)?;
|
|
||||||
self.send_buffer_helper(spi, buffer)?;
|
self.send_buffer_helper(spi, buffer)?;
|
||||||
|
|
||||||
// Clear chromatic layer since we won't be using it here
|
// Clear chromatic layer since we won't be using it here
|
||||||
self.interface
|
self.interface.cmd(spi, Command::DataStartTransmission2)?;
|
||||||
.cmd(spi, Command::DataStartTransmission2)?;
|
|
||||||
self.interface
|
self.interface
|
||||||
.data_x_times(spi, !self.color.get_byte_value(), WIDTH * HEIGHT / 8)?;
|
.data_x_times(spi, !self.color.get_byte_value(), WIDTH * HEIGHT / 8)?;
|
||||||
|
|
||||||
|
|
@ -217,15 +215,13 @@ where
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
|
|
||||||
let color_value = self.color.get_byte_value();
|
let color_value = self.color.get_byte_value();
|
||||||
self.interface
|
self.interface.cmd(spi, Command::DataStartTransmission1)?;
|
||||||
.cmd(spi, Command::DataStartTransmission1)?;
|
|
||||||
self.interface
|
self.interface
|
||||||
.data_x_times(spi, color_value, WIDTH * HEIGHT / 8)?;
|
.data_x_times(spi, color_value, WIDTH * HEIGHT / 8)?;
|
||||||
|
|
||||||
self.interface.cmd(spi, Command::DataStop)?;
|
self.interface.cmd(spi, Command::DataStop)?;
|
||||||
|
|
||||||
self.interface
|
self.interface.cmd(spi, Command::DataStartTransmission2)?;
|
||||||
.cmd(spi, Command::DataStartTransmission2)?;
|
|
||||||
self.interface
|
self.interface
|
||||||
.data_x_times(spi, color_value, WIDTH * HEIGHT / 8)?;
|
.data_x_times(spi, color_value, WIDTH * HEIGHT / 8)?;
|
||||||
self.interface.cmd(spi, Command::DataStop)?;
|
self.interface.cmd(spi, Command::DataStop)?;
|
||||||
|
|
@ -294,8 +290,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
achromatic: &[u8],
|
achromatic: &[u8],
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), SPI::Error> {
|
||||||
self.interface
|
self.interface.cmd(spi, Command::DataStartTransmission1)?;
|
||||||
.cmd(spi, Command::DataStartTransmission1)?;
|
|
||||||
|
|
||||||
self.send_buffer_helper(spi, achromatic)?;
|
self.send_buffer_helper(spi, achromatic)?;
|
||||||
|
|
||||||
|
|
@ -310,8 +305,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
chromatic: &[u8],
|
chromatic: &[u8],
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), SPI::Error> {
|
||||||
self.interface
|
self.interface.cmd(spi, Command::DataStartTransmission2)?;
|
||||||
.cmd(spi, Command::DataStartTransmission2)?;
|
|
||||||
|
|
||||||
self.send_buffer_helper(spi, chromatic)?;
|
self.send_buffer_helper(spi, chromatic)?;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -111,11 +111,8 @@ where
|
||||||
// 1 .. B[6:0] = 0xCE | 0xD6
|
// 1 .. B[6:0] = 0xCE | 0xD6
|
||||||
// 1 .. C[6:0] = 0x8D | 0x9D
|
// 1 .. C[6:0] = 0x8D | 0x9D
|
||||||
//TODO: test
|
//TODO: test
|
||||||
self.interface.cmd_with_data(
|
self.interface
|
||||||
spi,
|
.cmd_with_data(spi, Command::BoosterSoftStartControl, &[0xD7, 0xD6, 0x9D])?;
|
||||||
Command::BoosterSoftStartControl,
|
|
||||||
&[0xD7, 0xD6, 0x9D],
|
|
||||||
)?;
|
|
||||||
|
|
||||||
// One Databyte with value 0xA8 for 7V VCOM
|
// One Databyte with value 0xA8 for 7V VCOM
|
||||||
self.interface
|
self.interface
|
||||||
|
|
|
||||||
|
|
@ -165,8 +165,7 @@ where
|
||||||
///
|
///
|
||||||
/// Finish by calling `update_chromatic_frame`.
|
/// Finish by calling `update_chromatic_frame`.
|
||||||
fn update_achromatic_frame(&mut self, spi: &mut SPI, black: &[u8]) -> Result<(), SPI::Error> {
|
fn update_achromatic_frame(&mut self, spi: &mut SPI, black: &[u8]) -> Result<(), SPI::Error> {
|
||||||
self.interface
|
self.interface.cmd(spi, Command::DataStartTransmission1)?;
|
||||||
.cmd(spi, Command::DataStartTransmission1)?;
|
|
||||||
self.interface.data(spi, black)?;
|
self.interface.data(spi, black)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -179,8 +178,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
chromatic: &[u8],
|
chromatic: &[u8],
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), SPI::Error> {
|
||||||
self.interface
|
self.interface.cmd(spi, Command::DataStartTransmission2)?;
|
||||||
.cmd(spi, Command::DataStartTransmission2)?;
|
|
||||||
self.interface.data(spi, chromatic)?;
|
self.interface.data(spi, chromatic)?;
|
||||||
|
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
|
|
@ -258,16 +256,14 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> {
|
fn update_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> {
|
||||||
self.interface
|
self.interface.cmd(spi, Command::DataStartTransmission1)?;
|
||||||
.cmd(spi, Command::DataStartTransmission1)?;
|
|
||||||
|
|
||||||
self.interface.data(spi, &buffer)?;
|
self.interface.data(spi, &buffer)?;
|
||||||
|
|
||||||
// Clear the chromatic layer
|
// Clear the chromatic layer
|
||||||
let color = self.color.get_byte_value();
|
let color = self.color.get_byte_value();
|
||||||
|
|
||||||
self.interface
|
self.interface.cmd(spi, Command::DataStartTransmission2)?;
|
||||||
.cmd(spi, Command::DataStartTransmission2)?;
|
|
||||||
self.interface.data_x_times(spi, color, NUM_DISPLAY_BITS)?;
|
self.interface.data_x_times(spi, color, NUM_DISPLAY_BITS)?;
|
||||||
|
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
|
|
@ -306,14 +302,12 @@ where
|
||||||
let color = DEFAULT_BACKGROUND_COLOR.get_byte_value();
|
let color = DEFAULT_BACKGROUND_COLOR.get_byte_value();
|
||||||
|
|
||||||
// Clear the black
|
// Clear the black
|
||||||
self.interface
|
self.interface.cmd(spi, Command::DataStartTransmission1)?;
|
||||||
.cmd(spi, Command::DataStartTransmission1)?;
|
|
||||||
|
|
||||||
self.interface.data_x_times(spi, color, NUM_DISPLAY_BITS)?;
|
self.interface.data_x_times(spi, color, NUM_DISPLAY_BITS)?;
|
||||||
|
|
||||||
// Clear the chromatic
|
// Clear the chromatic
|
||||||
self.interface
|
self.interface.cmd(spi, Command::DataStartTransmission2)?;
|
||||||
.cmd(spi, Command::DataStartTransmission2)?;
|
|
||||||
self.interface.data_x_times(spi, color, NUM_DISPLAY_BITS)?;
|
self.interface.data_x_times(spi, color, NUM_DISPLAY_BITS)?;
|
||||||
|
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
|
|
|
||||||
|
|
@ -211,8 +211,7 @@ where
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
let color_value = self.color.get_byte_value();
|
let color_value = self.color.get_byte_value();
|
||||||
|
|
||||||
self.interface
|
self.interface.cmd(spi, Command::DataStartTransmission1)?;
|
||||||
.cmd(spi, Command::DataStartTransmission1)?;
|
|
||||||
self.interface
|
self.interface
|
||||||
.data_x_times(spi, color_value, WIDTH / 8 * HEIGHT)?;
|
.data_x_times(spi, color_value, WIDTH / 8 * HEIGHT)?;
|
||||||
|
|
||||||
|
|
@ -285,13 +284,11 @@ where
|
||||||
|
|
||||||
let color_value = self.color.get_byte_value();
|
let color_value = self.color.get_byte_value();
|
||||||
|
|
||||||
self.interface
|
self.interface.cmd(spi, Command::DataStartTransmission1)?;
|
||||||
.cmd(spi, Command::DataStartTransmission1)?;
|
|
||||||
self.interface
|
self.interface
|
||||||
.data_x_times(spi, color_value, WIDTH / 8 * HEIGHT)?;
|
.data_x_times(spi, color_value, WIDTH / 8 * HEIGHT)?;
|
||||||
|
|
||||||
self.interface
|
self.interface.cmd(spi, Command::DataStartTransmission2)?;
|
||||||
.cmd(spi, Command::DataStartTransmission2)?;
|
|
||||||
self.interface
|
self.interface
|
||||||
.data_x_times(spi, color_value, WIDTH / 8 * HEIGHT)?;
|
.data_x_times(spi, color_value, WIDTH / 8 * HEIGHT)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -450,8 +447,7 @@ where
|
||||||
fn update_old_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> {
|
fn update_old_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> {
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
|
|
||||||
self.interface
|
self.interface.cmd(spi, Command::DataStartTransmission1)?;
|
||||||
.cmd(spi, Command::DataStartTransmission1)?;
|
|
||||||
|
|
||||||
self.interface.data(spi, buffer)?;
|
self.interface.data(spi, buffer)?;
|
||||||
|
|
||||||
|
|
@ -463,8 +459,7 @@ where
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
// self.send_resolution(spi)?;
|
// self.send_resolution(spi)?;
|
||||||
|
|
||||||
self.interface
|
self.interface.cmd(spi, Command::DataStartTransmission2)?;
|
||||||
.cmd(spi, Command::DataStartTransmission2)?;
|
|
||||||
|
|
||||||
self.interface.data(spi, buffer)?;
|
self.interface.data(spi, buffer)?;
|
||||||
|
|
||||||
|
|
@ -492,8 +487,7 @@ where
|
||||||
|
|
||||||
self.shift_display(spi, x, y, width, height)?;
|
self.shift_display(spi, x, y, width, height)?;
|
||||||
|
|
||||||
self.interface
|
self.interface.cmd(spi, Command::DataStartTransmission1)?;
|
||||||
.cmd(spi, Command::DataStartTransmission1)?;
|
|
||||||
|
|
||||||
self.interface.data(spi, buffer)?;
|
self.interface.data(spi, buffer)?;
|
||||||
|
|
||||||
|
|
@ -519,8 +513,7 @@ where
|
||||||
|
|
||||||
self.shift_display(spi, x, y, width, height)?;
|
self.shift_display(spi, x, y, width, height)?;
|
||||||
|
|
||||||
self.interface
|
self.interface.cmd(spi, Command::DataStartTransmission2)?;
|
||||||
.cmd(spi, Command::DataStartTransmission2)?;
|
|
||||||
|
|
||||||
self.interface.data(spi, buffer)?;
|
self.interface.data(spi, buffer)?;
|
||||||
|
|
||||||
|
|
@ -546,13 +539,11 @@ where
|
||||||
|
|
||||||
self.shift_display(spi, x, y, width, height)?;
|
self.shift_display(spi, x, y, width, height)?;
|
||||||
|
|
||||||
self.interface
|
self.interface.cmd(spi, Command::DataStartTransmission1)?;
|
||||||
.cmd(spi, Command::DataStartTransmission1)?;
|
|
||||||
self.interface
|
self.interface
|
||||||
.data_x_times(spi, color_value, width / 8 * height)?;
|
.data_x_times(spi, color_value, width / 8 * height)?;
|
||||||
|
|
||||||
self.interface
|
self.interface.cmd(spi, Command::DataStartTransmission2)?;
|
||||||
.cmd(spi, Command::DataStartTransmission2)?;
|
|
||||||
self.interface
|
self.interface
|
||||||
.data_x_times(spi, color_value, width / 8 * height)?;
|
.data_x_times(spi, color_value, width / 8 * height)?;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue