Skip to content

Commit

Permalink
add Waveshare 7.5" B V2 (#95)
Browse files Browse the repository at this point in the history
* preliminary B/W support
  • Loading branch information
TheGreyDiamond authored Jul 16, 2022
1 parent cf46954 commit c2a5d72
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 1 deletion.
1 change: 1 addition & 0 deletions papertty/drivers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ All of the SPI displays listed on the Waveshare Wiki at the time of writing are
- **EPD 7.5" (monochrome)**
- **EPD 7.5" (monochrome, GDEW075T7, only full refresh)**
- **EPD 7.5" B (black/white/red)**
- **EPD 7.5" B V2 (black/white/red)**
- **EPD 7.5" C (black/white/yellow)** - should work with `EPD7in5b`
- **Displays using the IT8951 controller (6", 7.8", 9.7", 10.3")**
- **Special drivers**
Expand Down
117 changes: 117 additions & 0 deletions papertty/drivers/drivers_color.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,123 @@ def sleep(self):
self.send_data(0xa5)


class EPD7in5b_V2(WaveshareColor):
"""Waveshare 7.5" B V2 - black / white / red"""

IMAGE_PROCESS = 0x13
LUT_BLUE = 0x21
LUT_GRAY_1 = 0x23
LUT_GRAY_2 = 0x24
LUT_RED_0 = 0x25
LUT_RED_1 = 0x26
LUT_RED_2 = 0x27
LUT_RED_3 = 0x28
LUT_WHITE = 0x22
LUT_XON = 0x29
READ_VCOM_VALUE = 0x81
REVISION = 0x70
SPI_FLASH_CONTROL = 0x65
TCON_RESOLUTION = 0x61
TEMPERATURE_CALIBRATION = 0x41

def __init__(self):
super().__init__(name='7.5" B V2', width=800, height=480)
print("!! You are using an EXPERIMENTAL DRIVER, USE AT OWN RISK !!")

def init(self, **kwargs):
if self.epd_init() != 0:
return -1
self.reset()

self.send_command(self.POWER_SETTING)
self.send_data(0x07)
self.send_data(0x07)#VGH=20V,VGL=-20V
self.send_data(0x3f)#VDH=15V
self.send_data(0x3f)#VDL=-15V
self.send_command(self.POWER_ON)
self.wait_until_idle()

self.send_command(self.PANEL_SETTING)
self.send_data(0x0F) #KW-3f KWR-2F BWROTP 0f BWOTP 1f
self.send_command(0x61)

self.send_data(0x03) #source 800
self.send_data(0x20)
self.send_data(0x01) #gate 480
self.send_data(0xE0)


self.send_command(0X15)
self.send_data(0x00)

self.send_command(self.VCOM_AND_DATA_INTERVAL_SETTING); #VCOM AND DATA INTERVAL SETTING
self.send_data(0x11)
self.send_data(0x07)

self.send_command(self.TCON_SETTING) #TCON SETTING
self.send_data(0x22)

self.send_command(0x65)
self.send_data(0x00)
self.send_data(0x00)
self.send_data(0x00)
self.send_data(0x00)


def getbuffer(self, image):
img = image
imwidth, imheight = img.size
if(imwidth == self.width and imheight == self.height):
img = img.convert('1')
elif(imwidth == self.height and imheight == self.width):
# image has correct dimensions, but needs to be rotated
img = img.rotate(90, expand=True).convert('1')
else:
print("Wrong image dimensions: must be " + str(self.width) + "x" + str(self.height))
# return a blank buffer
return [0x00] * (int(self.width/8) * self.height)

buf = bytearray(img.tobytes('raw'))
# The bytes need to be inverted, because in the PIL world 0=black and 1=white, but
# in the e-paper world 0=white and 1=black.
for i in range(len(buf)):
buf[i] ^= 0xFF
return buf

def display_frame(self, frame_buffer, *args):
frame_buffer_red = args[0] if args else None

if frame_buffer:
self.send_command(self.DATA_START_TRANSMISSION_1)
self.delay_ms(2)
for i in range(0, int(self.width * self.height / 8)):
self.send_data(frame_buffer[i])
## self.send_data(0)
self.delay_ms(2)

self.send_command(0x13)

if frame_buffer_red:
#self.send_command(self.DATA_START_TRANSMISSION_2)
self.delay_ms(2)
for i in range(0, int(self.width * self.height / 8)):
self.send_data(frame_buffer_red[i])
self.delay_ms(2)
else:
for i in range(0, int(self.width * self.height / 8)):
self.send_data(0x00)

self.send_command(0x12)
self.send_command(self.DISPLAY_REFRESH)
self.delay_ms(100)
self.wait_until_idle()

def sleep(self):
self.send_command(self.POWER_OFF)
self.wait_until_idle()
self.send_command(self.DEEP_SLEEP)
self.send_data(0xa5)

class EPD5in65f(WaveshareColor):
"""Waveshare 5.65" - 7 colors"""

Expand Down
2 changes: 1 addition & 1 deletion papertty/papertty.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ def get_drivers():
drivers_partial.EPD2in13d, driver_4in2.EPD4in2,

drivers_full.EPD2in7, drivers_full.EPD3in7, drivers_full.EPD7in5,
drivers_full.EPD7in5v2,
drivers_color.EPD7in5b_V2, drivers_full.EPD7in5v2,

drivers_color.EPD4in2b, drivers_color.EPD7in5b,
drivers_color.EPD5in83, drivers_color.EPD5in83b,
Expand Down

0 comments on commit c2a5d72

Please sign in to comment.