December 3rd, 2012, 06:18 AM
Required delay before function execution!!!
Please refer the function mentioned below.
a[i] gives alarm conditions.
void ringAlarm(int8* ai)
static int16 time_delay=1000;
if(ai[i]==1 && time_delay==0)
}// if ends
My requirement is
1. Check a[i]==1 i.e checking condition
2. Wait for some delay
3. Again check for a[i]
4. And if a[i]==1 after delay then only execute the function
But i can not use delay function which halts execution of next code.
As mentioned i have used a variable and it decrements every time when it enters into function.
But with the above mentioned code i am not getting expected result.
Please suggest where i have to re-initialize it's original value once it becomes zero?
December 3rd, 2012, 06:34 AM
Post your code between [code][/code] tags, to preserve indentation and readability.
December 3rd, 2012, 06:43 AM
Ohhh my mistake...
I am sorry!!!!
December 3rd, 2012, 08:44 AM
Perhaps you need a threaded application?
one thread can sleep or usleep as needed while the other thread continues the important application.
This tutorial was so clear that even I was able to write a threaded program. Actually my program doesn't work so well on linux. A histogram of the interval between my gui updates revealed a bimodal distribution of 40 and 200 milliseconds. I'll need to install the real time kernel (not really an option for a general purpose program) or find some other solution.
[/code] are essential for python code and Makefiles!
December 3rd, 2012, 11:01 PM
Thanks for support.
I forgot to tell that i am using windows os.
December 4th, 2012, 12:21 AM
So how about
if ( time_delay > 0 ) return;
// time_delay is now 0, so reset it
time_delay = 1000;
// now do the rest
December 4th, 2012, 12:42 AM
Okay. I will check with this.
Originally Posted by salem