31 lines
No EOL
707 B
C++
31 lines
No EOL
707 B
C++
#ifndef COMPLIB_SERVER_ENCODER_HPP
|
|
#define COMPLIB_SERVER_ENCODER_HPP
|
|
|
|
#include <vector>
|
|
#include <cstdint>
|
|
#include <chrono>
|
|
|
|
#define ENCODER_COUNT 4
|
|
#define ENCODER_CACHE_DURATION_MS 4 // 200 HZ
|
|
|
|
class Encoder {
|
|
public:
|
|
std::vector<int32_t> read_all();
|
|
std::vector<int32_t> read_all_cached();
|
|
|
|
static Encoder& get_instance()
|
|
{
|
|
static Encoder instance;
|
|
return instance;
|
|
}
|
|
|
|
Encoder(Encoder const&) = delete;
|
|
void operator=(Encoder const&) = delete;
|
|
|
|
private:
|
|
Encoder();
|
|
int32_t encoder_cache[ENCODER_COUNT] = {0};
|
|
std::chrono::time_point<std::chrono::system_clock> last_read = std::chrono::system_clock::now();
|
|
};
|
|
|
|
#endif // COMPLIB_SERVER_ENCODER_HPP
|