Skip to content

Commit 96dbaf1

Browse files
committed
Fix partial update coordinates
The addresses are little endian. CircuitPython 8.1.0+ is needed for this to work.
1 parent 67ccde8 commit 96dbaf1

File tree

2 files changed

+89
-1
lines changed

2 files changed

+89
-1
lines changed

adafruit_ssd1680.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,5 +98,7 @@ def __init__(self, bus: displayio.Fourwire, **kwargs) -> None:
9898
set_current_column_command=0x4E,
9999
set_current_row_command=0x4F,
100100
refresh_display_command=0x20,
101-
always_toggle_chip_select=True,
101+
always_toggle_chip_select=False,
102+
address_little_endian=True
102103
)
104+

examples/ssd1680_four_corners.py

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2023 Scott Shawcroft for Adafruit Industries
2+
# SPDX-FileCopyrightText: Copyright (c) 2021 Melissa LeBlanc-Williams for Adafruit Industries
3+
#
4+
# SPDX-License-Identifier: Unlicense
5+
6+
"""Test partial updates by moving a simple label around each of the four corners."""
7+
8+
# The top left is 0 or 4, top right is 1 or 5, bottom left is 2 or 6 and bottom
9+
# right is 3 or 7. (It does % 8 for the label and % 4 for position.)
10+
# pylint: disable=no-member
11+
12+
import time
13+
import board
14+
import busio
15+
import displayio
16+
import digitalio
17+
import terminalio
18+
import adafruit_ssd1680
19+
20+
displayio.release_displays()
21+
22+
# This pinout works on a Feather RP2040 EPD and may need to be altered for other
23+
# boards. The newer SSD1680 version with FPC on the ribbon cable 2.13" dual color
24+
# is connected directly via the ribbon cable.
25+
spi = busio.SPI(board.EPD_SCK, board.EPD_MOSI) # Uses SCK and MOSI
26+
epd_cs = board.EPD_CS
27+
epd_dc = board.EPD_DC
28+
epd_reset = board.EPD_RESET
29+
epd_busy = board.EPD_BUSY
30+
31+
display_bus = displayio.FourWire(
32+
spi,
33+
command=epd_dc,
34+
chip_select=epd_cs,
35+
reset=epd_reset,
36+
baudrate=1000000
37+
)
38+
display = adafruit_ssd1680.SSD1680(
39+
display_bus,
40+
colstart=8,
41+
width=250,
42+
height=122,
43+
busy_pin=epd_busy,
44+
highlight_color=0xFFFFFF,
45+
rotation=270,
46+
seconds_per_frame=10
47+
)
48+
49+
# Make the display context
50+
main_group = displayio.Group()
51+
display.show(main_group)
52+
53+
palette = displayio.Palette(2)
54+
palette[0] = 0x000000
55+
palette[1] = 0xffffff
56+
57+
zero_glyph = terminalio.FONT.get_glyph(ord('0'))
58+
59+
padding = max(zero_glyph.height, zero_glyph.width) + 1
60+
label = displayio.TileGrid(terminalio.FONT.bitmap, pixel_shader=palette, tile_width=zero_glyph.width, tile_height=zero_glyph.height)
61+
main_group.append(label)
62+
63+
# Number each of the 4 corners
64+
i = 0
65+
while True:
66+
if i % 2 == 0:
67+
label.x = padding
68+
else:
69+
label.x = display.width - padding - zero_glyph.width
70+
if (i % 4) // 2 == 0:
71+
label.y = padding
72+
else:
73+
label.y = display.height - padding - zero_glyph.height
74+
75+
label[0] = zero_glyph.tile_index + i
76+
77+
# update text property to change the text showing on the display
78+
sleep_time = display.time_to_refresh
79+
print(f"Sleeping {sleep_time} seconds")
80+
time.sleep(sleep_time)
81+
82+
print(f"{i % 8} @ ({label.x}, {label.y})")
83+
display.refresh()
84+
85+
i += 1
86+
i %= 8

0 commit comments

Comments
 (0)