kh
Dependencies: mbed PinDetect Servo
Diff: lock.cpp
- Revision:
- 2:04bbd14722bd
- Parent:
- 1:2c365f6da61d
--- a/lock.cpp Sat Nov 10 20:08:46 2018 +0000 +++ b/lock.cpp Mon Nov 12 23:36:11 2018 +0000 @@ -1,40 +1,41 @@ -/* -* Authors: Group 4 Adam Elghor, Brian Kaplan, Sayak Chatterjee, Moraa Onwonga -* Purpose: Controls the LOCK state of the machine -* Language: C -*/ -#include "lock.h" -#include "authentication.h" -#include "actuators.h" -#include "powerManagement.h" -#include "parameters.h" +/* +* Authors: Group 4 Adam Elghor, Brian Kaplan, Sayak Chatterjee, Moraa Onwonga +* Purpose: Controls the LOCK state of the machine +* Language: C +*/ +#include "lock.h" +#include "authentication.h" +#include "actuators.h" +#include "powerManagement.h" +#include "parameters.h" + +/* +* Function: lock +* -------------------- +* Locks safe +* +* returns: the next state in the state machine +* Open: After it has been locked +* +*/ +enum states lock() { + if(authenticateLock()) { + openSafe(); + wait(5); + return OPEN; + } else { + return LOCK; + } +} + +/* +* Function: authenticate +* ---------------------------- +* Checks whether a cup was found through the sonar sensor +* +* returns: true if cup found else false +*/ +bool authenticateLock() { + return CorrectEntrySequenceAttempt(); +} -/* -* Function: lock -* -------------------- -* Locks safe -* -* returns: the next state in the state machine -* Open: After it has been locked -* -*/ -enum states lock() { - if(authenticateLock()) { - openSafe(); - wait(5000); - return OPEN; - } else { - return LOCK; - } -} - -/* -* Function: authenticate -* ---------------------------- -* Checks whether a cup was found through the sonar sensor -* -* returns: true if cup found else false -*/ -bool authenticateLock() { - return CorrectEntrySequenceAttempt(); -}