that the Arduino IDE can show them in the appropriate color when users are editing code.
The other is to include some examples of how to use the library.
Keywords
To define the keywords, you have to create a file called keywords.txt, which goes into the
Flasher directory. This file contains just the two following lines:
This is essentially a two-column table in a text file. The left column is the keyword and
the right column an indication of the type of keyword it is. Class names should be a
KEYWORD1
and methods should be
KEYWORD2
. It does not matter how many spaces
or tabs you put between the columns, but each keyword should start on a new line.
Examples
The other thing that you, as a good Arduino citizen, should include as part of the library is
a folder of examples.
In this case, the library is so simple that a single example will
suffice.
The examples must all be placed in a folder called examples inside the Flasher folder.
The example is
in fact just an Arduino sketch, so you can create the example using the
Arduino IDE. But first, you have to quit and then reopen
the Arduino IDE to make it
aware of the new library.
After restarting the Arduino IDE, from the Arduino IDE’s menu,
select File and then
New to create a new sketch window. Then from the Menu, select Sketch and the Import
Library option. The Options should look something like
Figure 11-1
.
The libraries above the line in the submenu are the official libraries; below this line are
the “unofficial” contributed libraries. If all has gone well, you
should see Flasher in the
list.
If Flasher is not in the list, it is very likely that the Flasher folder is not in the libraries
folder of your sketches folder, so go back and check.
The Arduino IDE will not allow you to save the example sketch directly into the
libraries folder, so save it somewhere else under the name
Simple Flasher Example and
then move the whole Simple Flasher Example folder that you just saved into the examples
folder in your library.
If you restart your Arduino IDE, you should now see that
you are able to open the
example sketch from the menu as shown in
Figure 11-2
.
Dostları ilə paylaş: