forked from Wien60Pioneers/beerbox
		
	added debug enable for serial output
This commit is contained in:
		
							
								
								
									
										78
									
								
								beerbox.ino
									
									
									
									
									
								
							
							
						
						
									
										78
									
								
								beerbox.ino
									
									
									
									
									
								
							| @@ -12,7 +12,7 @@ Adafruit_Fingerprint finger = Adafruit_Fingerprint(&Serial2); | ||||
| LiquidCrystal_I2C lcd(0x38, 8, 2); // 0x38 for PCF***A on address 000 | ||||
|  | ||||
|  | ||||
|  | ||||
| #define debug 0 //General debug out on/off | ||||
|  | ||||
| File myFile; | ||||
| const int chipSelect = 53; | ||||
| @@ -52,9 +52,9 @@ void setup() { | ||||
|   //Fingerprint init | ||||
|   finger.begin(57600); | ||||
|   if (finger.verifyPassword()) { | ||||
|     Serial.println("Found fingerprint sensor!"); | ||||
|     if(debug)Serial.println("Found fingerprint sensor!"); | ||||
|   } else { | ||||
|     Serial.println("Did not find fingerprint sensor :("); | ||||
|     if(debug)Serial.println("Did not find fingerprint sensor :("); | ||||
|     while (1); | ||||
|   } | ||||
|  | ||||
| @@ -65,7 +65,7 @@ void setup() { | ||||
|   Serial3.begin(115200); | ||||
|  | ||||
|  | ||||
|   Serial.print("Initializing SD card..."); | ||||
|   if(debug)Serial.print("Initializing SD card..."); | ||||
|   // On the Ethernet Shield, CS is pin 4. It's set as an output by default. | ||||
|   // Note that even if it's not used as the CS pin, the hardware SS pin | ||||
|   // (10 on most Arduino boards, 53 on the Mega) must be left as an output | ||||
| @@ -73,10 +73,10 @@ void setup() { | ||||
|   pinMode(SS, OUTPUT); | ||||
|  | ||||
|   if (!SD.begin(chipSelect)) { | ||||
|     Serial.println("initialization failed!"); | ||||
|     if(debug)Serial.println("initialization failed!"); | ||||
|     return; | ||||
|   } | ||||
|   Serial.println("initialization done."); | ||||
|   if(debug)Serial.println("initialization done."); | ||||
|  | ||||
|   //check_for_file("p001", "per"); | ||||
|  | ||||
| @@ -120,10 +120,10 @@ void loop() { | ||||
|         personName =  String(personName + incomingByte); | ||||
|         incomingByte = Serial3.read(); | ||||
|       } | ||||
|       Serial.println(personName); | ||||
|       if(debug)Serial.println(personName); | ||||
|       lcd.clear(); | ||||
|       lcd.print(personName); | ||||
|       Serial.println(maxID); | ||||
|       if(debug)Serial.println(maxID); | ||||
|       //lcd.setCursor(0,1); | ||||
|       //lcd.print("Fin pls"); | ||||
|       int fingerReturn = -1; | ||||
| @@ -140,7 +140,7 @@ void loop() { | ||||
|       while (zugang == "") { | ||||
|         getRFIDEnroll(); | ||||
|       } | ||||
|       Serial.println(zugang); | ||||
|       if(debug)Serial.println(zugang); | ||||
|       maxID++; | ||||
|       Person* newPerson = new Person; | ||||
|       personName.toCharArray(newPerson->name, personName.length()+1); | ||||
| @@ -182,10 +182,10 @@ void check_for_file(String filename, String extension) { | ||||
|   str.toCharArray(buf, str.length() + 1); | ||||
|  | ||||
|   if (SD.exists("p001.per")) { | ||||
|     Serial.println(str + " exists."); | ||||
|     if(debug)Serial.println(str + " exists."); | ||||
|   } | ||||
|   else { | ||||
|     Serial.println(str + " doesn't exist."); | ||||
|     if(debug)Serial.println(str + " doesn't exist."); | ||||
|   } | ||||
| } | ||||
|  | ||||
| @@ -207,8 +207,8 @@ Beerbox* read_beerbox(Beerbox *box) { | ||||
|   read = SD.open("bb.con", FILE_READ); | ||||
|   if (read == false) { | ||||
|  | ||||
|     Serial.print("error while reading!\n"); | ||||
|     Serial.print("-ABORT!\n\n"); | ||||
|     if(debug)Serial.print("error while reading!\n"); | ||||
|     if(debug)Serial.print("-ABORT!\n\n"); | ||||
|     while (1); | ||||
|  | ||||
|   } | ||||
| @@ -234,13 +234,13 @@ Beerbox* read_beerbox(Beerbox *box) { | ||||
|   for (i = 0; (i < NUM_OF_DRINKS) && (box->drinks[i].price != -1); i++) { | ||||
|  | ||||
|     sprintf(toprint, "drink number %i: %s\nprice: %d\n", i , box->drinks[i].name, box->drinks[i].price); | ||||
|     Serial.println(toprint); | ||||
|     if(debug)Serial.println(toprint); | ||||
|   } | ||||
|  | ||||
|   if (i < NUM_OF_DRINKS) { | ||||
|     sprintf(toprint, "Slots %d - %d are not in use!\n", i + 1, NUM_OF_DRINKS); | ||||
|     drinksMax = i; | ||||
|     Serial.println(toprint); | ||||
|     if(debug)Serial.println(toprint); | ||||
|   } | ||||
|  | ||||
|   read.close(); | ||||
| @@ -257,13 +257,13 @@ Person read_person(Beerbox *box, char *filename) { | ||||
|  | ||||
|  | ||||
|   //giving the full filename here, since it makes stuff easier | ||||
|   //Serial.print("The filename is: "); | ||||
|   //Serial.println(filename); | ||||
|   //if(debug)Serial.print("The filename is: "); | ||||
|   //if(debug)Serial.println(filename); | ||||
|   read = SD.open(filename, FILE_READ); | ||||
|   if (read == false) { | ||||
|  | ||||
|     Serial.print("error while reading!\n"); | ||||
|     Serial.print("ABORT!\n\n"); | ||||
|     if(debug)Serial.print("error while reading!\n"); | ||||
|     if(debug)Serial.print("ABORT!\n\n"); | ||||
|     while (-1); | ||||
|  | ||||
|   } | ||||
| @@ -283,24 +283,24 @@ Person read_person(Beerbox *box, char *filename) { | ||||
|   memset(aperson.rfid_uuid, 0, 13); | ||||
|   read_line_from_file(read, tmp, sizeof(tmp)); | ||||
|   sscanf(tmp, "rfid_uuid: %12s", &aperson.rfid_uuid); | ||||
|   Serial.println(aperson.rfid_uuid); | ||||
|   if(debug)Serial.println(aperson.rfid_uuid); | ||||
|   read_line_from_file(read, tmp, sizeof(tmp)); | ||||
|   sscanf(tmp, "finger_uuid: %d", &aperson.finger_uuid); | ||||
|   //Serial.println(aperson.finger_uuid); | ||||
|   //if(debug)Serial.println(aperson.finger_uuid); | ||||
|   //credits_left | ||||
|   read_line_from_file(read, tmp, sizeof(tmp)); | ||||
|   sscanf(tmp, "credits_left: %d", &aperson.credits_left); | ||||
|   //Serial.println(aperson.credits_left); | ||||
|   //if(debug)Serial.println(aperson.credits_left); | ||||
|  | ||||
|   while (read_line_from_file(read, tmp, sizeof(tmp)), strlen(tmp) > 0) { | ||||
|     int tmpCount = 0; | ||||
|     int tmpDrink = 0; | ||||
|     sscanf(tmp, "drink_Count_%d: %d", &tmpDrink, &tmpCount); | ||||
|     if (strlen(tmp)) { | ||||
|       //Serial.print("drink: "); | ||||
|       //Serial.print(tmpDrink); | ||||
|       //Serial.print(" count: "); | ||||
|       //Serial.println(tmpCount); | ||||
|       //if(debug)Serial.print("drink: "); | ||||
|       //if(debug)Serial.print(tmpDrink); | ||||
|       //if(debug)Serial.print(" count: "); | ||||
|       //if(debug)Serial.println(tmpCount); | ||||
|       aperson.drinks_taken[tmpDrink] = tmpCount; | ||||
|     } | ||||
|   } | ||||
| @@ -323,9 +323,9 @@ void print_person(Beerbox *box, Person *aperson) { | ||||
|   Serial.write(toprint); | ||||
|   sprintf(toprint, "finger_uuid: %u\n", aperson->finger_uuid); | ||||
|   if (aperson->finger_uuid > maxID) maxID = aperson->finger_uuid; | ||||
|   Serial.print(toprint); | ||||
|   if(debug)Serial.print(toprint); | ||||
|   sprintf(toprint, "credits_left: %u\n", aperson->credits_left); | ||||
|   Serial.print(toprint); | ||||
|   if(debug)Serial.print(toprint); | ||||
|  | ||||
|   for (i = 0; i < drinksMax; i++) { | ||||
|  | ||||
| @@ -350,12 +350,12 @@ int update_pers_file() { | ||||
|   char tmp[25]; | ||||
|  | ||||
|   int i = 0; | ||||
|   //Serial.println(thisPerson.file_name); | ||||
|   //if(debug)Serial.println(thisPerson.file_name); | ||||
|   write = SD.open(thisPerson.file_name, FILE_WRITE); | ||||
|  | ||||
|   if (write == NULL) { | ||||
|     Serial.print("error while reading!\n"); | ||||
|     Serial.print("ABORT!\n\n"); | ||||
|     if(debug)Serial.print("error while reading!\n"); | ||||
|     if(debug)Serial.print("ABORT!\n\n"); | ||||
|     while (-1); | ||||
|   } | ||||
|   write.seek(0); | ||||
| @@ -375,7 +375,7 @@ int update_pers_file() { | ||||
|     if (thisPerson.drinks_taken[i] != -1) { | ||||
|       sprintf(tmp, "\ndrink_Count_%d: %d\n", i, thisPerson.drinks_taken[i]); | ||||
|       write.write(tmp, strlen(tmp)); | ||||
|       Serial.println(tmp); | ||||
|       if(debug)Serial.println(tmp); | ||||
|     } | ||||
|  | ||||
|   } | ||||
| @@ -397,7 +397,7 @@ char* read_from_file_until(File stream, char *str, int max_len, char until) { | ||||
|  | ||||
|   for (i = 0; (tmp_int != until) && (i < (max_len - 1)) && (tmp_int != -1); i++) { | ||||
|     tmp_int = stream.read(); | ||||
|     //Serial.print("%c", tmp_int); | ||||
|     //if(debug)Serial.print("%c", tmp_int); | ||||
|     str[i] = tmp_int; | ||||
|   } | ||||
|  | ||||
| @@ -405,7 +405,7 @@ char* read_from_file_until(File stream, char *str, int max_len, char until) { | ||||
|   if (tmp_int == -1) { | ||||
|  | ||||
|     //May occur more often as the function tries to read a certain number of drinks. | ||||
|     //Serial.print("END OF FILE REACHED!\nABORT!!\n\n"); | ||||
|     //if(debug)Serial.print("END OF FILE REACHED!\nABORT!!\n\n"); | ||||
|  | ||||
|     str[0] = 0; | ||||
|     return str; | ||||
| @@ -452,8 +452,8 @@ Person* readAllPersons () { | ||||
|     entry.close(); | ||||
|   } | ||||
|   //now store them | ||||
|   //Serial.print("count:"); | ||||
|   //Serial.print(personCount); | ||||
|   //if(debug)Serial.print("count:"); | ||||
|   //if(debug)Serial.print(personCount); | ||||
|   Person* readPersons = new Person[personCount]; | ||||
|   int counter = 0; | ||||
|   dir.rewindDirectory(); | ||||
| @@ -467,8 +467,8 @@ Person* readAllPersons () { | ||||
|       if (strstr(strlwr(entry.name() + (len - 4)), ".per")) | ||||
|       { | ||||
|         //Yeah it is a person! | ||||
|         //Serial.print("Person: "); | ||||
|         //Serial.println(entry.name()); | ||||
|         //if(debug)Serial.print("Person: "); | ||||
|         //if(debug)Serial.println(entry.name()); | ||||
|         Person thisPerson = read_person(box, entry.name()); | ||||
|         readPersons[counter] = thisPerson; | ||||
|         counter++; | ||||
| @@ -477,7 +477,7 @@ Person* readAllPersons () { | ||||
|     entry.close(); | ||||
|   } | ||||
|   dir.close(); | ||||
|   Serial.println("Read all!"); | ||||
|   if(debug)Serial.println("Read all!"); | ||||
|   return readPersons; | ||||
| } | ||||
|  | ||||
|   | ||||
							
								
								
									
										100
									
								
								enroll.ino
									
									
									
									
									
								
							
							
						
						
									
										100
									
								
								enroll.ino
									
									
									
									
									
								
							| @@ -7,27 +7,27 @@ uint8_t getFingerprintEnroll(int id) { | ||||
|     p = finger.getImage(); | ||||
|     switch (p) { | ||||
|       case FINGERPRINT_OK: | ||||
|         Serial.println("Image taken"); | ||||
|         if(debug)Serial.println("Image taken"); | ||||
|         lcd.clear(); | ||||
|         lcd.print("Image 1"); | ||||
|         lcd.setCursor(0, 1); | ||||
|         lcd.print("Done"); | ||||
|         break; | ||||
|       case FINGERPRINT_NOFINGER: | ||||
|         Serial.println("."); | ||||
|         if(debug)Serial.println("."); | ||||
|         break; | ||||
|       case FINGERPRINT_PACKETRECIEVEERR: | ||||
|         Serial.println("Communication error"); | ||||
|         if(debug)Serial.println("Communication error"); | ||||
|         lcd.clear(); | ||||
|         lcd.print("Error"); | ||||
|         break; | ||||
|       case FINGERPRINT_IMAGEFAIL: | ||||
|         Serial.println("Imaging error"); | ||||
|         if(debug)Serial.println("Imaging error"); | ||||
|         lcd.clear(); | ||||
|         lcd.print("Error"); | ||||
|         break; | ||||
|       default: | ||||
|         Serial.println("Unknown error"); | ||||
|         if(debug)Serial.println("Unknown error"); | ||||
|         lcd.clear(); | ||||
|         lcd.print("Error"); | ||||
|         break; | ||||
| @@ -39,26 +39,26 @@ uint8_t getFingerprintEnroll(int id) { | ||||
|   p = finger.image2Tz(1); | ||||
|   switch (p) { | ||||
|     case FINGERPRINT_OK: | ||||
|       Serial.println("Image converted"); | ||||
|       if(debug)Serial.println("Image converted"); | ||||
|       break; | ||||
|     case FINGERPRINT_IMAGEMESS: | ||||
|       Serial.println("Image too messy"); | ||||
|       if(debug)Serial.println("Image too messy"); | ||||
|       return p; | ||||
|     case FINGERPRINT_PACKETRECIEVEERR: | ||||
|       Serial.println("Communication error"); | ||||
|       if(debug)Serial.println("Communication error"); | ||||
|       return p; | ||||
|     case FINGERPRINT_FEATUREFAIL: | ||||
|       Serial.println("Could not find fingerprint features"); | ||||
|       if(debug)Serial.println("Could not find fingerprint features"); | ||||
|       return p; | ||||
|     case FINGERPRINT_INVALIDIMAGE: | ||||
|       Serial.println("Could not find fingerprint features"); | ||||
|       if(debug)Serial.println("Could not find fingerprint features"); | ||||
|       return p; | ||||
|     default: | ||||
|       Serial.println("Unknown error"); | ||||
|       if(debug)Serial.println("Unknown error"); | ||||
|       return p; | ||||
|   } | ||||
|  | ||||
|   //Serial.println("Remove finger"); | ||||
|   //if(debug)Serial.println("Remove finger"); | ||||
|   lcd.clear(); | ||||
|   lcd.print("Remove"); | ||||
|   lcd.setCursor(0, 1); | ||||
| @@ -74,28 +74,28 @@ uint8_t getFingerprintEnroll(int id) { | ||||
|   lcd.print("Second"); | ||||
|   lcd.setCursor(0, 1); | ||||
|   lcd.print("time pls"); | ||||
|   Serial.println("Place same finger again"); | ||||
|   if(debug)Serial.println("Place same finger again"); | ||||
|   while (p != FINGERPRINT_OK) { | ||||
|     p = finger.getImage(); | ||||
|     switch (p) { | ||||
|       case FINGERPRINT_OK: | ||||
|         Serial.println("Image taken"); | ||||
|         if(debug)Serial.println("Image taken"); | ||||
|         break; | ||||
|       case FINGERPRINT_NOFINGER: | ||||
|         Serial.print("."); | ||||
|         if(debug)Serial.print("."); | ||||
|         break; | ||||
|       case FINGERPRINT_PACKETRECIEVEERR: | ||||
|         Serial.println("Communication error"); | ||||
|         if(debug)Serial.println("Communication error"); | ||||
|         lcd.clear(); | ||||
|         lcd.print("Error"); | ||||
|         break; | ||||
|       case FINGERPRINT_IMAGEFAIL: | ||||
|         Serial.println("Imaging error"); | ||||
|         if(debug)Serial.println("Imaging error"); | ||||
|         lcd.clear(); | ||||
|         lcd.print("Error"); | ||||
|         break; | ||||
|       default: | ||||
|         Serial.println("Unknown error"); | ||||
|         if(debug)Serial.println("Unknown error"); | ||||
|         lcd.clear(); | ||||
|         lcd.print("Error"); | ||||
|         break; | ||||
| @@ -107,28 +107,28 @@ uint8_t getFingerprintEnroll(int id) { | ||||
|   p = finger.image2Tz(2); | ||||
|   switch (p) { | ||||
|     case FINGERPRINT_OK: | ||||
|       Serial.println("Image converted"); | ||||
|       if(debug)Serial.println("Image converted"); | ||||
|       break; | ||||
|     case FINGERPRINT_IMAGEMESS: | ||||
|       Serial.println("Image too messy"); | ||||
|       if(debug)Serial.println("Image too messy"); | ||||
|       return p; | ||||
|     case FINGERPRINT_PACKETRECIEVEERR: | ||||
|       Serial.println("Communication error"); | ||||
|       if(debug)Serial.println("Communication error"); | ||||
|       lcd.clear(); | ||||
|       lcd.print("Error"); | ||||
|       return p; | ||||
|     case FINGERPRINT_FEATUREFAIL: | ||||
|       Serial.println("Could not find fingerprint features"); | ||||
|       if(debug)Serial.println("Could not find fingerprint features"); | ||||
|       lcd.clear(); | ||||
|       lcd.print("Error"); | ||||
|       return p; | ||||
|     case FINGERPRINT_INVALIDIMAGE: | ||||
|       Serial.println("Could not find fingerprint features"); | ||||
|       if(debug)Serial.println("Could not find fingerprint features"); | ||||
|       lcd.clear(); | ||||
|       lcd.print("Error"); | ||||
|       return p; | ||||
|     default: | ||||
|       Serial.println("Unknown error"); | ||||
|       if(debug)Serial.println("Unknown error"); | ||||
|       lcd.clear(); | ||||
|       lcd.print("Error"); | ||||
|       return p; | ||||
| @@ -138,14 +138,14 @@ uint8_t getFingerprintEnroll(int id) { | ||||
|   // OK converted! | ||||
|   p = finger.createModel(); | ||||
|   if (p == FINGERPRINT_OK) { | ||||
|     Serial.println("Prints matched!"); | ||||
|     if(debug)Serial.println("Prints matched!"); | ||||
|     lcd.clear(); | ||||
|     lcd.print("Match!"); | ||||
|   } else if (p == FINGERPRINT_PACKETRECIEVEERR) { | ||||
|     Serial.println("Communication error"); | ||||
|     if(debug)Serial.println("Communication error"); | ||||
|     return p; | ||||
|   } else if (p == FINGERPRINT_ENROLLMISMATCH) { | ||||
|     Serial.println("Fingerprints did not match"); | ||||
|     if(debug)Serial.println("Fingerprints did not match"); | ||||
|     lcd.clear(); | ||||
|     lcd.print("Error"); | ||||
|     lcd.setCursor(0, 1); | ||||
| @@ -153,25 +153,25 @@ uint8_t getFingerprintEnroll(int id) { | ||||
|     delay(1000); | ||||
|     return p; | ||||
|   } else { | ||||
|     Serial.println("Unknown error"); | ||||
|     if(debug)Serial.println("Unknown error"); | ||||
|     return p; | ||||
|   } | ||||
|  | ||||
|   Serial.print("ID "); Serial.println(id); | ||||
|   if(debug)Serial.print("ID "); if(debug)Serial.println(id); | ||||
|   p = finger.storeModel(id); | ||||
|   if (p == FINGERPRINT_OK) { | ||||
|     Serial.println("Stored!"); | ||||
|     if(debug)Serial.println("Stored!"); | ||||
|   } else if (p == FINGERPRINT_PACKETRECIEVEERR) { | ||||
|     Serial.println("Communication error"); | ||||
|     if(debug)Serial.println("Communication error"); | ||||
|     return p; | ||||
|   } else if (p == FINGERPRINT_BADLOCATION) { | ||||
|     Serial.println("Could not store in that location"); | ||||
|     if(debug)Serial.println("Could not store in that location"); | ||||
|     return p; | ||||
|   } else if (p == FINGERPRINT_FLASHERR) { | ||||
|     Serial.println("Error writing to flash"); | ||||
|     if(debug)Serial.println("Error writing to flash"); | ||||
|     return p; | ||||
|   } else { | ||||
|     Serial.println("Unknown error"); | ||||
|     if(debug)Serial.println("Unknown error"); | ||||
|     return p; | ||||
|   } | ||||
|   return 0; | ||||
| @@ -184,31 +184,31 @@ void getRFIDEnroll() { | ||||
|   { | ||||
|     if (Serial1.read() == startZeichen) // und das Startzeichen erkannt wurde ... | ||||
|     { | ||||
|       //Serial.print("Start-Byte erkannt ... "); | ||||
|       //if(debug)Serial.print("Start-Byte erkannt ... "); | ||||
|       bytesGelesen = 0; // starten Lesen, also Zaehler auf 0 | ||||
|       while (bytesGelesen < kennungLaenge) // lese 12-stelligen Code | ||||
|       { | ||||
|         char zeichen = Serial1.read(); // lesen Zeichen | ||||
|         //Serial.print(zeichen); // zur Kontrolle | ||||
|         //Serial.print(" "); | ||||
|         //if(debug)Serial.print(zeichen); // zur Kontrolle | ||||
|         //if(debug)Serial.print(" "); | ||||
|         if (zeichen == endeZeichen) // suche nach Ende-Befehl | ||||
|         { | ||||
|           //Serial.println("CR erkannt ..."); | ||||
|           //if(debug)Serial.println("CR erkannt ..."); | ||||
|           break; | ||||
|         } | ||||
|         code[bytesGelesen] = zeichen; // speicher Zeichen im Puffer | ||||
|         bytesGelesen = bytesGelesen + 1; // ein Zeichen weiter | ||||
|       } | ||||
|       code[bytesGelesen] = 0; // beende Zeichenkette | ||||
|       Serial.print("RFID-Code lautet: "); | ||||
|       Serial.println(code); | ||||
|       if(debug)Serial.print("RFID-Code lautet: "); | ||||
|       if(debug)Serial.println(code); | ||||
|       zugang = code; //char[] to string | ||||
|  | ||||
|       //already existing | ||||
|       if (getRFIDIndex(code) != -1) { | ||||
|         Serial.print("Error: "); | ||||
|         Serial.print("This is "); | ||||
|         Serial.println(persons[getRFIDIndex(code)].name); | ||||
|         if(debug)Serial.print("Error: "); | ||||
|         if(debug)Serial.print("This is "); | ||||
|         if(debug)Serial.println(persons[getRFIDIndex(code)].name); | ||||
|         lcd.setCursor(0, 1); | ||||
|         lcd.print("Error!  "); | ||||
|  | ||||
| @@ -232,25 +232,25 @@ void getRFIDEnroll() { | ||||
|  | ||||
|  | ||||
| int write_pers_file(Person* thisPerson) { | ||||
|   Serial.println("Writing Person:"); | ||||
|   if(debug)Serial.println("Writing Person:"); | ||||
|   File write; | ||||
|   char tmp[25]; | ||||
|  | ||||
|   int i = 0; | ||||
|   //Serial.println(thisPerson.file_name); | ||||
|   //if(debug)Serial.println(thisPerson.file_name); | ||||
|   write = SD.open(thisPerson->file_name, FILE_WRITE); | ||||
|  | ||||
| // write.seek(0); | ||||
|  | ||||
|  | ||||
|   sprintf(tmp, "%s\n", thisPerson->name); | ||||
|   Serial.print(tmp); | ||||
|   if(debug)Serial.print(tmp); | ||||
|   write.write(tmp, strlen(tmp)); | ||||
|   sprintf(tmp, "rfid_uuid: %s\n", thisPerson->rfid_uuid); | ||||
|   Serial.print(tmp); | ||||
|   if(debug)Serial.print(tmp); | ||||
|   write.write(tmp, strlen(tmp)); | ||||
|   sprintf(tmp, "finger_uuid: %u\n", thisPerson->finger_uuid); | ||||
|   Serial.print(tmp); | ||||
|   if(debug)Serial.print(tmp); | ||||
|   write.write(tmp, strlen(tmp)); | ||||
|   sprintf(tmp, "credits_left: %u\n", thisPerson->credits_left); | ||||
|   write.write(tmp, strlen(tmp)); | ||||
| @@ -259,7 +259,7 @@ int write_pers_file(Person* thisPerson) { | ||||
|     if (thisPerson->drinks_taken[i] != -1) { | ||||
|       sprintf(tmp, "\ndrink_Count_%d: %d\n", i, thisPerson->drinks_taken[i]); | ||||
|       write.write(tmp, strlen(tmp)); | ||||
|       Serial.println(tmp); | ||||
|       if(debug)Serial.println(tmp); | ||||
|     } | ||||
|   } | ||||
|  | ||||
| @@ -270,7 +270,7 @@ int write_pers_file(Person* thisPerson) { | ||||
|  delete [] persons;  // When done, free memory pointed to | ||||
|  persons = NULL; | ||||
|   persons = readAllPersons(); | ||||
|   Serial.println(sizeof(persons)); | ||||
|   if(debug)Serial.println(sizeof(persons)); | ||||
|   return 0; | ||||
|  | ||||
| } | ||||
|   | ||||
							
								
								
									
										28
									
								
								inputs.ino
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								inputs.ino
									
									
									
									
									
								
							| @@ -13,7 +13,7 @@ void checkButton() { | ||||
|       if (box->waiting == 0) { | ||||
|         if (currentDrink == drinksMax - 1) currentDrink = -1; | ||||
|         currentDrink++; | ||||
|         Serial.println(box->drinks[currentDrink].name); | ||||
|         if(debug)Serial.println(box->drinks[currentDrink].name); | ||||
|         lcd.clear(); | ||||
|         lcd.print("Drink:"); | ||||
|         lcd.setCursor(0, 1); | ||||
| @@ -58,14 +58,14 @@ bool checkFinger() { | ||||
|   if (p != FINGERPRINT_OK)  return -1; | ||||
|  | ||||
|   // found a match! | ||||
|   // Serial.print("Found ID #"); Serial.print(finger.fingerID); | ||||
|   // Serial.print(" with confidence of "); Serial.println(finger.confidence); | ||||
|   // if(debug)Serial.print("Found ID #"); if(debug)Serial.print(finger.fingerID); | ||||
|   // if(debug)Serial.print(" with confidence of "); if(debug)Serial.println(finger.confidence); | ||||
|  | ||||
|   //ok now check which person that is! | ||||
|    | ||||
|   if (getFingerIndex(finger.fingerID) != -1) { | ||||
|     Serial.print("This is "); | ||||
|     Serial.println(persons[getFingerIndex(finger.fingerID)].name); | ||||
|     if(debug)Serial.print("This is "); | ||||
|     if(debug)Serial.println(persons[getFingerIndex(finger.fingerID)].name); | ||||
|     countUp(getFingerIndex(finger.fingerID), 0);//for finger context | ||||
|   } | ||||
| } | ||||
| @@ -76,33 +76,33 @@ void checkRFID() { | ||||
|   { | ||||
|     if (Serial1.read() == startZeichen) // und das Startzeichen erkannt wurde ... | ||||
|     { | ||||
|       //Serial.print("Start-Byte erkannt ... "); | ||||
|       //if(debug)Serial.print("Start-Byte erkannt ... "); | ||||
|       bytesGelesen = 0; // starten Lesen, also Zaehler auf 0 | ||||
|       while (bytesGelesen < kennungLaenge) // lese 12-stelligen Code | ||||
|       { | ||||
|         char zeichen = Serial1.read(); // lesen Zeichen | ||||
|         //Serial.print(zeichen); // zur Kontrolle | ||||
|         //Serial.print(" "); | ||||
|         //if(debug)Serial.print(zeichen); // zur Kontrolle | ||||
|         //if(debug)Serial.print(" "); | ||||
|         if (zeichen == endeZeichen) // suche nach Ende-Befehl | ||||
|         { | ||||
|           //Serial.println("CR erkannt ..."); | ||||
|           //if(debug)Serial.println("CR erkannt ..."); | ||||
|           break; | ||||
|         } | ||||
|         code[bytesGelesen] = zeichen; // speicher Zeichen im Puffer | ||||
|         bytesGelesen = bytesGelesen + 1; // ein Zeichen weiter | ||||
|       } | ||||
|       code[bytesGelesen] = 0; // beende Zeichenkette | ||||
|       Serial.print("RFID-Code lautet: "); | ||||
|       Serial.println(code); | ||||
|       if(debug)Serial.print("RFID-Code lautet: "); | ||||
|       if(debug)Serial.println(code); | ||||
|       digitalWrite(led,HIGH); | ||||
|       ledTime = millis(); | ||||
|  | ||||
|       //Serial.print("This is "); | ||||
|       //Serial.println(persons[getRFIDIndex(persons, code)].name); | ||||
|       //if(debug)Serial.print("This is "); | ||||
|       //if(debug)Serial.println(persons[getRFIDIndex(persons, code)].name); | ||||
|       if(getRFIDIndex( code)!=-1) | ||||
|       countUp(getRFIDIndex( code), 1); // 1 for rfid context | ||||
|       else | ||||
|       Serial.println("Error: Nonexisting Card"); | ||||
|       if(debug)Serial.println("Error: Nonexisting Card"); | ||||
|  | ||||
|       zugang = ""; | ||||
|       delay(1000); // debounce time | ||||
|   | ||||
		Reference in New Issue
	
	Block a user