Skip to content

Performance issues with Raspberry Pi #18

@ilikecake

Description

@ilikecake

Hi All,

I was having issues with performance using this display on a Raspberry Pi. The details of my issue can be found here. It basically boiled down to two issues with the code:

  • The nested for loops in the framebuffer image() function taking a very long time to convert a PIL frame into a framebuffer.
  • Delays when sending SPI data that I speculate is because of the underlying Linux OS on the Pi limiting the rate of SPI transactions.

I was able to fix both of these issues and significantly speed up the device. (frame generation time went from ~6s per frame to .011s) I would like to submit this code back to the repo so that others can use it, but I am not sure of the implications of how this would affect the code running on other devices. I am looking for help/guidance on how this code can be implemented in a way that does not break things for other devices.

  • The solution uses numpy. I think this should be available for any device running circuit python, but I am not sure.
  • Part of the speed up comes from precomputing the static headers that need to be appended to the framebuffer as it is sent to the device. These precomputed headers are 2 bytes per line for a total of ~480bytes of extra memory usage. This is not a problem on the Raspberry Pi, but it may be a problem on more memory constrained processors.
  • In addition to that, part of the speedup comes from sending all of the data to the display as a single SPI transaction. This requires combining the static headers with the frame data. This can be achieved in several ways, but it may also have implications for memory usage on small static-memory-mapped devices.

Given freedom to change any of the code, the best way to implement this would probably be

  • Change display buffer in the SharpMemoryDisplay class from a buffer that only holds the image data to one that holds both the image data and the headers. This would involve changing how that buffer is accessed in the FrameBuffer class, either by changing the functions in MHMSBFormat or making a new format for this.
  • Change the show function in the SharpMemoryDisplay class to send this buffer all at once.

Does this make sense? I worry that this is too big of a change and it would affect other devices too much to be allowable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions