![]() |
Fraise
2.1
FRAmework for Interfacing Software and Electronics
|
Automates the use of analog input pins. More...
Automates the use of analog input pins.
Example:
Settings to put in config.h | |
These parameters can be overloaded in the config.h of your firmware. | |
#define | ANALOG_MAX_CHANNELS |
default 16. | |
#define | ANALOG_FILTER |
default 3, maximum 5; analog values are filtered and multiplied by 1<<ANALOG_FILTER. | |
#define | ANALOG_THRESHOLD |
default 7: don't send an analog channel until it differs from last sent value by more than ANALOG_THRESHOLD. | |
#define | ANALOG_MINMAX_MARGIN |
default 100: increase the minimum measured value by this amount (and decrease max value) for scaling output. | |
#define | ANALOG_SCALED_MAX |
default 16383: maximum scaled output value. | |
Output mode switchs | |
The different mode switchs can be OR-ed together and passed to analogSetMode(). | |
void | analogSelectAdc (unsigned char chan, unsigned char hwchan) |
void | analogSelectAdcTouch (unsigned char chan, unsigned char hwchan, unsigned char *port, unsigned char bit) |
#define | AMODE_SCALE |
Map each channel to a normalized scale (see analogScaling() ). | |
#define | AMODE_NUM |
Send values in a raw (numerical) message, parsed by analog/parse.pd patch. Otherwise send text messages: "A channel value". | |
#define | AMODE_CROSS |
Crossing mode. If channel value has been set (see analogSet() ), wait for the measurement value to cross the set value before sending value updates. | |
#define | analogSelectTouch_(num, adchan, port, bit) |
Initialization | |
void | analogInit () |
Init the module in setup() | |
void | analogInitTouch () |
Enable capacitive touch function in setup() | |
void | analogSetMode (unsigned char mode) |
Configure the way analog values are sent by analogSend() (use Output mode switchs). | |
#define | analogSelect(num, conn) |
Select a pin for an analog channel. More... | |
#define | analogSelectTouch(num, conn) |
Select a pin for a capacitive touch channel and prepare it for capacitive measurement. More... | |
Main loop functions | |
unsigned char | analogService (void) |
Module service routine, to be called by the main loop(). More... | |
char | analogSend (void) |
Send analog values that changed. More... | |
Utilities | |
void | analogDeselect (unsigned char chan) |
Deselect a channel. | |
void | analogSet (unsigned char chan, int val) |
Set the value of a channel (to be used in conjunction with AMODE_CROSS). | |
int | analogGet (unsigned char chan) |
Get the last measured value of a channel. | |
int | analogGetDistance (unsigned char chan) |
Get the distance between the last measured value of a channel and its internal value (set by analogSet() ) | |
void | analogScaling (unsigned char scaling) |
Start or stop the scaling calibration. More... | |
void | analogDeclareEE () |
EEPROM declaration for this module Call this function in your EEdeclareMain() if you want to save analog scaling calibration. | |
unsigned char analogService | ( | void | ) |
Module service routine, to be called by the main loop().
char analogSend | ( | void | ) |
Send analog values that changed.
Call at the maximum rate you want to report analog.
The way values are sent depends on the Output mode switchs. See analogSetMode().
void analogScaling | ( | unsigned char | scaling | ) |
Start or stop the scaling calibration.
scaling | 1:start 0:stop First use analogScaling(1) to start calibration, which will measure the minimum and maximum values for each channel; then stop calibration with analogScaling(0). |
#define analogSelect | ( | num, | |
conn | |||
) |
Select a pin for an analog channel.
num | Number of the channel (first channel = 0) |
conn | Symbol of the pin (example: K1 for connector 1) |
#define analogSelectTouch | ( | num, | |
conn | |||
) |
Select a pin for a capacitive touch channel and prepare it for capacitive measurement.
num | Number of the channel (first channel = 0) |
conn | Symbol of the pin (example: K1 for connector 1) |