st7565/driver/
mode_raw.rs

1use display_interface::{DataFormat::U8, DisplayError, WriteOnlyDataCommand};
2
3use crate::command::{Command, SendSt7565Command};
4use crate::ST7565;
5
6/// Raw mode provides functionality to control the ST7565 chip directly
7/// through low-level commands.
8pub struct RawMode;
9
10/// ---- Functionality of the raw mode ----
11/// =======================================
12///
13/// This mode exists for interacting with the ST7565 chip via direct low level commands.
14impl<DI, SPECS, const WIDTH: usize, const HEIGHT: usize, const PAGES: usize>
15    ST7565<DI, SPECS, RawMode, WIDTH, HEIGHT, PAGES>
16where
17    DI: WriteOnlyDataCommand,
18{
19    /// Sets the page to write into
20    pub fn set_page(&mut self, page: u8) -> Result<(), DisplayError> {
21        self.interface
22            .send_command(Command::PageAddressSet { address: page })
23    }
24
25    /// Sets the column to write into
26    pub fn set_column(&mut self, address: u8) -> Result<(), DisplayError> {
27        self.interface
28            .send_command(Command::ColumnAddressSet { address })
29    }
30
31    /// Writes raw pixel data.
32    ///
33    /// For more information how data is processed by the display, read the
34    /// ST7565 reference manual.
35    pub fn write_pixel_data(&mut self, data: &[u8]) -> Result<(), DisplayError> {
36        self.interface.send_data(U8(data))
37    }
38
39    /// Sets the adc direction.
40    ///
41    /// Effectively flips the display horizontally.
42    pub fn adc_select(&mut self, reverse: bool) -> Result<(), DisplayError> {
43        self.interface.send_command(Command::AdcSelect { reverse })
44    }
45
46    /// Sets the common mode direction.
47    ///
48    /// Effectively flips the display vertically.
49    pub fn common_output_mode_select(&mut self, reverse: bool) -> Result<(), DisplayError> {
50        self.interface
51            .send_command(Command::CommonOutputModeSelect { reverse })
52    }
53}