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, basically a push button. Each item has its own id, analog value and tolerance interval.

Events thrown:

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

Constructor & Destructor Documentation

ButtonsCommanderAnalogPushes::ButtonsCommanderAnalogPushes ( )

Default constructor.

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.
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.

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

Gets one push item through its id.

Reimplemented from ButtonsCommanderButton.

ButtonsCommanderAnalogPushesItem* ButtonsCommanderAnalogPushes::GetItem ( uint8_t  inNumber)
inline

Gets one push item.

uint8_t ButtonsCommanderAnalogPushes::GetLastButtonPressed ( ) const
inline

Gets the last push button pressed.

unsigned long ButtonsCommanderAnalogPushes::loop ( )
virtual

Main loop function.

Reimplemented from ButtonsCommanderButton.


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