Utilities Library
Last updated
Last updated
WaspUtils.h ; WaspUtils.cpp
To start using the Waspmote Utilities library, an object from class 'WaspUtils'
must be created. This object, called Utils
, is created inside the Waspmote Utilities library and it is public to all libraries. It is used through the guide to show how the Waspmote Utilities library works.
When creating this constructor, no variables are initialized.
There are some constants defined in 'WaspUtils.h' used to make it easier the understanding of the code.
These functions are capable of changing the state of the LEDs. There are two programmable LEDs in Waspmote: a green LED and a red LED. LED1
refers to the green LED. LED0
refers to the red LED. It is possible to change their state, to get their state and to blink both LEDs for a specific time.
The function setLED()
changes the state of the LEDs. It is necessary to indicate two different inputs: the LED which is set and the state to be set.
Example of use:
Using LEDs example: http://www.development.libelium.com/ut-02-using-leds
The function blinkLEDs()
blinks both LEDs once using the time input specified as argument in this function in milliseconds units.
Example of use:
The function blinkRedLED()
blinks the red LED once during 200 ms. It is possible to modify the number of times it blinks and the amount of time used in each blinking.
Example of use:
The function blinkGreenLED()
blinks the green LED once during 200 ms. It is possible to modify the number of times it blinks and the amount of time used in each blinking.
Example of use:
Using LEDs example: http://www.development.libelium.com/ut-02-using-leds
This is the microcontroller's EEPROM (4 KB) non-volatile memory. EEPROM addresses from 0 to 1023 are reserved by Waspmote API to save important data, so they must not be over-written. Thus, the available storage addresses go from 1024 to 4095.
Reserved | Available |
0 1023 | 1024 4095 |
Figure: EEPROM availability overview
The function that writes the EEPROM is Utils.writeEEPROM()
. This function does not permit to write reserved EEPROM addresses.
Example of use:
Using EEPROM example: http://www.development.libelium.com/ut-01-using-eeprom
This function reads the Waspmote unique serial identifier. This identifier is composed by 8 bytes.
Example of use:
Using EEPROM example: http://www.development.libelium.com/ut-03-reading-serial-id
Convert from long int to string:
Convert from float to string:
AVR Libc Library allows the user to convert between different variable types. This is a list with some supported function prototypes:
Convert string to int (2 bytes):
Convert from string to long integer (4 bytes):
Converting types example: http://www.development.libelium.com/ut-04-convert-types