Quellcode durchsuchen

added login result display

develop
Robin Thoni vor 8 Jahren
Ursprung
Commit
33f4ee1dd7
1 geänderte Dateien mit 31 neuen und 1 gelöschten Zeilen
  1. 31
    1
      main.ino

+ 31
- 1
main.ino Datei anzeigen

@@ -25,6 +25,10 @@ LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
25 25
 #define SELF_TEST_ERROR_LABEL "Error: "
26 26
 #define UID_LABEL "UID:"
27 27
 #define PWD_LABEL "PWD:"
28
+#define LOGIN_IN_PROGRESS "Login..."
29
+#define LOGIN_FAILED "Login failed"
30
+#define LOGIN_SUCCESS "Access granted"
31
+
28 32
 #define UID_MAX_LEN 12
29 33
 #define PWD_MAX_LEN 12
30 34
 String uid;
@@ -32,12 +36,18 @@ String password;
32 36
 enum Status {
33 37
     Uid,
34 38
     Password,
35
-    SelfTest
39
+    SelfTest,
40
+    LoginInProgress,
41
+    LoginFailed,
42
+    LoginSuccess
36 43
 };
37 44
 Status status = Uid;
38 45
 
39 46
 #define MAX_IDLE_TIME 20
40 47
 unsigned long lastActivity = 0;
48
+
49
+#define LOGIN_FAILED_TIME 2
50
+
41 51
 #define SELF_TEST_INTERVAL 60
42 52
 #define SELF_TEST_ERROR_INTERVAL 2
43 53
 #define MAX_SELF_TEST_TIME 5
@@ -155,6 +165,15 @@ void updateLcd()
155 165
             lcd.print(lastSelfTestResult);
156 166
         }
157 167
     }
168
+    else if (status == LoginInProgress) {
169
+        lcd.print(LOGIN_IN_PROGRESS);
170
+    }
171
+    else if (status == LoginFailed) {
172
+        lcd.print(LOGIN_FAILED);
173
+    }
174
+    else if (status == LoginSuccess) {
175
+        lcd.print(LOGIN_SUCCESS);
176
+    }
158 177
 }
159 178
 
160 179
 void askUidPassword()
@@ -167,8 +186,19 @@ void askUidPassword()
167 186
 
168 187
 void login(String uid, String password)
169 188
 {
189
+    status = LoginInProgress;
190
+    updateLcd();
191
+
192
+    delay(LOGIN_FAILED_TIME * 1000);
193
+
170 194
     Serial.println(uid);
171 195
     Serial.println(password);
196
+
197
+    status = LoginSuccess;
198
+    updateLcd();
199
+
200
+    delay(LOGIN_FAILED_TIME * 1000);
201
+
172 202
     askUidPassword();
173 203
 }
174 204
 

Laden…
Abbrechen
Speichern