QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
EdgeTriggeredCounter.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <cstdint>
4
5
namespace
QGC
{
6
9
template
<
typename
CountT = u
int
8_t>
10
class
EdgeTriggeredCounter
11
{
12
public
:
13
explicit
EdgeTriggeredCounter
(CountT threshold) : _threshold(threshold) {}
14
16
bool
record
()
17
{
18
++_count;
19
if
(_count >= _threshold && !_armed) {
20
_armed =
true
;
21
return
true
;
22
}
23
return
false
;
24
}
25
26
void
reset
()
27
{
28
_count = 0;
29
_armed =
false
;
30
}
31
32
CountT
count
()
const
{
return
_count; }
33
bool
armed
()
const
{
return
_armed; }
34
35
private
:
36
const
CountT _threshold;
37
CountT _count = 0;
38
bool
_armed =
false
;
39
};
40
41
}
// namespace QGC
QGC::EdgeTriggeredCounter
Definition
EdgeTriggeredCounter.h:11
QGC::EdgeTriggeredCounter::reset
void reset()
Definition
EdgeTriggeredCounter.h:26
QGC::EdgeTriggeredCounter::armed
bool armed() const
Definition
EdgeTriggeredCounter.h:33
QGC::EdgeTriggeredCounter::record
bool record()
Returns true on the rising-edge crossing into >= threshold.
Definition
EdgeTriggeredCounter.h:16
QGC::EdgeTriggeredCounter::count
CountT count() const
Definition
EdgeTriggeredCounter.h:32
QGC::EdgeTriggeredCounter::EdgeTriggeredCounter
EdgeTriggeredCounter(CountT threshold)
Definition
EdgeTriggeredCounter.h:13
QGC
Definition
AppMessages.cc:7
src
Utilities
Diagnostics
EdgeTriggeredCounter.h
Generated by
1.9.8