microphone

wayland/wio-terminal-sensors/microphone

Wio Terminal's built-in microphone.
microphone
@/microphone
Wio Terminal's built-in microphone.
UPDpulse
Triggers new read
microphone
VAL
DONE
UPD
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 wayland/wio-terminal-sensors 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) {
         if (!isInputDirty<input_UPD>(ctx))
            return;

        ::pinMode(WIO_MIC, INPUT);
        emitValue<output_VAL>(ctx, ::analogRead(WIO_MIC) / 1023.);
        emitValue<output_DONE>(ctx, 1);
    }
}