21 #ifndef COSA_ROTARY_HH 22 #define COSA_ROTARY_HH 69 } __attribute__((packed));
77 } __attribute__((packed));
118 __attribute__((always_inline))
128 __attribute__((always_inline))
154 virtual void on_interrupt(uint16_t arg);
212 T initial, T min, T max, T step) :
270 virtual void on_event(uint8_t type, uint16_t value)
274 if (m_value == m_max)
return;
278 if (m_value == m_min)
return;
303 template<
typename T, u
int32_t THRESHOLD>
320 T initial, T min, T max, T step, T steps) :
402 virtual void on_event(uint8_t type, uint16_t direction)
405 int32_t diff = now - m_latest;
407 if (direction ==
CW) {
408 if (m_value == m_max)
return;
409 if (diff > THRESHOLD)
413 if (m_value > m_max) m_value = m_max;
416 if (m_value == m_min)
return;
417 if (diff > THRESHOLD)
421 if (m_value < m_min) m_value = m_min;
virtual void on_event(uint8_t type, uint16_t value)
virtual void on_change(T value)
static const uint8_t half_cycle_table[6][4]
static const uint8_t full_cycle_table[7][4]
Dial(Board::InterruptPin clk, Board::InterruptPin dt, Mode mode, T initial, T min, T max, T step)
SignalPin(Board::InterruptPin pin, Encoder *encoder)
AcceleratedDial(Board::InterruptPin clk, Board::InterruptPin dt, Mode mode, T initial, T min, T max, T step, T steps)
Anti-clock-wise direction.
virtual void on_change(T value)
virtual void on_event(uint8_t type, uint16_t value)
Encoder(Board::InterruptPin clk, Board::InterruptPin dt, Mode mode=FULL_CYCLE)