I'm working on a native class to recognize gestures.
Input will be a distance sensor HC-SR04.
To recognize a gesture something like setWatch is used.
Its running up to the point that an interupt is recognized, but there are no args that would help to assign the interupt to a parent.
Any idea ?
void gotInterrupt(int n, ... ){ jsWarn("got it %j",n); }
void jswrap_Gesture_scan(JsVar *parent){
JsGesture gest;
if(!getFromVar(&gest,parent)) return;
IOEventFlags exti = EV_NONE;
if (!jsiIsWatchingPin(gest.data.echo))
exti = jshPinWatch(gest.data.echo, true);
// disable event callbacks by default
if (exti) {
jshSetEventCallback(exti, 0);
JsVar *fn = jsvNewNativeFunction((void (*)(void))gotInterrupt, JSWAT_VOID|JSWAT_THIS_ARG|(JSWAT_JSVAR<<JSWAT_BITS));
if (!fn) return;
jshSetEventCallback(exti, (JshEventCallbackCallback)jsvGetNativeFunctionPtr(fn));
jsvUnLock(fn);
}
}
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
I'm working on a native class to recognize gestures.
Input will be a distance sensor HC-SR04.
To recognize a gesture something like setWatch is used.
Its running up to the point that an interupt is recognized, but there are no args that would help to assign the interupt to a parent.
Any idea ?