Pages: [1]   Go Down
Author Topic: Issues with TimeAlarms  (Read 184 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 60
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.


Code:
#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: [code] [/code] tags added.
« Last Edit: February 05, 2014, 02:11:31 am by Coding Badly » Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 60
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I tried going further with the trialID but it still wont display the time it should. the code is posted. How do I get it to display 9,29,10? As of now it doesnt read trialID and prints the message and the time of 8,29,7.


Code:
#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 now();
time_t read(AlarmID_t trialID);
time_t read(AlarmID_t afternoonAlarmID);

 if(trialID == trialID) {
    if(hour() != 9 || minute() != 29){

  sprintf(buf2,"Morning Alarm Failure: Time %d:%d:%d %d/%d/%d", hour(),minute(),second(),month(),day(),year());
  Serial.println(buf2);

    }
 
}
 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 ()
{}

Moderator edit: [code] [/code] tags added.
« Last Edit: February 05, 2014, 03:50:02 am by Coding Badly » Logged

Pages: [1]   Go Up
Jump to: