remove funktion

This commit is contained in:
interfisch 2016-11-17 22:48:57 +01:00
parent aca4178b69
commit 99cc4163da
1 changed files with 65 additions and 7 deletions

View File

@ -36,7 +36,9 @@ boolean outputOn = false;
int displayLogIndex = -1; int displayLogIndex = -1;
int displayLogIndexLast = -1; int displayLogIndexLast = -1;
int displayCardsIndex = -1;
int displayCardsIndexLast = -1;
boolean cardsshow=false;
void setup() { void setup() {
pinMode(10, OUTPUT); // LCD backlight pinMode(10, OUTPUT); // LCD backlight
@ -174,9 +176,18 @@ void handleCards(long currentMillis) {
if(unlocked) { if(unlocked) {
if(save_client_uid(&(mfrc522.uid))) { if(save_client_uid(&(mfrc522.uid))) {
lcd.clear(); lcd.clear();
lcd.print("Karte wurde"); lcd.print("Hinzugefuegt");
lcd.setCursor(0, 1); lcd.setCursor(0, 1);
lcd.print("hinzugefuegt"); lcd.print("");
lcd_print_uid(&(mfrc522.uid));
delay(500);
while(!mfrc522.PICC_IsNewCardPresent() && !mfrc522.PICC_ReadCardSerial()){
delay(50);
}
lcd.setCursor(0, 0);
lcd.print(" ");
delay(200);
} else { } else {
lcd.clear(); lcd.clear();
@ -203,11 +214,11 @@ void loop() {
handleCards(currentMillis); handleCards(currentMillis);
if(readButtons() == 1) { if(readButtons() == 1 && !cardsshow) { //select button shows log, if not showing cards atm
displayLogIndex++; displayLogIndex++;
displayLogIndex %= 10; displayLogIndex %= 10;
lastActionMillis = currentMillis; lastActionMillis = currentMillis;
delay(500); delay(200);
} }
// log display function // log display function
@ -226,10 +237,57 @@ void loop() {
} }
if(readButtons() == 3) { //down
displayCardsIndex++;
displayCardsIndex %= EEP_CLIENT_MAX;
lastActionMillis = currentMillis;
cardsshow=true;
delay(200);
}
if(readButtons() == 4) { //up
displayCardsIndex--;
if (displayCardsIndex<0){
displayCardsIndex=EEP_CLIENT_MAX-1;
}
displayCardsIndex %= EEP_CLIENT_MAX;
lastActionMillis = currentMillis;
cardsshow=true;
delay(200);
}
// saved cards display function
if(displayCardsIndex != displayCardsIndexLast) {
if(displayCardsIndex >= 0) {
lcd_backlight(true);
lcd.clear();
lcd.print("SLOT ");
lcd.print(displayCardsIndex);
if (displayCardsIndex==0){
lcd.print(" Master");
}
lcd.setCursor(0, 1);
MFRC522::Uid uid = get_uid(displayCardsIndex, EEP_ADDR_START);
lcd_print_uid(&uid);
}
displayCardsIndexLast = displayCardsIndex;
}
//card removal
if(readButtons() == 1 && cardsshow && unlocked) { //cards are shown, is unlocked an select pressed
lastActionMillis = currentMillis;
lcd.clear();
lcd.print("Karte");
lcd.setCursor(0, 1);
lcd.print("entfernt");
delete_uid(displayCardsIndex, EEP_ADDR_START);
delay(1000);
}
// timeout handling for returning to locked state // timeout handling for returning to locked state
if(currentMillis - lastActionMillis > 11000) { if(currentMillis - lastActionMillis > 30000) {
unlocked = false; unlocked = false;
displayLogIndex = -1; displayLogIndex = -1;
displayCardsIndex = -1;
cardsshow=false;
lcd_backlight(false); lcd_backlight(false);
if(cardWasPresent) { if(cardWasPresent) {