Skip to content

Commit a736e2a

Browse files
authored
Merge pull request #14 from tannewt/little_endian
Fix partial update coordinates
2 parents 67ccde8 + a2423d5 commit a736e2a

File tree

2 files changed

+88
-1
lines changed

2 files changed

+88
-1
lines changed

adafruit_ssd1680.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,5 +98,6 @@ 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
)

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 terminalio
17+
import adafruit_ssd1680
18+
19+
displayio.release_displays()
20+
21+
# This pinout works on a Feather RP2040 EPD and may need to be altered for other
22+
# boards. The newer SSD1680 version with FPC on the ribbon cable 2.13" dual color
23+
# is connected directly via the ribbon cable.
24+
spi = busio.SPI(board.EPD_SCK, board.EPD_MOSI) # Uses SCK and MOSI
25+
epd_cs = board.EPD_CS
26+
epd_dc = board.EPD_DC
27+
epd_reset = board.EPD_RESET
28+
epd_busy = board.EPD_BUSY
29+
30+
display_bus = displayio.FourWire(
31+
spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset, baudrate=1000000
32+
)
33+
display = adafruit_ssd1680.SSD1680(
34+
display_bus,
35+
colstart=8,
36+
width=250,
37+
height=122,
38+
busy_pin=epd_busy,
39+
highlight_color=0xFFFFFF,
40+
rotation=270,
41+
seconds_per_frame=10,
42+
)
43+
44+
# Make the display context
45+
main_group = displayio.Group()
46+
display.show(main_group)
47+
48+
palette = displayio.Palette(2)
49+
palette[0] = 0x000000
50+
palette[1] = 0xFFFFFF
51+
52+
zero_glyph = terminalio.FONT.get_glyph(ord("0"))
53+
54+
padding = max(zero_glyph.height, zero_glyph.width) + 1
55+
label = displayio.TileGrid(
56+
terminalio.FONT.bitmap,
57+
pixel_shader=palette,
58+
tile_width=zero_glyph.width,
59+
tile_height=zero_glyph.height,
60+
)
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)