kh

Dependencies:   mbed PinDetect Servo

Files at this revision

API Documentation at this revision

Comitter:
Sayak97
Date:
Sat Nov 10 20:08:46 2018 +0000
Parent:
0:28e05e1a3d1e
Child:
2:04bbd14722bd
Commit message:
hjughj'; \; \;

Changed in this revision

actuators.cpp Show annotated file Show diff for this revision Revisions of this file
authentication.cpp Show annotated file Show diff for this revision Revisions of this file
authentication.h Show annotated file Show diff for this revision Revisions of this file
lock.cpp Show annotated file Show diff for this revision Revisions of this file
lock.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
moter.cpp Show diff for this revision Revisions of this file
motor.h Show diff for this revision Revisions of this file
open.cpp Show annotated file Show diff for this revision Revisions of this file
open.h Show annotated file Show diff for this revision Revisions of this file
parameters.h Show annotated file Show diff for this revision Revisions of this file
powerManagement.cpp Show annotated file Show diff for this revision Revisions of this file
powerManagement.h Show annotated file Show diff for this revision Revisions of this file
powerMangement.cpp Show diff for this revision Revisions of this file
setup.cpp Show annotated file Show diff for this revision Revisions of this file
setup.h Show annotated file Show diff for this revision Revisions of this file
--- a/actuators.cpp	Sat Nov 10 19:30:54 2018 +0000
+++ b/actuators.cpp	Sat Nov 10 20:08:46 2018 +0000
@@ -6,6 +6,11 @@
 #include "actuators.h"
 #include "parameters.h"
 #include "mbed.h"
+
+
+PwmOut rcServo1(p23); // pwm, fwd, rev
+PwmOut rcServo2(p24); // pwm, fwd, rev
+
 /*
 * Function:  turnsRcServosRight
 * --------------------
--- a/authentication.cpp	Sat Nov 10 19:30:54 2018 +0000
+++ b/authentication.cpp	Sat Nov 10 20:08:46 2018 +0000
@@ -3,7 +3,7 @@
 * Purpose: Controls Input and Output Data
 * Language: C
 */
-#include "logging.h"
+#include "authentication.h"
 #include "powerManagement.h"
 #include "parameters.h"
 
@@ -17,6 +17,14 @@
 int entryNum3;
 int entryNum4;
 
+
+Serial blue(p28,p27);
+
+AnalogIn pot1(p18);
+AnalogIn pot2(p18);
+AnalogIn pot3(p20);
+AnalogIn pot4(p20);
+
 /*
 * Function: setEntrySequence
 * --------------------
@@ -44,9 +52,7 @@
 	p3 = float(pot3) * 10;
 	p4 = float(pot4) * 10;
 
-	if(checkPot(p1,entryNum1) && checkPot(p2,entryNum2) && checkPot(p3,entryNum3) && checkPot(p3,entryNum3) ){
-		return true;
-	}
+	return (checkPot(p1,entryNum1) && checkPot(p2,entryNum2) && checkPot(p3,entryNum3) && checkPot(p3,entryNum3));
 }
 
 bool checkPot(int p1, int p2) {
--- a/authentication.h	Sat Nov 10 19:30:54 2018 +0000
+++ b/authentication.h	Sat Nov 10 20:08:46 2018 +0000
@@ -3,15 +3,12 @@
 * Purpose: Controls Input and Output Data
 * Language: C
 */
-#include "authentication.cpp"
 /*
 * Function: setEntrySequence
 * --------------------
 *  Reads in user's entry sequence attempt
 */
-void setEntrySequenceAttempt() {
-}
-
+void setEntrySequenceAttempt();
 /*
 * Function:  CorrectEntrySequenceAttempt
 * --------------------
@@ -21,11 +18,9 @@
 *  the set entry sequence otherwise false
 *
 */
-bool CorrectEntrySequenceAttempt() {
-}
+bool CorrectEntrySequenceAttempt();
 
-bool checkPot(int p1, int p2) {
-}
+bool checkPot(int p1, int p2);
 
 
 
@@ -37,9 +32,7 @@
 *  returns:
 *
 */
-void bluetooth() {
-
-}
+void bluetooth();
 
 
 /*
@@ -50,7 +43,5 @@
 *  returns:
 *
 */
-void sdCard() {
+void sdCard();
 
-}
-
--- a/lock.cpp	Sat Nov 10 19:30:54 2018 +0000
+++ b/lock.cpp	Sat Nov 10 20:08:46 2018 +0000
@@ -4,6 +4,7 @@
 * Language: C
 */
 #include "lock.h"
+#include "authentication.h"
 #include "actuators.h"
 #include "powerManagement.h"
 #include "parameters.h"
@@ -18,12 +19,12 @@
 *
 */
 enum states lock() {
-	if(authenticate()) {
+	if(authenticateLock()) {
 		openSafe();
 		wait(5000);
 		return OPEN;
 	} else {
-		return LOCK:
+		return LOCK;
 	}
 }
 
@@ -34,6 +35,6 @@
 *
 *  returns: true if cup found else false
 */
-bool authenticate() {
+bool authenticateLock() {
     return CorrectEntrySequenceAttempt();
 }
--- a/lock.h	Sat Nov 10 19:30:54 2018 +0000
+++ b/lock.h	Sat Nov 10 20:08:46 2018 +0000
@@ -1,29 +1,25 @@
-/*
-* Authors: Group 4 Adam Elghor, Brian Kaplan, Sayak Chatterjee, Moraa Onwonga
-* Purpose: Controls the LOCK state of the machine
-* Language: C
-*/
-#include "lock.cpp"
-
-/*
-* Function:  lock
-* --------------------
-*  Locks safe
-*
-*  returns: the next state in the state machine
-*  Open: After it has been locked
-*
-*/
-enum states lock() {
-}
-
-/*
-* Function: authenticate
-* ----------------------------
-*  Checks whether a cup was found through the sonar sensor
-*
-*  returns: true if cup found else false
-*/
-bool authenticate() {
-    
-}
+/*
+* Authors: Group 4 Adam Elghor, Brian Kaplan, Sayak Chatterjee, Moraa Onwonga
+* Purpose: Controls the LOCK state of the machine
+* Language: C
+*/
+
+/*
+* Function:  lock
+* --------------------
+*  Locks safe
+*
+*  returns: the next state in the state machine
+*  Open: After it has been locked
+*
+*/
+enum states lock();
+
+/*
+* Function: authenticate
+* ----------------------------
+*  Checks whether a cup was found through the sonar sensor
+*
+*  returns: true if cup found else false
+*/
+bool authenticateLock();
--- a/main.cpp	Sat Nov 10 19:30:54 2018 +0000
+++ b/main.cpp	Sat Nov 10 20:08:46 2018 +0000
@@ -9,9 +9,6 @@
 #include "sleep.h"
 #include "parameters.h"
 
-task main() {
-    SafeStateMachine();
-}
 
 /*
 * Function:  SafeStateMachine
@@ -38,10 +35,14 @@
             state = setup();
             break;
         default:
-            state = locked();
+            state = lock();
         }
     }
 }
 
+int main() {
+    SafeStateMachine();
+}
 
 
+
--- a/moter.cpp	Sat Nov 10 19:30:54 2018 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/* mbed simple H-bridge motor controller
- * Copyright (c) 2007-2010, sford, http://mbed.org
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-#include "Motor.h"
-
-#include "mbed.h"
-
-Motor::Motor(PinName pwm, PinName fwd, PinName rev):
-        _pwm(pwm), _fwd(fwd), _rev(rev) {
-
-    // Set initial condition of PWM
-    _pwm.period(0.001);
-    _pwm = 0;
-
-    // Initial condition of output enables
-    _fwd = 0;
-    _rev = 0;
-}
-
-void Motor::speed(float speed) {
-    _fwd = (speed > 0.0);
-    _rev = (speed < 0.0);
-    _pwm = abs(speed);
-}
-
--- a/motor.h	Sat Nov 10 19:30:54 2018 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-/* mbed simple H-bridge motor controller
- * Copyright (c) 2007-2010, sford, http://mbed.org
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-#ifndef MBED_MOTOR_H
-#define MBED_MOTOR_H
-
-#include "mbed.h"
-
-/** Interface to control a standard DC motor 
- *
- * with an H-bridge using a PwmOut and 2 DigitalOuts
- */
-class Motor {
-public:
-
-    /** Create a motor control interface    
-     *
-     * @param pwm A PwmOut pin, driving the H-bridge enable line to control the speed
-     * @param fwd A DigitalOut, set high when the motor should go forward
-     * @param rev A DigitalOut, set high when the motor should go backwards
-     */
-    Motor(PinName pwm, PinName fwd, PinName rev);
-    
-    /** Set the speed of the motor
-     * 
-     * @param speed The speed of the motor as a normalised value between -1.0 and 1.0
-     */
-    void speed(float speed);
-
-protected:
-    PwmOut _pwm;
-    DigitalOut _fwd;
-    DigitalOut _rev;
-
-};
-
-#endif
--- a/open.cpp	Sat Nov 10 19:30:54 2018 +0000
+++ b/open.cpp	Sat Nov 10 20:08:46 2018 +0000
@@ -20,7 +20,7 @@
 *
 */
 enum states open() {
-    if (authenticate()) {
+    if (authenticateOpen()) {
         return OPEN;
     } else {
         lockSafe();
@@ -36,7 +36,7 @@
 *
 *  returns: true if cup found else false
 */
-bool authenticate() {
+bool authenticateOpen() {
     return CorrectEntrySequenceAttempt();
 }
 
--- a/open.h	Sat Nov 10 19:30:54 2018 +0000
+++ b/open.h	Sat Nov 10 20:08:46 2018 +0000
@@ -1,31 +1,27 @@
-/*
-* Authors: Group 4 Adam Elghor, Brian Kaplan, Sayak Chatterjee, Moraa Onwonga
-* Purpose: Controls the OPEN state of the machine
-* Language:  C
-*/
-#include "open.cpp"
-
-/*
-* Function:  OPEN
-* --------------------
-*  Calls the functions needed to for the open state
-*
-*
-*  returns: the next state in the state machine
-*  LOCK: if closed properly
-*  ALARM: if cup is not found after searching in a full circle
-*
-*/
-enum states open() {
-}
-
-/*
-* Function: authenticate
-* ----------------------------
-*  Checks whether a cup was found through the sonar sensor
-*
-*  returns: true if cup found else false
-*/
-bool authenticate() {
-}
+/*
+* Authors: Group 4 Adam Elghor, Brian Kaplan, Sayak Chatterjee, Moraa Onwonga
+* Purpose: Controls the OPEN state of the machine
+* Language:  C
+*/
+/*
+* Function:  OPEN
+* --------------------
+*  Calls the functions needed to for the open state
+*
+*
+*  returns: the next state in the state machine
+*  LOCK: if closed properly
+*  ALARM: if cup is not found after searching in a full circle
+*
+*/
+enum states open();
 
+/*
+* Function: authenticate
+* ----------------------------
+*  Checks whether a cup was found through the sonar sensor
+*
+*  returns: true if cup found else false
+*/
+bool authenticateOpen();
+
--- a/parameters.h	Sat Nov 10 19:30:54 2018 +0000
+++ b/parameters.h	Sat Nov 10 20:08:46 2018 +0000
@@ -4,17 +4,7 @@
  * Purpose: Controls the parameters of the safe
  * Language:  C
  */
-enum state{OPEN, LOCK, SETUP};/*Name of the states in the Safe Cups State Machine*/
+enum states{OPEN, LOCK, SETUP};/*Name of the states in the Safe Cups State Machine*/
 #define  maxFailedAtttemps 6; /*number of max failed attemps entered before alarm is thrown*/
-DigitalIn button(p8);
-
-PwmOut rcServo1(p23); // pwm, fwd, rev
-PwmOut rcServo2(p24); // pwm, fwd, rev
 
-Serial blue(p28,p27);
 
-AnalogIn pot1(p20);
-AnalogIn pot2(p21);
-AnalogIn pot3(p22);
-AnalogIn pot4(p22);
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/powerManagement.cpp	Sat Nov 10 20:08:46 2018 +0000
@@ -0,0 +1,31 @@
+/*
+* Authors: Group 4 Adam Elghor, Brian Kaplan, Sayak Chatterjee, Moraa Onwonga
+* Purpose: Controls Input and Output Data
+* Language: C
+*/
+#include "powerManagement.h"
+#include "parameters.h"
+
+int batteryLevels;
+
+/*
+* Function: powerSavingMode
+* --------------------
+*  Controls what is on while the safe is on this mode
+*/
+void powerSavingMode() {
+//however we decide to implement 
+}
+
+/*
+* Function: getBatteryLevels
+* --------------------
+*  Get the battery level for the safe
+*
+*  returns: the battery level for the safe
+*
+*/
+int getBatteryLevels() {
+	//EDIT LATER maybe have it send a notification in the future
+	return batteryLevels;
+}
--- a/powerManagement.h	Sat Nov 10 19:30:54 2018 +0000
+++ b/powerManagement.h	Sat Nov 10 20:08:46 2018 +0000
@@ -1,27 +1,22 @@
-/*
-* Authors: Group 4 Adam Elghor, Brian Kaplan, Sayak Chatterjee, Moraa Onwonga
-* Purpose: Controls Input and Output Data
-* Language: C
-*/
-#include "powerManagement.cpp"
-
-
-/*
-* Function: powerSavingMode
-* --------------------
-*  Controls what is on while the safe is on this mode
-*/
-void powerSavingMode() {
-//however we decide to implement 
-}
-
-/*
-* Function: getBatteryLevels
-* --------------------
-*  Get the battery level for the safe
-*
-*  returns: the battery level for the safe
-*
-*/
-void getBatteryLevels() {
-}
+/*
+* Authors: Group 4 Adam Elghor, Brian Kaplan, Sayak Chatterjee, Moraa Onwonga
+* Purpose: Controls Input and Output Data
+* Language: C
+*/
+
+/*
+* Function: powerSavingMode
+* --------------------
+*  Controls what is on while the safe is on this mode
+*/
+void powerSavingMode();
+
+/*
+* Function: getBatteryLevels
+* --------------------
+*  Get the battery level for the safe
+*
+*  returns: the battery level for the safe
+*
+*/
+int getBatteryLevels();
--- a/powerMangement.cpp	Sat Nov 10 19:30:54 2018 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-/*
-* Authors: Group 4 Adam Elghor, Brian Kaplan, Sayak Chatterjee, Moraa Onwonga
-* Purpose: Controls Input and Output Data
-* Language: C
-*/
-#include "powerManagement.h"
-#include "parameters.h"
-
-int batteryLevels;
-
-/*
-* Function: powerSavingMode
-* --------------------
-*  Controls what is on while the safe is on this mode
-*/
-void powerSavingMode() {
-//however we decide to implement 
-}
-
-/*
-* Function: getBatteryLevels
-* --------------------
-*  Get the battery level for the safe
-*
-*  returns: the battery level for the safe
-*
-*/
-void getBatteryLevels() {
-	//EDIT LATER maybe have it send a notification in the future
-	return batteryLevels;
-}
--- a/setup.cpp	Sat Nov 10 19:30:54 2018 +0000
+++ b/setup.cpp	Sat Nov 10 20:08:46 2018 +0000
@@ -8,6 +8,9 @@
 #include "parameters.h"
 #include "actuators.h"
 
+
+DigitalIn button(p8);
+
 /*
 * Function:  setup
 * --------------------
@@ -20,8 +23,8 @@
 
 
 enum states setup() {
-	if(pb) {
-	setEntrySequence();
+	if(button) {
+	setEntrySequenceAttempt();
 	wait(5000);
 	lockSafe();
 	wait(5000);
--- a/setup.h	Sat Nov 10 19:30:54 2018 +0000
+++ b/setup.h	Sat Nov 10 20:08:46 2018 +0000
@@ -1,23 +1,20 @@
-/*
-* Authors: Group 4 Adam Elghor, Brian Kaplan, Sayak Chatterjee, Moraa Onwonga
-* Purpose: Controls the SETUP state of the machine
-* Language: C
-*/
-#include "setup.cpp"
-
-/*
-* Function:  setup
-* --------------------
-*  Calls the functions needed to setup the entry sequence for the safe.
-*
-*  returns: the next state in the state machine
-*  LOCK: after entry sequence has been entered
-*
-*/
-
-
-enum states setup() {
-}
-
-
+/*
+* Authors: Group 4 Adam Elghor, Brian Kaplan, Sayak Chatterjee, Moraa Onwonga
+* Purpose: Controls the SETUP state of the machine
+* Language: C
+*/
 
+/*
+* Function:  setup
+* --------------------
+*  Calls the functions needed to setup the entry sequence for the safe.
+*
+*  returns: the next state in the state machine
+*  LOCK: after entry sequence has been entered
+*
+*/
+
+
+enum states setup();
+
+