MicroPython driver for Sharp Memory Displays.
This driver was derived from the Adafruit CircuitPython version Adafruit_CircuitPython_SharpMemoryDisplay driver made by @ladyada and others. Some enhancements have been added.
An SPI connection at 2 MHz can achieve full screen updates in around 110 ms for the 400x240 display. This is the rated maximum speed for the display.
The driver builds in the facility to use the extended framebuffer methods large_text(), triangle() and circle() methods in the MicroPython FrameBuffer extension framebuf2.
To prevent potential permanent burn-in on the display the polarity must be reversed at least every 2 hours. This can be achieved by refreshing the display with the show() method. See display datasheet and application note for further information.
The display has an SPI interface, connections for SCLK, MOSI, CS are required.
The module code should be uploaded to the Raspberry Pico Pi (or other Microcontroller running MicroPython). The large font, triangle and circles extension is added by additionally uploading the framebuf2.py module code. (See framebuf2.)
The module includes the class SharpMemoryDisplay.
syntax:
display = sharp.SharpMemoryDisplay(width,
height,
spi,
cs)
width(default 400) andheight(default 240) define the size of the displayspiis an SPI object. The SCL (clock) and MOSI (data) pins must be defined. MISO is not used.csis a GPIO Pin object for Chip Select
In addition to all MicroPython's framebuffer drawing methods, the following methods and properties are available for controlling the display
show() - this method updates the display from the framebuffer.
clear() - this method clears the display to white (colour 1).
from machine import Pin, SPI
import sharp
spi0 = SPI(0, baudrate=2_000_000, sck=Pin(18), mosi=Pin(19), miso=Pin(16))
display = sharp_memory_display.SharpMemoryDisplay(400, 240, spi0, cs=Pin(15, Pin.OUT))
display.fill(0)
display.text('SHARP MEMORY DISPLAY', 0, 0, 1)
display.text('driver', 0, 8, 1)
display.show()
See demo example for further details and usage demonstrations of other methods. (The example code was written for 400x240 displays.)
This driver has been tested with a Raspberry Pi Pico and an Adafruit 400x240 display. It should work with other Adafruit Sharp Memory Displays.
- initial working version
Suggestions for improvements and pull requests are welcome.
to add: link to Adafruit documentation
to add: link to appliction note and datasheet
Application Note: Sharp Memory LCDs: Theory, Interfacing, and Programming
-
amend show to allow line updates rather than the full screen
-
use a buffer that includes the overhead bytes for writing a line to the display