Removed data_x_times function
parent
99d328575f
commit
6a24acf62b
|
|
@ -178,8 +178,11 @@ where
|
|||
// clear the ram with the background color
|
||||
let color = self.background_color.get_byte_value();
|
||||
|
||||
self.interface.cmd(Command::WRITE_RAM)?;
|
||||
self.interface.data_x_times(color, WIDTH / 8 * HEIGHT)
|
||||
//TODO: this is using a big buffer atm, is it better to just loop over sending a single byte?
|
||||
self.interface.cmd_with_data(
|
||||
Command::WRITE_RAM,
|
||||
&[color; WIDTH as usize / 8 * HEIGHT as usize]
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -175,8 +175,11 @@ where
|
|||
// clear the ram with the background color
|
||||
let color = self.background_color.get_byte_value();
|
||||
|
||||
self.interface.cmd(Command::WRITE_RAM)?;
|
||||
self.interface.data_x_times(color, WIDTH / 8 * HEIGHT)
|
||||
//TODO: this is using a big buffer atm, is it better to just loop over sending a single byte?
|
||||
self.interface.cmd_with_data(
|
||||
Command::WRITE_RAM,
|
||||
&[color; WIDTH as usize / 8 * HEIGHT as usize]
|
||||
)
|
||||
}
|
||||
|
||||
/// Sets the backgroundcolor for various commands like [WaveshareInterface::clear_frame()](clear_frame())
|
||||
|
|
|
|||
|
|
@ -191,7 +191,9 @@ where
|
|||
|
||||
|
||||
self.command(Command::DATA_START_TRANSMISSION_1)?;
|
||||
self.interface.data_x_times(color_value, buffer.len() as u16)?;
|
||||
for _ in 0..buffer.len() {
|
||||
self.send_data(&[color_value])?;
|
||||
}
|
||||
|
||||
//TODO: Removal of delay. TEST!
|
||||
//self.delay_ms(2);
|
||||
|
|
@ -254,17 +256,23 @@ where
|
|||
fn clear_frame(&mut self) -> Result<(), ERR> {
|
||||
self.send_resolution()?;
|
||||
|
||||
let size = WIDTH / 8 * HEIGHT;
|
||||
//let size = WIDTH as usize / 8 * HEIGHT as usize;
|
||||
let color_value = self.color.get_byte_value();
|
||||
|
||||
self.command(Command::DATA_START_TRANSMISSION_1)?;
|
||||
self.interface.data_x_times(color_value, size)?;
|
||||
//TODO: this is using a big buffer atm, is it better to just loop over sending a single byte?
|
||||
self.interface.cmd_with_data(
|
||||
Command::DATA_START_TRANSMISSION_1,
|
||||
&[color_value; WIDTH as usize / 8 * HEIGHT as usize]
|
||||
)?;
|
||||
|
||||
//TODO: Removal of delay. TEST!
|
||||
//self.delay_ms(2);
|
||||
|
||||
self.command(Command::DATA_START_TRANSMISSION_2)?;
|
||||
self.interface.data_x_times(color_value, size)
|
||||
//TODO: this is using a big buffer atm, is it better to just loop over sending a single byte?
|
||||
self.interface.cmd_with_data(
|
||||
Command::DATA_START_TRANSMISSION_2,
|
||||
&[color_value; WIDTH as usize / 8 * HEIGHT as usize]
|
||||
)
|
||||
}
|
||||
|
||||
/// Sets the backgroundcolor for various commands like [WaveshareInterface::clear_frame()](clear_frame())
|
||||
|
|
|
|||
|
|
@ -73,30 +73,6 @@ where
|
|||
self.data(data)
|
||||
}
|
||||
|
||||
/// Basic function for sending the same byte of data (one u8) multiple times over spi
|
||||
///
|
||||
/// Enables direct interaction with the device with the help of [command()](ConnectionInterface::command())
|
||||
///
|
||||
/// //TODO: make public?
|
||||
pub(crate) fn data_x_times(
|
||||
&mut self,
|
||||
val: u8,
|
||||
repetitions: u16,
|
||||
) -> Result<(), ERR> {
|
||||
// high for data
|
||||
self.dc.set_high();
|
||||
|
||||
// Transfer data (u8) over spi
|
||||
self.with_cs(|epd| {
|
||||
for _ in 0..repetitions {
|
||||
epd.spi.write(&[val])?;
|
||||
}
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
// spi write helper/abstraction function
|
||||
fn with_cs<F>(&mut self, f: F) -> Result<(), ERR>
|
||||
where
|
||||
|
|
|
|||
Loading…
Reference in New Issue