|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Time/timer function
Hello,
I am trying to include a time/timer function so that in a while loop I can keep track of how long it has been and still being able to run other code. Also I would like to use it so that when I press a joystick button, the button is disable for say 1 second (so that it only registers 1 press and not registering from consistent pressing). Could demonstrate how this function works? Thanks, Davis |
|
#2
|
||||
|
||||
|
Re: Time/timer function
Quote:
(button_is_pressed && button_was_not_pressed_in_previous_iteration) does what you want. It's true only in the iteration immediately after the button is pressed, and doesn't become true again until the button is released and pressed again. |
|
#3
|
|||
|
|||
|
Re: Time/timer function
Thanks, that helps a lot!
Although I am still interested in learning how to use the time/timer feature. I'm not sure if there is a specific function that can be used as a timer, or if I have to get the time off the cRIO (if possible) and do my own math. Thanks! |
|
#4
|
||||
|
||||
|
Re: Time/timer function
I use this macro.
Code:
#define GetMsecTime() (GetFPGATime()/1000) |
|
#5
|
|||
|
|||
|
Re: Time/timer function
So i just add the #define up with the includes and use the function wherever I need to and do the math from there.
Thanks. |
|
#6
|
||||
|
||||
|
Re: Time/timer function
Quote:
Code:
UINT32 startTime = GetMsecTime();
//
// Do something that you want to time.
//
printf("Elapsed time = %d msec\n", GetMsecTime() - startTime);
|
|
#7
|
||||
|
||||
|
Re: Time/timer function
There is also a Timer class, but I don't like it much. Remember to call the Start() method if you use it.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|