/* * Encoder.hpp * * Created on: Mar 17, 2023 * Author: Gabriel */ #ifndef SRC_COMPONENTS_ENCODER_HPP_ #define SRC_COMPONENTS_ENCODER_HPP_ #include "main.h" class Encoder { public: Encoder(__IO uint32_t* cnt, __IO uint32_t* arr, uint32_t countsPerRevolution); virtual ~Encoder(); void callback(GPIO_PinState _direction); uint32_t getCount(); int16_t getDelta(); float getOmega(); uint32_t getCountsPerRevolution(); private: __IO uint32_t* cnt; __IO uint32_t* arr; uint32_t lastCount = 0; uint32_t countsPerRevolution = 0; uint32_t lastTick = 0; uint32_t currentTick = 0; bool direction; bool updated; }; #endif /* SRC_COMPONENTS_ENCODER_HPP_ */