Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/dmaspi multi buffer #41

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

ahoenerBE
Copy link

@ahoenerBE ahoenerBE commented Jun 28, 2021

This primary feature of this PR is the addition of library code to support the DMA controller of various Arduino devices.
Currently the only implementation defined is for the Arduino Due, but there are config options to allow for fallback to the default Arduino SPI class.

Additionally this PR provides a new non-DMA method drawPixelsArea to support drawing a rectangle of pixels to the screen (which to my knowledge the library doesn't currently support.

All the changes should allow the RA8875 to work better with libraries like LVGL that refresh portions of the screen at a time.

Changes & Scope

  • Replaced all references to SPI.h with a driver based on Bill Greiman's sdFat-beta library.
    • Added the sdFat-beta MIT license to the repository and updated the license file to reflect that code was adapted.
  • Added a config file to turn off various features of the new DMA SPI, as well as choose which driver to use.
  • Added an Arduino Due driver.
  • Added a function drawPixelsArea to allow redrawing of a specific rect on the screen from a pixel buffer. Makes it a lot easier to use LVGL, even in blocking SPI mode.
  • Added a DMA Manager for different platforms to extend if they have applicable DMA controllers.
  • Added DMA Manager for the Arduino Due.
  • Added structs for easily addressing different parts of DMA control registers (arduino due)
  • Added faster drawPixelsAreaDMA as an alternative to drawPixelsArea when DMA is enabled. Also added drawPixelsDMASlow for testing purposes. The slow one recreates its frames every time the delegate callback is called, the normal one only creates the frames once and then updates specific portions to save time.
  • Added callback functions to easily write custom code to tell if the function is complete, what to do when it's complete, etc. Works well with lambda functions.

Limitations

  • Most of the code in the PR is Arduino Due specific, and if the platform doesn't match, it's left out by guard statements.
    • There are struct defs and method stubs left to extend the capability to other compatible boards, but I haven't done any of that work myself.
  • There are timing/debug capabilities, but they're currently limited to the Due. On top of that, the speed at which the debug is printed is too much for the default buffer, so it's not usable unless you increase the serial buffer size. To do so, you need to exit the Arduino library file RingBuffer.h and change SERIAL_BUFFER_SIZE to be >=128.
    • This timing is disabled by default.

Examples

An example has been provided at examples/dma_squares/dma_squares.ino. It should draw a series of colored squares across the screen using the chosen drawing function.

Partially fixes #39, the drawPixelsArea method makes using this driver with LVGL a lot easier, but the real speed increase comes from using an MCU with DMA capabilities, like the Due. If the clock is high enough it can work though.

Fixes #40

@ahoenerBE ahoenerBE force-pushed the feature/dmaspi-multi-buffer branch from 4b8aeef to 82bc88d Compare June 30, 2021 18:02
@cmorganBE
Copy link

Ping for review on this?

@ladyada
Copy link
Member

ladyada commented Nov 16, 2021

hiya, with a cursory look - could you split out the DMA handling to another library? its so platform specific it will need updating often and will need its own maintenance cycles. we're worried it will break this (old, but so far dependable) library

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Contributing -- LVGL & DMA SPI Add support to Adafruit_LvGL_Glue
3 participants