-
Notifications
You must be signed in to change notification settings - Fork 125
Analog Values
Analog values are always represented as floating points, in order to save RAM half-precision floating point (2 bytes) is used to store and send the value over the network.
The GCC math libs doesn't support half-precision floating point, so all math operation need single-precision (4 bytes) floating point.
Read a value from an analog pin and store it directly into the node can be done through AnalogIn method, this read the analog input, convert and store it directly. The scaling and bias allow to convert the value as
storedvalue = (readvalue * scaling) + bias
.
void AnalogIn(U8 pin, U8 slot, float scaling, float bias)
Once you have stored this value, you need to process it using a relevant analog Typicals, like T51.
If you need to perform maths, read the analog value using analogRead() from Processing/Arduino and then import the value using
void ImportAnalog(U8 slot, float* analogvalue)
This applies also in case of data acquired via external libraries, like DHT and DA1820 sensors.
...
#define TEMPERATURE 0 // Analog values use two slot, in this case 0 and 1
... // Include DHT related code
float read_temperature = dht.readTemperature();
void ImportAnalog(TEMPERATURE, &read_temperature);
...
Analog values shall be transferred as half-precision floating point, use RemoteInputs() to send the two output bytes directly into a T5n Typicals of a destination node.
Use
RemoteInputs(U16 addr, U8 firstslot, U8 *commands, U8 numberof)
The following line of code send the analog value every time that is executed,
RemoteInputs(dst_addr, dst_slot, mOutput[src_slot], 2);
- Introduction
- Getting started
- User Interfaces
- Build your Souliss
- Examples
- Boards
- Interfaces
- Hacks
- Advanced
- Source Code
- Downloads
- Community