Timer Example

Post a reply

Confirmation code
Enter the code exactly as it appears. All letters are case insensitive.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :arrow: :| :mrgreen: :geek: :ugeek:

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
Confirmation code
Enter the code exactly as it appears. All letters are case insensitive.
   

If you wish to attach one or more files enter the details below.

Maximum filesize per attachment: 1 MiB.

Expand view Topic review: Timer Example

Re: Timer Example

by surfrider » 01 May 2021 05:12

Most software I have work on, when you create a thread or have a while loop it is always advised to have at least a very short sleep so the OS can to task switching during the sleep.
It depends a bit on the multi-threading system of the EV3 or cpp4robots.

Re: Timer Example

by cpp4robots_admin » 19 Feb 2021 07:39

I'm sorry, but I don't know.
I don't know any tool to find out if our application in EV3 brick uses the processor at 100%.
I don't know if other applications in EV3 brick are affected(slow down) by our process.

In any case, it is a very interesting topic for discussion.

Re: Timer Example

by surfrider » 18 Feb 2021 16:02

Is it needed/advised to put a sleep in the while loop? To prevent 100% CPU load?

Re: Timer Example

by cpp4robots_admin » 16 Feb 2021 08:38

Code: Select all

#include <EV3_Timer.h>
#include <EV3_BrickUI.h>
#include <EV3_LCDDisplay.h>


int EV3_main()
{
    using namespace ev3_c_api;

    T_TimerId idTimer = Timer_Start();

    while ( 1 )
    {
        if ( isBrickButtonPressed(E_BTN_ESC) )
            break;

        Draw_Text(3, E_Font_Normal, false, "Elapsed time:");
        Draw_Text(4, E_Font_Normal, false, "%.5lu", Timer_GetTime(idTimer));
    }

    Timer_Destroy(idTimer);

    return 0;
}

Timer Example

by Robot_Programmer » 15 Feb 2021 20:50

Can someone provide me with an example of using the Timer on the EV3? I would like to start a timer, and then display the elapsed time on the LCD display.

Top