|
41 | 41 | __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display.git"
|
42 | 42 |
|
43 | 43 | # This is the size of the buffer to be used for fill operations, in 16-bit
|
44 |
| -# units. #We use 256, which is 512 bytes — size of the DMA buffer on SAMD21. |
45 |
| -_BUFFER_SIZE = const(256) |
46 |
| -# If we're on CPython, we have more memory, so get a big ol chunk! |
| 44 | +# units. |
47 | 45 | try:
|
| 46 | + # If we're on CPython, try to set as large as possible |
48 | 47 | import platform
|
49 | 48 | if "CPython" in platform.python_implementation():
|
50 |
| - _BUFFER_SIZE = const(320*240) # blit the whole thing at once |
| 49 | + # check for FT232H special case |
| 50 | + import os |
| 51 | + if os.environ['BLINKA_FT232H']: |
| 52 | + # we are limited by pyftdi's max SPI payload |
| 53 | + from pyftdi.spi import SpiController |
| 54 | + _BUFFER_SIZE = SpiController.PAYLOAD_MAX_LENGTH // 2 # max bytes / bytes per pixel |
| 55 | + else: |
| 56 | + # set it to blit the whole thing |
| 57 | + _BUFFER_SIZE = 320 * 240 |
| 58 | + else: |
| 59 | + # in case CircuitPython ever implements platform |
| 60 | + _BUFFER_SIZE = 256 |
51 | 61 | except ImportError:
|
52 |
| - pass |
| 62 | + # Otherwise set smaller MCU friendly size |
| 63 | + _BUFFER_SIZE = 256 |
53 | 64 |
|
54 | 65 | def color565(r, g=0, b=0):
|
55 | 66 | """Convert red, green and blue values (0-255) into a 16-bit 565 encoding. As
|
@@ -200,6 +211,7 @@ def fill_rectangle(self, x, y, width, height, color):
|
200 | 211 | pixel = self._encode_pixel(color)
|
201 | 212 | if chunks:
|
202 | 213 | data = pixel * _BUFFER_SIZE
|
| 214 | + print(pixel, len(data)) |
203 | 215 | for _ in range(chunks):
|
204 | 216 | self.write(None, data)
|
205 | 217 | self.write(None, pixel * rest)
|
|
0 commit comments