Commanders
Arduino buttons/bus library
ButtonsCommanderSwitch Class Reference

#include "ButtonsCommanderSwitch.hpp"

Inheritance diagram for ButtonsCommanderSwitch:
ButtonsCommanderButton

Public Member Functions

 ButtonsCommanderSwitch ()
 
void begin ()
 
EventPinAddEvent (unsigned long inId, int inPin, COMMANDERS_EVENT_TYPE inEvent = COMMANDERS_EVENT_MOVEPOSITIONID, int inData = 0)
 
void beforeFirstLoop ()
 
unsigned long loop ()
 
unsigned long GetId (GPIO_pin_t inPin) const
 
- Public Member Functions inherited from ButtonsCommanderButton
 ButtonsCommanderButton (unsigned long inId)
 
unsigned long GetId () const
 
virtual ButtonsCommanderButton * GetFromId (unsigned long inId)
 
virtual int GetPosition () const
 
virtual void EndLoop ()
 
void SetNextButton (ButtonsCommanderButton *inpButton)
 
ButtonsCommanderButton * GetNextButton () const
 

Static Public Member Functions

static unsigned long loopOnePin (GPIO_pin_t inPin, unsigned long inId, unsigned long inPreviousId, unsigned long *apDebounceDelay, GPIO_pin_t *apLastSelectedPin, int *apLastButtonState, unsigned long *apLastDebounceTime, bool inSendEvent = true)
 

Additional Inherited Members

- Protected Attributes inherited from ButtonsCommanderButton
unsigned long Id
 

Detailed Description

This class describes a switch with a variable number of pins/positions. The common cases are handled by ButtonsCommanderSwitchOnePin and ButtonsCommanderSwitchTwoPins, but if you have a switch with any other number of positions, this class is for you !

Events thrown:

    reason            |           id       |         type          | data

-----------------------—|-----------------—|--------------------—|-----------------— pin state to HIGH | button id pin | COMMANDERS_EVENT_MOVE | COMMANDERS_MOVE_ON previous pin state to LOW | button id prev pin | COMMANDERS_EVENT_MOVE | COMMANDERS_MOVE_OFF

Definition at line 33 of file ButtonsCommanderSwitch.hpp.

Constructor & Destructor Documentation

ButtonsCommanderSwitch::ButtonsCommanderSwitch ( )

Default constructor.

Definition at line 11 of file ButtonsCommanderSwitch.cpp.

Member Function Documentation

EventPin * ButtonsCommanderSwitch::AddEvent ( unsigned long  inId,
int  inPin,
COMMANDERS_EVENT_TYPE  inEvent = COMMANDERS_EVENT_MOVEPOSITIONID,
int  inData = 0 
)

Each position of the switch can be defined with an Arduino pin, and an event definition... In this case of switch, there is an event when one pin is activated, but there is no OFF event for the disactivated pin.

Parameters
inIdid of the position.
inPinArduino pin connected to the button.
inEventEvent type used when the pin is activated. Default COMMANDERS_EVENT_MOVEPOSITIONID.
inDataAssociated data when the pin is activated. Default 0.

Definition at line 60 of file ButtonsCommanderSwitch.cpp.

void ButtonsCommanderSwitch::beforeFirstLoop ( )
virtual

This function will be called after sketch Setup(), but before the first call to loop(). It will be called only one time.

Reimplemented from ButtonsCommanderButton.

Definition at line 126 of file ButtonsCommanderSwitch.cpp.

void ButtonsCommanderSwitch::begin ( )

Initialize the instance.

Definition at line 25 of file ButtonsCommanderSwitch.cpp.

unsigned long ButtonsCommanderSwitch::GetId ( GPIO_pin_t  inPin) const

Gets the right id according to the activated pin.

Definition at line 46 of file ButtonsCommanderSwitch.cpp.

unsigned long ButtonsCommanderSwitch::loop ( )
virtual

Main loop function.

Reimplemented from ButtonsCommanderButton.

Definition at line 149 of file ButtonsCommanderSwitch.cpp.

unsigned long ButtonsCommanderSwitch::loopOnePin ( GPIO_pin_t  inPin,
unsigned long  inId,
unsigned long  inPreviousId,
unsigned long *  apDebounceDelay,
GPIO_pin_t *  apLastSelectedPin,
int *  apLastButtonState,
unsigned long *  apLastDebounceTime,
bool  inSendEvent = true 
)
static

Check if a pin has changed its state, and send an event if necessary.

Remarks
This is an internal function.

Definition at line 72 of file ButtonsCommanderSwitch.cpp.


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