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
8 changes: 6 additions & 2 deletions adafruit_rgb_display/ili9341.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import ustruct
try:
import struct
except ImportError:
import ustruct as struct

from adafruit_rgb_display.rgb import DisplaySPI


Expand Down Expand Up @@ -60,4 +64,4 @@ def scroll(self, dy=None):
if dy is None:
return self._scroll
self._scroll = (self._scroll + dy) % self.height
self._write(0x37, ustruct.pack('>H', self._scroll))
self._write(0x37, struct.pack('>H', self._scroll))
13 changes: 8 additions & 5 deletions adafruit_rgb_display/rgb.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import time
import ustruct
try:
import struct
except ImportError:
import ustruct as struct

import adafruit_bus_device.spi_device as spi_device

Expand Down Expand Up @@ -45,22 +48,22 @@ def _block(self, x0, y0, x1, y1, data=None):
self._write(self._COLUMN_SET, self._encode_pos(x0, x1))
self._write(self._PAGE_SET, self._encode_pos(y0, y1))
if data is None:
size = ustruct.calcsize(self._DECODE_PIXEL)
size = struct.calcsize(self._DECODE_PIXEL)
return self._read(self._RAM_READ,
(x1 - x0 + 1) * (y1 - y0 + 1) * size)
self._write(self._RAM_WRITE, data)

def _encode_pos(self, a, b):
"""Encode a postion into bytes."""
return ustruct.pack(self._ENCODE_POS, a, b)
return struct.pack(self._ENCODE_POS, a, b)

def _encode_pixel(self, color):
"""Encode a pixel color into bytes."""
return ustruct.pack(self._ENCODE_PIXEL, color)
return struct.pack(self._ENCODE_PIXEL, color)

def _decode_pixel(self, data):
"""Decode bytes into a pixel color."""
return color565(*ustruct.unpack(self._DECODE_PIXEL, data))
return color565(*struct.unpack(self._DECODE_PIXEL, data))

def pixel(self, x, y, color=None):
"""Read or write a pixel."""
Expand Down
9 changes: 6 additions & 3 deletions adafruit_rgb_display/st7735.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from adafruit_rgb_display.rgb import DisplaySPI
import ustruct
try:
import struct
except ImportError:
import ustruct as struct


_NOP=const(0x00)
Expand Down Expand Up @@ -132,8 +135,8 @@ def __init__(self, spi, dc, cs, rst=None, width=128, height=160):

def init(self):
super().init()
cols = ustruct.pack('>HH', 0, self.width - 1)
rows = ustruct.pack('>HH', 0, self.height - 1)
cols = struct.pack('>HH', 0, self.width - 1)
rows = struct.pack('>HH', 0, self.height - 1)
for command, data in (
(_CASET, cols),
(_RASET, rows),
Expand Down