|
1 | 1 | # A touch GUI for the official MicroPython display
|
2 | 2 |
|
3 |
| -v0.21 29th Oct 2020 Add `Scale` and `Pad` widgets. |
| 3 | +v0.21 29th Oct 2020 Add `Scale` and `Pad` widgets. |
4 | 4 | V0.20 21st Oct 2020 Refactor as a Python package. The refactor is a breaking
|
5 | 5 | change: applications must adapt `import` statements. There is now no need to
|
6 | 6 | cross compile on a Pyboard 1.1. Unused widgets no longer consume RAM. The
|
7 |
| -structure also facilitates adding new widgets. |
8 |
| - |
9 |
| -Supports Jim Mussared's fast text rendering. |
10 |
| - |
| 7 | +structure also facilitates adding new widgets. Supports Jim Mussared's fast |
| 8 | +text rendering. |
11 | 9 | V0.12 21st Sep 2020 Updated for (and requires) uasyncio V3.
|
12 | 10 |
|
13 |
| -Provides a simple touch driven event based GUI interface for the Pyboard when |
14 |
| -used with the official LCD160CR colour display. It is based on the official |
15 |
| -driver and uses `uasyncio` for scheduling. The V1.1 display enables a Pyboard D |
16 |
| -to be plugged in. The GUI has been tested in this configuration. |
| 11 | +Provides a simple touch driven event based GUI interface for the the official |
| 12 | +LCD160CR colour display. It is based on the official driver and uses `uasyncio` |
| 13 | +for scheduling. It has been tested on: |
| 14 | + * Pyboard 1.0 and 1.1 |
| 15 | + * Pyboard D |
| 16 | + * ESP32 |
| 17 | +It should be easy to port to platforms having both I2C and SPI interfaces, |
| 18 | +given sufficient RAM. The V1.1 display enables a Pyboard D to be plugged in to |
| 19 | +the rear. The GUI has been tested in this configuration. |
17 | 20 |
|
18 | 21 | It is targeted at hardware control and display applications. GUI objects are
|
19 | 22 | drawn using graphics primitives rather than by rendering bitmap images. This
|
@@ -68,7 +71,6 @@ The Plot module: Cartesian and polar graphs.
|
68 | 71 | 1.1 [Pre installation](./README.md#11-pre-installation)
|
69 | 72 | 1.2 [Library Documentation](./README.md#12-library-documentation)
|
70 | 73 | 1.3 [Installation](./README.md#13-installation)
|
71 |
| - 1.3.1 [ESP32](./README.md#131-esp32) |
72 | 74 | 1.4 [Dependencies and Python files](./README.md#14-dependencies-and-python-files)
|
73 | 75 | 1.5 [A performance boost](./README.md#15-a-performance-boost)
|
74 | 76 | 2. [Concepts](./README.md#2-concepts)
|
@@ -109,6 +111,7 @@ The Plot module: Cartesian and polar graphs.
|
109 | 111 | 8.2 [Internal fonts: Class IFont](./README.md#82-internal-fonts-class-ifont)
|
110 | 112 | 9. [Issues](./README.md#9-issues) A problem encountered with old LCD160CR firmware
|
111 | 113 | 10. [Application design note](./README.md#10-application-design-note) Touch application design
|
| 114 | +11. [ESP32](./README.md#11-esp32) Use with non-Pyboard targets |
112 | 115 |
|
113 | 116 | # 1. Pre requisites
|
114 | 117 |
|
@@ -154,15 +157,8 @@ directory containing `gui` with:
|
154 | 157 | > rsync gui /sd/gui
|
155 | 158 | ```
|
156 | 159 |
|
157 |
| -### 1.3.1 ESP32 |
158 |
| - |
159 |
| -The library can be installed on ESP32. The file `lcd_local_esp.py` should be |
160 |
| -copied to `/pyboard/lcd_local.py` after making any edits to support your |
161 |
| -physical connection and maximum font size. |
162 |
| - |
163 |
| -[Fast mode](./README.md#15-a-performance-boost) will fail because the example |
164 |
| -is compiled for STM architecture. Options are to recompile for `xtensawin` or |
165 |
| -to disable fast mode by deleting `gui/framebuf_utils/framebuf_utils.mpy`. |
| 160 | +For use with non-Pyboard targets, including ESP32, see |
| 161 | +[ESP32](./README.md#11-esp32). |
166 | 162 |
|
167 | 163 | ## 1.4 Dependencies and Python files
|
168 | 164 |
|
@@ -1214,3 +1210,73 @@ to run the callback on press or use a control such as a listbox.
|
1214 | 1210 |
|
1215 | 1211 | The general point, where screens change, is to consider how continuing touch
|
1216 | 1212 | will affect the new screen.
|
| 1213 | + |
| 1214 | +# 11. ESP32 |
| 1215 | + |
| 1216 | +The official display may be connected to non-Pyboard targets via I2C and SPI |
| 1217 | +interfaces. Both interfaces are required. The display has an AP2210 LDO voltage |
| 1218 | +regulator so it may be powered from 5V or 3.3V. Connections may be made via |
| 1219 | +the downward facing pins or the black connector at the end of the PCB. In my |
| 1220 | +testing the SPI connections on that connector did not work, however the power |
| 1221 | +and I2C connections were OK. |
| 1222 | + |
| 1223 | +The downward facing pins are as follows. The table is arranged such that the |
| 1224 | +black connector is at the top. The view is looking at the display surface. |
| 1225 | + |
| 1226 | +Pin names are those on a mating Pyboard 1.x. Only signals with an entry in the |
| 1227 | +`Link` column require connection to the target. |
| 1228 | + |
| 1229 | +| Pin | Signal | Link | Signal | Link | Pin | |
| 1230 | +|:---:|:-------:|:----:|:------:|:----:|:---:| |
| 1231 | +| Y1 | UART Rx | | Vin | 5V | Vin | |
| 1232 | +| Y2 | UART Tx | | NC | | 3V3 | |
| 1233 | +| Y3 | LCD CS1 | | Gnd | Gnd | Gnd | |
| 1234 | +| Y4 | LCD RST | PWR | Rst | | Rst | |
| 1235 | +| Y5 | SS\ | | LCD BL | | Y12 | |
| 1236 | +| Y6 | SCK | SPI | T-IRQ | | Y11 | |
| 1237 | +| Y7 | MISO | | SDA | I2C | Y10 | |
| 1238 | +| Y8 | MOSI | SPI | SCL | I2C | Y9 | |
| 1239 | + |
| 1240 | +The `PWR` signal enables power to the display and should be assigned to an |
| 1241 | +arbitrary I/O pin. The display board has no I2C pullups. If the target does not |
| 1242 | +have them, pullups to 3.3V on `SDA` and `SCL` are essential. Values are not |
| 1243 | +critical - 1.5KΩ to 4.7KΩ are typical. |
| 1244 | + |
| 1245 | +This code from `lcd_local_esp.py` works on the reference board: |
| 1246 | +```python |
| 1247 | +from gui.core import lcd160cr |
| 1248 | +from gui.core.lcd160_gui import Screen, LCD160CR_G |
| 1249 | + |
| 1250 | +from machine import Pin, I2C, SPI |
| 1251 | + |
| 1252 | +def setup(): |
| 1253 | + pwr = Pin(25, Pin.OUT) |
| 1254 | + # Hardware SPI on native pins for performance |
| 1255 | + spi = SPI(1, 10_000_000, sck=Pin(14), mosi=Pin(13), miso=Pin(12)) |
| 1256 | + i2c = I2C(1, scl=Pin(32), sda=Pin(33), freq=1_000_000) |
| 1257 | + lcd = LCD160CR_G(pwr=pwr, spi=spi, i2c=i2c) # Set connection |
| 1258 | + lcd.set_orient(lcd160cr.LANDSCAPE) # and orientation |
| 1259 | + Screen.setup(lcd) |
| 1260 | +``` |
| 1261 | +I experienced problems specifying different pins for I2C. The |
| 1262 | +[manual](http://docs.micropython.org/en/latest/esp32/quickref.html#hardware-i2c-bus) |
| 1263 | +indicates that pins 18 and 19 can be used, but I experienced timeout errors |
| 1264 | +with these pins. |
| 1265 | + |
| 1266 | +To install the library on ESP32 the file `lcd_local_esp.py` should be copied to |
| 1267 | +`/pyboard/lcd_local.py` after making any edits to support your physical |
| 1268 | +connection and maximum font size. |
| 1269 | + |
| 1270 | +The supplied [framebuf_utils.mpy](./README.md#15-a-performance-boost) will |
| 1271 | +produce a harmless warning message because the supplied example is compiled for |
| 1272 | +STM architecture. To enable fast text rendering it is necessary to recompile |
| 1273 | +for `xtensawin`. |
| 1274 | + |
| 1275 | +### Debug notes |
| 1276 | + |
| 1277 | +If changing the pins or migrating to a different target the following errors |
| 1278 | +can occur. |
| 1279 | + * ENOENT or timeout exception: I2C problem. Check pullups. |
| 1280 | + * Blank display: check the pwr pin. |
| 1281 | + * The GUI works but lacks text on buttons. Meters and sliders show |
| 1282 | + corruption: this is an SPI problem. |
0 commit comments