Im trying to import a mbed library that works really well on button ISRs. Anyone got any tips on how to create/port libraries which can be used with my P1. I have small knowledge on how to create libraries for particle/arduino.
I really like the ability for the library to detect a “held” press etc. I dont really like the click button library.
- First I’d just copy the sources for the library into a normal project and make it first build by adapting the syntax to the new platform scheme.
- Once it builds without errors make it work as expected.
- When that’s done, you can use CLI
particle library create to get the correct library structure layed out.
- Modify the
library.properties fields to fit your library.
- Put the adapted library sources (with names that match the library name) into the
- Add some examples
- Upload via
particle library upload
- Test that everything works as it should
- Publish via
particle library publish
Since there is no stock
Ticker interrupt source on Particle devices, you may need to use
SparkIntervalTimer as replacement. In order to have your contributed library use it you’d import it via
particle library add SparkIntervalTimer.
However, it seems somewhat excessive to have a permanently polling timed interrupt to “detect” button actions. Wouldn’t a CHANGE interrupt on the respective pin be the more effective way?