Commanders
Arduino buttons/bus library
ButtonsCommanderEncoder Class Reference

#include "ButtonsCommanderEncoder.hpp"

Inheritance diagram for ButtonsCommanderEncoder:
ButtonsCommanderButton

Public Member Functions

 ButtonsCommanderEncoder ()
 
int GetPosition () const
 
void ResetStartingPosition ()
 
void begin (unsigned long inId, int inPin1, int inPin2, byte inMoveIncrement = 3, int inStartingCurrentValue = 0, int inMinimum = 0, int inMaximum = 0)
 
unsigned long loop ()
 
- Public Member Functions inherited from ButtonsCommanderButton
 ButtonsCommanderButton (unsigned long inId)
 
unsigned long GetId () const
 
virtual ButtonsCommanderButton * GetFromId (unsigned long inId)
 
virtual void beforeFirstLoop ()
 
virtual void EndLoop ()
 
void SetNextButton (ButtonsCommanderButton *inpButton)
 
ButtonsCommanderButton * GetNextButton () const
 

Additional Inherited Members

- Protected Attributes inherited from ButtonsCommanderButton
unsigned long Id
 

Detailed Description

This class describes a rotary encoder. A rotary or "shaft" encoder is an angular measuring device. It is used to precisely measure rotation of motors or to create wheel controllers (knobs) that can turn infinitely (with no end stop like a potentiometer has). Some of them are also equipped with a pushbutton when you press on the axis (like the ones used for navigation on many music controllers). In this case, only add a new ButtonsCommanderPush class instance beside the encoder. This class can handles also a current position, using the encoder like a potentiometer...

Events thrown:

reason id type data
clockwise movement button id COMMANDERS_EVENT_MOVE COMMANDERS_MOVE_MORE
counter-clockwise movement button id COMMANDERS_EVENT_MOVE COMMANDERS_MOVE_LESS
positional position changed button id COMMANDERS_EVENT_MOVEPOSITION value

Definition at line 28 of file ButtonsCommanderEncoder.hpp.

Constructor & Destructor Documentation

ButtonsCommanderEncoder::ButtonsCommanderEncoder ( )

Default constructor.

Definition at line 11 of file ButtonsCommanderEncoder.cpp.

Member Function Documentation

void ButtonsCommanderEncoder::begin ( unsigned long  inId,
int  inPin1,
int  inPin2,
byte  inMoveIncrement = 3,
int  inStartingCurrentValue = 0,
int  inMinimum = 0,
int  inMaximum = 0 
)

Initialize the instance. This encoder can be use like a potentiometer. To use this positional value, give a different value to minimum and maximum arguments.

Parameters
inIdid of the button.
inPin1Arduino pin connected to this encoder.
inPin2Arduino pin connected to this encoder.
inMoveIncrementminimum change value to throw a new event. Default is 3, but it can depends of the material used.
inStartingCurrentValueIn positional use, starting position. Must be between minimum and maximum ! Default is 0.
inMinimumminimum value in positional use, default is 0.
inMaximummaximum value in positional use, default is 0.

Definition at line 15 of file ButtonsCommanderEncoder.cpp.

int ButtonsCommanderEncoder::GetPosition ( ) const
inlinevirtual

Gets current value of the positional mode.

Reimplemented from ButtonsCommanderButton.

Definition at line 45 of file ButtonsCommanderEncoder.hpp.

unsigned long ButtonsCommanderEncoder::loop ( )
virtual

Main loop function.

Reimplemented from ButtonsCommanderButton.

Definition at line 35 of file ButtonsCommanderEncoder.cpp.

void ButtonsCommanderEncoder::ResetStartingPosition ( )
inline

Resets the current value of the positional mode to its starting value.

Definition at line 47 of file ButtonsCommanderEncoder.hpp.


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