diff options
| author | Syndamia <kamen.d.mladenov@protonmail.com> | 2020-07-08 23:38:59 +0300 |
|---|---|---|
| committer | Syndamia <kamen.d.mladenov@protonmail.com> | 2020-07-08 23:38:59 +0300 |
| commit | d02ca2a130eec444a203dae0d056cf6a76fd0316 (patch) | |
| tree | 770d76161788f36d1b336d9469b991f33a2a2bf7 | |
| parent | ee5c633a84548eb748c097b5413ee12e83950d95 (diff) | |
| download | RemiHap-d02ca2a130eec444a203dae0d056cf6a76fd0316.tar RemiHap-d02ca2a130eec444a203dae0d056cf6a76fd0316.tar.gz RemiHap-d02ca2a130eec444a203dae0d056cf6a76fd0316.zip | |
Improved main controller input and clock implementations
| -rw-r--r-- | remihap/remihap.ino | 49 |
1 files changed, 27 insertions, 22 deletions
diff --git a/remihap/remihap.ino b/remihap/remihap.ino index 034e692..48123fb 100644 --- a/remihap/remihap.ino +++ b/remihap/remihap.ino @@ -8,7 +8,7 @@ #define LCD_COLS 16 #define MSG_ERR_R1 " Error! " -#define ERROR_VISIBILITY_TIMEOUT 2000 +#define ERROR_VISIBILITY_TIMEOUT 500 #define MSG_ERR_DAY " Invalid day " #define MSG_ERR_HOUR " Invalid hour " @@ -453,6 +453,8 @@ void setup() char key; +unsigned long lastTime; + void loop() { if (menu == mainMenu) { @@ -469,28 +471,31 @@ void loop() dispensePill(3); // dispense correct pill alarm(millis()); } - delay(990); + delay(10); - seconds++; + if (millis() - lastTime >= 1000) { + lastTime = millis(); + seconds++; - if(seconds > 59) { - seconds = 0; - minutes++; - } - if (minutes > 59) { - minutes = 0; - hours++; - } - if (hours > 23) { - hours = 0; - day++; - } - if (day > maxDays[month]) { - day = 1; - month++; - } - if (month > 12) { - month = 1; - year++; + if(seconds > 59) { + seconds = 0; + minutes++; + } + if (minutes > 59) { + minutes = 0; + hours++; + } + if (hours > 23) { + hours = 0; + day++; + } + if (day > maxDays[month]) { + day = 1; + month++; + } + if (month > 12) { + month = 1; + year++; + } } } |
