Set up scheduled program cycles #24
|
@ -116,7 +116,7 @@ const char index_html[] PROGMEM = R"rawliteral(
|
||||||
<select name="inputSend" id="send-program">
|
<select name="inputSend" id="send-program">
|
||||||
<option value="0" >0 - Off</option>
|
<option value="0" >0 - Off</option>
|
||||||
<option value="1">1 - Continuous</option>
|
<option value="1">1 - Continuous</option>
|
||||||
<option value="2">2 - Cycle Program</option>
|
<option value="2">2 - Cycle</option>
|
||||||
</select><br>
|
</select><br>
|
||||||
|
|
||||||
Message (current value <b>%inputMsg%</b>):
|
Message (current value <b>%inputMsg%</b>):
|
||||||
|
@ -129,8 +129,10 @@ const char index_html[] PROGMEM = R"rawliteral(
|
||||||
<option value="5">5 - MO5</option>
|
<option value="5">5 - MO5</option>
|
||||||
</select></p>
|
</select></p>
|
||||||
|
|
||||||
<p>Program start time <input type="datetime-local" id="js_start_time_unix_entry" /><br>
|
<p>Cycle start time <input type="datetime-local" id="js_start_time_unix_entry" /><br>
|
||||||
Current value: <b><span id=current-start></span></b>
|
Current value: <b><span id=current-start></span></b>, but only day-of-month HH:MM:SS are used.
|
||||||
|
Only applies when <em>Sending Program</em> is set to "2 - Cycle".
|
||||||
|
You cannot set a cycle start date more than a month in advance.
|
||||||
<!-- JS converts the entered start time to a unix timestamp, and copies that value
|
<!-- JS converts the entered start time to a unix timestamp, and copies that value
|
||||||
to this hidden field so the user doesn't have to see it. -->
|
to this hidden field so the user doesn't have to see it. -->
|
||||||
<input type="hidden" name="inputStartTimeUnix" id="js_start_time_unix" /></p>
|
<input type="hidden" name="inputStartTimeUnix" id="js_start_time_unix" /></p>
|
||||||
|
@ -437,10 +439,10 @@ void setup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Are there any RTC alarms set?
|
// Are there any RTC alarms set?
|
||||||
DateTime alarm_two = rtc.getAlarm2(); // Get the current time
|
DateTime alarm_one = rtc.getAlarm1(); // Get the current time
|
||||||
char buff[] = "Alarm 2 set for at hh:mm:ss DDD, DD MMM YYYY";
|
char buff[] = "Alarm 1 set for at hh:mm:ss DDD, DD MMM YYYY";
|
||||||
Serial.print(alarm_two.toString(buff));
|
Serial.print(alarm_one.toString(buff));
|
||||||
Serial.println(" (only accurate to day of month)");
|
Serial.println(" (only HH:MM:SS day-of-month are accurate)");
|
||||||
|
|
||||||
// Timer example, blink main LED
|
// Timer example, blink main LED
|
||||||
pinMode(LED_BUILTIN, OUTPUT); // set LED pin to OUTPUT
|
pinMode(LED_BUILTIN, OUTPUT); // set LED pin to OUTPUT
|
||||||
|
@ -575,14 +577,17 @@ void setup() {
|
||||||
Serial.println(yourInputTime);
|
Serial.println(yourInputTime);
|
||||||
// update the RTC time
|
// update the RTC time
|
||||||
rtc.adjust(DateTime(yourInputTime));
|
rtc.adjust(DateTime(yourInputTime));
|
||||||
|
DateTime now = rtc.now();
|
||||||
// Might work to fix random errors? If date is far in the future,
|
// Might work to fix random errors? If date is far in the future,
|
||||||
// try to update again.
|
// try to update again.
|
||||||
while(rtc.now().year() > 2040){
|
// replace if with while if you want it to try a bunch...
|
||||||
|
if(now.year() > 2040){
|
||||||
|
Serial.print("Year is ");
|
||||||
|
Serial.println(now.year());
|
||||||
Serial.println("RTC can't set time. Trying again.");
|
Serial.println("RTC can't set time. Trying again.");
|
||||||
rtc.adjust(DateTime(yourInputTime));
|
rtc.adjust(DateTime(yourInputTime));
|
||||||
}
|
}
|
||||||
;
|
|
||||||
DateTime now = rtc.now();
|
|
||||||
Serial.print("UTC time from browser: ");
|
Serial.print("UTC time from browser: ");
|
||||||
Serial.print(now.year(), DEC);
|
Serial.print(now.year(), DEC);
|
||||||
Serial.print('/');
|
Serial.print('/');
|
||||||
|
@ -627,12 +632,12 @@ void setup() {
|
||||||
// Serial.println(active_tasks);
|
// Serial.println(active_tasks);
|
||||||
|
|
||||||
// Use alarm built into RTC
|
// Use alarm built into RTC
|
||||||
rtc.setAlarm2(DateTime(yourInputStartTimeUnix), DS3231_A2_Date);
|
rtc.setAlarm1(DateTime(yourInputStartTimeUnix), DS3231_A1_Date);
|
||||||
//rtc.setAlarm1(DateTime(2020, 6, 25, 15, 34, 0), DS3231_A2_Date);
|
//rtc.setAlarm1(DateTime(2020, 6, 25, 15, 34, 0), DS3231_A2_Date);
|
||||||
DateTime alarm_two = rtc.getAlarm2(); // Get the current time
|
DateTime alarm_one = rtc.getAlarm1(); // Get the current alarm time
|
||||||
char buff[] = "Alarm 2 set for at hh:mm:ss DDD, DD MMM YYYY";
|
char buff[] = "Alarm 1 set for at hh:mm:ss DDD, DD MMM YYYY";
|
||||||
Serial.print(alarm_two.toString(buff));
|
Serial.print(alarm_one.toString(buff));
|
||||||
Serial.println(" (only accurate to day of month)");
|
Serial.println(" (only HH:MM:SS day-of-month are accurate)");
|
||||||
}
|
}
|
||||||
// else {
|
// else {
|
||||||
// inputMessage = "No message sent";
|
// inputMessage = "No message sent";
|
||||||
|
@ -659,20 +664,17 @@ void loop() {
|
||||||
// Timers
|
// Timers
|
||||||
timer.tick();
|
timer.tick();
|
||||||
|
|
||||||
// This function from https://github.com/garrysblog/DS3231-Alarm-With-Adafruit-RTClib-Library/blob/master/DS3231-RTClib-Adafruit-Alarm-Poll-alarmFired/DS3231-RTClib-Adafruit-Alarm-Poll-alarmFired.ino
|
// This statement from https://github.com/garrysblog/DS3231-Alarm-With-Adafruit-RTClib-Library/blob/master/DS3231-RTClib-Adafruit-Alarm-Poll-alarmFired/DS3231-RTClib-Adafruit-Alarm-Poll-alarmFired.ino
|
||||||
// Check if alarm by polling by using alarmFired
|
// Check if alarm by polling SQW alarm pin
|
||||||
// We don't want old alarms, though.
|
if (yourInputSend == 2 & digitalRead(alarmPin) == LOW) {
|
||||||
//& (rtc.getAlarm2() >= rtc.now())
|
|
||||||
// if ((rtc.alarmFired(2) == 1) ){
|
|
||||||
if (digitalRead(alarmPin) == LOW) {
|
|
||||||
|
|
||||||
// Print current time and date
|
// Print current time and date
|
||||||
DateTime now = rtc.now(); // Get the current time
|
DateTime now = rtc.now(); // Get the current time
|
||||||
char buff[] = "Alarm triggered at hh:mm:ss DDD, DD MMM YYYY";
|
char buff[] = "Alarm triggered at hh:mm:ss DDD, DD MMM YYYY";
|
||||||
Serial.println(now.toString(buff));
|
Serial.println(now.toString(buff));
|
||||||
|
|
||||||
// Disable and clear alarm
|
// Disable and clear alarm
|
||||||
rtc.clearAlarm(2);
|
rtc.clearAlarm(1);
|
||||||
|
rtc.clearAlarm(2); // clear the other one just in case
|
||||||
}
|
}
|
||||||
|
|
||||||
// DateTime now = rtc.now();
|
// DateTime now = rtc.now();
|
||||||
|
@ -742,7 +744,7 @@ void loop() {
|
||||||
morseToSend_blink.Update();
|
morseToSend_blink.Update();
|
||||||
|
|
||||||
// if you want to send cycle code and it's not sending, then start it up
|
// if you want to send cycle code and it's not sending, then start it up
|
||||||
} else if((yourInputSend == 2) & (morseToSend.IsRunning() == true)){
|
} else if((yourInputSend == 2) & (morseToSend.IsRunning() == false)){
|
||||||
morseToSend.Reset().Update();
|
morseToSend.Reset().Update();
|
||||||
morseToSend_blink.Reset().Update();
|
morseToSend_blink.Reset().Update();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user