class of Buttons -isPressed -wasPressed -notPressed -LongPress (Timer)

Revision:
8:6c8a00baae91
Parent:
7:09fb38cf8526
--- a/Button.cpp	Tue Jun 04 14:19:35 2019 +0000
+++ b/Button.cpp	Fri Apr 17 14:05:36 2020 +0000
@@ -3,7 +3,11 @@
 
 
 /******************************************************************************/
-// constructor
+// constructor of instance button
+//      - PinName:  Name of pin of MBed LPC1768 (e.g. p9, p10,...)
+//      - PinMode:  PullUp, PullDown, PullNone, OpenDrain
+//      - time:     defines the time after the longPress-Flag is set.
+//
 /******************************************************************************/
 Button::Button(PinName pBtn, PinMode  pBtnMode, float time)
 {
@@ -20,14 +24,22 @@
 
 /******************************************************************************/
 // initialisation
+//      - bNewState:        current state of button
+//      - bOldState:        previous state of button
+//      - bIsPressed:       flag is set if button is pressed
+//      - bLongPresed:      flag is set, after timer is zero (bIsPressed = true)
+//      - bWasPressed:      after button is not pressed anymore
+//
 /******************************************************************************/
 void Button::init()
 {
+    bNewState   = false;
+    bOldState   = false;    
+    
     bIsPressed  = false;
     bLongPress  = false;
     bWasPressed = false;
-    bNewState   = false;
-    bOldState   = false;
+
 
     bBtnNewAction = false;
 
@@ -47,7 +59,8 @@
 //      - bBtnNewAction:    flag, if an action is occur
 //      - iNumCycle:        cycle counter of same state
 //      - NUNCYCLES:        max. value of cycle counter
-//      - *iNumBtn:         pointer of variable, which counts pressed buttons
+//      - *iNumBtn:         pointer to variable, which counts the number of pressed buttons
+//
 /******************************************************************************/
 void Button::polling(uint8_t *iNumBtn)
 {
@@ -90,8 +103,8 @@
                         timer->detach();
                         bLongPress = false;
                         
-                    if((iNumBtn != NULL && *iNumBtn) > 0)
-                        (*iNumBtn)--;
+                    if(iNumBtn != NULL && *iNumBtn > 0)                         // if there is a pointer to a counter-Variable and the value is greater than 0
+                        (*iNumBtn)--;                                           // decrease iNumBtn by one 
                 }
 
             }
@@ -104,7 +117,6 @@
 }
 
 
-
 /******************************************************************************/
 //
 /******************************************************************************/