ADC gain multiplier. Can take values of: 0.5, 1, 2, 4, 8, 16, 32, 64, 128, 256 and 512.
UPDpulse
Update.
DONEpulse
Pulses if gain is successfully set.
To use the node in your project you should have the wayland/as7343-spectrometer 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) {
// The node responds only if there is an input pulse
if (!isInputDirty<input_UPD>(ctx))
return;
auto sensor = getValue<input_DEV>(ctx);
auto gain = getValue<input_GAIN>(ctx);
if (gain<1) {
if (!sensor->setGain(AS7343_GAIN_0_5X)) {
raiseError(ctx);
return;
}
emitValue<output_DONE>(ctx, 1);
}
if (gain==1) {
if (!sensor->setGain(AS7343_GAIN_1X)) {
raiseError(ctx);
return;
}
emitValue<output_DONE>(ctx, 1);
}
if (gain==2) {
if (!sensor->setGain(AS7343_GAIN_2X)) {
raiseError(ctx);
return;
}
emitValue<output_DONE>(ctx, 1);
}
if (gain==4) {
if (!sensor->setGain(AS7343_GAIN_4X)) {
raiseError(ctx);
return;
}
emitValue<output_DONE>(ctx, 1);
}
if (gain==8) {
if (!sensor->setGain(AS7343_GAIN_8X)) {
raiseError(ctx);
return;
}
emitValue<output_DONE>(ctx, 1);
}
if (gain==16) {
if (!sensor->setGain(AS7343_GAIN_16X)) {
raiseError(ctx);
return;
}
emitValue<output_DONE>(ctx, 1);
}
if (gain==32) {
if (!sensor->setGain(AS7343_GAIN_32X)) {
raiseError(ctx);
return;
}
emitValue<output_DONE>(ctx, 1);
}
if (gain==64) {
if (!sensor->setGain(AS7343_GAIN_64X)) {
raiseError(ctx);
return;
}
emitValue<output_DONE>(ctx, 1);
}
if (gain==128) {
if (!sensor->setGain(AS7343_GAIN_128X)) {
raiseError(ctx);
return;
}
emitValue<output_DONE>(ctx, 1);
}
if (gain==256) {
if (!sensor->setGain(AS7343_GAIN_256X)) {
raiseError(ctx);
return;
}
emitValue<output_DONE>(ctx, 1);
}
if (gain==512) {
if (!sensor->setGain(AS7343_GAIN_512X)) {
raiseError(ctx);
return;
}
emitValue<output_DONE>(ctx, 1);
}
if (gain==1024) {
if (!sensor->setGain(AS7343_GAIN_1024X)) {
raiseError(ctx);
return;
}
emitValue<output_DONE>(ctx, 1);
}
if (gain==2048) {
if (!sensor->setGain(AS7343_GAIN_2048X)) {
raiseError(ctx);
return;
}
emitValue<output_DONE>(ctx, 1);
}
}
}