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, or A/Neutral/B. 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. The pins are independant, but probably when one is activated, the other is disactivated. In a case of a central/neutral position is available on the switch, none of the pins will be activated !

Events thrown:

reason id type data
event pin1 state to HIGH event id1 COMMANDERS_EVENT_MOVE COMMANDERS_MOVE_ON
event pin1 state to LOW event id1 COMMANDERS_EVENT_MOVE COMMANDERS_MOVE_OFF
event pin2 state to HIGH event id2 COMMANDERS_EVENT_MOVE COMMANDERS_MOVE_ON
event pin2 state to LOW event id2 COMMANDERS_EVENT_MOVE COMMANDERS_MOVE_OFF

Definition at line 25 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 31 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 16 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 57 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: