Commanders
Arduino buttons/bus library
ButtonsCommanderAnalogPushes Class Reference

#include "ButtonsCommanderAnalogPushes.hpp"

Inheritance diagram for ButtonsCommanderAnalogPushes:
ButtonsCommanderButton

Public Member Functions

 ButtonsCommanderAnalogPushes ()
 
void begin (int inButtonPin, uint8_t inNumber, unsigned long *inpIds, int *inpButtonValues, int inTolerancy = 20)
 
unsigned long loop ()
 
void EndLoop ()
 
ButtonsCommanderAnalogPushesItemGetItem (uint8_t inNumber)
 
ButtonsCommanderButtonGetFromId (unsigned long inId)
 
uint8_t GetLastButtonPressed () const
 
- Public Member Functions inherited from ButtonsCommanderButton
 ButtonsCommanderButton (unsigned long inId)
 
unsigned long GetId () const
 
virtual int GetPosition () const
 
virtual void beforeFirstLoop ()
 
void SetNextButton (ButtonsCommanderButton *inpButton)
 
ButtonsCommanderButton * GetNextButton () const
 

Additional Inherited Members

- Protected Attributes inherited from ButtonsCommanderButton
unsigned long Id
 

Detailed Description

A push button is a hardware device giving a time limited impulsion. It will return one Dccid at a time, passing through the whole list of DccIds. The analog pushes variant use one analog pin with some pushes connected through resistors.

Sample for five pushes.
+        +         +         +         + GND
|        |         |         |         |
/        /         /         /         / Pushes
|        |         |         |         |
| 3kOhms | 1kOhms  | 620 Ohms| 330 Ohms|
|        |         |         |         |
+--***---+---***---+---***---+---***---+------> Analog pin
                                       |
                                       *
                                       * 10kOhms
                                       *
                                       |
                                       + 5v

When one push button is pressed, the value read on the analog pin depends of the resistor addition from the button to the pin. It is important that only one button was pushed at a time. It is possible to use more or less buttons, but resistor values have to be computed to avoid confusing analog values between near pushes...

This class is a list of ButtonsCommanderAnalogPushesItem, basicaly a push button. Each item has its own id, analog value and tolerancy interval.

Events thrown:

reason id type data
pin state to LOW push id COMMANDERS_EVENT_MOVEPOSITIONID 0

Definition at line 49 of file ButtonsCommanderAnalogPushes.hpp.

Constructor & Destructor Documentation

ButtonsCommanderAnalogPushes::ButtonsCommanderAnalogPushes ( )

Default constructor.

Definition at line 11 of file ButtonsCommanderAnalogPushes.cpp.

Member Function Documentation

void ButtonsCommanderAnalogPushes::begin ( int  inButtonPin,
uint8_t  inNumber,
unsigned long *  inpIds,
int *  inpButtonValues,
int  inTolerancy = 20 
)

Initialize the instance.

Parameters
inButtonPinAnalog Arduino pin connected to this group of pushes.
inNumbernumber of push buttons.
inpIdsArray of ids of each button.
inpButtonValuesarray of analog values, one for each button.
inTolerancytolerancy of the read analog value to identify the correct push button.

Definition at line 22 of file ButtonsCommanderAnalogPushes.cpp.

void ButtonsCommanderAnalogPushes::EndLoop ( )
virtual

Reinitialize the list for future use. Called at the end of the loop, if an event has been raised.

Reimplemented from ButtonsCommanderButton.

Definition at line 109 of file ButtonsCommanderAnalogPushes.cpp.

ButtonsCommanderButton * ButtonsCommanderAnalogPushes::GetFromId ( unsigned long  inId)
virtual

Gets one push item through its id.

Reimplemented from ButtonsCommanderButton.

Definition at line 48 of file ButtonsCommanderAnalogPushes.cpp.

ButtonsCommanderAnalogPushesItem* ButtonsCommanderAnalogPushes::GetItem ( uint8_t  inNumber)
inline

Gets one push item.

Definition at line 82 of file ButtonsCommanderAnalogPushes.hpp.

uint8_t ButtonsCommanderAnalogPushes::GetLastButtonPressed ( ) const
inline

Gets the last push button pressed.

Definition at line 87 of file ButtonsCommanderAnalogPushes.hpp.

unsigned long ButtonsCommanderAnalogPushes::loop ( )
virtual

Main loop function.

Reimplemented from ButtonsCommanderButton.

Definition at line 57 of file ButtonsCommanderAnalogPushes.cpp.


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