Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing the timer to check a condition inside a if
    primarykey
    data
    text
    <p>I have to develop an application where it does following things,</p> <ol> <li>Switch is used to initiate the accelerometer</li> <li>Then accelerometer data is inserted to an array of size 5</li> <li>Then use those accelerometer data to calculate a output value using a equation</li> <li>Every times a new reading comes, i delete the last element of the array and add it to the array( array remains dynamic through out the loop</li> <li>Then i want to compare whether the output calculated is greater than a specified value and update a global counter?</li> </ol> <p>I implemented this by using a if condition</p> <pre><code>if(output&gt;10){ [[shared sharedInstance].counter++; } </code></pre> <p>(all above are implemented and they work perfectly)</p> <p>BUT the problem is.....................</p> <p>I want to check this if condition, used to update to be active for 5ms and deactivate for 10ms but it's also important to "NOT" to stop the accelerometer data process and calculating output.</p> <p>So i thought that i can implement two global variables and set their values as shown below 1. var_x - set it's value for 1 for 5ms after that set it to 10ms and this process should repeat continuously and it should start after the user activate accelerometer,</p> <p>So by using this inside my if condition i can make sure it check the condition after 10ms and keep on checking for 5ms like this.........</p> <pre><code>if(output&gt;10 &amp;&amp; [[shared sharedInstance].var_x &gt;1){ [[shared sharedInstance].counter++; } </code></pre> <p>can anyone help me to code this timing function inside the global variable to set the variable value to 1 and 0 ? (</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload