Hi all,
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
Yeah. I noticed that. I randomly found it via the documentation some hours ago, but it didn’t seem to solve the problem automatically? I’ll dig some further into it.
UPDATE: I tested and this is not working as it should. It works fine from CLI though.
I noticed in the zip you linked on github that your binary is inside the src folder.
To properly build Dev should be pointing to the folder containing the project.properties file.
If that was the case your binary should end up along side the project.properties file.
I have no idea where this document is gone nor what it was all about.
All I know about v2.0 libs & projects is what I found out playing and investigating (without reading boring manuals - if it’s not intuitive it’s worth an issue report )
A few more things on porting libraries. For I2C - there’s no need to include wire.h (but also no problem to leave it in).
Arduino libraries may contain: Wire.setClock(400000UL);
The Particle way is to do this: Wire.setSpeed( CLOCK_SPEED_400KHZ );
Some libraries will use Wire.send(x) instead of Wire.write(x). This is deprecated in the Arduino libraries (since version 1.0) and correctly implemented by Particle, but Arduino still have a documentation page up that shows the method, but does not list it as deprecated https://www.arduino.cc/en/Reference/WireSend