lasercutter/arduino/SafetyBoard3/password.ino
2017-07-09 19:58:38 +02:00

47 lines
1.3 KiB
C++

//#include "safetyboard.h";
//******************************************************
// Password related stuff
//******************************************************
//take care of some special events
void pwdKeypadEvent(KeypadEvent eKey) {
switch (kpd.getState()){
case PRESSED:
Serial.print("Pressed: ");
Serial.println(eKey);
lcd.setCursor(0, 4);
lcd.print(" "); //empty "Wrong"
switch (eKey){
case '*':
checkPassword();
break;
case '#':
password.reset();
break;
default:
password.append(eKey);
}
}
}
void checkPassword() {
if (password.evaluate()) {
Serial.println("Success");
passwordCorrect = true;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Menu"); // Print a message to the LCD.
setupFlowMeter();
digitalWrite(airAssistPin, HIGH); // sets the airAssist on
digitalWrite(ventilationPin, HIGH); // sets the air ventilation on
digitalWrite(waterCoolerPin, HIGH); // sets the watercooler fans on
digitalWrite(laserEnablePin, HIGH); // sets the watercooler fans on
kpd.addEventListener(menuKeypadEvent); //add an event listener for this keypad
} else {
Serial.println("Wrong");
password.reset();
lcd.setCursor(0, 4);
lcd.print("Wrong");
}
}