Skip to content

Commit

Permalink
Readme file
Browse files Browse the repository at this point in the history
  • Loading branch information
sofian committed Apr 28, 2015
1 parent bbd05d3 commit 6b4f9e1
Showing 1 changed file with 165 additions and 0 deletions.
165 changes: 165 additions & 0 deletions README.md
@@ -0,0 +1,165 @@
SuperChrono
=====================
SuperChrono library for Arduino or Wiring
by Sofian Audry

Advanced chronometer/stopwatch class that counts the time passed since started.

Installation
=====================
Copy the SuperChrono folder to your Arduino libraries.


Basic Example
=====================
```arduino
#include <SuperChrono.h>
// Instanciate a SuperChrono object.
SuperChrono mySuperChrono;
void setup() {
// Start the chronometer on setup.
mySuperChrono.start();
}
void loop() {
// Check whether the chronometer has reached 1000 ms
if (mySuperChrono.hasPassed(1000)) {
// Do something here...
// Restart the SuperChrono.
mySuperChrono.start();
}
}
```


Include the library
=====================
```arduino
// INCLUDE SuperChrono LIBRARY :
#include <SuperChrono.h>
```

Create an instance
=====================
Once a SuperChrono is created, it starts counting.

```arduino
// CREATE A SuperChrono INSTANCE :
SuperChrono mySuperChrono;
```

You can create a SuperChrono that counts in microseconds or seconds:
```arduino
SuperChrono mySuperChronoMicros(SuperChrono::MICROS);
SuperChrono mySuperChronoSeconds(SuperChrono::SECONDS);
```

Alternatively you can create a SuperChrono with a custom time function:
```arduino
unsigned long mySpecialTimeFunction();
SuperChrono mySuperChronoMicros(mySpecialTimeFunction);
```


start(offset)
=====================

Starts/restarts the chronometer.

```arduino
// START/RESTART THE CHRONOMETER :
mySuperChrono.start();
// START/RESTART THE CHRONOMETER WITH ALREADY 1000 TIME UNITS AS AN OFFSET :
mySuperChrono.start(1000);
```

stop()
=====================

Stops/pauses the chronometer.

```arduino
// STOPS/PAUSES THE CHRONOMETER :
mySuperChrono.stop();
```

resume()
=====================

Resumes the chronometer.

```arduino
// STOPS/PAUSES THE CHRONOMETER :
mySuperChrono.stop();
```


elapsed()
=====================

Returns the elasped time.

```arduino
// GET ELAPSED MILLISECONDS :
unsigned long elapsed = mySuperChrono.elapsed();
```


hasPassed(timeout)
=====================
Returns true if the chronometer passed the timeout.
```arduino
if ( mySuperChrono.hasPassed(500) ) {
// DO SOMETHING IF 500 TIME UNITS HAVE PASSED.
}
```

Combined with start() you can have a metronome :
```arduino
if ( mySuperChrono.hasPassed(200) ) {
mySuperChrono.start();
// DO SOMETHING EVERY 200 TIME UNITS.
}
```

add(time)
=====================

Adds some time to the chronometer.

```arduino
// ADDS 500 TIME UNITS TO THE CHRONOMETER :
mySuperChrono.add(500);
```

isRunning()
=====================

Returns true if the chronometer is currently running.

```arduino
mySuperChrono.start();
Serial.println( mySuperChrono.isRunning() ); // will print "1" (true)
mySuperChrono.stop();
Serial.println( mySuperChrono.isRunning() ); // will print "0" (false)
mySuperChrono.resume();
Serial.println( mySuperChrono.isRunning() ); // will print "1" (true)
```

0 comments on commit 6b4f9e1

Please sign in to comment.