I am trying to display alarm times by calling a different functions and using the read(AlarmID_t ID) tool in the timealarms.h file. However, I know i am not using it correctly because its not printing the times within that function or ID. The code is psted below and hopefully it makes sense as to what i am trying to do. In the end, I am merely using a timer and when that timer goes off, I have a print out of all the alarm times that are being claled in my program.
The getTriggered function the h file presents works fine but only displays the time of an alarm that went off. I dont care as to when it goes off or what it does when it does go off, I just want a print out of the actual time its supposed to goe off at. the read(AlarmID_t ID) I thought does this functionality but i cant seem to work through it.
Any sugguestions? Thanks
#include <Time.h>
#include <TimeAlarms.h>
AlarmID_t trialID, afternoonAlarmID, GetTriggeredAlarmID;
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 trialID);
{
if(isAllocated(trialID))
return Alarm[trialID].value ;
sprintf(buf2,"Morning Alarm Failure: Time %d:%d:%d %d/%d/%d", hour(),minute(),second(),month(),day(),year());
Serial.println(buf2);
else
return dtINVALID_TIME;
}
//time_t now();
//time_t read(AlarmID_t afternoonAlarmID);
//time_t read(AlarmID_t trialID);
//if(trialID == trialID) {
//if(hour() != 9 || minute() != 29){
}
}
afternoonAlarmID;
sprintf(buf,"Morning Alarm Failure: Time %d:%d:%d %d/%d/%d", hour(),minute(),second(),month(),day(),year());
Serial.print(buf);
Serial.println();
}
void GetTriggeredAlarms(){
}
void loop(){
digitalClockDisplay();
Alarm.delay(1000);
}
void digitalClockDisplay()
{
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 ()
{}
THE ERRORS I AM GETTING
alarm_time_latest_and_greatest.ino: In function 'void GetAllAlarmTimes()':
alarm_time_latest_and_greatest:28: error: 'isAllocated' was not declared in this scope
alarm_time_latest_and_greatest:29: error: no match for 'operator[]' in 'Alarm[trialID]'
alarm_time_latest_and_greatest:29: error: return-statement with a value, in function returning 'void'
alarm_time_latest_and_greatest:32: error: 'else' without a previous 'if'
alarm_time_latest_and_greatest:33: error: return-statement with a value, in function returning 'void'
alarm_time_latest_and_greatest.ino: At global scope:
alarm_time_latest_and_greatest:47: error: expected declaration before '}' token