adafruit / circuitpython

CircuitPython - a Python implementation for teaching coding with microcontrollers
https://circuitpython.org
Other
4.02k stars 1.19k forks source link

Read from displays (SPI or parallel) #5882

Open kmatch98 opened 2 years ago

kmatch98 commented 2 years ago

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

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

desired functions

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)

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

Questions

ladyada commented 2 years ago

have you found any SPI displays that let you read pixel data? so far we've only seen this ability on the parallel interfaces

kmatch98 commented 2 years ago

Yep I’ve got it working in Arduino by adding some found readPixel code to the Adafruit TFT library. I’ve demoed readPixel on your 2.8” capacitive touch breakout connected via SPI (this unit uses a ILI9341 driver chip) to the Metro M4 express.

(Note: I haven’t tested on ST7789 displays.)

Attached demo video is grabbing the pixels and redrawing pixels at an x,y offset.

I see that many of the Adafruit all-in-one display/micro controller boards don’t connect the MISO pin (Clue, PyGamer, PyBadge, MonsterMask, Hallowing, FunHouse). Perhaps a MISO pad could be added in future products to allow for full loop display hardware testing, and to catch display timing issues like https://github.com/adafruit/circuitpython/issues/4775

https://user-images.githubusercontent.com/33587466/149996666-2bce9be1-245e-4ca6-b038-8da5fbb920e3.mov

tannewt commented 2 years ago

I think we may want to expand the lower level send capability of FourWire and ParallelBus instead of providing something higher level. That will minimize the amount of code we need to add to the core but still give you the access you need.