Commanders
Arduino buttons/bus library
|
#include "ButtonsCommanderAnalogPushes.hpp"
Public Member Functions | |
ButtonsCommanderAnalogPushes () | |
void | begin (int inButtonPin, uint8_t inNumber, unsigned long *inpIds, int *inpButtonValues, int inTolerancy = 20) |
unsigned long | loop () |
void | EndLoop () |
ButtonsCommanderAnalogPushesItem * | GetItem (uint8_t inNumber) |
ButtonsCommanderButton * | GetFromId (unsigned long inId) |
uint8_t | GetLastButtonPressed () const |
![]() | |
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 | |
![]() | |
unsigned long | Id |
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 |
ButtonsCommanderAnalogPushes::ButtonsCommanderAnalogPushes | ( | ) |
Default constructor.
void ButtonsCommanderAnalogPushes::begin | ( | int | inButtonPin, |
uint8_t | inNumber, | ||
unsigned long * | inpIds, | ||
int * | inpButtonValues, | ||
int | inTolerancy = 20 |
||
) |
Initialize the instance.
inButtonPin | Analog Arduino pin connected to this group of pushes. |
inNumber | number of push buttons. |
inpIds | Array of ids of each button. |
inpButtonValues | array of analog values, one for each button. |
inTolerancy | tolerancy of the read analog value to identify the correct push button. |
|
virtual |
Reinitialize the list for future use. Called at the end of the loop, if an event has been raised.
Reimplemented from ButtonsCommanderButton.
|
virtual |
Gets one push item through its id.
Reimplemented from ButtonsCommanderButton.
|
inline |
Gets one push item.
|
inline |
Gets the last push button pressed.
|
virtual |
Main loop function.
Reimplemented from ButtonsCommanderButton.