Skip to content

Commit fd26ded

Browse files
authored
Merge pull request #171 from wsndshx/main
Add support for EPD 2in9 D
2 parents 0c8a84c + 8986f93 commit fd26ded

File tree

4 files changed

+619
-0
lines changed

4 files changed

+619
-0
lines changed

src/epd2in9d/command.rs

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
//! SPI Commands for the Waveshare 2.9" FLEXIBLE E-PAPER DISPLAY
2+
use crate::traits;
3+
4+
#[allow(dead_code)]
5+
#[derive(Copy, Clone)]
6+
pub(crate) enum Command {
7+
PanelSetting = 0x00,
8+
/// selecting internal and external power
9+
/// self.send_data(0x03)?; //VDS_EN, VDG_EN
10+
/// self.send_data(0x00)?; //VCOM_HV, VGHL_LV[1], VGHL_LV[0]
11+
/// self.send_data(0x2b)?; //VDH
12+
/// self.send_data(0x2b)?; //VDL
13+
/// self.send_data(0xff)?; //VDHR
14+
PowerSetting = 0x01,
15+
/// After the Power Off command, the driver will power off following the Power Off Sequence. This command will turn off charge
16+
/// pump, T-con, source driver, gate driver, VCOM, and temperature sensor, but register data will be kept until VDD becomes OFF.
17+
/// Source Driver output and Vcom will remain as previous condition, which may have 2 conditions: floating.
18+
PowerOff = 0x02,
19+
/// Setting Power OFF sequence
20+
PowerOffSequenceSetting = 0x03,
21+
/// Turning On the Power
22+
PowerOn = 0x04,
23+
/// This command enables the internal bandgap, which will be cleared by the next POF.
24+
PowerOnMeasure = 0x05,
25+
/// Starting data transmission
26+
/// 3-times: self.send_data(0x17)?; //07 0f 17 1f 27 2F 37 2f
27+
BoosterSoftStart = 0x06,
28+
/// After this command is transmitted, the chip would enter the deep-sleep mode to save power.
29+
///
30+
/// The deep sleep mode would return to standby by hardware reset.
31+
///
32+
/// The only one parameter is a check code, the command would be excuted if check code = 0xA5.
33+
DeepSleep = 0x07,
34+
/// This command starts transmitting data and write them into SRAM. To complete data transmission, command DSP (Data
35+
/// transmission Stop) must be issued. Then the chip will start to send data/VCOM for panel.
36+
///
37+
/// - In B/W mode, this command writes “OLD” data to SRAM.
38+
/// - In B/W/Red mode, this command writes “B/W” data to SRAM.
39+
/// - In Program mode, this command writes “OTP” data to SRAM for programming.
40+
DataStartTransmission1 = 0x10,
41+
/// Stopping data transmission
42+
DataStop = 0x11,
43+
/// While user sent this command, driver will refresh display (data/VCOM) according to SRAM data and LUT.
44+
///
45+
/// After Display Refresh command, BUSY_N signal will become “0” and the refreshing of panel starts.
46+
DisplayRefresh = 0x12,
47+
/// This command starts transmitting data and write them into SRAM. To complete data transmission, command DSP (Data
48+
/// transmission Stop) must be issued. Then the chip will start to send data/VCOM for panel.
49+
/// - In B/W mode, this command writes “NEW” data to SRAM.
50+
/// - In B/W/Red mode, this command writes “RED” data to SRAM.
51+
DataStartTransmission2 = 0x13,
52+
53+
/// This command stores VCOM Look-Up Table with 7 groups of data. Each group contains information for one state and is stored
54+
/// with 6 bytes, while the sixth byte indicates how many times that phase will repeat.
55+
///
56+
/// from IL0373
57+
LutForVcom = 0x20,
58+
/// This command stores White-to-White Look-Up Table with 7 groups of data. Each group contains information for one state and is
59+
/// stored with 6 bytes, while the sixth byte indicates how many times that phase will repeat.
60+
///
61+
/// from IL0373
62+
LutWhiteToWhite = 0x21,
63+
/// This command stores Black-to-White Look-Up Table with 7 groups of data. Each group contains information for one state and is
64+
/// stored with 6 bytes, while the sixth byte indicates how many times that phase will repeat.
65+
///
66+
/// from IL0373
67+
LutBlackToWhite = 0x22,
68+
/// This command stores White-to-Black Look-Up Table with 7 groups of data. Each group contains information for one state and is
69+
/// stored with 6 bytes, while the sixth byte indicates how many times that phase will repeat.
70+
///
71+
/// from IL0373
72+
LutWhiteToBlack = 0x23,
73+
/// This command stores Black-to-Black Look-Up Table with 7 groups of data. Each group contains information for one state and is
74+
/// stored with 6 bytes, while the sixth byte indicates how many times that phase will repeat.
75+
///
76+
/// from IL0373
77+
LutBlackToBlack = 0x24,
78+
/// The command controls the PLL clock frequency.
79+
PllControl = 0x30,
80+
/// This command reads the temperature sensed by the temperature sensor.
81+
///
82+
/// Doesn't work! Waveshare doesn't connect the read pin
83+
TemperatureSensor = 0x40,
84+
/// Selects the Internal or External temperature sensor and offset
85+
TemperatureSensorSelection = 0x41,
86+
/// Write External Temperature Sensor
87+
TemperatureSensorWrite = 0x42,
88+
/// Read External Temperature Sensor
89+
///
90+
/// Doesn't work! Waveshare doesn't connect the read pin
91+
TemperatureSensorRead = 0x43,
92+
/// This command indicates the interval of Vcom and data output. When setting the vertical back porch, the total blanking will be kept (20 Hsync)
93+
VcomAndDataIntervalSetting = 0x50,
94+
/// This command indicates the input power condition. Host can read this flag to learn the battery condition.
95+
LowPowerDetection = 0x51,
96+
/// This command defines non-overlap period of Gate and Source.
97+
TconSetting = 0x60,
98+
/// This command defines alternative resolution and this setting is of higher priority than the RES\[1:0\] in R00H (PSR).
99+
ResolutionSetting = 0x61,
100+
/// This command defines the Fist Active Gate and First Active Source of active channels.
101+
// GsstSetting = 0x65,
102+
/// The LUT_REV / Chip Revision is read from OTP address = 0x001.
103+
///
104+
/// Doesn't work! Waveshare doesn't connect the read pin
105+
// Revision = 0x70,
106+
/// Read Flags. This command reads the IC status
107+
/// PTL, I2C_ERR, I2C_BUSY, DATA, PON, POF, BUSY
108+
///
109+
/// Doesn't work! Waveshare doesn't connect the read pin
110+
GetStatus = 0x71,
111+
/// Automatically measure VCOM. This command reads the IC status
112+
AutoMeasurementVcom = 0x80,
113+
/// This command gets the VCOM value
114+
///
115+
/// Doesn't work! Waveshare doesn't connect the read pin
116+
ReadVcomValue = 0x81,
117+
/// Set VCM_DC
118+
VcmDcSetting = 0x82,
119+
/// This command sets partial window
120+
PartialWindow = 0x90,
121+
/// This command makes the display enter partial mode
122+
PartialIn = 0x91,
123+
/// This command makes the display exit partial mode and enter normal mode
124+
PartialOut = 0x92,
125+
/// After this command is issued, the chip would enter the program mode.
126+
///
127+
/// After the programming procedure completed, a hardware reset is necessary for leaving program mode.
128+
///
129+
/// The only one parameter is a check code, the command would be excuted if check code = 0xA5.
130+
ProgramMode = 0xA0,
131+
/// After this command is transmitted, the programming state machine would be activated.
132+
///
133+
/// The BUSY flag would fall to 0 until the programming is completed.
134+
ActiveProgramming = 0xA1,
135+
/// The command is used for reading the content of OTP for checking the data of programming.
136+
///
137+
/// The value of (n) is depending on the amount of programmed data, tha max address = 0xFFF.
138+
ReadOtp = 0xA2,
139+
/// This command is set for saving power during fresh period. If the output voltage of VCOM / Source is from negative to positive or
140+
/// from positive to negative, the power saving mechanism will be activated. The active period width is defined by the following two
141+
/// parameters.
142+
PowerSaving = 0xE3,
143+
}
144+
145+
impl traits::Command for Command {
146+
/// Returns the address of the command
147+
fn address(self) -> u8 {
148+
self as u8
149+
}
150+
}

src/epd2in9d/constants.rs

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
//! This file contains look-up-tables used to set voltages used during
2+
//! various categories of pixel refreshes.
3+
4+
/**
5+
* partial screen update LUT
6+
**/
7+
#[rustfmt::skip]
8+
pub(crate) const LUT_VCOM1: [u8; 44] = [
9+
0x00, 0x19, 0x01, 0x00, 0x00, 0x01,
10+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16+
0x00, 0x00,
17+
];
18+
19+
#[rustfmt::skip]
20+
pub(crate) const LUT_WW1: [u8; 42] =[
21+
0x00, 0x19, 0x01, 0x00, 0x00, 0x01,
22+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28+
];
29+
30+
#[rustfmt::skip]
31+
pub(crate) const LUT_BW1: [u8; 42] =[
32+
0x80, 0x19, 0x01, 0x00, 0x00, 0x01,
33+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39+
];
40+
41+
#[rustfmt::skip]
42+
pub(crate) const LUT_BB1: [u8; 42] =[
43+
0x00, 0x19, 0x01, 0x00, 0x00, 0x01,
44+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50+
];
51+
52+
#[rustfmt::skip]
53+
pub(crate) const LUT_WB1: [u8; 42] =[
54+
0x40, 0x19, 0x01, 0x00, 0x00, 0x01,
55+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
56+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
57+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
58+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
59+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
60+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
61+
];

0 commit comments

Comments
 (0)