Better keypad scanning and reboot with *****

This commit is contained in:
Moirtz Wagner 2026-01-02 20:37:25 +01:00
parent 1d35684c53
commit 9a193e837f
3 changed files with 9 additions and 7 deletions

View File

@ -40,7 +40,7 @@ Keypad::Keypad(char *userKeymap, byte *row, byte *col, byte numRows, byte numCol
begin(userKeymap); begin(userKeymap);
setDebounceTime(10); setDebounceTime(15);
setHoldTime(500); setHoldTime(500);
keypadEventListener = 0; keypadEventListener = 0;
@ -86,7 +86,7 @@ void Keypad::scanKeys() {
pin_mode(rowPins[r],OUTPUT); pin_mode(rowPins[r],OUTPUT);
pin_write(rowPins[r],HIGH); pin_write(rowPins[r],HIGH);
} }
delayMicroseconds(3); // Let pins settle. delayMicroseconds(1000); // Let pins settle.
for (byte r=0; r<sizeKpd.rows; r++) { for (byte r=0; r<sizeKpd.rows; r++) {
pin_mode(rowPins[r],INPUT_PULLUP); pin_mode(rowPins[r],INPUT_PULLUP);
} }

View File

@ -53,7 +53,7 @@ const int buzzerOutputPin = 8; // pin connected to the buzzer (when using hardwa
const int doorOpenerOutputPin = 9; //USE 6 HERE pin connected to the door opener (when using hardware connection instead of mqtt to open the door) const int doorOpenerOutputPin = 9; //USE 6 HERE pin connected to the door opener (when using hardware connection instead of mqtt to open the door)
const int doorbellOutputPin = 10; // pin connected to the doorbell (when using hardware connection instead of mqtt to ring the bell) const int doorbellOutputPin = 10; // pin connected to the doorbell (when using hardware connection instead of mqtt to ring the bell)
const int KeyboardPin = 4; //pin connected to an analog keyboard (see voltage ranges for the nubers in seperate array) const int KeyboardPin = 4; //pin connected to an analog keyboard (see voltage ranges for the nubers in seperate array)
const int KEY_POLLING_MS = 25; const int KEY_POLLING_MS = 50;
const uint8_t NUM_PIN_MAX_DIGITS = {10}; const uint8_t NUM_PIN_MAX_DIGITS = {10};
#ifdef CUSTOM_GPIOS #ifdef CUSTOM_GPIOS
const int customOutput1 = 18; // not used internally, but can be set over MQTT const int customOutput1 = 18; // not used internally, but can be set over MQTT
@ -783,7 +783,9 @@ void keyboardPoller(void){
static uint8_t pin[NUM_PIN_MAX_DIGITS] = {0}; static uint8_t pin[NUM_PIN_MAX_DIGITS] = {0};
uint8_t key = keypad.getKey(); uint8_t key = keypad.getKey();
if(key){ if(key){
Serial.printf("KeyVal: %c\n", key); //String keyStr(key);
//notifyClients("Key: "+keyStr);
//Serial.printf("KeyVal: %c\n", key);
pin[pinpos++] = key; pin[pinpos++] = key;
resetTimer = 0; resetTimer = 0;
io.digitalWrite(buzzerOutputPin, HIGH); io.digitalWrite(buzzerOutputPin, HIGH);
@ -792,7 +794,7 @@ void keyboardPoller(void){
} }
if(pinpos){ if(pinpos){
resetTimer++; resetTimer++;
if(resetTimer > 4000/KEY_POLLING_MS){ if(resetTimer > 2000/KEY_POLLING_MS){
resetTimer = 0; resetTimer = 0;
pinpos = 0; pinpos = 0;
Serial.println("RESET"); Serial.println("RESET");
@ -814,7 +816,7 @@ void keyboardPoller(void){
openDoor(match); openDoor(match);
}else{ }else{
pinOK = true; pinOK = true;
PinStr = "#############"; PinStr = "************";
for(uint8_t i=0;i<pinpos;i++){ for(uint8_t i=0;i<pinpos;i++){
uint8_t coosenPinDigit = PinStr.charAt(i); uint8_t coosenPinDigit = PinStr.charAt(i);
if(pin[i] != coosenPinDigit){ if(pin[i] != coosenPinDigit){

View File

@ -88,7 +88,7 @@ uint32_t calculateSunrise(float lat, float lng,int localOffset, bool sunset = fa
UT -= 24.0; UT -= 24.0;
} }
//10. convert UT value to local time zone of latitude/longitude //10. convert UT value to local time zone of latitude/longitude
return (UT + localOffset + timeinfo.tm_isdst) * 60; // convert to minutes return (UT + localOffset + timeinfo.tm_isdst - 1) * 60; // convert to minutes
} }
uint32_t calculateSunset(float lat, float lng,int localOffset) { uint32_t calculateSunset(float lat, float lng,int localOffset) {
return calculateSunrise(lat, lng, localOffset, true); return calculateSunrise(lat, lng, localOffset, true);