Trouble creating a usable repository

I am getting hung up on this step:

"1. Define a function to create library boilerplate

Copy and paste this into a bash or zsh shell or .profile file.

create_spark_library() {
LIB_NAME=$1

# Make sure a library name was passed
if [ -z "${LIB_NAME}" ]; then
    echo "Please provide a library name"
    return...."

This might be stupid but I don’t know where to put that code so I can run it?

I am trying to create a repository so I can use a library I found online in my code that I am writing on the online IDE.

Am I missing something or doing something wrong? Or is there an easier way for me to add my own library?

Thank you

You don’t need to use that if you don’t understand.

The idea is to have a spark.json file in the repo.

Click on any of the published library and see their files structure and the content inside spark.json :slight_smile:

Awesome thanks for the quick response I will give that a try!!!

1 Like

I’m new at this and from what I understand I need to create a repository on the cloud to use libraries in my program for my photon. I was having the same problem as busterdavidson. I don’t understand how the reply addresses the question and don’t follow the explanation in getting started. How do I create a repository or is that actually what I need to do?

Hi @jariding

If you are just using the web IDE (build button on the website) to compile and flash your code, then you can also cut and paste your libraries in to be used in sketch. Just click the small grey “circle-plus” in the upper right-hand corner of the window. This will allow you to add a library as a .h and .cpp file to your web project.

If you are the author of a library and want to share it with the community, then you need a github repository to share it from.

If you are using Particle Dev or other tools, tell us and we can help you there too.

Hello bko,

I attempted what I think you said, but I’m still having issues. The library I’m attempting to use is “OneWire”. So, what I should do is, go into the web IDE and click on the plus, locate the code in the Arduino library, and cut and paste it into the command file. Do I need to add anything to the header file? I ask because all I see is code that looks like a command file and no header file. I have a small amount of experience with header files from a C++ class I had a couple of years ago, but I don’t remember how to compose one.

Thanks very much for your reply!

Hi @jariding

You don’t need to even do that for the onewire library! There is an official Particle onewire library in the web IDE.

Find the icons on the lower left side and click on the one that looks like a little ribbon with a notch cut out of the bottom, second from the top in the bottom group. That will open the libraries tab and you can select the onewire library.

But this bound to change once Libraries v2.0 is released. Then you could just upload a library from your own harddrive directly (at least for private use - for public it would still be good to offer a GitHub repo to accept issue reports and PRs :wink: )

And for the “How to import libraries” looking in the docs doesn’t hurt
https://docs.particle.io/guide/getting-started/build/photon/#using-libraries

There are even pictures :wink:

1 Like