I’ve now forked Sumotoy’s great library for RA8875 based displays from Eastrising/Buydisplay so it can be used with Photon/P1. You can find the files here https://github.com/jenschr/RA8875/ This version will not work with the alternate SPI1, only the normal SPI.
Feedback much appreciated!
For others wanting to port libraries using SPI, here’s a few things I learned along the way:
- The Macro SPI_HAS_TRANSACTION does not seem to be defined for Photon, so you have to set this yourself at the top of your code (#define SPI_HAS_TRANSACTION 1)
- Most Arduino libraries use SPI.setClockDivider and SPI.setDataMode. Photon does not (need to) use these. Instead we use beginTransaction to set these parameters: SPI.beginTransaction(SPISettings(spi_speed, MSBFIRST, SPI_MODE3));
- SPI devices have a max speed. What speed you can use will depend on the hardware. Start low and increase is my best advice. The Photon will typically be able to use the same speeds as other ARM based devices.
- The cloud compiler does a few interesting things, including flattening your directories. This means that any library containing a folder structure cannot compile with either Particle Dev or the online IDE. Instead you’ll have to use Particle CLI for compilation. It’s clumsy, but it works. Adding support for this is on the list, but not yet implemented. Probably because the issue that held the thread was closed? https://github.com/spark/particle-dev-app/issues/6
- This page was of good help initially https://github.com/harrisonhjones/Spark-Ported-Libraries/ I’m sure that if someone made a more complete list than this, it would cause many more libraries to be ported.
- The Particle compiler dislikes .c files as used by the RA8875 fonts. Renaming them to .cpp solves the compilation issue, ref Compiling C files error
I hope this can be of use to others porting libraries!
Here’s a video of it running on my custom P1 based board: https://www.youtube.com/watch?v=lLZtcwHS09c