Merge remote-tracking branch 'origin/main'

# Conflicts:
#	src/src/main.cpp
This commit is contained in:
Matěj Kubíček
2026-06-08 10:05:25 +02:00
+71
View File
@@ -181,6 +181,77 @@ void runPasswordSetup() {
}
}
// setup hesla
void showSetupScreen(bool showValue) {
lcd.setCursor(0, 0);
lcd.printstr("Nastavte heslo: ");
lcd.setCursor(0, 1);
if (showValue) {
String code = formatCode(passwordValue);
// mezery okolo pro vizuální oddělení číslic
String display = code[0] + String(" ") + code[1] + String(" ") + code[2] + String(" ") + code[3] + String(" ");
lcd.printstr(display.c_str());
} else {
lcd.printstr("* * * * ");
}
}
// setup fáze blokující, dokud není heslo uloženo
void runPasswordSetup() {
NeutralLED();
passwordValue = 0;
masked = false;
lastEncoderMove = millis();
lastCLK = digitalRead(ENCODER_CLK_PIN);
showSetupScreen(true);
while (savedPassword == "") {
// čtení enkodéru
int currentCLK = digitalRead(ENCODER_CLK_PIN);
if (currentCLK != lastCLK && currentCLK == LOW) {
int dt = digitalRead(ENCODER_DT_PIN);
if (dt != currentCLK) {
passwordValue = (passwordValue + 1) % 10000;
} else {
passwordValue = (passwordValue - 1 + 10000) % 10000;
}
masked = false;
lastEncoderMove = millis();
showSetupScreen(true);
}
lastCLK = currentCLK;
// maskování po nečinnosti
if (!masked && millis() - lastEncoderMove >= MASK_DELAY_MS) {
masked = true;
showSetupScreen(false);
}
// potvrzení tlačítkem
if (digitalRead(BUTTON_PIN) == HIGH) {
savedPassword = formatCode(passwordValue);
ConfirmSound();
lcd.setCursor(0, 0);
lcd.printstr("Heslo ulozeno! ");
lcd.setCursor(0, 1);
lcd.printstr("* * * * ");
delay(1500);
// přechod do normálního režimu
lcd.setCursor(0, 0);
lcd.printstr("Zadejte heslo: ");
lcd.setCursor(0, 1);
lcd.printstr(" ");
// debounce
while (digitalRead(BUTTON_PIN) == HIGH) {}
delay(50);
}
}
}
void setup() {
Serial.begin(9600);