Skip to content

Read from displays (SPI or parallel) #5882

Open
@kmatch98

Description

@kmatch98

There are some situations where you may want to read data from a display:

  • verify the code and hardware is working, and the display is connected properly
  • reduce microcontroller memory usage by storing data on the display rather than in a large buffer (for example, interactions with the display could be “non-displayio”, possibly with display drivers that have hardware acceleration)
  • Creative visual or display interaction projects

Note: With SPI displays, they will need to have the MISO (sometimes called SDO) pin connected to the microcontroller

desired functions

  • readPixel(x,y): returns an RGB value of the pixel at location x,y
  • readRect(x1,y1,x2,y2,buffer): places into the buffer the RGB values of the pixels in the rectangular boundary specified by x1,y1 and x2,y2

CircuitPython additions required

To enable reading from displays in CircuitPython will require additions to the core. Here is my first look at what might be required:

displayio (also see questions below)

  • add functions for readPixel and readRect - these are the high level commands that the user would normally use.
  • SPI “FourWire” and “paralleldisplay” - add read functions to support the high level displayio functions

Additions to display drivers

Add the specific display driver chip’s command constants that are sent to the display to trigger the readPixel or readRect operation

error handling

  • For SPI, it’s desirable to provide an error if the MISO pin is not connected (if not connected, does a read operation return all zeroes or ones?)
  • If the display driver isn’t updated with the chip-specific Read constant commands, it should error that “this driver chip library is not configured for Read operations”.

Questions

  • A CircuitPython display doesn’t necessarily need to run using displayio. Should the display readPixel and readRect commands fall into a separate module, unrelated to displayio?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions