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
--- a/SecurityUnlockDemo-Main.cpp	Sat Jun 01 21:04:17 2019 +0000
+++ b/SecurityUnlockDemo-Main.cpp	Mon Jun 03 21:56:36 2019 +0000
@@ -49,6 +49,9 @@
     // our numbers for the animation
     static uint32_t u32_randomSeeder;
     
+    // We keep track of what access level we may have granted
+    static uint8_t u8_thisAccessLevel;
+    
 // ----------------------------------------------------------------------
 // MainInit()
 //
@@ -63,7 +66,8 @@
 static void MainInit(void)
 {
     // Initialize locally-held data
-    u32_randomSeeder = 0;
+    u32_randomSeeder   = 0;
+    u8_thisAccessLevel = 0;
     
     uint8_t u8_TouchScreenStatus = 0;
         
@@ -107,6 +111,9 @@
     
     // Perform the screen animation
     AnimationPerformAnimation(u32_randomSeeder);
+    
+    // Flag the fact that we have granted access already
+    uint8_t u8_accessLevelGranted = u8_thisAccessLevel;
 }
 
 // ----------------------------------------------------------------------
@@ -129,23 +136,27 @@
     uint16_t        u16_screenY          = 0;
     TS_StateTypeDef st_touchScreenState;
     
-    // Get the status of the Touch Screen interface
-    st_touchScreen.GetState(&st_touchScreenState);
-        
-    // Has the screen been touched?
-    if (st_touchScreenState.TouchDetected)
+    // Have we not offered access already?
+    if (0 == u8_thisAccessLevel)
     {
-        // It has been, extract the X and Y coordinates touched
-        u16_screenX = st_touchScreenState.X;
-        u16_screenY = st_touchScreenState.Y;
+        // Get the status of the Touch Screen interface
+        st_touchScreen.GetState(&st_touchScreenState);
         
-        // Call the routine which handles the key press
-        KeypadHandleKeyPress(u16_screenX, u16_screenY);
-    }
+        // Has the screen been touched?
+        if (st_touchScreenState.TouchDetected)
+        {
+            // It has been, extract the X and Y coordinates touched
+            u16_screenX = st_touchScreenState.X;
+            u16_screenY = st_touchScreenState.Y;
+        
+            // Call the routine which handles the key press
+            KeypadHandleKeyPress(u16_screenX, u16_screenY);
+        }
     
-    // Drive the Moorse Code access functionality, scanning the
-    // push button 10 times a second
-    MoorseScanPushButton();
+        // Drive the Moorse Code access functionality, scanning the
+        // push button 10 times a second
+        MoorseScanPushButton();
+    }
     
     // Keep track of how many times this function has been called
     // so that we can attempt to see the random generator