Good day. In the library TimeAlarms/TimeAlarms.h there is a ‘time_t read(AlarmID_t ID);’ command which is supposed to return the value of the given timer. I havent seen an example on the web at all to display this. The ‘AlarmID_t getTriggeredAlarmId();’ works fine. But lets say I have 2 alarms that all go off at a different time and do different things. I also have another timer that reads those 2 different alarm functions and displays them. I cant seem to have them display without using the getTriggeredAlarmId. I dont know where to call out the read command. Any thoughts. As I said before I havent seen this functionality done on any forum yet, so I dont have much to go off of otherwise thise question would be posted in the Programming Questions. Any help is most appreciated.
#include <Time.h>
#include <TimeAlarms.h>
AlarmID_t trialID, afternoonAlarmID, GetTriggeredAlarmID;
//time_t now();
char buf[50];
char buf2[50];
void setup()
{
Serial.begin(9600);
setTime(8,29,0,1,1,11);
trialID = Alarm.alarmRepeat(9,29,10, GetTriggeredAlarms1);
afternoonAlarmID = Alarm.alarmRepeat(9,29,12,GetTriggeredAlarms2);
Alarm.alarmRepeat(8,29,7, GetAllAlarmTimes);
}
void GetAllAlarmTimes ()
{
time_t read(AlarmID_t ID);
// if(ID == trialID) {
//if(hour() != 8 || minute() != 29){
trialID;
sprintf(buf2,"Morning Alarm Failure: Time %d:%d:%d %d/%d/%d", hour(),minute(),second(),month(),day(),year());
//sprintf(buf2,"d:%d:%d", hour(),minute(),second());
//}
}
afternoonAlarmID;
// else if (id == afternoonAlarmID) {
// if(hour() != 8 || minute() != 19){
sprintf(buf,"Morning Alarm Failure: Time %d:%d:%d %d/%d/%d", hour(),minute(),second(),month(),day(),year());
//}
//}
//sprintf(buf,"Afternoon Alarm Failure: Time %d:%d:%d %d/%d/%d", hour(),minute(),second(),month(),day(),year());
Serial.print(buf);
Serial.println();
Serial.println(buf2);
}
void GetTriggeredAlarms(){
// AlarmId id = Alarm. getTriggeredAlarmId();
//if(id == trialID) {
//if(hour() != 8 || minute() != 29){
// sprintf(buf2,"Morning Alarm Failure: Time %d:%d:%d %d/%d/%d", hour(),minute(),second(),month(),day(),year());
// Serial.println(buf2);
//}
//}
//else if (id == afternoonAlarmID) {
// if(hour() != 8 || minute() != 19){
// sprintf(buf,"Afternoon Alarm Failure: Time %d:%d:%d %d/%d/%d", hour(),minute(),second(),month(),day(),year());
// Serial.println(buf);
//}
//}
}
void loop(){
digitalClockDisplay();
Alarm.delay(1000);
}
void digitalClockDisplay()
{
// digital clock display of the time
Serial.print(hour());
printDigits(minute());
printDigits(second());
Serial.println();
}
void printDigits(int digits)
{
Serial.print(":");
if(digits < 10)
Serial.print('0');
Serial.print(digits);
}
void GetTriggeredAlarms1 ()
{}
void GetTriggeredAlarms2 ()
{}
Moderator edit:
</mark> <mark>[code]</mark> <mark>
</mark> <mark>[/code]</mark> <mark>
tags added.