Props to prop no plural

This commit is contained in:
fauresystems
2020-04-15 10:55:37 +02:00
parent 142ff52329
commit 6cff784cc6
30 changed files with 532 additions and 528 deletions
+66
View File
@@ -0,0 +1,66 @@
/*
Name: PropAction.h
Created: 29/10/2019 09:20:31
Author: Marie Faure <dev at faure dot systems>
Editor: https://github.com/fauresystems
License: MIT License (c) Marie Faure <dev at faure dot systems>
Provide an easy way of triggering functions at a set _interval.
*/
#include "PropAction.h"
PropAction::PropAction()
{
_active = true;
_previous = 0;
_interval = 400;
_execute = NULL;
}
PropAction::PropAction(unsigned long intervl, void (*function)())
{
_active = true;
_previous = 0;
_interval = intervl;
_execute = function;
}
void PropAction::reset(unsigned long intervl)
{
_active = true;
_previous = 0;
_interval = intervl;
}
void PropAction::disable()
{
_active = false;
}
void PropAction::enable()
{
_active = true;
}
void PropAction::check() {
if (_active && (millis() - _previous >= _interval))
{
_previous = millis();
if (_execute) _execute();
}
}
bool PropAction::tick() {
if (_active && (millis() - _previous >= _interval))
{
_previous = millis();
return true;
}
return false;
}
unsigned long PropAction::getInterval()
{
return _interval;
}