This is a demonstration program which draws a keypad on the LCD and uses the touch screen to allow an operator to key-in an access code. Two possible codes are allowed to grant to different levels of access. Additionally the push button is used to allow an operator to send Moorse Code pulses in to the device which is checked against two characters to determine if there was a match, and if so, access is granted.

Dependencies:   LCD_DISCO_F429ZI mbed TS_DISCO_F429ZI mbed-os BSP_DISCO_F429ZI

Also draws a mushroom on the screen and animates it.

Revision:
3:0e554d8d5a19
Parent:
1:316582aec4fb
Child:
5:5c507689ae66
diff -r 444eeedb41f0 -r 0e554d8d5a19 SecurityUnlockDemo-Keypad.cpp
--- a/SecurityUnlockDemo-Keypad.cpp	Sat Jun 01 21:04:17 2019 +0000
+++ b/SecurityUnlockDemo-Keypad.cpp	Mon Jun 03 21:56:36 2019 +0000
@@ -208,6 +208,48 @@
 }
 
 // ----------------------------------------------------------------------
+// KeypadFlashThisKey()
+//
+// The key that was touched and whose index got passed to this function
+// is written in YELLOW and then restored to its original displayed
+// graphic with one quarter of a second between.
+//
+// ----------------------------------------------------------------------
+static void KeypadFlashThisKey(uint8_t u8_thisKeyPadItem)
+{
+    // Set everything to YELLOW
+    st_lcd.SetBackColor(LCD_COLOR_YELLOW);
+    st_lcd.SetTextColor(LCD_COLOR_YELLOW);
+
+    // Draw the rectangle as all yellow
+    st_lcd.FillRect(st_KeypadInformation[u8_thisKeyPadItem].u16_screenXLocation,
+        st_KeypadInformation[u8_thisKeyPadItem].u16_screenYLocation,
+        st_KeypadInformation[u8_thisKeyPadItem].u16_keyHeight,
+        st_KeypadInformation[u8_thisKeyPadItem].u16_keyWidth);
+
+    // Wait for one quarter of a second
+    wait(0.25);
+    
+    // Restore the normal colors
+    st_lcd.SetBackColor(LCD_COLOR_WHITE);
+    st_lcd.SetTextColor(LCD_COLOR_BLUE);
+    
+    // Draw the rectangle with its regular color and text
+    st_lcd.FillRect(st_KeypadInformation[u8_thisKeyPadItem].u16_screenXLocation,
+        st_KeypadInformation[u8_thisKeyPadItem].u16_screenYLocation,
+        st_KeypadInformation[u8_thisKeyPadItem].u16_keyHeight,
+        st_KeypadInformation[u8_thisKeyPadItem].u16_keyWidth);
+    
+    // Display the character near the lower right corner of the rectangle
+    st_lcd.DisplayChar(
+        st_KeypadInformation[u8_thisKeyPadItem].u16_screenXLocation + 
+            (st_KeypadInformation[u8_thisKeyPadItem].u16_keyHeight / 2) + 6,
+        st_KeypadInformation[u8_thisKeyPadItem].u16_screenYLocation + 
+            (st_KeypadInformation[u8_thisKeyPadItem].u16_keyWidth / 2) + 2,
+        st_KeypadInformation[u8_thisKeyPadItem].u8_keyASCIICharacter);    
+}
+
+// ----------------------------------------------------------------------
 // KeypadHandleKeyPress()
 //
 // When a key is pressed, the X and Y coordinates of the position where
@@ -247,7 +289,10 @@
         {
             if (u16_screenY > u16_keyMinimumY && u16_screenY < u16_keyMaximumY)
             {
-                // This is the key that was pressed
+                // Flash the key that was pressed
+                KeypadFlashThisKey(u8_keyPadItem);
+                
+                // Process the key that was pressed
                 KeypadProcessKeypadKey(st_KeypadInformation[u8_keyPadItem].u8_keyASCIICharacter);
                 
                 // We are finished searching