Libraries to Update for the Photon

MQTT works for me with photon if you add #include “application.h” in all files, comment out the three spark_wiring* includes, and change all boolean references to bool

Here’s a version of the NeoPixel library that works for the photon, who owns that library in the IDE / wants to update it?

{REMOVED POSTED CODE -BDub} NeoPixel Library Updated Here

Thanks,
David

I think @BDub owns the GitHub repo. I started playing around with NeoPixels on the Photon last night with the updated files and they worked great. If @BDub is too busy, I can do a diff, modify the library to support both platforms, and submit a pull request.

Wouldn’t it be a good idea to merge this with the current neopixel library and use conditional compilation to target the Core or Photon?

1 Like

Totally, I thought the library already does that with some defines, but I could be mistaken.

NeoPixel Library has been updated guys! Let me know if you see any issues.

4 Likes

I suppose this may change when we add more devices, but the way I added the Photon was simply to add more of the right delays everywhere appropriate if the build target was a Photon, otherwise none of that is added and the library more or less looks like it did when it was just the Core. This is because the Photon runs at 120MHz vs the 72MHz of the Core, so it needs more delay to have the same timing. Keeping it all together actually helped me fine tune the Core delays as well.

4 Likes

Onewire

3 Likes

HTTPClient was fixed by adding #include “application.h” to the top of HttpClient.cpp I hate to make a pull request for something so simple, but if the owner wont update it let me know and I will post a new version with the fix included.

I took a stab at this: https://github.com/balbano/OneWire-Photon

It’s pretty rough, but it works for me. It definitely could use a look by someone with more familiar with the internals of both the Photon and the OneWire protocol, but it’s a start!

3 Likes

Hi Beebs, Thanks for doing this. I’m a complete newbie and tried to use your library by “contributing” it, but it said it was missing several files, including “spark.json”. What’s the correct way for me to use it? Thanks for your help!

If your only goal is to use it, and not actually contribute to it, you can copy the contents of the files into the web IDE by hitting the small + sign in the top right corner of the IDE, and then pasting the contents of the files in the newly created pages. That should work. Once the library is fully ported, it can go into the library system where it can be used like the other libraries :smile:

2 Likes

I can convert my stab at OneWire into a real library if that makes it easier for people to test it out/contribute.

I’m new to the particle ecosystem, so just to check, is this the official instructions for making a library: https://github.com/spark/uber-library-example? Is there a way to use this style of library with the desktop Particle Dev, or is it web IDE only?

2 Likes

As for now there are some things to consider when providing a lib for Web IDE and other IDEs.
Web IDE does place contributed libs in your project inside a folder named after the lib, while Particle Dev wants (at least used to, last time I used it ;-)) it to be in your project root folder.

So I usually do this

#define PARTICLE_WEB_IDE  // uncomment for Web IDE
//#define PARTICLE_DEV_IDE  // uncomment for Particle DEV

// to avoid "No such file" errors
#if defined(PARTICLE_WEB_IDE)
#include "LibName/LibName.h"
#elif defined(PARICLE_DEV_IDE)
#include "LibName.h"
#else
// whatever else
#endif

Some other things, like the folder structure and the mentiond JSON file and other things should be done as shown in UBER-LIBRARY, but are also checked when contributing your lib.
Just make sure that all your provided examples do actually build without error before publishing your private lib to the public - that makes corrections easier :wink:
I usually need at least three iterations to get it running propperly :blush:

Thanks Beebs for porting the OneWire library. I made a small modification to line 91 of the .h file. I removed the “OneWire::” in front of digitalReadFast(). It now seems to compile both for a core and a photon. I have also put the OneWire library in a format that matches the WebIDE with the name “Particle-OneWire”. I have modified the dallas library to match “ParticleDallasTemperature” . I have yet to fully check all of the examples, etc so I have not made it public to the WebIDE.

3 Likes

What would it take to get the OneWire library fixed in the Web IDE Libraries?

Is it something users can contribute too or something that Particle Team needs to do?

I just issued a pull request to the existing OneWire library on the web IDE. I thought this would be better than publishing a new OneWire library, because then there would be multiple versions on the web IDE, some that support the Photon and some that don’t. If the maintainer of that library merges the pull request, then we’re good to go. It looks like they haven’t been on github in a while though, so if they don’t, then we can publish a new library or something.

@Carsten4207 if you want to contribute to a library, I think they best way is to fork it on github, make a change, then submit a pull request. It doesn’t look like OneWire is an official library the way SPI or something is, so anyone can contribute. Once the discussion about PIN_MAP gets sorted out, there will likely need to be some updates to the OneWire library!

If you need an interim solution you can import the above linked libraries and into your account on the WebIDE. This is done under the “libraries” tab in the WebIDE. Click on “contribute library” and import. There will be a warning that another user has a library under the same name, disregard this. Note that any library that relies on OneWire will need to be changed to Particle-OneWire as is done for DallasTemperature in the above link. The Dallas library works but I am still working on getting fixing all of the examples. As Beebs mentioned ideally this will happen through a merger with the original OneWire library or through PIN_MAP modification so as not to add any confusion or reworking of already existing sketches.

1 Like

Thanks for that! I never realized you could import libraries.

Anyway I got the DS18B20 working with the Photon. Thanks!