31 lines
546 B
C++
31 lines
546 B
C++
#ifndef POSITION_WATCHER_H
|
|
#define POSITION_WATCHER_H
|
|
|
|
#include <stdint.h>
|
|
|
|
class PositionWatcher
|
|
{
|
|
private:
|
|
bool isActive;
|
|
|
|
int8_t targetValue;
|
|
int8_t lastValue;
|
|
int8_t consecutiveDuplicates;
|
|
|
|
uint32_t pollingInterval;
|
|
|
|
int8_t maxAttempts;
|
|
int8_t maxConsecutiveDuplicates;
|
|
|
|
int8_t currentAttempt;
|
|
uint32_t lastPollTime;
|
|
|
|
public:
|
|
void start(int8_t newTargetValue);
|
|
bool shouldFetch();
|
|
bool isWatching();
|
|
void fetchQueued();
|
|
void fetchReceived(int8_t value);
|
|
};
|
|
|
|
#endif // POSITION_WATCHER_H
|