Skip to content

Commit b18ec5e

Browse files
committed
Merge branch 'main' of https://github.com/hakierspejs/hsldz_totp_lock into feature/bugfixes-and-improvements
2 parents 8dfb374 + 1833667 commit b18ec5e

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "vendor/librares/Watchdog"]
2+
path = vendor/librares/Watchdog
3+
url = [email protected]:janelia-arduino/Watchdog.git

hsldz_totp_lock/hsldz_totp_lock.ino

+9-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
#include <DS3231.h>
55
#include <Wire.h>
66
#include <Eeprom24C32_64.h>
7-
#include <Eeprom24C04_16.h>
7+
#include <Eeprom24C04_16.h>
8+
#include <Watchdog.h>
89

910

1011
#define BUZZER_PIN 10
@@ -48,6 +49,7 @@ Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS
4849
// RTC
4950
RTClib RTC;
5051

52+
Watchdog watchdog;
5153

5254

5355
const bool morseKeys[10][5] = {
@@ -91,11 +93,13 @@ String userInputPrev = "";
9193

9294

9395
void setup(){
96+
watchdog.reset();
9497
Serial.begin(9600);
9598
Wire.begin();
9699
eeprom.initialize();
97100
pinMode(BUZZER_PIN, OUTPUT);
98101
pinMode(LOCK_PIN, OUTPUT);
102+
watchdog.enable(Watchdog::TIMEOUT_8S);
99103
int size = sizeof(melodyMain) / sizeof(int);
100104
playMaintenanceMelody(melodyMain, size);
101105
}
@@ -109,6 +113,7 @@ void echo_morse_reversed_int(unsigned long value) {
109113
// Serial.println(digit);
110114
delay(MORSE_SOUND_TIME * MORSE_PAUSE);
111115
for(int i =0; i < 5; i++ ) {
116+
watchdog.reset();
112117
if (morseKeys[digit][i]) {
113118
tone(BUZZER_PIN, MORSE_FREQ, MORSE_SOUND_TIME);
114119
delay(MORSE_SOUND_TIME + MORSE_SOUND_TIME);
@@ -266,6 +271,7 @@ void buzz(int targetPin, long frequency, long length) {
266271
void playMaintenanceMelody(int melody[], int size) {
267272
int melodyPin = BUZZER_PIN;
268273
for (int thisNote = 0; thisNote < size; thisNote++) {
274+
watchdog.reset();
269275
// to calculate the note duration, take one second
270276
// divided by the note type.
271277
//e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
@@ -352,10 +358,12 @@ void makeMaintenance(String userInputPrev) {
352358

353359

354360
void loop(){
361+
watchdog.reset();
355362
digitalWrite(LOCK_PIN, LOW);
356363
char customKey = customKeypad.getKey();
357364
if (customKey){
358365
tone(BUZZER_PIN, FREQ_BUTTON_PRESS, SOUND_TIME_BUTTON_PRESS);
366+
watchdog.reset();
359367
if (customKey == '*') {
360368
userInput = "";
361369
userInputPrev = "";

vendor/librares/Watchdog

Submodule Watchdog added at 7cbbb1b

0 commit comments

Comments
 (0)