kopia lustrzana https://github.com/peterhinch/micropython-nano-gui
Add ili9341 setup file for Pi Pico.
rodzic
92ca07f699
commit
82770e9544
|
@ -0,0 +1,40 @@
|
|||
# color_setup.py Customise for your hardware config
|
||||
|
||||
# Released under the MIT License (MIT). See LICENSE.
|
||||
# Copyright (c) 2020 Peter Hinch
|
||||
|
||||
# As written, supports:
|
||||
# ili9341 240x320 displays on Pi Pico
|
||||
# Edit the driver import for other displays.
|
||||
|
||||
# Demo of initialisation procedure designed to minimise risk of memory fail
|
||||
# when instantiating the frame buffer. The aim is to do this as early as
|
||||
# possible before importing other modules.
|
||||
|
||||
# WIRING
|
||||
# Pico Display
|
||||
# GPIO Pin
|
||||
# 3v3 36 Vin
|
||||
# IO6 9 CLK Hardware SPI0
|
||||
# IO7 10 DATA (AKA SI MOSI)
|
||||
# IO8 11 DC
|
||||
# IO9 12 Rst
|
||||
# Gnd 13 Gnd
|
||||
# IO10 14 CS
|
||||
|
||||
from machine import Pin, SPI
|
||||
import gc
|
||||
|
||||
# *** Choose your color display driver here ***
|
||||
# ili9341 specific driver
|
||||
from drivers.ili93xx.ili9341 import ILI9341 as SSD
|
||||
|
||||
pdc = Pin(8, Pin.OUT, value=0) # Arbitrary pins
|
||||
prst = Pin(9, Pin.OUT, value=1)
|
||||
pcs = Pin(10, Pin.OUT, value=1)
|
||||
|
||||
# Kept as ssd to maintain compatability
|
||||
gc.collect() # Precaution before instantiating framebuf
|
||||
# See DRIVERS.md re overclocking the SPI bus
|
||||
spi = SPI(0, 10_000_000)
|
||||
ssd = SSD(spi, dc=pdc, cs=pcs, rst=prst)
|
|
@ -0,0 +1,46 @@
|
|||
# pico_setup.py Customise for your hardware config
|
||||
|
||||
# Released under the MIT License (MIT). See LICENSE.
|
||||
# Copyright (c) 2020 Peter Hinch
|
||||
|
||||
# As written, supports:
|
||||
# Adafruit 1.5" 128*128 OLED display: https://www.adafruit.com/product/1431
|
||||
# Adafruit 1.27" 128*96 display https://www.adafruit.com/product/1673
|
||||
# Edit the driver import for other displays.
|
||||
|
||||
# Demo of initialisation procedure designed to minimise risk of memory fail
|
||||
# when instantiating the frame buffer. The aim is to do this as early as
|
||||
# possible before importing other modules.
|
||||
|
||||
# WIRING
|
||||
# Pico GPIO no (package pin no. in parens)
|
||||
# Adafruit package pin nos and names.
|
||||
# Pico SSD
|
||||
# Vbus(40) Vin (10)
|
||||
# Gnd(18) Gnd (11)
|
||||
# 15(20) DC (3 DC)
|
||||
# 13(17) CS (5 OC OLEDCS)
|
||||
# 14(19) Rst (4 R RESET)
|
||||
# 10(14) CLK (2 CL SCK)
|
||||
# 11(15) DATA (1 SI MOSI)
|
||||
|
||||
import machine
|
||||
import gc
|
||||
|
||||
# *** Choose your color display driver here ***
|
||||
# Driver supporting non-STM platforms
|
||||
# from drivers.ssd1351.ssd1351_generic import SSD1351 as SSD
|
||||
|
||||
# STM specific driver
|
||||
from drivers.ssd1351.ssd1351 import SSD1351 as SSD
|
||||
|
||||
#height = 96 # 1.27 inch 96*128 (rows*cols) display
|
||||
height = 128 # 1.5 inch 128*128 display
|
||||
|
||||
pdc = machine.Pin(15, machine.Pin.OUT, value=0)
|
||||
pcs = machine.Pin(13, machine.Pin.OUT, value=1)
|
||||
prst = machine.Pin(14, machine.Pin.OUT, value=1)
|
||||
#spi = machine.SPI(1, baudrate=1_000_000)
|
||||
spi = machine.SoftSPI(sck=machine.Pin(10, machine.Pin.OUT), mosi=machine.Pin(11, machine.Pin.OUT), miso=machine.Pin(8, machine.Pin.OUT))
|
||||
gc.collect() # Precaution before instantiating framebuf
|
||||
ssd = SSD(spi, pcs, pdc, prst, height) # Create a display instance
|
|
@ -15,19 +15,14 @@ import framebuf
|
|||
import uasyncio as asyncio
|
||||
|
||||
@micropython.viper
|
||||
def _lcopy(dest:ptr8, source:ptr8, lut:ptr8, length:int):
|
||||
def _lcopy(dest:ptr16, source:ptr8, lut:ptr16, length:int):
|
||||
# rgb565 - 16bit/pixel
|
||||
n = 0
|
||||
for x in range(length):
|
||||
c = source[x]
|
||||
d = (c & 0xf0) >> 3 # 2* pointers (lut is 16 bit color)
|
||||
e = (c & 0x0f) << 1
|
||||
dest[n] = lut[d] # LS byte 1st
|
||||
dest[n] = lut[c >> 4] # current pixel
|
||||
n += 1
|
||||
dest[n] = lut[d + 1]
|
||||
n += 1
|
||||
dest[n] = lut[e]
|
||||
n += 1
|
||||
dest[n] = lut[e + 1]
|
||||
dest[n] = lut[c & 0x0f] # next pixel
|
||||
n += 1
|
||||
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue