Because we ve encapsulated the whole Morse code logic in the
our main program is short and concise. Creating software for embedded
devices doesn t mean we can t benefit from the advantages of object-oriented
programming.
Still, we have some minor things to do to turn our project into a first-class
library. Read more about it in the next section.
Publishing Your Own Library
One of the nice features of the Arduino IDE is its syntax coloring. Class names,
function names, variables, and so on all have different colors in the editor.
This makes it much easier to read source code, and it s possible to add syntax
coloring for libraries. You only have to add a file named
project:
TelegraphLibrary/keywords.txt
# Syntax-coloring for the telegraph library
Telegraph
KEYWORD1
send_message
KEYWORD2
Blank lines and lines starting with a # character will be ignored. The
remaining lines contain the name of one of the library s members and the
member s type. Separate them with a tab character. Classes have the type
KEYWORD1
, while functions have the type
To enable syntax coloring for the telegraph library, copy
libraries/Telegraph
folder and restart the IDE. Now the name of the
will be orange, and
send_message
Before you finally publish your library, you should add a few more things:
• Store all example sketches in a folder named
libraries/Telegraph
folder. Every example sketch should get its own subdirec-
tory within that folder.
• Choose a license for your project and copy its terms into a file named
3
.
You might think this is over the top for many libraries, but it will
LICENSE
give your potential audience confidence.
• Add installation instructions and documentation. Usually, users expect
to find documentation in a file named
installation instructions in a file named
3.
At
http://www.opensource.org/
standard licenses.
KEYWORD2
will be brown.
README
INSTALL
, you can find a lot of background information and many
www.it-ebooks.info
Publishing Your Own Library
Telegraph
keywords.txt
to your
. For constants, use
LITERAL1
keywords.txt
Telegraph
examples
and copy it to the
, and they will look for
. You should try to install
71
class,
.
to the
class
report erratum
discuss
Need help?
Do you have a question about the Arduino Uno and is the answer not in the manual?