How to develop or edit an Arduino library?
I'm not accepting any answer because they are only focused on versioning/git/github fork->edit->share and I am very interested on all the things that I have to do to make the development.




I will run through the basics of making a library. It's really quite simple, and they persist through upgrades to the IDE.

Let's imagine I have a useful function (or lots of functions) that I want to use in lots of sketches. For example, something that blinks an LED:

void blinkLED (const byte which, const int times)
  {
  for (int i = 0; i &lt; times; i++)
    {
    digitalWrite (which, HIGH);
    delay (500);
    digitalWrite (which, LOW);
    delay (500);
    }  // end of for loop
  } // end of blinkLED


And some test code:

void setup ()
  {
  Serial.begin (115200);
  Serial.println ();
  pinMode (13, OUTPUT);
  blinkLED (13, 5);
  }  // end of setup

void loop ()
  {
  }  // end of loop




Make a library

To turn that into a library we need three steps:


Make a folder for the library. This should be placed inside the libraries folder in your sketchbook folder. This folder:



In my case: /home/nick/sketchbook/libraries. It does not go into anywhere associated with the IDE download.


  but now I have to edit some located at %appdata%\Arduino15\packages\esp8266\hardware\esp8266\1.6.5-947-g39819f0\libraries


No, not there.

I will call my library blinkLED. So I make that folder, which is now: /home/nick/sketchbook/libraries/blinkLED





Make a function prototype for any functions your library is going to "expose" to the end-user, and put that into a .h file, like this:

blinkLED.h

#include &lt;Arduino.h&gt;

void blinkLED (const byte which, const int times);


Important: You must include &lt;Arduino.h&gt; as in the example, or you will get compile errors.





Put the C++ code into a .cpp file, like this:

blinkLED.cpp

#include &lt;blinkLED.h&gt;

void blinkLED (const byte which, const int times)
  {
  for (int i = 0; i &lt; times; i++)
    {
    digitalWrite (which, HIGH);
    delay (500);
    digitalWrite (which, LOW);
    delay (500);
    }  // end of for loop
  } // end of blinkLED


Important: You must include the .h file created in step 2, as in the example, or you will get compile errors.




That's it! Restart the IDE now so it notices the new folder with the library in it.

Now our test sketch can just use the new library.

#include &lt;blinkLED.h&gt;

void setup ()
  {
  Serial.begin (115200);
  Serial.println ();
  pinMode (13, OUTPUT);
  blinkLED (13, 5);
  }  // end of setup

void loop ()
  {
  }  // end of loop




Testing

For testing I just keep the library files open in a separate text editor (I am using Geany these days, but whatever your favourite editor is).

You can make changes to the library source and save them. You do not need to restart the IDE if you do this. It will always pick up the latest version.

In the IDE you alter your calling code, upload and test. It is really quite fast and simple.



Git

Once you have put a bit of work into your library you probably want to put it under source control. Using a terminal/command window, navigate to the library folder and put it into a Git repository:

git init
git add *.cpp
git add *.h
git commit -m "Initial commit"