Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1702 - 1
/*
2
 * AP_Loop.h
3
 * Copyright (C) James Goppert 2010 <james.goppert@gmail.com>
4
 *
5
 * This file is free software: you can redistribute it and/or modify it
6
 * under the terms of the GNU General Public License as published by the
7
 * Free Software Foundation, either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This file is distributed in the hope that it will be useful, but
11
 * WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
 * See the GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License along
16
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
17
 */
18
 
19
#ifndef AP_Loop_H
20
#define AP_Loop_H
21
 
22
#include "AP_Vector.h"
23
 
24
class Loop
25
{
26
public:
27
    Loop() : _fptr(), _data(), _period(), _subLoops(), _timeStamp(), _load(), _dt() {};
28
    Loop(float frequency, void (*fptr)(void *) = NULL, void * data = NULL);
29
    void update();
30
    Vector<Loop *> & subLoops() {
31
        return _subLoops;
32
    }
33
    float frequency() {
34
        return 1.0e6/_period;
35
    }
36
    void frequency(float _frequency) {
37
        _period = 1e6/_frequency;
38
    }
39
    uint32_t timeStamp() {
40
        return _timeStamp;
41
    }
42
    float dt() {
43
        return _dt;
44
    }
45
    uint8_t load() {
46
        return _load;
47
    }
48
protected:
49
    void (*_fptr)(void *);
50
    void * _data;
51
    uint32_t _period;
52
    Vector<Loop *> _subLoops;
53
    uint32_t _timeStamp;
54
    uint8_t _load;
55
    float _dt;
56
};
57
 
58
#endif
59
 
60
// vim:ts=4:sw=4:expandtab