kopia lustrzana https://github.com/peterhinch/micropython-nano-gui
ili9488.py: Add acknowledgement of Carl Pottle.
rodzic
e136541191
commit
332fd6d709
|
@ -6,14 +6,15 @@
|
|||
# Copyright (c) Peter Hinch 2022-2025
|
||||
# Released under the MIT license see LICENSE
|
||||
|
||||
#
|
||||
# This driver, adapted from ILI9486, was contributed by Carl Pottle (cpottle9).
|
||||
|
||||
# Note: If your hardware uses the ILI9488 parallel interface
|
||||
# you will likely be better off using the ili9486 driver.
|
||||
# It will send 2 bytes per pixel which will run faster.
|
||||
#
|
||||
# You must use this driver only when using the ILI9488 SPI
|
||||
# interface. It will send 3 bytes per pixel.
|
||||
#
|
||||
|
||||
|
||||
from time import sleep_ms
|
||||
import gc
|
||||
|
@ -80,6 +81,7 @@ def _lcopy(dest: ptr8, source: ptr8, lut: ptr16, length: int) :
|
|||
|
||||
x += 1
|
||||
|
||||
|
||||
# FB is in landscape mode greyscale
|
||||
@micropython.viper
|
||||
def _lscopy_gs(dest: ptr8, source: ptr8, ch: int):
|
||||
|
@ -94,7 +96,7 @@ def _lscopy_gs(dest: ptr8, source: ptr8, ch: int) :
|
|||
if clsb:
|
||||
c = source[idx] << 4
|
||||
else:
|
||||
c = source[idx] & 0xf0
|
||||
c = source[idx] & 0xF0
|
||||
dest[n] = c
|
||||
n += 1
|
||||
dest[n] = c
|
||||
|
@ -104,6 +106,7 @@ def _lscopy_gs(dest: ptr8, source: ptr8, ch: int) :
|
|||
idx += wbytes
|
||||
height -= 1
|
||||
|
||||
|
||||
# FB is in landscape mode color, hence issue a column at a time to portrait mode hardware.
|
||||
@micropython.viper
|
||||
def _lscopy(dest: ptr8, source: ptr8, lut: ptr16, ch: int):
|
||||
|
@ -142,9 +145,7 @@ class ILI9488(framebuf.FrameBuffer):
|
|||
# byte order not swapped (compared to ili9486 driver).
|
||||
@classmethod
|
||||
def rgb(cls, r, g, b):
|
||||
return cls.COLOR_INVERT ^ (
|
||||
(r & 0xF8) << 8 | (g & 0xFC) << 3 | (b >> 3)
|
||||
)
|
||||
return cls.COLOR_INVERT ^ ((r & 0xF8) << 8 | (g & 0xFC) << 3 | (b >> 3))
|
||||
|
||||
# Transpose width & height for landscape mode
|
||||
def __init__(
|
||||
|
@ -289,11 +290,15 @@ class ILI9488(framebuf.FrameBuffer):
|
|||
self._spi_init(self._spi) # Bus may be shared
|
||||
self._cs(0)
|
||||
if cm:
|
||||
for start in range(wd * line, wd * (line + lines), wd): # For each line
|
||||
for start in range(
|
||||
wd * line, wd * (line + lines), wd
|
||||
): # For each line
|
||||
_lcopy_gs(lb, buf[start:], wd) # Copy and greyscale
|
||||
self._spi.write(lb)
|
||||
else:
|
||||
for start in range(wd * line, wd * (line + lines), wd): # For each line
|
||||
for start in range(
|
||||
wd * line, wd * (line + lines), wd
|
||||
): # For each line
|
||||
_lcopy(lb, buf[start:], clut, wd) # Copy and map colors
|
||||
self._spi.write(lb)
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue