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:
2:444eeedb41f0
Parent:
1:316582aec4fb
Child:
3:0e554d8d5a19
--- a/SecurityUnlockDemo-Animation.cpp	Sat Jun 01 20:43:11 2019 +0000
+++ b/SecurityUnlockDemo-Animation.cpp	Sat Jun 01 21:04:17 2019 +0000
@@ -4,6 +4,14 @@
 //
 // Fredric L. Rice, June 2019
 //
+// This module draws a mushroom on the display and then animates it as
+// the mushroom moves around "randomly." Every 10 moves or so it will
+// "teleport" to a "random" place on the screen.
+//
+// The random number generator provided by mbed is not very good
+// so we attempt to use the analog inputs on PF_3, PF_4, PF_5 to help
+// drive some randomness.
+//
 // ----------------------------------------------------------------------
 
 #include "mbed.h"                           // The mbed operating system
@@ -92,10 +100,23 @@
     // After about 1 second we want to remove that message from
     // the screen so we maintain this count down timer
     static uint16_t u16_teleportMessageRemovalCountDown;
+    
+    // In an effort to assist the random number generator we will read
+    // vaues from some of the analog inputs which should be near zero
+    // but perhaps not entirely
+    static AnalogIn st_analog1(PF_3);
+    static AnalogIn st_analog2(PF_4);
+    static AnalogIn st_analog3(PF_5);
 
 // ----------------------------------------------------------------------
 // AnimationDrawSpriteAtThisLocation()
 //
+// This function will draw or erase the sprite at the X and Y 
+// coordinate position passed to it, or it will erase the sprite
+// depending upon the argument passed to it.
+//
+// The colors that are supported are described in the sprite's
+// bit mapping.
 //
 // ----------------------------------------------------------------------
 static void AnimationDrawOrEraseSpriteAtThisLocation(uint16_t u16_thisX, uint16_t u16_thisY, bool b_drawSprite)
@@ -229,6 +250,13 @@
 // ----------------------------------------------------------------------
 // AnimationMoveSprite()
 //
+// This function is the one that performs the actual move by 1 pixel
+// of the sprite. The sprite is erased from the screen and then the
+// new location is computed. If that places the sprite outside of the
+// boundaries, a new direction is selected and then the proposed
+// new location is selected.
+//
+// Once there is a new sprite location proposed, it gets re-drawn.
 //
 // ----------------------------------------------------------------------
 static void AnimationMoveSprite(void)
@@ -369,6 +397,12 @@
 // ----------------------------------------------------------------------
 // AnimationThread()
 //
+// This is the main thread for the animation functionality. The thread
+// usually runs forever however there is a mechanism for terminating
+// it provided in this module.
+//
+// The thread wakes up about 40 times a second so that the animation
+// can move fairly quickly and smoothly.
 //
 // ----------------------------------------------------------------------
 void AnimationThread(void)
@@ -387,6 +421,9 @@
 // ----------------------------------------------------------------------
 // AnimationPerformAnimation()
 //
+// This function is called when it is time to start animating the
+// sprite. It checks to make sure that the animation thread is not
+// yet started before it starts the animation.
 //
 // ----------------------------------------------------------------------
 void AnimationPerformAnimation(uint32_t u32_randomSeeder)
@@ -402,6 +439,10 @@
     
         // Flag the fact that the thread is running
         b_animationThreadRunning = true;
+        
+        // In an effort to add more "randomness," read some of the
+        // analog inputs and add their values, if any, to the seed
+        u32_randomSeeder = (st_analog1 * 100) + (st_analog2 * 100) + (st_analog3 * 100);
     
         // In order to "seed" the random number generator, we acquire
         // and discard up to 2000 random numbers
@@ -419,6 +460,8 @@
 // ----------------------------------------------------------------------
 // AnimationStopAnimation()
 //
+// In the event the animation thread needs to be stopped, this function
+// may be called to terminate the animation thread.
 //
 // ----------------------------------------------------------------------
 void AnimationStopAnimation(void)