2010-12-24 19:59:10 -04:00
|
|
|
/*
|
|
|
|
* AP_Loop.h
|
|
|
|
* Copyright (C) James Goppert 2010 <james.goppert@gmail.com>
|
|
|
|
*
|
|
|
|
* This file is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This file 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef AP_Loop_H
|
|
|
|
#define AP_Loop_H
|
|
|
|
|
|
|
|
#include "AP_Vector.h"
|
|
|
|
|
|
|
|
class Loop
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Loop() : _fptr(), _data(), _period(), _subLoops(), _timeStamp(), _load(), _dt() {};
|
|
|
|
Loop(float frequency, void (*fptr)(void *) = NULL, void * data = NULL);
|
|
|
|
void update();
|
|
|
|
Vector<Loop *> & subLoops() {
|
|
|
|
return _subLoops;
|
|
|
|
}
|
2011-10-16 03:55:34 -03:00
|
|
|
float frequency() {
|
2010-12-24 19:59:10 -04:00
|
|
|
return 1.0e6/_period;
|
|
|
|
}
|
2011-05-04 16:12:27 -03:00
|
|
|
void frequency(float _frequency) {
|
|
|
|
_period = 1e6/_frequency;
|
2010-12-24 19:59:10 -04:00
|
|
|
}
|
|
|
|
uint32_t timeStamp() {
|
|
|
|
return _timeStamp;
|
|
|
|
}
|
|
|
|
float dt() {
|
|
|
|
return _dt;
|
|
|
|
}
|
|
|
|
uint8_t load() {
|
|
|
|
return _load;
|
|
|
|
}
|
2011-10-16 03:55:34 -03:00
|
|
|
protected:
|
2010-12-24 19:59:10 -04:00
|
|
|
void (*_fptr)(void *);
|
|
|
|
void * _data;
|
|
|
|
uint32_t _period;
|
|
|
|
Vector<Loop *> _subLoops;
|
|
|
|
uint32_t _timeStamp;
|
|
|
|
uint8_t _load;
|
|
|
|
float _dt;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// vim:ts=4:sw=4:expandtab
|