Questo sito non è ne attivo ne aggiornato, specialmente la pagina del download รจ ferma a 5 vesioni fa , utilizzate il sito in inglese finchè questo sito non sarà annunciato ufficialmente

Learning   Examples | Foundations | Hacking | Links

TextString Library

A lot of programming work involves sending and receiving strings of ASCII data. Altough Arduino isn't designed as a platform for complex manipulation of text strings, there are often times when you need to read strings, look for substrings, compare strings, and so forth. You might be trying to read a GPS receiver, or sending commands to a Bluetooth or Zigbee radio that uses an AT-style command set. If that's what you're doing, this library is for you.

Download: TextString.zip

To use, unzip it and copy the resulting folder, called TextString, into the lib/targets/libraries directory of your arduino application folder. Then copy the examples folder from the TextString folder to your Arduino code folder (the devault location is Documents/Arduino/). Then re-start the Arduino application.

When you restart, you'll see a few warning messages in the debugger pane at the bottom of the program. You can ignore them.

As of version 0.1, this library has very limited functionality. Here's what you can do:

TextString(int strLength) - initialize a TextString of a given length e.g.

TextString myString = TextString(50); // makes a 50-byte long TextString

clear(void) - fill the TextString with zeroes, e.g.

myString.clear();     // clears the string

length(void) - get the length up to the first zero byte e.g.

int stringLength = myString.length(); // gives the string length

equals( char *thatString) - compare your TextString to a given string, e.g.

if (myString.equals("Hello")) {
   // compares myString to "Hello"
}

contains(char *subString) - whether the TextString contains a given substring e.g.

if (myString.contains("Hello")) {
   // checks if myString contains the subString "Hello"
}

trim(void) - trim whitespace from both ends of the TextString. Removes any space characters, carriage returns, newlines, tabs, or vertical tabs. e.g.

Serial.print(myString.trim());   // prints the trimmed version of myString 

trimRight(void) - trim whitespace from the end of the TextString e.g.

Serial.print(myString.trimRight());   // prints the version of myString trimmed on the end


trimLeft(void) - trim whitespace from the beginning of the TextString e.g.

Serial.print(myString.trimLeft());   // prints the version of myString trimmed from the beginning


setArray(char* thatString) - set the whole character array e.g.

myString.setArray("What's up Doc?");   // puts a string in the array


getArray(void) - get the whole character array e.g.

Serial.println(myString.getArray());   // prints the string

getCharAt(int charNum) - get a given character from the TextString e.g.

char thisChar = myString.getCharAt(5);   // gets the sixth character in the array

setCharAt(int charNum, char thisChar) - set a given charracter in the TextString e.g.

myString.setCharAt(5, 'A');   // sets the sixth character in the array to "A"

version(void) - get the library version. Since there will be more functions added, printing the version is a useful debugging tool when you get an error from a given function. Perhaps you're using an earlier version that doesn't feature the version you need! e.g.

Serial.println(myString.version());   // prints the version of the library 


If anyone's interested in helping to develop this library further, please contact me at tom.igoe at gmail.com