Drivers for various displays and portable GUI

Discuss development of drivers for external hardware and components, such as LCD screens, sensors, motor drivers, etc.
Target audience: Users and developers of drivers.
User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Drivers for various displays and portable GUI

Post by pythoncoder » Mon Sep 24, 2018 8:21 am

This nanogui project is intended to provide a simple GUI and graph plotting module portable to any display whose driver is subclassed from framebuf and which meets some other very simple requirements. The GUI is aimed at the display of sensor data. It has no provision for user input which must be handled in the application. To save RAM it uses 8 bit colour. Widgets are drawn using graphics primitives and hence may be scaled to very small displays.

If user input is required the official LCD160CR display with touch overlay should be used, with a GUI available here or for large 4.3" SSD1963 displays this one.

Display drivers are provided for Adafruit 1.5, 1.27 and 0.96 inch colour OLED displays. There is also the official SSD1306 driver for monochrome OLED displays. These may be used:
  • Alone (inheriting the framebuf graphics primitives).
  • With the CWriter class to display text in arbitrary fonts and colours.
  • Or with nanogui which builds on the CWriter class.
Some sample images. Small OLED displays are hard to photograph well. In practice they are very good with clear colours and extreme contrast. The following are samples from the test scripts running on a Pyboard with a 1.27" Adafruit display.

Image
The meter levels, LED text strings and colours change dynamically as the data changes.

Image
Analog clock. The widget is actually capable of displaying vectors of varying length, as straight line pointers or as arrows.

Image
The plot module displaying analog data being captured in (slow) real time.

The Nokia 5110 with this driver may also be used with the monochrome Writer class to display arbitrary fonts, but the resolution of these displays is probably inadequate for the GUI.
Peter Hinch
Index to my micropython libraries.

kevinkk525
Posts: 969
Joined: Sat Feb 03, 2018 7:02 pm

Re: Drivers for OLED displays and portable GUI

Post by kevinkk525 » Mon Sep 24, 2018 9:04 am

Sounds amazing!
When I have time to play with my SSD1306 I'll give it a try.
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Cheaper options

Post by pythoncoder » Mon Sep 24, 2018 9:14 am

I should add that Adafruit colour OLED displays are expensive. I usually pay their prices to support the work they do and because their quality, documentation and code is great. But cheap Chinese displays are available. They are inevitably something of an unknown quantity; the one I tried worked fine.
Peter Hinch
Index to my micropython libraries.

cmisztur
Posts: 3
Joined: Wed Sep 26, 2018 2:04 am

Re: Drivers for OLED displays and portable GUI

Post by cmisztur » Wed Sep 26, 2018 2:31 am

This looks great. Thank You!

Jonwalter
Posts: 6
Joined: Mon Apr 09, 2018 12:41 pm
Contact:

Re: Drivers for OLED displays and portable GUI

Post by Jonwalter » Wed Nov 28, 2018 10:53 pm

pythoncoder wrote:
Mon Sep 24, 2018 8:21 am
Image
Analog clock. The widget is actually capable of displaying vectors of varying length, as straight line pointers or as arrows.
Hey, pythoncoder!
Could you show the example of the calendar in same way like a clock or better. I really need for my new project, we create all kinds of widgets, etc. Now I have the first task to make an cool widget called economic calendar by Tradays - https://www.tradays.com/en/widget .
Thanks in advance! :oops:
Last edited by Jonwalter on Thu Nov 29, 2018 8:58 am, edited 1 time in total.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Drivers for OLED displays and portable GUI

Post by pythoncoder » Thu Nov 29, 2018 5:45 am

Alas I'm too busy with other (MicroPython) things to write custom code for people. Hopefully you can use my code as a template for extending the widget set.

It's an open question whether it's feasible to display a full month on a 1.5 inch display.
Peter Hinch
Index to my micropython libraries.

User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: Drivers for OLED displays and portable GUI

Post by deshipu » Wed Dec 19, 2018 8:57 am

In case anybody finds it useful, I wrote an article about handling the small OLED displays without a library: https://hackaday.io/page/5722

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Support for Sharp displays

Post by pythoncoder » Thu Oct 08, 2020 7:20 am

This now supports Sharp displays. These are monochrome displays with excellent resolution, fast refresh and extremely low power consumption (I measured 90μA). See the Adafruit offerings. Note that the video demonstrates refresh rate but the low resolution is not representative. These things can display very fine detail.

There is a downside. Viewing angles are not great: white pixels are reflective so they work best when the light source and your eyes are positioned accordingly. They work quite well outdoors. As a competitor to ePaper, refresh time is instantaneous rather than seconds of flashing. But ePpaper wins on viewing angles and visibility in a wide range of lighting conditions. And ePaper power consumption can actually be zero with a MOSFET switch. That said, there is a digital and analog clock demo script which should be capable of running off a 2000mAH LiPo battery for 92 days between charges.

The driver works with nano-gui and the Writer class. It also supports the framebuf graphics primitives.
Peter Hinch
Index to my micropython libraries.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Drivers for OLED displays and portable GUI

Post by pythoncoder » Fri Nov 06, 2020 5:11 pm

The nano-gui library has now been refactored as a Python package. I've also updated the docs and made a number of changes to its organisation with a view to making it easier to install and use and to simplify use with non-Pyboard targets.

The main new features are:
  • Reduced RAM usage: widgets are imported on demand.
  • New widgets can therefore be added with zero impact on existing applications.
  • A Scale widget has been added for precision display of floats.
  • Simplified installation with dependencies included in the source tree.
  • Hardware configuration now confined to one small Python file.
  • This simplifies ESP32 support.
It is a breaking change: import statements need to be adapted but the API is otherwise unchanged.

New widgets to follow...
Peter Hinch
Index to my micropython libraries.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Drivers for OLED displays and portable GUI

Post by pythoncoder » Mon Dec 21, 2020 8:55 am

Another update to nano-gui.

It now supports a wider range of displays. Here is a full list:
  • SSD1306 monochrome.
  • PCD8544/Nokia 5110.
  • Adafruit 0.96 inch color OLED (SSD1331).
  • Adafruit 1.5 inch OLED and Adafruit 1.27 inch OLED (SSD1351).
  • Sharp monochrome transflective displays.
  • Adafruit color TFT's: 1.8 inch and 1.44 inch (ST7735R).
  • Adafruit color TFT's: 2.4, 2.8 and 3.2 inch 240*320 (ILI9341).
Non-square color TFT's can operate in landscape or portrait mode, normal or upside down. Others assume normal, landscape.

New drivers have been added for most of these color displays with reduced RAM demands. These optional drivers are based on 4-bit color, and use a lookup table to provide a set of 16 16-bit colors. The ILI9341 only supports 4-bit mode because the size of the framebuffer would otherwise be excessive.

Applications which only use the predefined colors will work unchanged after upgrading the GUI if a 4-bit driver is substituted.

Drivers have been tested on Pyboards and ESP32. In the case of SSD1351 the GUI has run on ESP8266 using the 4-bit driver with 18K of RAM free.
Peter Hinch
Index to my micropython libraries.

Post Reply