Trung Nguyen
/
FINAL_PROJECT_4180
asdasdasd
Fork of FINAL_PROJECT_4180 by
main.cpp
- Committer:
- nyengele
- Date:
- 2016-04-25
- Revision:
- 11:1d7021c0739d
- Parent:
- 10:c3556e27e576
- Child:
- 12:5cb9ffad1ad7
File content as of revision 11:1d7021c0739d:
#include "mbed.h" #include "lib.h" Serial mag_card(p13, p14); Serial android(USBTX, USBRX); FPScanner fp(p9, p10); uLCD_4DGL lcd(p28, p27, p30); PwmOut speaker(p21); // Flash Memory SPI spi(p5, p6, p7); // MOSI, MISO, CLK DigitalOut cs(p20); // Chip Select // hash table const int MAX_ENTRIES = 100; HASH_RECORD records[MAX_ENTRIES]; int record_index = 0; enum STATE {STANDBY, ENROLL, AUTH, FP_ENROLL, FP_AUTH, MC_ENROLL, MC_AUTH, FACE_ENROLL, FACE_AUTH, SPEECH_ENROLL, ENROLL_SUCCESS, AUTH_SUCCESS, ENROLL_FAIL, AUTH_FAIL, UNLOCK }; char user_id[4]; char mag_card_data[250]; int mc_bytes = 0; int temp; int temp1; int main() { STATE current_state = STANDBY; while (true) { switch (current_state) { case STANDBY: greeting(&lcd); int input = read_keypad(); while (input != 10 && input != 11) { wait(0.03); input = read_keypad(); } if (input == 10) current_state = ENROLL; else current_state = AUTH; break; case ENROLL: if (get_user_id(user_id)) current_state = FP_ENROLL; else current_state = ENROLL_FAIL; break; case FP_ENROLL: if (fp_enroll(&fp)) { current_state = MC_ENROLL; } else { current_state = ENROLL_FAIL; } break; case MC_ENROLL: read_mag_card(&mag_card, mag_card_data, &mc_bytes); temp = hashcode(mag_card_data, mc_bytes); temp1 = id_to_int(user_id, 4); add_to_table(records, record_index++, temp1, temp); current_state = FACE_ENROLL; break; case FACE_ENROLL: if (face_enroll(user_id, &android)) { current_state = SPEECH_ENROLL; } else current_state = ENROLL_FAIL; break; case SPEECH_ENROLL: if (speech_enroll(user_id, &android)) { current_state = ENROLL_SUCCESS; } else current_state = ENROLL_FAIL; break; case ENROLL_SUCCESS: success_display(&lcd, "ENROLLMENT SUCCESSFUL."); current_state = STANDBY; break; } } }