1#ifndef PinMixerAdapter_h
2#define PinMixerAdapter_h
24 : pin1(pin1), pin2(pin2)
30 currentStatePin1 = previousStatePin1 = pin1->
read();
31 currentStatePin2 = previousStatePin2 = pin2->
read();
32 state = currentStatePin1;
37 currentStatePin1 = pin1->
read();
38 if ( currentStatePin1 != previousStatePin1 ) {
39 previousStatePin1 = currentStatePin1;
40 state = currentStatePin1;
42 currentStatePin2 = pin2->
read();
43 if ( currentStatePin2 != previousStatePin2 ) {
44 previousStatePin2 = currentStatePin2;
45 state = currentStatePin2;
54 bool currentStatePin1;
55 bool previousStatePin1;
56 bool currentStatePin2;
57 bool previousStatePin2;
The interface specification for button, encoder button and switch pins.
Definition: PinAdapter.h:8
virtual bool read()=0
Read the current state of the pin.
virtual void begin()=0
Initialise the pin adapter. Must be safe for repeated calls (Idempotent)
This is the default PinAdapter for regular GPIO pins.
Definition: PinMixerAdapter.h:11
void begin()
Initialise the pin adapter. Must be safe for repeated calls (Idempotent)
Definition: PinMixerAdapter.h:27
bool read()
Read the current state of the pin.
Definition: PinMixerAdapter.h:35
PinMixerAdapter(PinAdapter *pin1, PinAdapter *pin2)
Takes two PinAdapter classes and mixes their read() calls. Initial state is taken from pin1.
Definition: PinMixerAdapter.h:23