Skip to content

Commit 4a196bf

Browse files
committed
Add 5.83 and 5.83(B)
1 parent 4d4faf9 commit 4a196bf

File tree

2 files changed

+330
-0
lines changed

2 files changed

+330
-0
lines changed

epaper5in83.py

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
"""
2+
MicroPython Waveshare 5.83" Black/White GDEW0583T7 e-paper display driver
3+
https://github.com/mcauser/micropython-waveshare-epaper
4+
5+
MIT License
6+
Copyright (c) 2017 Waveshare
7+
Copyright (c) 2018 Mike Causer
8+
9+
Permission is hereby granted, free of charge, to any person obtaining a copy
10+
of this software and associated documentation files (the "Software"), to deal
11+
in the Software without restriction, including without limitation the rights
12+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
copies of the Software, and to permit persons to whom the Software is
14+
furnished to do so, subject to the following conditions:
15+
16+
The above copyright notice and this permission notice shall be included in all
17+
copies or substantial portions of the Software.
18+
19+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25+
SOFTWARE.
26+
"""
27+
28+
from micropython import const
29+
from time import sleep_ms
30+
import ustruct
31+
32+
# Display resolution
33+
EPD_WIDTH = const(600)
34+
EPD_HEIGHT = const(448)
35+
36+
# Display commands
37+
PANEL_SETTING = const(0x00)
38+
POWER_SETTING = const(0x01)
39+
POWER_OFF = const(0x02)
40+
#POWER_OFF_SEQUENCE_SETTING = const(0x03)
41+
POWER_ON = const(0x04)
42+
#POWER_ON_MEASURE = const(0x05)
43+
BOOSTER_SOFT_START = const(0x06)
44+
DEEP_SLEEP = const(0x07)
45+
DATA_START_TRANSMISSION_1 = const(0x10)
46+
#DATA_STOP = const(0x11)
47+
DISPLAY_REFRESH = const(0x12)
48+
#IMAGE_PROCESS = const(0x13)
49+
#LUT_FOR_VCOM = const(0x20)
50+
#LUT_BLUE = const(0x21)
51+
#LUT_WHITE = const(0x22)
52+
#LUT_GRAY_1 = const(0x23)
53+
#LUT_GRAY_2 = const(0x24)
54+
#LUT_RED_0 = const(0x25)
55+
#LUT_RED_1 = const(0x26)
56+
#LUT_RED_2 = const(0x27)
57+
#LUT_RED_3 = const(0x28)
58+
#LUT_XON = const(0x29)
59+
PLL_CONTROL = const(0x30)
60+
#TEMPERATURE_SENSOR_COMMAND = const(0x40)
61+
TEMPERATURE_CALIBRATION = const(0x41)
62+
#TEMPERATURE_SENSOR_WRITE = const(0x42)
63+
#TEMPERATURE_SENSOR_READ = const(0x43)
64+
VCOM_AND_DATA_INTERVAL_SETTING = const(0x50)
65+
#LOW_POWER_DETECTION = const(0x51)
66+
TCON_SETTING = const(0x60)
67+
TCON_RESOLUTION = const(0x61)
68+
#SPI_FLASH_CONTROL = const(0x65)
69+
#REVISION = const(0x70)
70+
#GET_STATUS = const(0x71)
71+
#AUTO_MEASUREMENT_VCOM = const(0x80)
72+
#READ_VCOM_VALUE = const(0x81)
73+
VCM_DC_SETTING = const(0x82)
74+
FLASH_MODE = const(0xE5)
75+
76+
class EPD:
77+
def __init__(self, spi, cs, dc, rst, busy):
78+
self.spi = spi
79+
self.cs = cs
80+
self.dc = dc
81+
self.rst = rst
82+
self.busy = busy
83+
self.cs.init(self.cs.OUT, value=1)
84+
self.dc.init(self.dc.OUT, value=0)
85+
self.rst.init(self.rst.OUT, value=0)
86+
self.busy.init(self.busy.IN)
87+
self.width = EPD_WIDTH
88+
self.height = EPD_HEIGHT
89+
90+
def _command(self, command, data=None):
91+
self.dc.low()
92+
self.cs.low()
93+
self.spi.write(bytearray([command]))
94+
self.cs.high()
95+
if data is not None:
96+
self._data(data)
97+
98+
def _data(self, data):
99+
self.dc.high()
100+
self.cs.low()
101+
self.spi.write(data)
102+
self.cs.high()
103+
104+
def init(self):
105+
self.reset()
106+
self._command(POWER_SETTING, b'\x37\x00')
107+
self._command(PANEL_SETTING, b'\xCF\x08')
108+
self._command(BOOSTER_SOFT_START, b'\xC7\xCC\x28')
109+
self._command(POWER_ON)
110+
self.wait_until_idle()
111+
self._command(PLL_CONTROL, b'\x3C')
112+
self._command(TEMPERATURE_CALIBRATION, b'\x00')
113+
self._command(VCOM_AND_DATA_INTERVAL_SETTING, b'\x77')
114+
self._command(TCON_SETTING, b'\x22')
115+
self._command(TCON_RESOLUTION, b'\x02\x58\x01\xC0') # 0x02 = source 600, 0x01 = gate 448
116+
self._command(VCM_DC_SETTING, b'\x1E') # decide by LUT file
117+
self._command(FLASH_MODE, b'\x03')
118+
119+
def wait_until_idle(self):
120+
while self.busy.value() == 0:
121+
sleep_ms(100)
122+
123+
def reset(self):
124+
self.rst.low()
125+
sleep_ms(200)
126+
self.rst.high()
127+
sleep_ms(200)
128+
129+
# draw the current frame memory
130+
def display_frame(self, frame_buffer):
131+
if (frame_buffer != None):
132+
self._command(DATA_START_TRANSMISSION_1)
133+
for i in range(0, self.width // 4 * self.height):
134+
temp1 = frame_buffer[i]
135+
j = 0
136+
while (j < 4):
137+
if ((temp1 & 0xC0) == 0xC0):
138+
temp2 = 0x03
139+
elif ((temp1 & 0xC0) == 0x00):
140+
temp2 = 0x00
141+
else:
142+
temp2 = 0x04
143+
temp2 = (temp2 << 4) & 0xFF
144+
temp1 = (temp1 << 2) & 0xFF
145+
j += 1
146+
if((temp1 & 0xC0) == 0xC0):
147+
temp2 |= 0x03
148+
elif ((temp1 & 0xC0) == 0x00):
149+
temp2 |= 0x00
150+
else:
151+
temp2 |= 0x04
152+
temp1 = (temp1 << 2) & 0xFF
153+
self._data(bytearray([temp2]))
154+
j += 1
155+
self._command(DISPLAY_REFRESH)
156+
sleep_ms(100)
157+
self.wait_until_idle()
158+
159+
# to wake call reset() or init()
160+
def sleep(self):
161+
self._command(POWER_OFF)
162+
self.wait_until_idle()
163+
self._command(DEEP_SLEEP, b'\xA5')

epaper5in83b.py

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
"""
2+
MicroPython Waveshare 5.83" Black/White/Red GDEW0583Z21 e-paper display driver
3+
https://github.com/mcauser/micropython-waveshare-epaper
4+
5+
MIT License
6+
Copyright (c) 2017 Waveshare
7+
Copyright (c) 2018 Mike Causer
8+
9+
Permission is hereby granted, free of charge, to any person obtaining a copy
10+
of this software and associated documentation files (the "Software"), to deal
11+
in the Software without restriction, including without limitation the rights
12+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
copies of the Software, and to permit persons to whom the Software is
14+
furnished to do so, subject to the following conditions:
15+
16+
The above copyright notice and this permission notice shall be included in all
17+
copies or substantial portions of the Software.
18+
19+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25+
SOFTWARE.
26+
"""
27+
28+
from micropython import const
29+
from time import sleep_ms
30+
import ustruct
31+
32+
# Display resolution
33+
EPD_WIDTH = const(600)
34+
EPD_HEIGHT = const(448)
35+
36+
# Display commands
37+
PANEL_SETTING = const(0x00)
38+
POWER_SETTING = const(0x01)
39+
POWER_OFF = const(0x02)
40+
#POWER_OFF_SEQUENCE_SETTING = const(0x03)
41+
POWER_ON = const(0x04)
42+
#POWER_ON_MEASURE = const(0x05)
43+
BOOSTER_SOFT_START = const(0x06)
44+
DEEP_SLEEP = const(0x07)
45+
DATA_START_TRANSMISSION_1 = const(0x10)
46+
#DATA_STOP = const(0x11)
47+
DISPLAY_REFRESH = const(0x12)
48+
#IMAGE_PROCESS = const(0x13)
49+
#LUT_FOR_VCOM = const(0x20)
50+
#LUT_BLUE = const(0x21)
51+
#LUT_WHITE = const(0x22)
52+
#LUT_GRAY_1 = const(0x23)
53+
#LUT_GRAY_2 = const(0x24)
54+
#LUT_RED_0 = const(0x25)
55+
#LUT_RED_1 = const(0x26)
56+
#LUT_RED_2 = const(0x27)
57+
#LUT_RED_3 = const(0x28)
58+
#LUT_XON = const(0x29)
59+
PLL_CONTROL = const(0x30)
60+
#TEMPERATURE_SENSOR_COMMAND = const(0x40)
61+
TEMPERATURE_CALIBRATION = const(0x41)
62+
#TEMPERATURE_SENSOR_WRITE = const(0x42)
63+
#TEMPERATURE_SENSOR_READ = const(0x43)
64+
VCOM_AND_DATA_INTERVAL_SETTING = const(0x50)
65+
#LOW_POWER_DETECTION = const(0x51)
66+
TCON_SETTING = const(0x60)
67+
TCON_RESOLUTION = const(0x61)
68+
#SPI_FLASH_CONTROL = const(0x65)
69+
#REVISION = const(0x70)
70+
#GET_STATUS = const(0x71)
71+
#AUTO_MEASUREMENT_VCOM = const(0x80)
72+
#READ_VCOM_VALUE = const(0x81)
73+
VCM_DC_SETTING = const(0x82)
74+
FLASH_MODE = const(0xE5)
75+
76+
class EPD:
77+
def __init__(self, spi, cs, dc, rst, busy):
78+
self.spi = spi
79+
self.cs = cs
80+
self.dc = dc
81+
self.rst = rst
82+
self.busy = busy
83+
self.cs.init(self.cs.OUT, value=1)
84+
self.dc.init(self.dc.OUT, value=0)
85+
self.rst.init(self.rst.OUT, value=0)
86+
self.busy.init(self.busy.IN)
87+
self.width = EPD_WIDTH
88+
self.height = EPD_HEIGHT
89+
90+
def _command(self, command, data=None):
91+
self.dc.low()
92+
self.cs.low()
93+
self.spi.write(bytearray([command]))
94+
self.cs.high()
95+
if data is not None:
96+
self._data(data)
97+
98+
def _data(self, data):
99+
self.dc.high()
100+
self.cs.low()
101+
self.spi.write(data)
102+
self.cs.high()
103+
104+
def init(self):
105+
self.reset()
106+
self._command(POWER_SETTING, b'\x37\x00')
107+
self._command(PANEL_SETTING, b'\xCF\x08')
108+
self._command(BOOSTER_SOFT_START, b'\xC7\xCC\x28')
109+
self._command(POWER_ON)
110+
self.wait_until_idle()
111+
self._command(PLL_CONTROL, b'\x3C')
112+
self._command(TEMPERATURE_CALIBRATION, b'\x00')
113+
self._command(VCOM_AND_DATA_INTERVAL_SETTING, b'\x77')
114+
self._command(TCON_SETTING, b'\x22')
115+
self._command(TCON_RESOLUTION, b'\x02\x58\x01\xC0') # 0x02 = source 600, 0x01 = gate 448
116+
self._command(VCM_DC_SETTING, b'\x20') # decide by LUT file
117+
self._command(FLASH_MODE, b'\x03')
118+
119+
def wait_until_idle(self):
120+
while self.busy.value() == 0:
121+
sleep_ms(100)
122+
123+
def reset(self):
124+
self.rst.low()
125+
sleep_ms(200)
126+
self.rst.high()
127+
sleep_ms(200)
128+
129+
# draw the current frame memory
130+
def display_frame(self, frame_buffer_black, frame_buffer_red):
131+
if (frame_buffer != None and frame_buffer_red != None):
132+
self._command(DATA_START_TRANSMISSION_1)
133+
for i in range(0, self.width // 8 * self.height):
134+
temp1 = frame_buffer_black[i]
135+
temp2 = frame_buffer_red[i]
136+
j = 0
137+
while (j < 8):
138+
if ((temp2 & 0x80) == 0x00):
139+
temp3 = 0x04 #red
140+
elif ((temp1 & 0x80) == 0x00):
141+
temp3 = 0x00 #black
142+
else:
143+
temp3 = 0x03 #white
144+
145+
temp3 = (temp3 << 4) & 0xFF
146+
temp1 = (temp1 << 1) & 0xFF
147+
temp2 = (temp2 << 1) & 0xFF
148+
j += 1
149+
if ((temp2 & 0x80) == 0x00):
150+
temp3 |= 0x04 #red
151+
elif ((temp1 & 0x80) == 0x00):
152+
temp3 |= 0x00 #black
153+
else:
154+
temp3 |= 0x03 #white
155+
temp1 = (temp1 << 1) & 0xFF
156+
temp2 = (temp2 << 1) & 0xFF
157+
self._data(bytearray([temp3]))
158+
j += 1
159+
self._command(DISPLAY_REFRESH)
160+
sleep_ms(100)
161+
self.wait_until_idle()
162+
163+
# to wake call reset() or init()
164+
def sleep(self):
165+
self._command(POWER_OFF)
166+
self.wait_until_idle()
167+
self._command(DEEP_SLEEP, b'\xA5')

0 commit comments

Comments
 (0)