#ifndef __ENCODER_H #define __ENCODER_H #include "stm32f1xx_hal.h" typedef struct { TIM_HandleTypeDef *htim_enc; int32_t count; int32_t last_count; float speed; /* counts per second */ float speed_filtered; /* low-pass filtered */ } Encoder; void Encoder_Init(Encoder *enc, TIM_HandleTypeDef *htim); void Encoder_Update(Encoder *enc, float dt); int32_t Encoder_GetCount(Encoder *enc); float Encoder_GetSpeed(Encoder *enc); void Encoder_Reset(Encoder *enc); #endif /* __ENCODER_H */