COSA
An Object-Oriented Platform for Arduino Programming
Periodic.hh File Reference
#include "Cosa/Types.h"
#include "Cosa/Job.hh"
Include dependency graph for Periodic.hh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Periodic
 

Macros

#define periodic(timer, ms)
 
#define PERIODIC(timer, us)
 

Detailed Description

Version
1.0

License

Copyright (C) 2012-2015, Mikael Patel

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

This file is part of the Arduino Che Cosa project.

Definition in file Periodic.hh.

Macro Definition Documentation

#define periodic (   timer,
  ms 
)
Value:
static uint32_t timer = RTT::millis(); \
for (int __UNIQUE(i) = 1; \
(__UNIQUE(i) != 0) && ((RTT::since(timer)) >= ms); \
__UNIQUE(i)--, timer += ms)
static uint32_t since(uint32_t start)
Definition: RTT.hh:107
static uint32_t millis()
Definition: RTT.cpp:121
#define __UNIQUE(name)
Definition: Types.h:47

Syntactic sugar for periodic blocks in the loop() function. Used in the form:

1 void loop()
2 {
3  periodic(timer,ms) {
4  ...
5  }
6  ...
7 }

May be used several times in the loop() function. The timer variable is defined and available in the loop().

Parameters
[in]timervariable.
[in]msperiod in milli-seconds.
Note
requires RTT.

Definition at line 121 of file Periodic.hh.

#define PERIODIC (   timer,
  us 
)
Value:
static uint32_t timer = RTT::micros(); \
for (int __UNIQUE(i) = 1; \
(__UNIQUE(i) != 0) && ((RTT::micros() - timer) >= us); \
__UNIQUE(i)--, timer += us)
static uint32_t micros()
Definition: RTT.cpp:103
#define __UNIQUE(name)
Definition: Types.h:47

Syntactic sugar for periodic blocks in the loop() function. Used in the form:

1 void loop()
2 {
3  PERIODIC(timer,us) {
4  ...
5  }
6  ...
7 }

May be used several times in the loop() function. The timer variable is defined and available in the loop().

Parameters
[in]timervariable.
[in]usperiod in micro-seconds.
Note
requires RTT.

Definition at line 145 of file Periodic.hh.