Mechatronic Zen Garden  0.1
This webpage contains documentation for the ME 507 term project: Mechatronic Zen Garden.
EncoderDriver.h
Go to the documentation of this file.
1 
22 #include <Arduino.h>
23 #include <HardwareTimer.h>
24 
25 
44 {
45 protected:
46  HardwareTimer* p_timer;
47 
48 public:
49  STM32Encoder (TIM_TypeDef* timer, uint8_t pin1, uint8_t pin2);
50 
54  uint16_t getCount (void)
55  {
56  return p_timer->getCount ();
57  }
58 
61  void zero (void)
62  {
63  realCt = 0;
64  p_timer->setCount (0);
65  }
66 
69  void pause (void)
70  {
71  p_timer->pause ();
72  }
73 
77  void resume (void)
78  {
79  p_timer->resume ();
80  }
81 
84  int32_t update (void);
85 
87  uint16_t ctNow;
88 
90  int32_t realCt;
91 
93  int32_t delta;
94 
95 };
STM32Encoder::realCt
int32_t realCt
Internal count value, unprocessed.
Definition: EncoderDriver.h:90
STM32Encoder::update
int32_t update(void)
Updates count value accounting for overflow.
Definition: EncoderDriver.cpp:82
STM32Encoder::delta
int32_t delta
Change in internal count value.
Definition: EncoderDriver.h:93
STM32Encoder::getCount
uint16_t getCount(void)
Return the current position count from the timer.
Definition: EncoderDriver.h:54
STM32Encoder
Class which operates an STM32 timer in quadrature encoder mode.
Definition: EncoderDriver.h:44
STM32Encoder::pause
void pause(void)
Pause the counter so it won't update its count until resumed.
Definition: EncoderDriver.h:69
STM32Encoder::STM32Encoder
STM32Encoder(TIM_TypeDef *timer, uint8_t pin1, uint8_t pin2)
Set up an STM32 timer to read a quadrature encoder.
Definition: EncoderDriver.cpp:49
STM32Encoder::resume
void resume(void)
Resume the counter so it will update its count when the encoder is moved.
Definition: EncoderDriver.h:77
STM32Encoder::p_timer
HardwareTimer * p_timer
Pointer to the timer/counter to be used.
Definition: EncoderDriver.h:46
STM32Encoder::zero
void zero(void)
Set the counter reading to zero.
Definition: EncoderDriver.h:61
STM32Encoder::ctNow
uint16_t ctNow
Current count value, ready for use.
Definition: EncoderDriver.h:87