Reads analog signal value from board ADC port. Does not check if port is valid.
utilitiy-analog-read-no-port-check
@/utilitiy-analog-read-no-port-check
Reads analog signal value from board ADC port. Does not check if port is valid.
PORTport
Analog port to read from. Should start with `A` to succeed.
UPDpulse
Triggers new read
DONEpulse
Fires on reading complete
VALnumber
The latest read value in range 0.0 … 1.0
To use the node in your project you should have the hio/nwt-gus-hi library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.
C++ implementation
#pragma XOD evaluate_on_pin disable
#pragma XOD evaluate_on_pin enable input_UPD
node {
void evaluate(Context ctx) {
//static_assert(isValidAnalogPort(constant_input_PORT), "must be a valid analog port");
if (!isInputDirty<input_UPD>(ctx))
return;
::pinMode(constant_input_PORT, INPUT);
emitValue<output_VAL>(ctx, ::analogRead(constant_input_PORT) / 1023.);
emitValue<output_DONE>(ctx, 1);
}
}