
4180 Final Project
Dependencies: 4DGL-uLCD-SE mbed Servo
main.cpp
- Committer:
- ecarrick
- Date:
- 2016-04-12
- Revision:
- 1:dd048edb2716
- Parent:
- 0:5d35ff3dc9a5
- Child:
- 3:babc3bec33ca
File content as of revision 1:dd048edb2716:
#include "mbed.h" #include <string> #include <vector> #include <iostream> #include <sstream> #include <iterator> #include <stdio.h> #include <ctype.h> #include "uLCD_4DGL.h" LocalFileSystem local("local"); DigitalOut myled(LED1); Serial pc(USBTX,USBRX); uLCD_4DGL lcd(p28,p27,p30); // serial tx, serial rx, reset pin; vector<char> im; vector<char> vec; vector<char> name; vector<char> final; int i = 0; void checkResult(vector<char> vec, vector<char> name) { // This function will check the keypad values and check if the passcode exists or not vector<char> ans; //This vector should be the values coming from keypad ans.push_back('1'); ans.push_back('2'); ans.push_back('3'); ans.push_back('4'); ans.push_back('5'); ans.push_back('6'); if (vec.size()==6) { i++; //use "i" to find which person logged in. if (ans == vec) { // pc.printf("Found"); lcd.printf("\nFound\n"); final = name; final.insert(name.end(),vec.begin(),vec.end()); } else { // pc.printf("not found"); lcd.printf("\nnot found\n"); final.clear(); } } } void checkKeyboard(char c) { if (c ==' ') { checkResult(vec,name); vec.clear(); name.clear(); final.clear(); // pc.printf("clear"); lcd.printf("clear"); } else { if (isdigit(c)) { // write numbers (char) to vector vec vec.push_back(c); // pc.printf("\nnumber %c\n",c); } else if (isalpha(c)) { // write letters (char) to vector name name.push_back(c); // pc.printf("\nname %c\n",c); } } } int main() { load_from_file(); //interupt driven read from serial port // calls save_to_file(); while(1) { char c = pc.getc(); if (c!='#') { im.push_back(c); //writing all the characters into vector checkKeyboard(c); } else { for (int cnt = 0; cnt<im.size(); cnt++) { pc.printf("%c",im[cnt]); lcd.printf("%c",im[cnt]); } } } }