epd_waveshare/epd7in5/
command.rs

1//! SPI Commands for the Waveshare 7.5" E-Ink Display
2
3use crate::traits;
4
5/// Epd7in5 commands
6///
7/// Should rarely (never?) be needed directly.
8///
9/// For more infos about the addresses and what they are doing look into the PDFs.
10#[allow(dead_code)]
11#[derive(Copy, Clone)]
12pub(crate) enum Command {
13    /// Set Resolution, LUT selection, BWR pixels, gate scan direction, source shift
14    /// direction, booster switch, soft reset.
15    PanelSetting = 0x00,
16
17    /// Selecting internal and external power
18    PowerSetting = 0x01,
19
20    /// After the Power Off command, the driver will power off following the Power Off
21    /// Sequence; BUSY signal will become "0". This command will turn off charge pump,
22    /// T-con, source driver, gate driver, VCOM, and temperature sensor, but register
23    /// data will be kept until VDD becomes OFF. Source Driver output and Vcom will remain
24    /// as previous condition, which may have 2 conditions: 0V or floating.
25    PowerOff = 0x02,
26
27    /// Setting Power OFF sequence
28    PowerOffSequenceSetting = 0x03,
29
30    /// Turning On the Power
31    ///
32    /// After the Power ON command, the driver will power on following the Power ON
33    /// sequence. Once complete, the BUSY signal will become "1".
34    PowerOn = 0x04,
35
36    /// Starting data transmission
37    BoosterSoftStart = 0x06,
38
39    /// This command makes the chip enter the deep-sleep mode to save power.
40    ///
41    /// The deep sleep mode would return to stand-by by hardware reset.
42    ///
43    /// The only one parameter is a check code, the command would be excuted if check code = 0xA5.
44    DeepSleep = 0x07,
45
46    /// This command starts transmitting data and write them into SRAM. To complete data
47    /// transmission, command DSP (Data Stop) must be issued. Then the chip will start to
48    /// send data/VCOM for panel.
49    DataStartTransmission1 = 0x10,
50
51    /// To stop data transmission, this command must be issued to check the `data_flag`.
52    ///
53    /// After this command, BUSY signal will become "0" until the display update is
54    /// finished.
55    DataStop = 0x11,
56
57    /// After this command is issued, driver will refresh display (data/VCOM) according to
58    /// SRAM data and LUT.
59    ///
60    /// After Display Refresh command, BUSY signal will become "0" until the display
61    /// update is finished.
62    DisplayRefresh = 0x12,
63
64    /// After this command is issued, image process engine will find thin lines/pixels
65    /// from frame SRAM and update the frame SRAM for applying new gray level waveform.
66    ///
67    /// After "Image Process Command", BUSY_N signal will become "0" until image process
68    /// is finished.
69    ImageProcess = 0x13,
70
71    /// This command builds the VCOM Look-Up Table (LUTC).
72    LutForVcom = 0x20,
73    /// This command builds the Black Look-Up Table (LUTB).
74    LutBlack = 0x21,
75    /// This command builds the White Look-Up Table (LUTW).
76    LutWhite = 0x22,
77    /// This command builds the Gray1 Look-Up Table (LUTG1).
78    LutGray1 = 0x23,
79    /// This command builds the Gray2 Look-Up Table (LUTG2).
80    LutGray2 = 0x24,
81    /// This command builds the Red0 Look-Up Table (LUTR0).
82    LutRed0 = 0x25,
83    /// This command builds the Red1 Look-Up Table (LUTR1).
84    LutRed1 = 0x26,
85    /// This command builds the Red2 Look-Up Table (LUTR2).
86    LutRed2 = 0x27,
87    /// This command builds the Red3 Look-Up Table (LUTR3).
88    LutRed3 = 0x28,
89    /// This command builds the XON Look-Up Table (LUTXON).
90    LutXon = 0x29,
91
92    /// The command controls the PLL clock frequency.
93    PllControl = 0x30,
94
95    /// This command reads the temperature sensed by the temperature sensor.
96    TemperatureSensor = 0x40,
97    /// This command selects the Internal or External temperature sensor.
98    TemperatureCalibration = 0x41,
99    /// This command could write data to the external temperature sensor.
100    TemperatureSensorWrite = 0x42,
101    /// This command could read data from the external temperature sensor.
102    TemperatureSensorRead = 0x43,
103
104    /// This command indicates the interval of Vcom and data output. When setting the
105    /// vertical back porch, the total blanking will be kept (20 Hsync).
106    VcomAndDataIntervalSetting = 0x50,
107    /// This command indicates the input power condition. Host can read this flag to learn
108    /// the battery condition.
109    LowPowerDetection = 0x51,
110
111    /// This command defines non-overlap period of Gate and Source.
112    TconSetting = 0x60,
113    /// This command defines alternative resolution and this setting is of higher priority
114    /// than the RES\[1:0\] in R00H (PSR).
115    TconResolution = 0x61,
116    /// This command defines MCU host direct access external memory mode.
117    SpiFlashControl = 0x65,
118
119    /// The LUT_REV / Chip Revision is read from OTP address = 25001 and 25000.
120    Revision = 0x70,
121    /// This command reads the IC status.
122    GetStatus = 0x71,
123
124    /// This command implements related VCOM sensing setting.
125    AutoMeasurementVcom = 0x80,
126    /// This command gets the VCOM value.
127    ReadVcomValue = 0x81,
128    /// This command sets `VCOM_DC` value.
129    VcmDcSetting = 0x82,
130
131    /// This is in all the Waveshare controllers for Epd7in5, but it's not documented
132    /// anywhere in the datasheet `¯\_(ツ)_/¯`
133    FlashMode = 0xE5,
134}
135
136impl traits::Command for Command {
137    /// Returns the address of the command
138    fn address(self) -> u8 {
139        self as u8
140    }
141}
142
143#[cfg(test)]
144mod tests {
145    use super::*;
146    use crate::traits::Command as CommandTrait;
147
148    #[test]
149    fn command_addr() {
150        assert_eq!(Command::PanelSetting.address(), 0x00);
151        assert_eq!(Command::DisplayRefresh.address(), 0x12);
152    }
153}