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, COMMANDERS_EVENT_TYPE *apEvent = NULL, int *apData = NULL) 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 (unsigned long inId, GPIO_pin_t inPin, unsigned long inPreviousId, unsigned long inDebounceDelay, byte *inpLastPinState, unsigned long *inpLastDebounceTime, 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
event pin state to HIGH event id Event Type Event Data

event pin state to LOW | nothing | |

Definition at line 35 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 inactivated 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 64 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 132 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,
COMMANDERS_EVENT_TYPE apEvent = NULL,
int *  apData = NULL 
) const

Gets the right id according to the activated pin.

Definition at line 44 of file ButtonsCommanderSwitch.cpp.

unsigned long ButtonsCommanderSwitch::loop ( )
virtual

Main loop function.

Reimplemented from ButtonsCommanderButton.

Definition at line 153 of file ButtonsCommanderSwitch.cpp.

unsigned long ButtonsCommanderSwitch::loopOnePin ( unsigned long  inId,
GPIO_pin_t  inPin,
unsigned long  inPreviousId,
unsigned long  inDebounceDelay,
byte *  inpLastPinState,
unsigned long *  inpLastDebounceTime,
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 78 of file ButtonsCommanderSwitch.cpp.


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