2020-11-05 10:10:21 +00:00
|
|
|
# color_setup.py Customise for your hardware config
|
2020-11-03 18:43:24 +00:00
|
|
|
|
|
|
|
# Released under the MIT License (MIT). See LICENSE.
|
|
|
|
# Copyright (c) 2020 Peter Hinch
|
|
|
|
|
2020-11-05 10:10:21 +00:00
|
|
|
# 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.
|
|
|
|
|
2020-11-03 18:43:24 +00:00
|
|
|
# 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.
|
|
|
|
|
2020-11-05 11:45:42 +00:00
|
|
|
# WIRING (Adafruit pin nos and names).
|
2020-11-03 18:43:24 +00:00
|
|
|
# Pyb SSD
|
|
|
|
# 3v3 Vin (10)
|
|
|
|
# Gnd Gnd (11)
|
|
|
|
# Y1 DC (3 DC)
|
|
|
|
# Y2 CS (5 OC OLEDCS)
|
|
|
|
# Y3 Rst (4 R RESET)
|
|
|
|
# Y6 CLK (2 CL SCK)
|
|
|
|
# Y8 DATA (1 SI MOSI)
|
|
|
|
|
|
|
|
import machine
|
|
|
|
import gc
|
2020-11-05 10:10:21 +00:00
|
|
|
|
|
|
|
# *** Choose your color display driver here ***
|
|
|
|
# Driver supporting non-STM platforms
|
|
|
|
# from drivers.ssd1351.ssd1351_generic import SSD1351 as SSD
|
|
|
|
|
|
|
|
# STM specific driver
|
2020-11-03 18:43:24 +00:00
|
|
|
from drivers.ssd1351.ssd1351 import SSD1351 as SSD
|
|
|
|
|
2021-02-14 17:11:26 +00:00
|
|
|
#height = 96 # 1.27 inch 96*128 (rows*cols) display
|
|
|
|
height = 128 # 1.5 inch 128*128 display
|
2020-11-03 18:43:24 +00:00
|
|
|
|
|
|
|
pdc = machine.Pin('Y1', machine.Pin.OUT_PP, value=0)
|
|
|
|
pcs = machine.Pin('Y2', machine.Pin.OUT_PP, value=1)
|
|
|
|
prst = machine.Pin('Y3', machine.Pin.OUT_PP, value=1)
|
|
|
|
spi = machine.SPI(2)
|
|
|
|
gc.collect() # Precaution before instantiating framebuf
|
|
|
|
ssd = SSD(spi, pcs, pdc, prst, height) # Create a display instance
|