Can Opener - ME 507
encoder_counter.h
Go to the documentation of this file.
1 
13 #include <Arduino.h>
14 #include <HardwareTimer.h>
15 
16 
35 {
36 protected:
37  HardwareTimer* p_timer;
38 
39 public:
40  STM32Encoder (TIM_TypeDef* timer, uint8_t pin1, uint8_t pin2);
41 
45  uint32_t getCount (void)
46  {
47  return p_timer->getCount ();
48  }
49 
52  void zero (void)
53  {
54  p_timer->setCount (0);
55  }
56 
59  void pause (void)
60  {
61  p_timer->pause ();
62  }
63 
67  void resume (void)
68  {
69  p_timer->resume ();
70  }
71 };
72 
73 
Class which operates an STM32 timer in quadrature encoder mode.
Definition: encoder_counter.h:35
void pause(void)
Pause the counter so it won't update its count until resumed.
Definition: encoder_counter.h:59
HardwareTimer * p_timer
Pointer to the timer/counter to be used.
Definition: encoder_counter.h:37
void resume(void)
Resume the counter so it will update its count when the encoder is moved.
Definition: encoder_counter.h:67
uint32_t getCount(void)
Return the current position count from the timer.
Definition: encoder_counter.h:45
STM32Encoder(TIM_TypeDef *timer, uint8_t pin1, uint8_t pin2)
Set up an STM32 timer to read a quadrature encoder.
Definition: encoder_counter.cpp:44
void zero(void)
Set the counter reading to zero.
Definition: encoder_counter.h:52