Moraa Onwonga / Mbed 2 deprecated Safe_Of_the_Gods

Dependencies:   mbed Servo PinDetect

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers lock.cpp Source File

lock.cpp

00001 /*
00002 * Authors: Group 4 Adam Elghor, Brian Kaplan, Sayak Chatterjee, Moraa Onwonga
00003 * Purpose: Controls the LOCK state of the machine
00004 * Language: C++
00005 */
00006 #include "lock.h"
00007 #include "authentication.h"
00008 #include "actuators.h"
00009 #include "parameters.h"
00010 
00011 /*
00012 * Function:  lock
00013 * --------------------
00014 *  Locks safe
00015 *
00016 *  returns: the next state in the state machine
00017 *  Open: After it has been locked
00018 *
00019 */
00020 enum states lock() {
00021     if(authenticateLock()) {
00022         openSafe();
00023         wait(5);
00024         return OPEN;
00025     } else {
00026         return LOCK;
00027     }
00028 }
00029 
00030 /*
00031 * Function: authenticateLock
00032 * ----------------------------
00033 *  Checks whether a cup was found through the sonar sensor
00034 *
00035 *  returns: true if cup found else false
00036 */
00037 bool authenticateLock() {
00038     return CorrectEntrySequenceAttempt();
00039 }
00040