31 lines
531 B
C++
31 lines
531 B
C++
#pragma once
|
|
|
|
#include <Arduino.h>
|
|
#include <driver/pcnt.h>
|
|
|
|
#define COUNTER_HIGH_LIMIT INT16_MAX
|
|
#define COUNTER_LOW_LIMIT 0
|
|
|
|
class Counter {
|
|
public:
|
|
Counter(uint8_t pin);
|
|
|
|
void pause();
|
|
void resume();
|
|
void clear();
|
|
|
|
int16_t getValue();
|
|
|
|
void setFilterValue(uint16_t value);
|
|
void filterEnable();
|
|
void filterDisable();
|
|
|
|
private:
|
|
static uint8_t amountOfCounter;
|
|
|
|
bool initalised = false;
|
|
|
|
uint8_t pulsePin;
|
|
pcnt_unit_t unit;
|
|
};
|