Gesture updates too quickly

I’m looking for a simple solution for an if condition within my update function that updates too quickly.

I’m using a myo armband to read gestures and I want to create only 1 object when that gesture is collected. Here is the simple if statement:

if(myo.collector.currentPose == myo::Pose::waveIn){

//Do something only once


However, since the gesture is detected over the course of several update loops, the code within the if statement actually happens about 5 times after performing the gesture once.

Is there a way to remedy this with a timer? Any ideas?

you can do something like that, create a var to hold last time you called the function and later compare if have passed enough time.

long lastGestureCall;

if(myo.collector.currentPose == myo::Pose::waveIn && (ofGetElapsedMillis()-lastGestureCall > rangeValue) ){

//Do something only once

You could also create an ofEvent to be called when the pose is updated, instead of polling in the update loop.