op divider additional features
This commit is contained in:
parent
f0f7388c0d
commit
29e701d14d
@ -7,16 +7,26 @@ PeriodicOperationDivider::PeriodicOperationDivider(uint32_t divider,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool PeriodicOperationDivider::checkAndIncrement() {
|
bool PeriodicOperationDivider::checkAndIncrement() {
|
||||||
if(counter >= divider) {
|
bool opNecessary = check();
|
||||||
|
if(opNecessary) {
|
||||||
if(resetAutomatically) {
|
if(resetAutomatically) {
|
||||||
counter = 0;
|
counter = 0;
|
||||||
}
|
}
|
||||||
return true;
|
return opNecessary;
|
||||||
}
|
}
|
||||||
counter ++;
|
counter ++;
|
||||||
|
return opNecessary;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PeriodicOperationDivider::check() {
|
||||||
|
if(counter >= divider) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void PeriodicOperationDivider::resetCounter() {
|
void PeriodicOperationDivider::resetCounter() {
|
||||||
counter = 0;
|
counter = 0;
|
||||||
}
|
}
|
||||||
|
@ -21,17 +21,27 @@ public:
|
|||||||
*/
|
*/
|
||||||
PeriodicOperationDivider(uint32_t divider, bool resetAutomatically = true);
|
PeriodicOperationDivider(uint32_t divider, bool resetAutomatically = true);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether operation is necessary.
|
* Check whether operation is necessary.
|
||||||
* If an operation is necessary and the class has been
|
* If an operation is necessary and the class has been
|
||||||
* configured to be reset automatically, the counter will be reset.
|
* configured to be reset automatically, the counter will be reset.
|
||||||
* If not, the counter will be incremented.
|
*
|
||||||
* @return
|
* @return
|
||||||
* -@c true if the counter is larger or equal to the divider
|
* -@c true if the counter is larger or equal to the divider
|
||||||
* -@c false otherwise
|
* -@c false otherwise
|
||||||
*/
|
*/
|
||||||
bool checkAndIncrement();
|
bool checkAndIncrement();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether an operation is necessary.
|
||||||
|
* This function will not increment the counter!
|
||||||
|
* @return
|
||||||
|
* -@c true if the counter is larger or equal to the divider
|
||||||
|
* -@c false otherwise
|
||||||
|
*/
|
||||||
|
bool check();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Can be used to reset the counter to 0 manually.
|
* Can be used to reset the counter to 0 manually.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user