gabbapeople/lab-1-sensors-1
nodespace { volatile bool event0 = false; volatile bool event1 = false; void interrupt0Handler() { event0 = true; } void interrupt1Handler() { event1 = true; } } node { void evaluate(Context ctx) { if (isSettingUp()) { ::pinMode(constant_input_P0, INPUT_PULLUP); ::pinMode(constant_input_P1, INPUT_PULLUP); attachInterrupt(digitalPinToInterrupt(constant_input_P0), interrupt0Handler, FALLING); attachInterrupt(digitalPinToInterrupt(constant_input_P1), interrupt1Handler, RISING); } if (!isInputDirty<input_UPD>(ctx)) return; if (event0) { event0 = false; emitValue<output_EV0>(ctx, 1); } if (event1) { event1 = false; emitValue<output_EV1>(ctx, 1); } } }
© 2017–2024XOD Inc
Contact us: hello@xod.io