@@ -39,12 +39,12 @@ access via the `Writer` and `CWriter` classes is documented
3939 2.3 [ Drivers for SSD1327] ( ./DRIVERS.md#23-drivers-for-ssd1327 ) Greyscale OLEDs
4040 3 . [ Color TFT displays] ( ./DRIVERS.md#3-color-tft-displays )
4141 3.1 [ Drivers for ST7735R] ( ./DRIVERS.md#31-drivers-for-st7735r ) Small TFTs
42- 3.2 [ Drivers for ILI9341 ] ( ./DRIVERS.md#32-drivers-for-ili9341 ) Large TFTs
43- 3.3 [ Drivers for ST7789 ] ( ./DRIVERS.md#33-drivers-for-st7789 ) Small high density TFTs
44-   ;  ;  ;  ;  ; 3.3.1 [ TTGO T Display ] ( ./DRIVERS.md#331-ttgo-t-display ) Low cost ESP32 with integrated display
45-   ;  ;  ;  ;  ; 3.3.2 [ Waveshare Pico Res Touch ] ( ./DRIVERS.md#332 -waveshare-pico-res-touch )
46-   ;  ;  ;  ;  ; 3.3.3 [ Waveshare Pico LCD 2 ] ( ./DRIVERS.md#333-waveshare-pico-lcd-2 )
47- & nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ; 3.3.4 [ Troubleshooting ] ( ./DRIVERS.md#334-troubleshooting )
42+ 3.2 [ Drivers for ST7789 ] ( ./DRIVERS.md#32-drivers-for-st7789 ) Small high density TFTs
43+ & nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ; 3.2.1 [ TTGO T Display ] ( ./DRIVERS.md#321-ttgo-t-display ) Low cost ESP32 with integrated display
44+   ;  ;  ;  ;  ; 3.2.2 [ Waveshare Pico Res Touch ] ( ./DRIVERS.md#322-waveshare-pico-res-touch )
45+   ;  ;  ;  ;  ; 3.2.3 [ Waveshare Pico LCD 2 ] ( ./DRIVERS.md#323 -waveshare-pico-lcd-2 )
46+   ;  ;  ;  ;  ; 3.2.4 [ Troubleshooting ] ( ./DRIVERS.md#324-troubleshooting )
47+ 3.3 [ Drivers for ILI9341 ] ( ./DRIVERS.md#33-drivers-for-ili9341 ) Large TFTs
4848 3.4 [ Driver for ILI94xx] ( ./DRIVERS.md#34-driver-for-ili94xx ) Generic ILI94xx and HX8357D driver for large displays.
4949 3.5 [ Driver for gc9a01] ( ./DRIVERS.md#35-driver-for-gc9a01 ) Round 240x240 displays.
5050 4 . [ Drivers for sharp displays] ( ./DRIVERS.md#4-drivers-for-sharp-displays ) Large low power monochrome displays
@@ -389,110 +389,7 @@ def spi_init(spi):
389389
390390###### [ Contents] ( ./DRIVERS.md#contents )
391391
392- ## 3.2 Drivers for ILI9341
393-
394- Adafruit make several displays using this chip, for example
395- [ this 3.2 inch unit] ( https://www.adafruit.com/product/1743 ) . This display is
396- large by microcontroller standards. See below for discussion of which hosts can
397- be expected to work.
398-
399- The ` color_setup.py ` file should initialise the SPI bus with a baudrate of
400- 10_000_000. Args ` polarity ` , ` phase ` , ` bits ` , ` firstbit ` are defaults. Hard or
401- soft SPI may be used but hard may be faster. See note on overclocking below.
402-
403- #### ILI9341 Constructor args:
404- * ` spi ` An initialised SPI bus instance. The device can support clock rates of
405- upto 10MHz.
406- * ` cs ` An initialised output pin. Initial value should be 1.
407- * ` dc ` An initialised output pin. Initial value should be 0.
408- * ` rst ` An initialised output pin. Initial value should be 1.
409- * ` height=240 ` Display dimensions in pixels. For portrait mode exchange
410- ` height ` and ` width ` values.
411- * ` width=320 `
412- * ` usd=False ` Upside down: set ` True ` to invert display.
413- * ` init_spi=False ` Allow bus sharing. See note below.
414- * ` mod=None ` Set to a number from 0 to 7 to correct garbled display on some
415- Chinese units.
416- * ` bgr=False ` If ` True ` use BGR color rendition in place of RGB.
417-
418- #### Method (4-bit driver only)
419-
420- * ` greyscale(gs=None) ` Setting ` gs=True ` enables the screen to be used to show
421- a full screen monochrome image. By default the frame buffer contents are
422- interpreted as color values. In greyscale mode the contents are treated as
423- greyscale values. This mode persists until the method is called with
424- ` gs=False ` . The method returns the current greyscale state. It is possible to
425- superimpose widgets on an image, but the mapping of colors onto the greyscale
426- may yield unexpected shades of grey. ` WHITE ` and ` BLACK ` work well. In
427- [ micro-gui] ( https://github.com/peterhinch/micropython-micro-gui ) and
428- [ micropython-touch] ( https://github.com/peterhinch/micropython-touch ) the
429- ` after_open ` method should be used to render the image to the framebuf and to
430- overlay any widgets.
431-
432- The 4-bit driver uses four bits per pixel to conserve RAM. Even with this
433- adaptation the buffer size is 37.5KiB which is too large for some platforms. On
434- a Pyboard 1.1 the ` scale.py ` demo ran with 34.5K free with no modules frozen,
435- and with 47K free with ` gui ` and contents frozen. An ESP32 with SPIRAM has been
436- tested. On an ESP32 without SPIRAM, ` nano-gui ` runs but
437- [ micro-gui] ( https://github.com/peterhinch/micropython-micro-gui ) requires
438- frozen bytecode. The RP2 Pico runs both GUI's.
439-
440- See [ Color handling] ( ./DRIVERS.md#11-color-handling ) for details of the
441- implications of 4-bit color. The 8-bit driver enables color image display on
442- platforms with sufficient RAM: see [ IMAGE_DISPLAY.md] ( ./IMAGE_DISPLAY.md ) .
443-
444- The drivers use the ` micropython.viper ` decorator. If your platform does not
445- support this, the Viper code will need to be rewritten with a substantial hit
446- to performance.
447-
448- #### Use with asyncio
449-
450- A full refresh blocks for ~ 200ms. If this is acceptable, no special precautions
451- are required. However this period may be unacceptable for some ` asyncio `
452- applications. The driver provides an asynchronous ` do_refresh(split=4) ` method.
453- If this is run the display will be refreshed, but will periodically yield to
454- the scheduler enabling other tasks to run. This is documented
455- [ here] ( ./ASYNC.md ) . [ micro-gui] ( https://github.com/peterhinch/micropython-micro-gui )
456- uses this automatically.
457-
458- Another option to reduce blocking is overclocking the SPI bus.
459-
460- #### Overclocking SPI
461-
462- The ILI9341 datasheet section 19.3.4 specifies a minimum clock cycle time of
463- 100ns for write cycles. It seems that every man and his dog overclocks this,
464- even the normally conservative Adafruit
465- [ use 24MHz] ( https://learn.adafruit.com/adafruit-2-8-and-3-2-color-tft-touchscreen-breakout-v2/python-usage )
466- and [ rdagger] ( https://github.com/rdagger/micropython-ili9341/blob/master/demo_fonts.py )
467- uses 40MHz. I have successfully run my display at 40MHz. My engineering
468- training makes me baulk at exceeding datasheet limits but the choice is yours.
469- I raised [ this isse] ( https://github.com/adafruit/Adafruit_CircuitPython_ILI9341/issues/24 ) .
470- The response may be of interest.
471-
472- ### The init_spi constructor arg
473-
474- This optional arg enables flexible options in configuring the SPI bus. The
475- default assumes exclusive access to the bus. In this normal case,
476- ` color_setup.py ` initialises it and the settings will be left in place. If the
477- bus is shared with devices which require different settings, a callback function
478- should be passed. It will be called prior to each SPI bus write. The callback
479- will receive a single arg being the SPI bus instance. It will typically be a
480- one-liner or lambda initialising the bus. A minimal example is this function:
481- ``` python
482- def spi_init (spi ):
483- spi.init(baudrate = 10_000_000 )
484- ```
485-
486- #### Troubleshooting
487-
488- Some Chinese modules produce garbled displays. Please try the
489- [ ILI9486 driver] ( ./DRIVERS.md#34-driver-for-ili94xx ) with the ` mirror `
490- constructor arg set ` True ` . Patch and testing provided by
491- [ Abel Deuring] ( https://github.com/peterhinch/micropython-micro-gui/issues/25#issuecomment-1475329104 ) .
492-
493- ###### [ Contents] ( ./DRIVERS.md#contents )
494-
495- ## 3.3 Drivers for ST7789
392+ ## 3.2 Drivers for ST7789
496393
497394The chip supports sizes up to 240x320 pixels. To keep the buffer size down, the
498395normal driver uses 4-bit color with dynamic conversion to 16 bit RGB565 at
@@ -640,7 +537,7 @@ At a 60MHz baudrate this equates to
640537This suggests that about 80% of the latency results from the Python code. An
641538option may be to overclock.
642539
643- ### 3.3 .1 TTGO T Display
540+ ### 3.2 .1 TTGO T Display
644541
645542Thanks to [ Ihor Nehrutsa] ( https://github.com/IhorNehrutsa ) who wrote much of
646543the setup file for this device.
@@ -660,7 +557,7 @@ URL's. More in `st7789_ttgo.py`
660557[ Another MicroPython driver] ( https://github.com/jikegong/TTGO-Esp32-ST7789-Display-MicroPython/blob/2ed1816c41f25c8993038c35ef40b2efeb225dcc/st7789.py )
661558[ Factory test (C)] ( https://github.com/Xinyuan-LilyGO/TTGO-T-Display/blob/master/TFT_eSPI/examples/FactoryTest/FactoryTest.ino )
662559
663- ### 3.3 .2 Waveshare Pico Res Touch
560+ ### 3.2 .2 Waveshare Pico Res Touch
664561
665562This is a "plug and play" 2.8" color TFT for nano-gui and the Pi Pico. Users of
666563micro-gui will need to find a way to connect pushbuttons, either using stacking
@@ -701,7 +598,7 @@ driver which may be found in the MicroPython source tree in
701598` drivers/sdcard/sdcard.py ` . I am not an expert on SD cards. Mine worked fine at
70259931.25MHz but this may or may not be universally true.
703600
704- ### 3.3 .3 Waveshare Pico LCD 2
601+ ### 3.2 .3 Waveshare Pico LCD 2
705602
706603Support for this display resulted from a collaboration with Mike Wilson
707604(@MikeTheGent ).
@@ -728,7 +625,7 @@ pdc = Pin(8, Pin.OUT, value=0)
728625ssd = SSD(spi, height = 240 , width = 320 , dc = pdc, cs = pcs, rst = prst, disp_mode = LANDSCAPE , display = PI_PICO_LCD_2 )
729626```
730627
731- ### 3.3 .4 Troubleshooting
628+ ### 3.2 .4 Troubleshooting
732629
733630If your display shows garbage, check the following (I have seen both):
734631 * SPI baudrate too high for your physical layout.
@@ -737,6 +634,109 @@ If your display shows garbage, check the following (I have seen both):
737634
738635###### [ Contents] ( ./DRIVERS.md#contents )
739636
637+ ## 3.3 Drivers for ILI9341
638+
639+ Adafruit make several displays using this chip, for example
640+ [ this 3.2 inch unit] ( https://www.adafruit.com/product/1743 ) . This display is
641+ large by microcontroller standards. See below for discussion of which hosts can
642+ be expected to work.
643+
644+ The ` color_setup.py ` file should initialise the SPI bus with a baudrate of
645+ 10_000_000. Args ` polarity ` , ` phase ` , ` bits ` , ` firstbit ` are defaults. Hard or
646+ soft SPI may be used but hard may be faster. See note on overclocking below.
647+
648+ #### ILI9341 Constructor args:
649+ * ` spi ` An initialised SPI bus instance. The device can support clock rates of
650+ upto 10MHz.
651+ * ` cs ` An initialised output pin. Initial value should be 1.
652+ * ` dc ` An initialised output pin. Initial value should be 0.
653+ * ` rst ` An initialised output pin. Initial value should be 1.
654+ * ` height=240 ` Display dimensions in pixels. For portrait mode exchange
655+ ` height ` and ` width ` values.
656+ * ` width=320 `
657+ * ` usd=False ` Upside down: set ` True ` to invert display.
658+ * ` init_spi=False ` Allow bus sharing. See note below.
659+ * ` mod=None ` Set to a number from 0 to 7 to correct garbled display on some
660+ Chinese units.
661+ * ` bgr=False ` If ` True ` use BGR color rendition in place of RGB.
662+
663+ #### Method (4-bit driver only)
664+
665+ * ` greyscale(gs=None) ` Setting ` gs=True ` enables the screen to be used to show
666+ a full screen monochrome image. By default the frame buffer contents are
667+ interpreted as color values. In greyscale mode the contents are treated as
668+ greyscale values. This mode persists until the method is called with
669+ ` gs=False ` . The method returns the current greyscale state. It is possible to
670+ superimpose widgets on an image, but the mapping of colors onto the greyscale
671+ may yield unexpected shades of grey. ` WHITE ` and ` BLACK ` work well. In
672+ [ micro-gui] ( https://github.com/peterhinch/micropython-micro-gui ) and
673+ [ micropython-touch] ( https://github.com/peterhinch/micropython-touch ) the
674+ ` after_open ` method should be used to render the image to the framebuf and to
675+ overlay any widgets.
676+
677+ The 4-bit driver uses four bits per pixel to conserve RAM. Even with this
678+ adaptation the buffer size is 37.5KiB which is too large for some platforms. On
679+ a Pyboard 1.1 the ` scale.py ` demo ran with 34.5K free with no modules frozen,
680+ and with 47K free with ` gui ` and contents frozen. An ESP32 with SPIRAM has been
681+ tested. On an ESP32 without SPIRAM, ` nano-gui ` runs but
682+ [ micro-gui] ( https://github.com/peterhinch/micropython-micro-gui ) requires
683+ frozen bytecode. The RP2 Pico runs both GUI's.
684+
685+ See [ Color handling] ( ./DRIVERS.md#11-color-handling ) for details of the
686+ implications of 4-bit color. The 8-bit driver enables color image display on
687+ platforms with sufficient RAM: see [ IMAGE_DISPLAY.md] ( ./IMAGE_DISPLAY.md ) .
688+
689+ The drivers use the ` micropython.viper ` decorator. If your platform does not
690+ support this, the Viper code will need to be rewritten with a substantial hit
691+ to performance.
692+
693+ #### Use with asyncio
694+
695+ A full refresh blocks for ~ 200ms. If this is acceptable, no special precautions
696+ are required. However this period may be unacceptable for some ` asyncio `
697+ applications. The driver provides an asynchronous ` do_refresh(split=4) ` method.
698+ If this is run the display will be refreshed, but will periodically yield to
699+ the scheduler enabling other tasks to run. This is documented
700+ [ here] ( ./ASYNC.md ) . [ micro-gui] ( https://github.com/peterhinch/micropython-micro-gui )
701+ uses this automatically.
702+
703+ Another option to reduce blocking is overclocking the SPI bus.
704+
705+ #### Overclocking SPI
706+
707+ The ILI9341 datasheet section 19.3.4 specifies a minimum clock cycle time of
708+ 100ns for write cycles. It seems that every man and his dog overclocks this,
709+ even the normally conservative Adafruit
710+ [ use 24MHz] ( https://learn.adafruit.com/adafruit-2-8-and-3-2-color-tft-touchscreen-breakout-v2/python-usage )
711+ and [ rdagger] ( https://github.com/rdagger/micropython-ili9341/blob/master/demo_fonts.py )
712+ uses 40MHz. I have successfully run my display at 40MHz. My engineering
713+ training makes me baulk at exceeding datasheet limits but the choice is yours.
714+ I raised [ this isse] ( https://github.com/adafruit/Adafruit_CircuitPython_ILI9341/issues/24 ) .
715+ The response may be of interest.
716+
717+ ### The init_spi constructor arg
718+
719+ This optional arg enables flexible options in configuring the SPI bus. The
720+ default assumes exclusive access to the bus. In this normal case,
721+ ` color_setup.py ` initialises it and the settings will be left in place. If the
722+ bus is shared with devices which require different settings, a callback function
723+ should be passed. It will be called prior to each SPI bus write. The callback
724+ will receive a single arg being the SPI bus instance. It will typically be a
725+ one-liner or lambda initialising the bus. A minimal example is this function:
726+ ``` python
727+ def spi_init (spi ):
728+ spi.init(baudrate = 10_000_000 )
729+ ```
730+
731+ #### Troubleshooting
732+
733+ Some Chinese modules produce garbled displays. Please try the
734+ [ ILI9486 driver] ( ./DRIVERS.md#34-driver-for-ili94xx ) with the ` mirror `
735+ constructor arg set ` True ` . Patch and testing provided by
736+ [ Abel Deuring] ( https://github.com/peterhinch/micropython-micro-gui/issues/25#issuecomment-1475329104 ) .
737+
738+ ###### [ Contents] ( ./DRIVERS.md#contents )
739+
740740## 3.4 Driver for ILI94xx
741741
742742This was developed for the ILI9486 but its application is more wide ranging.
0 commit comments