pub struct ST7920<SPI, RST, CS>{ /* private fields */ }
Implementations§
source§impl<SPI, RST, CS, PinError, SPIError> ST7920<SPI, RST, CS>
impl<SPI, RST, CS, PinError, SPIError> ST7920<SPI, RST, CS>
sourcepub fn new(spi: SPI, rst: RST, cs: Option<CS>, flip: bool) -> Self
pub fn new(spi: SPI, rst: RST, cs: Option<CS>, flip: bool) -> Self
Create a new ST7920<SPI, RST, CS>
driver instance that uses SPI connection.
§Examples
use st7920::ST7920;
let result = ST7920::new(spi, GPIO::new(pins.p01), None, false);
assert_eq!(result, );
sourcepub fn init<Delay: DelayNs>(
&mut self,
delay: &mut Delay
) -> Result<(), Error<SPIError, PinError>>
pub fn init<Delay: DelayNs>( &mut self, delay: &mut Delay ) -> Result<(), Error<SPIError, PinError>>
Initialize the display controller
sourcepub fn modify_buffer(&mut self, f: fn(x: u8, y: u8, v: u8) -> u8)
pub fn modify_buffer(&mut self, f: fn(x: u8, y: u8, v: u8) -> u8)
Modify the raw buffer. 1 byte (u8) = 8 pixels
§Examples
let mut st7920 = st7920::ST7920(...);
// add crazy pattern
st7920.modify_buffer(|x, y, v| {
if x % 2 == y % 2 {
v | 0b10101010
} else {
v
}
});
st7920.flush();
sourcepub fn clear_buffer(&mut self)
pub fn clear_buffer(&mut self)
clears the buffer but don’t update the display
sourcepub fn clear<Delay: DelayNs>(
&mut self,
delay: &mut Delay
) -> Result<(), Error<SPIError, PinError>>
pub fn clear<Delay: DelayNs>( &mut self, delay: &mut Delay ) -> Result<(), Error<SPIError, PinError>>
Clear whole display area and clears the buffer
sourcepub fn clear_buffer_region(
&mut self,
x: u8,
y: u8,
w: u8,
h: u8
) -> Result<(), Error<SPIError, PinError>>
pub fn clear_buffer_region( &mut self, x: u8, y: u8, w: u8, h: u8 ) -> Result<(), Error<SPIError, PinError>>
Clear a buffer region.
If the region is completely off screen, nothing will be done and Ok()) will be returned. If the given width or height are too big, width and height will be trimmed to the screen dimensions.
sourcepub fn set_pixel(&mut self, x: u8, y: u8, val: u8)
pub fn set_pixel(&mut self, x: u8, y: u8, val: u8)
Draw pixel
Doesn’t draw anything, if the x or y coordinates are off canvas.
Supported values are 0 and (not 0)
sourcepub fn set_pixel_unchecked(&mut self, x: u8, y: u8, val: u8)
pub fn set_pixel_unchecked(&mut self, x: u8, y: u8, val: u8)
Draw pixel without canvas bounds checking.
Supported values are 0 and (not 0)
§Panics
May panic or draw to undefined pixels, if x or y coordinates are off canvas.
sourcepub fn flush<Delay: DelayNs>(
&mut self,
delay: &mut Delay
) -> Result<(), Error<SPIError, PinError>>
pub fn flush<Delay: DelayNs>( &mut self, delay: &mut Delay ) -> Result<(), Error<SPIError, PinError>>
Flush buffer to update entire display
sourcepub fn flush_region<Delay: DelayNs>(
&mut self,
x: u8,
y: u8,
w: u8,
h: u8,
delay: &mut Delay
) -> Result<(), Error<SPIError, PinError>>
pub fn flush_region<Delay: DelayNs>( &mut self, x: u8, y: u8, w: u8, h: u8, delay: &mut Delay ) -> Result<(), Error<SPIError, PinError>>
Flush buffer to update region of the display
If the region is completely off screen, nothing will be done and Ok()) will be returned. If the given width or height are too big, width and height will be trimmed to the screen dimensions.