Commanders
Arduino buttons/bus library
ButtonsCommanderSwitchTwoPins Class Reference

#include "ButtonsCommanderSwitchTwoPins.hpp"

Inheritance diagram for ButtonsCommanderSwitchTwoPins:
ButtonsCommanderButton

Public Member Functions

 ButtonsCommanderSwitchTwoPins ()
 
void begin (unsigned long inId1, int inPin1, unsigned long inId2, int inPin2)
 
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
 

Additional Inherited Members

- Protected Attributes inherited from ButtonsCommanderButton
unsigned long Id
 

Detailed Description

A switch can be used in a A/B way. In this case only two Arduino pins are connected to the switch. The event raised is always of type COMMANDERS_EVENT_MOVE and data is COMMANDERS_MOVE_ON or COMMANDERS_MOVE_OFF, but the id used depends on the activated pin. Two events are always thrown by Commanders : the activation of one pin, and the disactvation of the other !

Events thrown:

     reason            |   id       |         type          | data

------------------------—|---------—|--------------------—|-----------------— pin1 state to HIGH | button id1 | COMMANDERS_EVENT_MOVE | COMMANDERS_MOVE_ON previous pin2 state to LOW | button id2 | COMMANDERS_EVENT_MOVE | COMMANDERS_MOVE_OFF pin2 state to HIGH | button id2 | COMMANDERS_EVENT_MOVE | COMMANDERS_MOVE_ON previous pin1 state to LOW | button id1 | COMMANDERS_EVENT_MOVE | COMMANDERS_MOVE_OFF

Definition at line 24 of file ButtonsCommanderSwitchTwoPins.hpp.

Constructor & Destructor Documentation

ButtonsCommanderSwitchTwoPins::ButtonsCommanderSwitchTwoPins ( )

Default constructor.

Definition at line 11 of file ButtonsCommanderSwitchTwoPins.cpp.

Member Function Documentation

void ButtonsCommanderSwitchTwoPins::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 28 of file ButtonsCommanderSwitchTwoPins.cpp.

void ButtonsCommanderSwitchTwoPins::begin ( unsigned long  inId1,
int  inPin1,
unsigned long  inId2,
int  inPin2 
)

Initialize the instance.

Parameters
inId1id of the first position.
inPin1Arduino pin connected to the switch button for the first position.
inId2id of the second position.
inPin2Arduino pin connected to the switch button for the second position.

Definition at line 17 of file ButtonsCommanderSwitchTwoPins.cpp.

unsigned long ButtonsCommanderSwitchTwoPins::GetId ( GPIO_pin_t  inPin) const
inline

Gets the right id according to the activated pin.

Definition at line 55 of file ButtonsCommanderSwitchTwoPins.hpp.

unsigned long ButtonsCommanderSwitchTwoPins::loop ( )
virtual

Main loop function.

Reimplemented from ButtonsCommanderButton.

Definition at line 53 of file ButtonsCommanderSwitchTwoPins.cpp.


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