This repository has been archived on 2025-06-01. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
compLIB/server/include/encoder.hpp
2022-05-16 22:47:22 +01:00

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