kh
Dependencies: mbed PinDetect Servo
authentication.cpp
00001 /* 00002 * Authors: Group 4 Adam Elghor, Brian Kaplan, Sayak Chatterjee, Moraa Onwonga 00003 * Purpose: Controls Input and Output Data 00004 * Language: C 00005 */ 00006 #include "authentication.h" 00007 #include "powerManagement.h" 00008 #include "parameters.h" 00009 00010 int p1; 00011 int p2; 00012 int p3; 00013 int p4; 00014 00015 int entryNum1; 00016 int entryNum2; 00017 int entryNum3; 00018 int entryNum4; 00019 00020 00021 AnalogIn pot1(p15); 00022 AnalogIn pot2(p16); 00023 AnalogIn pot3(p18); 00024 AnalogIn pot4(p19); 00025 00026 bool bluetoothCode = false; 00027 bool bluetoothSetup = false; 00028 Serial blue(p28,p27); 00029 Serial pc(USBTX, USBRX); 00030 00031 /* 00032 * Function: setEntrySequence 00033 * -------------------- 00034 * Reads in user's entry sequence attempt 00035 */ 00036 void setEntrySequenceAttempt() { 00037 entryNum1 = float(pot1) * 6; 00038 entryNum2 = float(pot2) * 6; 00039 entryNum3 = float(pot3) * 6; 00040 entryNum4 = float(pot4) * 6; 00041 } 00042 00043 /* 00044 * Function: CorrectEntrySequenceAttempt 00045 * -------------------- 00046 * Checks whether the user's entry sequence attempt is correct 00047 * 00048 * returns: true if the entry sequence attempt from the user matches 00049 * the set entry sequence otherwise false 00050 * 00051 */ 00052 bool CorrectEntrySequenceAttempt() { 00053 if (bluetoothCode) { 00054 return true; 00055 00056 } 00057 p1 = float(pot1) * 6; 00058 p2 = float(pot2) * 6; 00059 p3 = float(pot3) * 6; 00060 p4 = float(pot4) * 6; 00061 00062 return (checkPot(p1,entryNum1) && checkPot(p2,entryNum2) && checkPot(p3,entryNum3) && checkPot(p3,entryNum3)); 00063 } 00064 00065 void printPotValues() { 00066 pc.printf("pot1 is %f", pot1); 00067 00068 } 00069 00070 bool checkPot(int p1, int p2) { 00071 return (p2 - p1) < 2 && (p1 - p2) > -2; 00072 00073 } 00074 00075 bool checkBluetooth() { 00076 if (bluetoothSetup) { 00077 bluetoothSetup = false; 00078 return true; 00079 } 00080 return false; 00081 } 00082 00083 00084 00085 /* 00086 * Function: parse_bluetooth 00087 * -------------------- 00088 * bluetooth stuff EDIT LATER 00089 * 00090 * returns: 00091 * 00092 */ 00093 void parse_bluetooth() 00094 { 00095 switch (blue.getc()) { 00096 case 'o': 00097 bluetoothCode = true; 00098 break; 00099 case 'l': 00100 bluetoothCode = false; 00101 break; 00102 case 's': 00103 bluetoothSetup = true; 00104 break; 00105 } 00106 00107 } 00108 00109 void start_bluetooth() { 00110 blue.attach(&parse_bluetooth, Serial::RxIrq); 00111 } 00112 00113 /* 00114 * Function: sdCard 00115 * -------------------- 00116 * sdCard stuff EDIT LATER 00117 * 00118 * returns: 00119 * 00120 */ 00121 void sdCard() { 00122 00123 } 00124 00125
Generated on Wed Jul 13 2022 11:24:16 by 1.7.2