-
Notifications
You must be signed in to change notification settings - Fork 7
getStopwatch
gicking edited this page Feb 6, 2018
·
4 revisions
back to Command Reference / Time
Returns the milliseconds since one of several stopwatches was started. Stopwatches are started via startStopwatch().
The number of different stopwatches is NUM_STOPWATCH=5
by default. Different values can be set via config.h
.
Notes:
- stopwatches are based on the 1ms clock, and therefore require the TIM4 interrupt to be active. For details refer to decription of millis().
- automatic scheduling in background, i.e. without polling, is easily done by combining stopwatches and attachInterruptMillis()
- defined in
stopwatch.h
-
not loaded by
main_general.h
- in
config.h
set#define USE_TIM4_UPD_ISR
for time-keeping functions (see millis()). - for different numbers of stopwatches, add
#define NUM_STOPWATCH newVal
inconfig.h
getStopwatch(n)
-
input:
- n: index of stopwatch to read (0..NUM_STOPWATCH-1)
-
output:
- none
- milliseconds since last startStopwatch(n)
The below code realizes a (very) simple scheduler using a a stopwatch.
#include "main_general.h"
#include "stopwatch.h"
void setup() {
pinMode(&PORT_D, 0, OUTPUT);
startStopwatch(0);
}
void loop() {
if (getStopwatch(0) >= 123) {
startStopwatch(0);
pinOutputReg(&PORT_D, pin0) ^= 1;
}
}
- tbd
-
Getting Started
-
- General Commands
- Libraries
- LCD BTHQ21605V
- poti AD5280
- poti AD5282
- freemodbus
- PetitFS SD-card (min)
- FatFS: SD card (full)
- Board Specific
-
- Universal
- Board Specific