Tag: PAM_Tools

Update for library PAM_Tools

Update for library PAM_Tools

While creating projects with my libraries, I found that most of them required some additions which I have created and will document here.

I have expanded the PAM_Tools library to allow it to handle float and bool as well. To this I have created the following functions:

float getFloatKey (String, String);
bool getBoolKey (String, String);
void putFloatKey (String, String, float);
void putBoolKey (String, String, bool);
float getPutFloatKey (String, String, float);
bool getPutBoolKey (String, String, bool);

They work the same as the versions for String and int except that since there are only two values possible for bool there is no way to detect if there is no value present so it will return false if there is no way. If you want to have a default value, you can use getPutBoolKey.

github-mark-32px Available on GitHub with a lot of comment in the code. Direct download.

Library PAM_Tools

Library PAM_Tools

After working with the Arduino IDE for some time, I decided it is time to write some convenient libraries that will help me quickly do some of the tasks that occur often and could do with a convenient wrapper.

This library is aimed at using the file system to store keys.

github-mark-32px Available on GitHub with a lot of comment in the code. Direct download.

Let’s look at the functions:

The following four functions are used to store and retrieve String and int values persistently (meaning between reboots).

String getStringKey (String location, String key)

This function will retrieve the content of a file in a string where the filename is /<location>/<key>.txt The .txt extension is used so on Windows you can create
the needed files in a data directory which you can than upload using the ESP8266 Sketch Data Upload. If the key is not found a NOSTRINGKEYFOUND will be returned.

int getIntKey (String location, String key)

This function will retrieve the content of a file and put it in an int where the filename is /<location>/<key>.txt The .txt extension is used so on Windows you can create
the needed files in a data directory which you can than upload using the ESP8266 Sketch Data Upload. If the key is not found a NOINTKEYFOUND will be returned.

void putStringKey (String location, String key, String value)

This function will put a String value into the file with filename
/<location>/<key>.txt If the file exists it will be overwritten.

void putIntKey (String location, String key, int value)

This function will put an int value into the file with filename
/<location>/<key>.txt If the file exists it will be overwritten.