kopia lustrzana https://github.com/peterhinch/micropython-micro-gui
Improve display driver Viper code.
rodzic
9e9f076d1b
commit
4c20bae0b0
|
@ -11,8 +11,7 @@ import asyncio
|
|||
from drivers.boolpalette import BoolPalette
|
||||
|
||||
# Initialisation ported from Russ Hughes' C driver
|
||||
# https://github.com/russhughes/gc9a01_mpy/blob/main/src/gc9a01.h
|
||||
# https://github.com/russhughes/gc9a01_mpy/blob/main/src/gc9a01.c
|
||||
# https://github.com/russhughes/gc9a01_mpy/
|
||||
# Based on a ST7789 C driver: https://github.com/devbis/st7789_mpy
|
||||
# Many registers are undocumented. Lines initialising them are commented "?"
|
||||
# in cases where initialising them seems to have no effect.
|
||||
|
@ -21,7 +20,7 @@ from drivers.boolpalette import BoolPalette
|
|||
# Waveshare touch board https://www.waveshare.com/wiki/1.28inch_Touch_LCD has CST816S touch controller
|
||||
# Touch controller uses I2C
|
||||
|
||||
# Portrait mode
|
||||
# Portrait mode. ~70μs on RP2 at standard clock.
|
||||
@micropython.viper
|
||||
def _lcopy(dest: ptr16, source: ptr8, lut: ptr16, length: int):
|
||||
# rgb565 - 16bit/pixel
|
||||
|
@ -84,7 +83,7 @@ class GC9A01(framebuf.FrameBuffer):
|
|||
sleep_ms(50)
|
||||
if self._spi_init: # A callback was passed
|
||||
self._spi_init(spi) # Bus may be shared
|
||||
self._lock = asyncio.Lock()
|
||||
self._lock = asyncio.Lock() # Prevent concurrent refreshes.
|
||||
sleep_ms(100)
|
||||
self._wcd(b"\x2a", int.to_bytes(width - 1, 4, "big"))
|
||||
# Default page address start == 0 end == 0xEF (239)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# ILI9341 nano-gui driver for ili9341 displays
|
||||
|
||||
# Copyright (c) Peter Hinch 2020
|
||||
# Copyright (c) Peter Hinch 2020-2024
|
||||
# Released under the MIT license see LICENSE
|
||||
|
||||
# This work is based on the following sources.
|
||||
|
@ -15,16 +15,20 @@ import asyncio
|
|||
from drivers.boolpalette import BoolPalette
|
||||
|
||||
|
||||
# ~80μs on RP2 @ 250MHz.
|
||||
@micropython.viper
|
||||
def _lcopy(dest: ptr16, source: ptr8, lut: ptr16, length: int):
|
||||
# rgb565 - 16bit/pixel
|
||||
n = 0
|
||||
for x in range(length):
|
||||
n: int = 0
|
||||
x: int = 0
|
||||
while length:
|
||||
c = source[x]
|
||||
dest[n] = lut[c >> 4] # current pixel
|
||||
n += 1
|
||||
dest[n] = lut[c & 0x0F] # next pixel
|
||||
n += 1
|
||||
x += 1
|
||||
length -= 1
|
||||
|
||||
|
||||
class ILI9341(framebuf.FrameBuffer):
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# ILI9486 nano-gui driver for ili9486 displays
|
||||
|
||||
# Copyright (c) Peter Hinch 2022
|
||||
# Copyright (c) Peter Hinch 2022-2024
|
||||
# Released under the MIT license see LICENSE
|
||||
|
||||
# Much help provided by @brave-ulysses in this thread
|
||||
|
@ -22,13 +22,16 @@ from drivers.boolpalette import BoolPalette
|
|||
@micropython.viper
|
||||
def _lcopy(dest: ptr16, source: ptr8, lut: ptr16, length: int):
|
||||
# rgb565 - 16bit/pixel
|
||||
n = 0
|
||||
for x in range(length):
|
||||
n: int = 0
|
||||
x: int = 0
|
||||
while length:
|
||||
c = source[x]
|
||||
dest[n] = lut[c >> 4] # current pixel
|
||||
n += 1
|
||||
dest[n] = lut[c & 0x0F] # next pixel
|
||||
n += 1
|
||||
x += 1
|
||||
length -= 1
|
||||
|
||||
|
||||
# FB is in landscape mode, hence issue a column at a time to portrait mode hardware.
|
||||
|
@ -41,7 +44,7 @@ def _lscopy(dest: ptr16, source: ptr8, lut: ptr16, ch: int):
|
|||
n = 0
|
||||
clsb = col & 1
|
||||
idx = col >> 1 # 2 pixels per byte
|
||||
for _ in range(height):
|
||||
while height:
|
||||
if clsb:
|
||||
c = source[idx] & 0x0F
|
||||
else:
|
||||
|
@ -49,6 +52,7 @@ def _lscopy(dest: ptr16, source: ptr8, lut: ptr16, ch: int):
|
|||
dest[n] = lut[c] # 16 bit transfer of rightmost 4-bit pixel
|
||||
n += 1 # 16 bit
|
||||
idx += wbytes
|
||||
height -= 1
|
||||
|
||||
|
||||
class ILI9486(framebuf.FrameBuffer):
|
||||
|
|
Ładowanie…
Reference in New Issue