Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 28 additions & 9 deletions adafruit_epd/uc8179.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,17 @@ def __init__(
sramcs_pin: DigitalInOut,
rst_pin: DigitalInOut,
busy_pin: DigitalInOut,
tri_color: bool = False,
) -> None:
# Adjust height to be divisible by 8 (direct from Arduino)
if (height % 8) != 0:
height += 8 - (height % 8)

super().__init__(width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin)

# Store whether this is a tricolor display
self._tri_color = tri_color

# Calculate buffer sizes exactly as Arduino does: width * height / 8
self._buffer1_size = width * height // 8
self._buffer2_size = self._buffer1_size
Expand Down Expand Up @@ -98,14 +102,19 @@ def __init__(
)

# Set up which frame buffer is which color
self.set_black_buffer(0, True)
self.set_color_buffer(1, False)
if self._tri_color:
self.set_black_buffer(0, False)
self.set_color_buffer(1, False)
# Tricolor has longer refresh time
self.default_refresh_delay = 13 # seconds
else:
# Monochrome settings
self.set_black_buffer(0, True)
self.set_color_buffer(1, False)
self.default_refresh_delay = 15 # seconds

# UC8179 uses single byte transactions
self._single_byte_tx = False

# Default refresh delay (from Adafruit_EPD base class in Arduino)
self.default_refresh_delay = 15 # seconds
# pylint: enable=too-many-arguments

def begin(self, reset: bool = True) -> None:
Expand Down Expand Up @@ -150,8 +159,13 @@ def power_up(self) -> None:
time.sleep(0.1) # 100ms delay
self.busy_wait()

# Panel setting
self.command(_UC8179_PANELSETTING, bytearray([0b011111])) # BW OTP LUT
# Panel setting - different for tricolor vs monochrome
if self._tri_color:
# Tricolor display: 0b000111 (0x07) - Tricolor OTP LUT
self.command(_UC8179_PANELSETTING, bytearray([0b001111]))
else:
# Monochrome display: 0b010111 (0x17) - BW OTP LUT
self.command(_UC8179_PANELSETTING, bytearray([0b011111]))

# Resolution setting
self.command(
Expand All @@ -164,8 +178,13 @@ def power_up(self) -> None:
# Dual SPI setting
self.command(_UC8179_DUALSPI, bytearray([0x00]))

# VCOM setting
self.command(_UC8179_WRITE_VCOM, bytearray([0x10, 0x07]))
# VCOM setting - different for tricolor
if self._tri_color:
# Tricolor VCOM setting
self.command(_UC8179_WRITE_VCOM, bytearray([0x90, 0x07]))
else:
# Monochrome VCOM setting
self.command(_UC8179_WRITE_VCOM, bytearray([0x10, 0x07]))

# TCON setting
self.command(_UC8179_TCON, bytearray([0x22]))
Expand Down
9 changes: 9 additions & 0 deletions examples/epd_bitmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@
rst_pin=rst,
busy_pin=busy,
)
""" display = Adafruit_UC8179(800, 480, # 7.5" tricolor 800x480 display
spi,
cs_pin=ecs,
dc_pin=dc,
sramcs_pin=srcs,
rst_pin=rst,
busy_pin=busy,
tri_color = True
)"""

# IF YOU HAVE A 2.13" FLEXIBLE DISPLAY OR!
# UC8179 5.83" or 7.5" displays
Expand Down
9 changes: 9 additions & 0 deletions examples/epd_pillow_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@
rst_pin=rst,
busy_pin=busy,
)
""" display = Adafruit_UC8179(800, 480, # 7.5" tricolor 800x480 display
spi,
cs_pin=ecs,
dc_pin=dc,
sramcs_pin=srcs,
rst_pin=rst,
busy_pin=busy,
tri_color = True
)"""

# IF YOU HAVE A 2.13" FLEXIBLE DISPLAY OR!
# UC8179 5.83" or 7.5" displays
Expand Down
9 changes: 9 additions & 0 deletions examples/epd_pillow_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@
rst_pin=rst,
busy_pin=busy,
)
""" display = Adafruit_UC8179(800, 480, # 7.5" tricolor 800x480 display
spi,
cs_pin=ecs,
dc_pin=dc,
sramcs_pin=srcs,
rst_pin=rst,
busy_pin=busy,
tri_color = True
)"""

# IF YOU HAVE A 2.13" FLEXIBLE DISPLAY OR!
# UC8179 5.83" or 7.5" displays
Expand Down
11 changes: 10 additions & 1 deletion examples/epd_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,18 @@
rst_pin=rst,
busy_pin=busy,
)
""" display = Adafruit_UC8179(800, 480, # 7.5" tricolor 800x480 display
spi,
cs_pin=ecs,
dc_pin=dc,
sramcs_pin=srcs,
rst_pin=rst,
busy_pin=busy,
tri_color = True
)"""

# IF YOU HAVE A 2.13" FLEXIBLE DISPLAY OR!
# UC8179 5.83" or 7.5" displays
# UC8179 5.83" or 7.5" monochrome displays
# uncomment these lines!
# display.set_black_buffer(1, False)
# display.set_color_buffer(1, False)
Expand Down