9 #ifndef NO_BUTTONSCOMMANDER 10 #ifndef NO_BUTTONSCOMMANDERPUSH 14 this->buttonPin = (GPIO_pin_t)DP_INVALID;
15 this->lastButtonState = HIGH;
16 this->lastDebounceTime = 0;
17 this->debounceDelay = 50;
23 this->buttonPin = Arduino_to_GPIO_pin(inButtonPin);
25 pinMode2f(this->buttonPin, INPUT_PULLUP);
28 this->
AddEvent(inId, inEventType, inData);
37 pEvent->
Data = inData;
43 if (this->Events.
pFirst == NULL)
45 #ifdef COMMANDERS_DEBUG_MODE 46 if (this->debounceDelay != UINT32_MAX)
48 Serial.println(F(
"This push button have no ID defined : call begin() !"));
50 this->debounceDelay = UINT32_MAX;
58 if (this->buttonPin == DP_INVALID)
62 int reading = digitalRead2f(this->buttonPin);
69 if (reading != this->lastButtonState)
72 this->lastDebounceTime = millis();
75 if (this->lastDebounceTime > 0 && (millis() - this->lastDebounceTime) > this->debounceDelay)
81 if (reading == this->lastButtonState)
89 this->Events.pCurrentItem->Obj->Data);
94 this->lastDebounceTime = 0;
99 this->lastButtonState = reading;
103 #ifdef COMMANDERS_PRINT_COMMANDERS 104 void ButtonsCommanderPush::printCommander()
106 Serial.print(F(
" Push - Pin :"));
107 Serial.println(this->
GetPin());
110 while (pCurr != NULL)
112 Serial.print(F(
" Event Id: "));
113 Serial.print(pCurr->
Obj->
Id);
114 Serial.print(F(
" / Event type: "));
117 Serial.print(F(
" / Debounce delay: "));
118 Serial.print(this->debounceDelay);
119 Serial.println(F(
""));
121 pCurr = pCurr->
pNext;
CMDRSCHAINEDLISTITEM * pNext
static void printEventData(COMMANDERS_EVENT_TYPE inEventType, int inEventData)
static unsigned long RaiseEvent(unsigned long inId, COMMANDERS_EVENT_TYPE inEvent = COMMANDERS_EVENT_MOVEPOSITIONID, int inData = 0)
CMDRSCHAINEDLISTITEM< T > * pCurrentItem
COMMANDERS_EVENT_TYPE EventType
static void printEventType(COMMANDERS_EVENT_TYPE inEventType, bool inDataFollow)
CMDRSCHAINEDLISTITEM< T > * pFirst