COSA
An Object-Oriented Platform for Arduino Programming
Menu::RotaryController Class Reference

#include <Menu.hh>

Inheritance diagram for Menu::RotaryController:
Inheritance graph
Collaboration diagram for Menu::RotaryController:
Collaboration graph

Public Types

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

Public Member Functions

 RotaryController (Menu::Walker *walker, Job::Scheduler *scheduler, Board::InterruptPin clk=Board::PCI4, Board::InterruptPin dt=Board::PCI3, Board::DigitalPin sw=Board::D2)
 
virtual void on_event (uint8_t type, uint16_t direction)
 
void begin ()
 
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

Menu walker controller for the Rotary encoder with push button. Rotary encoder CW is mapped to DOWN_KEY, CCW to UP_KEY. The push button is mapped to SELECT_KEY.

Definition at line 238 of file Menu.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

Menu::RotaryController::RotaryController ( Menu::Walker walker,
Job::Scheduler scheduler,
Board::InterruptPin  clk = Board::PCI4,
Board::InterruptPin  dt = Board::PCI3,
Board::DigitalPin  sw = Board::D2 
)
inline

Construct rotary encoder event adapter for menu walker.

Parameters
[in]walkerto control.
[in]schedulerfor button sampling.
[in]clkrotary encoder clock pin (Default PCI4).
[in]dtrotary encoder data pin (Default PCI3).
[in]swrotary encoder switch pin (Default D2).

Definition at line 285 of file Menu.hh.

Member Function Documentation

void Menu::RotaryController::begin ( )
inline

Start the rotary encoder change detector.

Definition at line 307 of file Menu.hh.

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.

void Menu::RotaryController::on_event ( uint8_t  type,
uint16_t  direction 
)
virtual

Rotary change event handler. Forward change as a key; CW is mapped to DOWN_KEY and CCW to UP_KEY (and reverse for RANGE).

Parameters
[in]typethe event type.
[in]directionthe event value.

Reimplemented from Event::Handler.

Definition at line 282 of file Menu.cpp.

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_3.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 files: