add falseStop function
This commit is contained in:
parent
dbc0e80c56
commit
35c7d5f4ad
|
@ -0,0 +1,27 @@
|
|||
This source code is released under the DWTW license.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under the terms of the Do What Thou Wilt License.
|
||||
|
||||
Boundless Public License
|
||||
DO WHAT THOU WILT
|
||||
TO PUBLIC LICENSE
|
||||
|
||||
Version 2.55
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it in full or in part is allowed without any restrictions.
|
||||
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. Do what thou wilt shall be the whole of the Law.
|
||||
|
||||
DWTWL – a license with a single requirement: DO WHAT THOU WILT
|
||||
|
||||
The license provides more freedom than any other one (such as GPL or BSD) and does not require saving the license text on copying.
|
||||
|
||||
DWTWL – an accomplished and eligible license for free text, code and any other symbols (including the software, documentation and artwork).
|
||||
|
||||
The license does not contain a "no warranty" clause. DWTWL can be used in countries that do not legally acknowledge the transition to public domain.
|
||||
|
||||
Summary:
|
||||
|
||||
An author-creator gives their source code to the world for free, without becoming distracted by worldly thinking regarding how and why the others will use it.
|
|
@ -1,3 +1,3 @@
|
|||
twobuttonstimer scetch for Arduino using DS1307RTC
|
||||
# twobuttonstimer scetch for Arduino using DS1307RTC
|
||||
|
||||
![pyGtkRDP](https://raw.githubusercontent.com/zlaxy/twobuttonstimer/master/twobuttonstimer_bb.png)
|
||||
![twobuttonstimer](https://gitlab.com/simplemicrocontrollers/twobuttonstimer/raw/master/twobuttonstimer_bb.png)
|
||||
|
|
|
@ -11,11 +11,11 @@ const byte redButton = 4; // RedButton: light on, open door
|
|||
const byte blackButton = 5; // BlackButton: light off, close door
|
||||
const byte stopButtonRelay = 6;
|
||||
const byte startButtonRelay = 7;
|
||||
const int msStart = 889; // Interval for pressing start button, ms
|
||||
const int msStop = 887; // Interval for pressing stop button, ms
|
||||
const int msStart = 650; // Interval for pressing start button, ms
|
||||
const int msStop = 750; // Interval for pressing stop button, ms
|
||||
const int updateTime = 1000; // Interval for digit display update
|
||||
const int buttonCheck = 200; // Interval for checking button state
|
||||
const long manualButtonTime = 3600000; // 60 min - actual state of manual pressed button
|
||||
const long manualButtonTime = 1800000; // 60 min - actual state of manual pressed button
|
||||
long buttonMillis = 0; // Previous button press counter
|
||||
byte indicator = 0; // Indicator of working states: 0 - scheduled off; 1 - scheduled on;
|
||||
// 2 - manual off, 3 - manual on
|
||||
|
@ -80,12 +80,12 @@ void showTime() {
|
|||
void pressStart() {
|
||||
serStr("scheduled start button pressed");
|
||||
display.print("on__");
|
||||
delay(5000);
|
||||
delay(55000);
|
||||
indicator = 1;
|
||||
digitalWrite(startButtonRelay, HIGH);
|
||||
delay(msStart);
|
||||
digitalWrite(startButtonRelay, LOW);
|
||||
delay(61000); // wait a minute
|
||||
delay(6000);
|
||||
serStr("scheduled start button delay finished");
|
||||
}
|
||||
|
||||
|
@ -98,9 +98,22 @@ void pressStop() {
|
|||
delay(msStop);
|
||||
digitalWrite(stopButtonRelay, LOW);
|
||||
delay(61000); // wait a minute
|
||||
// Double!
|
||||
digitalWrite(stopButtonRelay, HIGH);
|
||||
delay(msStop);
|
||||
digitalWrite(stopButtonRelay, LOW);
|
||||
delay(5000);
|
||||
serStr("scheduled stop button delay finished");
|
||||
}
|
||||
|
||||
void pressStopFalse() {
|
||||
serStr("scheduled false-stop");
|
||||
display.print("off_");
|
||||
delay(5000);
|
||||
indicator = 0;
|
||||
delay(61000); // wait a minute
|
||||
}
|
||||
|
||||
void pressStartManual() {
|
||||
serStr("manual start button pressed");
|
||||
display.print("on__");
|
||||
|
@ -186,44 +199,44 @@ void checkTime() {
|
|||
// 6:00 - 7:16 - working
|
||||
if ((hour()==6) && (indicator==0)) pressStart();
|
||||
// 7:01 - stop
|
||||
if ((hour()==7) && (minute()==16)) pressStop();
|
||||
if ((hour()==7) && (minute()==16)) pressStopFalse();
|
||||
// 12:00 - 13:01 - working
|
||||
if ((hour()==12) && (indicator==0)) pressStart();
|
||||
// 13:01 - stop
|
||||
if ((hour()==13) && (minute()==1)) pressStop();
|
||||
if ((hour()==13) && (minute()==1)) pressStopFalse();
|
||||
// 17:00 - 18:01 - working
|
||||
if ((hour()==17) && (indicator==0)) pressStart();
|
||||
// 18:01 - stop
|
||||
if ((hour()==18) && (minute()==1)) pressStop();
|
||||
if ((hour()==18) && (minute()==1)) pressStopFalse();
|
||||
}
|
||||
// Spring & Autumn
|
||||
if (month()==3 || month()==4 || month()==10 || month()==11) {
|
||||
// 6:00 - 8:21 - working
|
||||
if ((hour()==6 || hour()==7) && (indicator==0)) pressStart();
|
||||
if ((hour()==6 || hour()==7 || ((hour()==8) && (minute() < 5))) && (indicator==0)) pressStart();
|
||||
// 8:21 - stop
|
||||
if ((hour()==8) && (minute()==21)) pressStop();
|
||||
if ((hour()==8) && (minute()==21)) pressStopFalse();
|
||||
// 12:00 - 13:26 - working
|
||||
if ((hour()==12) && (indicator==0)) pressStart();
|
||||
if ((hour()==12 || ((hour()==13) && (minute() < 10))) && (indicator==0)) pressStart();
|
||||
// 13:26 - stop
|
||||
if ((hour()==13) && (minute()==26)) pressStop();
|
||||
if ((hour()==13) && (minute()==26)) pressStopFalse();
|
||||
// 17:00 - 18:21 - working
|
||||
if ((hour()==17) && (indicator==0)) pressStart();
|
||||
if ((hour()==17 || ((hour()==18) && (minute() < 5))) && (indicator==0)) pressStart();
|
||||
// 18:21 - stop
|
||||
if ((hour()==18) && (minute()==21)) pressStop();
|
||||
if ((hour()==18) && (minute()==21)) pressStopFalse();
|
||||
}
|
||||
// Summer
|
||||
if (month()==5 || month()==6 || month()==7 || month()==8 || month()==9) {
|
||||
// 6:00 - 8:28 - working
|
||||
if ((hour()==6 || hour()==7) && (indicator==0)) pressStart();
|
||||
// 8:23 - stop
|
||||
if ((hour()==8) && (minute()==28)) pressStop();
|
||||
// 12:00 - 14:11 - working
|
||||
// 6:00 - 9:05 - working
|
||||
if ((hour()==6 || hour()==7 || hour()==8) && (indicator==0)) pressStart();
|
||||
// 9:05 - stop
|
||||
if ((hour()==9) && (minute()==5)) pressStopFalse();
|
||||
// 12:00 - 14:05 - working
|
||||
if ((hour()==12 || hour()==13) && (indicator==0)) pressStart();
|
||||
// 14:11 - stop
|
||||
if ((hour()==14) && (minute()==11)) pressStop();
|
||||
// 17:00 - 18:35 - working
|
||||
if ((hour()==17) && (indicator==0)) pressStart();
|
||||
// 18:35 - stop
|
||||
if ((hour()==18) && (minute()==35)) pressStop();
|
||||
// 14:05 - stop
|
||||
if ((hour()==14) && (minute()==5)) pressStopFalse();
|
||||
// 17:00 - 19:50 - working
|
||||
if ((hour()==17 || hour()==18) && (indicator==0)) pressStart();
|
||||
// 19:50 - stop
|
||||
if ((hour()==19) && (minute()==50)) pressStopFalse();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue