Pages: [1]   Go Down
Author Topic: Elapsed Timing Library for 1.02  (Read 2330 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 44
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all,

I have the Elapsed Timer library for Arduino 022 and my program works great.
However it will not work in version 1.02, I get the following error messages.
Can anyone point me to the updated library or a fix ?

C:\Users\Denis\arduino-1.0.2\libraries\Elapsed\Elapsed.cpp: In member function 'void Elapsed::reset()':
C:\Users\Denis\arduino-1.0.2\libraries\Elapsed\Elapsed.cpp:52: error: 'micros' was not declared in this scope
C:\Users\Denis\arduino-1.0.2\libraries\Elapsed\Elapsed.cpp:53: error: 'millis' was not declared in this scope
C:\Users\Denis\arduino-1.0.2\libraries\Elapsed\Elapsed.cpp: In member function 'long unsigned int Elapsed::intervalMs()':
C:\Users\Denis\arduino-1.0.2\libraries\Elapsed\Elapsed.cpp:59: error: 'millis' was not declared in this scope
C:\Users\Denis\arduino-1.0.2\libraries\Elapsed\Elapsed.cpp: In member function 'long unsigned int Elapsed::intervalUs()':
C:\Users\Denis\arduino-1.0.2\libraries\Elapsed\Elapsed.cpp:65: error: 'micros' was not declared in this scope
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 650
Posts: 50833
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I have the Elapsed Timer library for Arduino 022 and my program works great.
Where did you get this library, which does not appear to have been updated for 1.0?

Logged

North Queensland, Australia
Offline Offline
Edison Member
*
Karma: 76
Posts: 2246
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Here is a little class I use to time stuff,
its template parameter is  'true' for high resolution ( micros ), or false for low ( millis ).

Code:
template< bool _HiRes = true >
  class TimeThis{
    protected:
      typedef TimeThis< _HiRes > MYTYPE;
      inline static const unsigned long GetTime( void )  { return ( _HiRes ? micros : millis )(); }
    public:
      TimeThis( unsigned long &u_TimeRef ) : u_Time( u_TimeRef = MYTYPE::GetTime() )  { return; }
      ~TimeThis( void )  { this->u_Time = MYTYPE::GetTime() - this->u_Time; }
    private:
      unsigned long   &u_Time;
};

void loop(){

    unsigned long u_Time;
    {
      TimeThis< true > t_Time( u_Time );
      
      //Lengthy operation
    }
    Serial.print( "Run Time: " );
    Serial.println( u_Time );
}

void setup(){Serial.begin(9600);}
« Last Edit: November 24, 2012, 09:54:47 pm by pYro_65 » Logged


Global Moderator
Melbourne, Australia
Offline Offline
Brattain Member
*****
Karma: 510
Posts: 19306
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Where did you get this library, which does not appear to have been updated for 1.0?

Looks like it might be one of mine, however the current one compiles OK under 1.0.2.

@OP: try downloading this file:

http://www.gammon.com.au/Arduino/Elapsed.zip

The original one probably didn't have the test for WProgram.h / Arduino.h.
Logged

http://www.gammon.com.au/electronics

Please post technical questions on the forum - not to me by personal message. Thanks a lot.

Global Moderator
Netherlands
Online Online
Shannon Member
*****
Karma: 227
Posts: 14007
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


alternative - http://arduino.cc/playground/Code/StopWatchClass -
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Pages: [1]   Go Up
Jump to: