COSA
An Object-Oriented Platform for Arduino Programming
Rotary::AcceleratedDial< T, THRESHOLD > Class Template Reference

#include <Rotary.hh>

Inheritance diagram for Rotary::AcceleratedDial< T, THRESHOLD >:
Inheritance graph
Collaboration diagram for Rotary::AcceleratedDial< T, THRESHOLD >:
Collaboration graph

Public Types

enum  Direction { NONE = 0x00, CW = 0x10, CCW = 0x20 }
 
enum  Mode { HALF_CYCLE, FULL_CYCLE }
 

Public Member Functions

 AcceleratedDial (Board::InterruptPin clk, Board::InterruptPin dt, Mode mode, T initial, T min, T max, T step, T steps)
 
value () const
 
step () const
 
void step (T step)
 
steps () const
 
void steps (T steps)
 
virtual void on_change (T value)
 
Mode mode () const
 
void mode (Mode mode)
 
void enable ()
 
void disable ()
 

Protected Member Functions

Direction detect ()
 

Protected Attributes

SignalPin m_clk
 
SignalPin m_dt
 
uint8_t m_state
 
Mode m_mode
 

Static Protected Attributes

static const uint8_t half_cycle_table [6][4]
 
static const uint8_t full_cycle_table [7][4]
 

Detailed Description

template<typename T, uint32_t THRESHOLD>
class Rotary::AcceleratedDial< T, THRESHOLD >

Use Rotary Encoder as an accelerated dial (integer). Allows a dial within a given number(T) range (min, max) and a given initial value. Two levels of step (increment/decrement) are allowed and selected depending on timing.

Circuit

Accelerated Dial
+------------+
(PCIc)--------------1-|CLK |
(PCId)--------------2-|DT |
3-|SW (/) |
(VCC)---------------4-|VCC |
(GND)---------------5-|GND |
+------------+

Definition at line 304 of file Rotary.hh.

Member Enumeration Documentation

Rotary Encoder turn direction.

Enumerator
NONE 

No direction change.

CW 

Clock-wise direction.

CCW 

Anti-clock-wise direction.

Definition at line 65 of file Rotary.hh.

enum Rotary::Encoder::Mode
inherited

Rotary Encoder cycle mode.

Enumerator
HALF_CYCLE 
FULL_CYCLE 

Definition at line 74 of file Rotary.hh.

Constructor & Destructor Documentation

template<typename T , uint32_t THRESHOLD>
Rotary::AcceleratedDial< T, THRESHOLD >::AcceleratedDial ( Board::InterruptPin  clk,
Board::InterruptPin  dt,
Mode  mode,
initial,
min,
max,
step,
steps 
)
inline

Construct Rotary Dial connected to given interrupt pins with given mode, min, max, initial, step on slow turn and steps on fast turn. The mode is one of the Rotary Encoder modes; HALF_CYCLE or FULL_CYCLE.

Parameters
[in]clkinterrupt pin.
[in]dtinterrupt pin.
[in]modestep.
[in]initialvalue.
[in]minvalue.
[in]maxvalue.
[in]stepvalue.
[in]stepsvalue.

Definition at line 319 of file Rotary.hh.

Member Function Documentation

Rotary::Encoder::Direction Rotary::Encoder::detect ( )
protectedinherited

Detect Rotary Encoder state change. Reads current input pin values and performs a possible state change. Return turn direction or none.

Returns
direction

Definition at line 222 of file Rotary.cpp.

void Rotary::Encoder::disable ( )
inlineinherited

Disable the encoder.

Definition at line 127 of file Rotary.hh.

void Rotary::Encoder::enable ( )
inlineinherited

Enable the encoder.

Definition at line 117 of file Rotary.hh.

Mode Rotary::Encoder::mode ( ) const
inlineinherited

Get current cycle mode.

Returns
mode.

Definition at line 100 of file Rotary.hh.

void Rotary::Encoder::mode ( Mode  mode)
inlineinherited

Set cycle mode.

Parameters
[in]modecycle.

Definition at line 109 of file Rotary.hh.

template<typename T , uint32_t THRESHOLD>
virtual void Rotary::AcceleratedDial< T, THRESHOLD >::on_change ( value)
inlinevirtual

Default on change function.

Parameters
[in]value.

Definition at line 380 of file Rotary.hh.

template<typename T , uint32_t THRESHOLD>
T Rotary::AcceleratedDial< T, THRESHOLD >::step ( ) const
inline

Get current step (slow increment/decrement).

Returns
step.

Definition at line 343 of file Rotary.hh.

template<typename T , uint32_t THRESHOLD>
void Rotary::AcceleratedDial< T, THRESHOLD >::step ( step)
inline

Set step (slow increment/decrement).

Parameters
[in]stepvalue.

Definition at line 352 of file Rotary.hh.

template<typename T , uint32_t THRESHOLD>
T Rotary::AcceleratedDial< T, THRESHOLD >::steps ( ) const
inline

Get current steps (fast increment/decrement).

Returns
steps.

Definition at line 361 of file Rotary.hh.

template<typename T , uint32_t THRESHOLD>
void Rotary::AcceleratedDial< T, THRESHOLD >::steps ( steps)
inline

Set step (fast increment/decrement).

Parameters
[in]stepsvalue.

Definition at line 370 of file Rotary.hh.

template<typename T , uint32_t THRESHOLD>
T Rotary::AcceleratedDial< T, THRESHOLD >::value ( ) const
inline

Return current dial value.

Returns
value.

Definition at line 334 of file Rotary.hh.

Member Data Documentation

const uint8_t Rotary::Encoder::full_cycle_table
staticprotectedinherited
Initial value:

Full-cycle state transition tables.

Full-cycle state table (emits a code at 00 only)

dot_inline_dotgraph_4.png

Definition at line 161 of file Rotary.hh.

const uint8_t Rotary::Encoder::half_cycle_table[6][4]
staticprotectedinherited

Half-cycle state transition tables.

Definition at line 158 of file Rotary.hh.

SignalPin Rotary::Encoder::m_clk
protectedinherited

Signal pins, previous state and cycle mode.

Definition at line 164 of file Rotary.hh.

SignalPin Rotary::Encoder::m_dt
protectedinherited

Definition at line 165 of file Rotary.hh.

Mode Rotary::Encoder::m_mode
protectedinherited

Definition at line 167 of file Rotary.hh.

uint8_t Rotary::Encoder::m_state
protectedinherited

Definition at line 166 of file Rotary.hh.


The documentation for this class was generated from the following file: