Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed Servo PinDetect
setup.cpp
00001 /* 00002 * Authors: Group 4 Adam Elghor, Brian Kaplan, Sayak Chatterjee, Moraa Onwonga 00003 * Purpose: Controls the SETUP state of the machine 00004 * Language: C++ 00005 */ 00006 #include "setup.h" 00007 #include "authentication.h" 00008 #include "parameters.h" 00009 #include "actuators.h" 00010 #include "PinDetect.h" 00011 00012 00013 PinDetect button(p8); 00014 00015 volatile bool buttonHit = false; 00016 bool firstTime = true; 00017 00018 /* 00019 * Function: button_hit_callback 00020 * -------------------- 00021 * Changes boolean buttonHit inversly when called 00022 * 00023 */ 00024 void button_hit_callback (void) 00025 { 00026 buttonHit = !buttonHit; 00027 } 00028 /* 00029 * Function: setup 00030 * -------------------- 00031 * Calls the functions needed to setup the entry sequence for the safe. 00032 * 00033 * returns: the next state in the state machine 00034 * LOCK: after entry sequence has been entered 00035 * 00036 */ 00037 00038 00039 enum states setup() 00040 { 00041 printf("%d",buttonHit); 00042 if (firstTime) { 00043 button.mode(PullUp); 00044 button.attach_deasserted(&button_hit_callback); 00045 button.setSampleFrequency(); 00046 firstTime = false; 00047 } 00048 if(buttonHit || checkBluetooth()) { 00049 setEntrySequenceAttempt(); 00050 wait(5); 00051 lockSafe(); 00052 wait(5); 00053 return LOCK; 00054 } 00055 return SETUP; 00056 } 00057 00058 00059 00060
Generated on Thu Jul 14 2022 04:06:30 by
1.7.2