Add notes and setup file for ESP8266.

ili9341
Peter Hinch 2020-11-18 10:41:15 +00:00
rodzic 52622ab0e6
commit bf898d323c
3 zmienionych plików z 87 dodań i 2 usunięć

Wyświetl plik

@ -53,6 +53,7 @@ wiring details, pin names and hardware issues.
3.7 [Class Textbox](./README.md#37-class-textbox) Scrolling text display.
4. [Device drivers](./README.md#4-device-drivers) Device driver compatibility
requirements (these are minimal).
5. [ESP8266](./README.md#5-esp8266) This can work.
# 1. Introduction
@ -179,6 +180,8 @@ MicroPython target and the electrical connections between display and target.
* `esp32_setup.py` As written supports an ESP32 connected to a 128x128 SSD1351
display. After editing to match the display and wiring, it should be copied to
the target as `/pyboard/color_setup.py`.
* `esp8266_setup.py` Similar for [ESP8266](./README.md#5-esp8266). Usage is
somewhat experimental.
The `gui/core` directory contains the GUI core and its principal dependencies:
@ -797,3 +800,51 @@ Drivers for displays using I2C may need to use
depending on the chip requirements.
###### [Contents](./README.md#contents)
# 5. ESP8266
Some personal observations on successful use with an ESP8266.
I chose an [Adafruit 128x128 OLED display](https://www.adafruit.com/product/1431)
to represent the biggest display I thought the ESP8266 might support. I
reasoned that, if this can be made to work, smaller or monochrome displays
would be no problem.
The ESP8266 is a minimal platform with typically 36.6KiB of free RAM. The
framebuffer for a 128*128 OLED requires 16KiB of contiguous RAM (the display
hardware uses 16 bit color but my driver uses an 8 bit buffer to conserve RAM).
A further issue is that, by default, ESP8266 firmware does not support complex
numbers. This rules out the plot module and the `Dial` widget. It is possible
to turn on complex support in the build, but I haven't tried this.
I set out to run the `scale.py` and `textbox.py` demos as these use `uasyncio`
to create dynamic content, and the widgets themselves are relatively complex.
I froze a subset of the `drivers` and the `gui` directories. A subset minimises
the size of the firmware build and eliminates modules which won't compile due
to the complex number issue. The directory structure in my frozen modules
directory matched that of the source: the directory had `gui` and `drivers`
subdirectories with their subdirectories intact (where they had necessary
contents).
In the following description, `__init__.py` was always left in place.
From `drivers` I removed everything except `ssd1351/ssd1351_generic.py`.
From `gui/fonts` I removed fonts except for `arial10`.
From `gui/demos` I removed all but `scale.py` and `tbox.py`.
From `gui/core` I removed all but `colors.py`,`writer.py` and `nanogui.py`.
I deleted unused directories such as `drivers/sharp` etc.
I erased flash, built and installed the new firmware. Finally I copied
`esp8266_setup.py` to `/pyboard/color_setup.py`. This could have been frozen
but I wanted to be able to change pins if required.
Both demos worked perfectly.
I modified the demos to regularly report free RAM. `scale.py` reported 10480
bytes, `tbox.py` reported 10512 bytes, sometimes more, as the demo progressed.
In conclusion I think that applications of moderate complexity should be
feasible.
###### [Contents](./README.md#contents)

Wyświetl plik

@ -2,7 +2,7 @@
There are three versions.
* `ssd1351.py` This is optimised for STM (e.g. Pyboard) platforms.
* `ssd1351_generic.py` Cross-platform version.
* `ssd1351_generic.py` Cross-platform version. Tested on ESP32 and ESP8266.
* `ssd1351_16bit.py` Cross-platform. Uses 16 bit RGB565 color.
To conserve RAM the first two use 8 bit (rrrgggbb) color. This works well with

34
esp8266_setup.py 100644
Wyświetl plik

@ -0,0 +1,34 @@
# esp8266_setup.py Copy to target as color_setup.py
# 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.
# WIRING (Adafruit pin nos and names).
# Pyb SSD
# 3v3 Vin (10)
# Gnd Gnd (11)
# IO0 DC (3 DC)
# IO16 CS (5 OC OLEDCS)
# IO2 Rst (4 R RESET)
# IO14 CLK (2 CL SCK) Hardware SPI1
# IO13 DATA (1 SI MOSI)
from machine import SPI, Pin
import gc
from drivers.ssd1351.ssd1351_generic import SSD1351 as SSD
height = 128 # Ensure height is correct (96/128)
pdc = Pin(0, Pin.OUT, value=0) # Arbitrary pins
pcs = Pin(16, Pin.OUT, value=1)
prst = Pin(2, Pin.OUT, value=1)
# Hardware SPI on native pins for performance
spi = SPI(1, baudrate=10_000_000, polarity=0, phase=0)
gc.collect()
ssd = SSD(spi, pcs, pdc, prst, height=height)