Skip to content

Commit d4a137b

Browse files
committed
Fix ST7789 PIO driver swapping pairs of pixels
Have to use 2 byte transfers with DMA. It still achieves the theoretical transfer time
1 parent 0e9857b commit d4a137b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

cv2_drivers/displays/st7789_pio.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ def __init__(
7070
# Call the parent class constructor
7171
super().__init__(width, height, rotation, color_order, reverse_bytes_in_word)
7272

73-
# Change the transfer size to 4 bytes for faster throughput
74-
self._setup_sm_and_dma(4)
73+
# Change the transfer size to 2 bytes for faster throughput. Can't do 4
74+
# bytes, because then pairs of pixels get swapped
75+
self._setup_sm_and_dma(2)
7576

7677
def _setup_sm_and_dma(self, bytes_per_transfer):
7778
# Store the bytes per transfer for later use
@@ -96,7 +97,8 @@ def _setup_sm_and_dma(self, bytes_per_transfer):
9697
dma_ctrl = self.dma.pack_ctrl(
9798
size = {1:0, 2:1, 4:2}[bytes_per_transfer], # 0 = 8-bit, 1 = 16-bit, 2 = 32-bit
9899
inc_write = False,
99-
treq_sel = req_num
100+
treq_sel = req_num,
101+
bswap = False
100102
)
101103
self.dma.config(
102104
write = self.sm,

0 commit comments

Comments
 (0)