Go Down

Topic: Time and TimeAlarms Libraries – Ask here for help or suggestions (Read 219636 times) previous topic - next topic

PaulS

Quote
I realize that each alarm is not strored in the EEPROM of the Arduino UNO , is it possible that they may be stored there ?

You could store a copy of the object in EEPROM. But, it makes no sense to do that. You can't recreate an object in memory just by reading some bytes from EEPROM. Now, storing and retreiving the time that an alarm is supposed to go off might make sense.
The art of getting good answers lies in asking good questions.

PaulS

Quote
How do I go about matching the DEVID to the alarmID or maybe assigning the DEVID as the alarmID ? OR get this to work.

In the callback function, call:
Code: [Select]
  AlarmID_t getTriggeredAlarmId();          // returns the currently triggered  alarm id

Compare the returned value with the list of AlarmID_t's you saved when creating the alarms, and use the index to get the device ID from the corresponding list.
The art of getting good answers lies in asking good questions.

joe4444

#332
Sep 27, 2014, 09:57 pm Last Edit: Sep 27, 2014, 11:32 pm by joe4444 Reason: 1
So as per this page http://arduino.cc/en/Main/arduinoBoardUno the Arduino UNO R3:
EEPROM is 1KB (1024 Bytes)
SRAM is 2KB (2048 Bytes)

If dtNBR_ALARMS allowable values is 0 to 255 MAX and
the RAM value as per the document is alarms * 11
a simple calculation using defaults (6 alarms set)
is 6 X 11 = 66 RAM (is this bytes ?? )
As you can see the documentation is not clear here
Quote

Q: How many alarms can be created?
A: Up to six alarms can be scheduled.  
The number of alarms can be changed in the TimeAlarms header file (set by the constant dtNBR_ALARMS,
note that the RAM used equals dtNBR_ALARMS  * 11)

Is this is indeed bytes the 255 X 11 = 2805 bytes

So just using an example of 1024 Bytes :
1024/11 = 93 alarms

Now lets say I want a device (yes a device can be anything that requires and on and off pulse.. strecth your mind here ...anything !!)
and this so called device is assigned a device ID (let's call this devID)
and each devID is assigned a number (as one probably would if you have lots of devices) like 465 (in other words LED number 465).

So devID 465
has:
an ON/START alarm
and OFF/END alarm


So to sum up each devID has two alarms linked/associated with it

(NOTE*** if we stretch our mind a little then a single device could have multiple alarms and patterns and delay patterns associated.)

So assuming on two alarms for each instance of devID the equation renders the following if 0 counts:
0-255 (256) /2 = 128 devices Max

and according to documentation the ram requirement for this is
128*11 = 1408 Bytes (? if this is bytes)

To be on the close to the 1024KB arduino UNO limit then a safe figure is 93 alarms
BUT
This does not take possible extra flags into operation.
We might need to flag an alarm to see if it is valid now after a power failure, not so ?

Of course if you are using a separate EEPROM then you could grow the max devices to to the MAX of 255.

So as per this document :
http://arduino.cc/en/Tutorial/Memory
We see that :
Quote

If you have look-up tables or other large arrays, use the smallest data type necessary to store the values you need; for example, an int takes up two bytes, while a byte uses only one (but can store a smaller range of values).
If you don't need to modify the strings or data while your sketch is running, you can store them in flash (program) memory instead of SRAM; to do this, use the PROGMEM keyword.



So going back to one of my earlier questions:
Quote

1.
I would like to assign a start and end time to each device using its deviceID.
What would be the correct(or a nice)  way to assign both an start and end time to each

single deviceID.


What is the correct/nice/most appropriate C/C++/C#/Arduino way to do this this ?
And before you answer, I would appreciate a stub of code to explain this or pseudo code to get me started or a pointer to an example coupled with an explanation of this if you wouldn't mind please.
I am not asking you to write my code for me I just want to be able to understand how and what the best method is.

@PaulS

Thanks for the replies and the first reply does add clarity to my earlier questions where I seem to have added a little fuzz into devID and the actual alarm, but later also refers to directly after create and not just after triggering ?
I would like to know how to reference the alarms after creating them.

Quote

2.
How does once store the alarm ID's so you can reference them later. (I remember seeing a post

answered by PaulS somewhere in the last few days/weeks about this very same question but for

the life of me I can't remember the topic to search on.


Quote


You could store a copy of the object in EEPROM. But, it makes no sense to do that. You can't recreate an object in memory just by reading some bytes from EEPROM.

Yes I agree

So yes I need to store the start and end dates for each  alarm ID in EEPROM and link those to the devID 465.
I have seen examples storing data into the EEPROM and retrieving it on the guides.
But what do I to (or how do I )make the link between devID and Alarm ID ?


Quote

Now, storing and retrieving the time that an alarm is supposed to go off might make sense.


Assuming that devID has two alarms associated with it , how do you do this in one foul swoop ?

So in conclusion...

How do I go about creating the link between a devID (which already exists for example devID 465) and the alarm ID's (assuming there are two alarm ID's for each devID ?

Is it an array ?

If I create something like this as a start (and please forgive my programming mistakes):
Code: [Select]

byte devID[128] =
OR
int devID[128] =


This could/would store the devID to two alarm ID's which in turn may or may not be stored in EEPROM not so ?
So devID needs to equal 2 alarm ID's
How do I link each devID with each devID ?

Would I be totally off the mark by thinking along these lines ?:
Code: [Select]

int alarmID = 1;//col
int stenAlarm = 2;//row
int[][] myArray = new int[alarmID][sten_alarm];

 
// For every alarmID i, for every start end alarm visit every row J.
for (int i = 0; i < alarmID; i++) {
 for (int j = 0; j < stenAlarm; j++) {
   myArray[i][j] = 0;
 }
}


May work but how would I link the devID to the alarmID ?

Here's what I have in mind in pseudo code:

receive a devID (example here is 465)
create a start alarm, store it in arduino EEPROM and link this Alarm ID to the devID
create and end alarm, store it in arduino EEPROM and link this Alarm ID to the devID
Store each alarm time in EEPROM

I understand that devID should always link to two alarm ID's and each Alarm ID points to the time and date.

I also understand that devID 465 may point to Alarm ID 5 and 70.

So how do I keep this mapping correct ?

I also read that alarms can be reset or freed.

Please can somebody shed some light or assist me

Regards

JOE4444

PaulS

Quote
As you can see the documentation is not clear here

It's clear to me. Memory usage is ALWAYS expressed in bytes.

Quote
To be on the close to the 1024KB arduino UNO limit then a safe figure is 93 alarms

There are no Arduinos with 1024 kilobytes of memory, of any kind.

Don't plan on using all of your memory on alarms. You also need to store device IDs and plenty of other stuff.

Quote
But what do I to (or how do I )make the link between devID and Alarm ID ?

Use two arrays. When an alarm goes off, get it's ID. Find that ID in the alarm ID array. The value in the correspond position of the other array is the device ID.

Quote
How do I link each devID with each devID ?

Pretty easy, really. What was your real question?

I'm thinking that you should have a struct, containing a device ID, two alarm IDs, and whatever other data you need - maybe a pin number or ?.

Quote
Would I be totally off the mark by thinking along these lines ?:

Absolutely. It makes not sense to dynamically define a statically sized array. And, this is NOT C#.

Quote
receive a devID (example here is 465)

From where?

Code: [Select]
create a start alarm, store it in arduino EEPROM and link this Alarm ID to the devID
Forget the notion of storing the Alarm object in EEPROM. Storing the alarm TIME makes sense. Storing the Alarm object does NOT.

The art of getting good answers lies in asking good questions.

joe4444

#334
Sep 28, 2014, 03:37 am Last Edit: Sep 28, 2014, 03:42 am by joe4444 Reason: 1
@PaulS

Quote
There are no Arduinos with 1024 kilobytes of memory, of any kind

Can you shed some light on this one ??
http://arduino.cc/en/Main/arduinoBoardUno
As per the spec ...
Quote
Flash Memory   32 KB (ATmega328) of which 0.5 KB used by bootloader
SRAM   2 KB (ATmega328)
EEPROM   1 KB (ATmega328)


Quote
It's clear to me. Memory usage is ALWAYS expressed in bytes.

All clear ..at least some clarification to say the least!
Thanks

Quote
Use two arrays. When an alarm goes off, get it's ID. Find that ID in the alarm ID array. The value in the correspond position of the other array is the device ID.


Why when the alarm goes off ??
I don't think you understand that I would like to catch the ID when the alarm is created for the start alarm and then catch the alarm ID of the end alarm and somehow link that to to what have called call a (device ID) devID. (See earlier posts(s))
You have asked me what the device is..I have given clarification in my previous posts.
What is not still clear to you ?

Quote

Don't plan on using all of your memory on alarms. You also need to store device IDs and plenty of other stuff.

Yes agreed ..thanks again !
So if you have read my last post what would be a safe number of alarms to create considering that each device ID (devID) would require two alarms namely a start and end alarm ?

Quote

Use two arrays. When an alarm goes off, get it's ID. Find that ID in the alarm ID array. The value in the correspond position of the other array is the device ID.

Could you possibly elaborate here regarding the correspond position ?

Quote

How do I link each devID with each devID ?
Pretty easy, really. What was your real question?


I think a typo by me here ...sorry , it is meant to read as
How do I link each devID with each alarm ID ?
Does that help ?

Quote

I'm thinking that you should have a struct, containing a device ID, two alarm IDs, and whatever other data you need - maybe a pin number or ?.


AAH :-) thank you (I'm starting to see a little little light at last) , so this would allow me to enter and store the devID and start and end alarm ID's in the format they need to be in ?

Quote
Absolutely. It makes not sense to dynamically define a statically sized array. And, this is NOT C#

So a 2D array is not the better method then ?
And you're right , this is not C# (or processing) but this is hobbyist(not so sharp)
:-)

Quote
receive a devID (example here is 465)
From where?


At the moment serial is the easiest to test with  OR I can pre-populate the variable as devID 465 OR it can be keypad or from anywhere I suppose.
But right now it's from serial console...
Does that help ?

Quote

create a start alarm, store it in arduino EEPROM and link this Alarm ID to the devID

Forget the notion of storing the Alarm object in EEPROM. Storing the alarm TIME makes sense. Storing the Alarm object does NOT.]


OK EEPROM alarm object is a no no then ... TIME is what should be stored in the EEPROM  ..agreed !
And those times are the time from the startalarm object and the time from from the end time object.
Going back to the earlier post , each devID should have both a start and end time.
That means that devID 465 has two alarm OBEJCTS namely a startalarm OBJECT and an endalarm OBJECT and each OBECJT has a time attached.
So as i mentioned in the earlier post  :
Quote

So devID 465
has:
an ON/START alarm
and OFF/END alarm


So to sum up each devID has two alarms linked/associated with it



To be inline with your statement and naming convention I guess true and correct with the timealarms library then:
devID 465
has:
an ON/START alarm OBJECT which has a set time
and OFF/END alarm OBJECT which has a set time

To sum up, each devID has two alarms linked/associated with it.

So if I'm finally getting the logic right here, I need :
1.
Two arrays
alarmID[] and devID[]
BUT that's why I thought using a 2D array here because each devID has two alarm ID's
With a 2D array the reference would be something like devid465 and alarmID [12] and alarmID [13]
@PaulS
What did you have in mind here ?
2.
a Struct for devID and two alarmID OBJECTS and a pin  
@PaulS
What was your intention for the use of the struct exactly ? Is it so I can reference the devID and two alarmID's as a single object from one of the arrays ?


Look forward to your replies (and anyone elses too)

Thanks again

Kind regards
JOE4444





bperrybap

#335
Sep 28, 2014, 07:12 am Last Edit: Sep 28, 2014, 07:14 am by bperrybap Reason: 1

@PaulS
Quote
There are no Arduinos with 1024 kilobytes of memory, of any kind

Can you shed some light on this one ??
http://arduino.cc/en/Main/arduinoBoardUno
As per the spec ...
Quote
Flash Memory   32 KB (ATmega328) of which 0.5 KB used by bootloader
SRAM   2 KB (ATmega328)



1 KB is not the same as 1024 kilobytes.
(Well not unless you do math like Verizon):  http://www.youtube.com/watch?v=zN9LZ3ojnxY
Units matter.
1024 kilobytes is 1MB.



PaulS

Quote
Why when the alarm goes off ??

You have 42 alarm clocks in your bedroom. Does it matter what they are for when they are all quiet? When one goes off, and wakes you up, does it matter which one needs to STFU?

Quote
I don't think you understand that I would like to catch the ID when the alarm is created for the start alarm and then catch the alarm ID of the end alarm and somehow link that to to what have called call a (device ID) devID. (See earlier posts(s))

I understand that. When you create the alarm, it tells you the alarm ID. The alarm hasn't a clue why you set it. That only matters to you.

Of course you need to record the alarm IDs when you create them. Since the alarm IDs have some relation to other things, you need to record that relationship when the alarms are created.

I assumed that you were asking about how to determine the device the alarm is for when the alarm goes activate. THAT is when it matters.

Quote
What was your intention for the use of the struct exactly ? Is it so I can reference the devID and two alarmID's as a single object from one of the arrays ?

Yes. It's still not clear what you intend to do when an alarm goes off. Looking through the array of structs to see if this alarm if the start alarm or the end alarm for the device at this position will let you determine the device. But, then what? Clearly (to me at least), the Arduino should actually do something when the alarm goes off. It should turn a pin on or off. It should display a message somewhere. It should do something.

The information needed to do whatever needs to be done could be stored in the struct, too, keeping all the related data together in one data structure.
The art of getting good answers lies in asking good questions.

AdaptTech

I'm using Ubuntu 14.04 LTS and Arduino IDE 1.0.5, and while using the Time library I get this errors:

Quote

In file included from /home/adapttech/sketchbook/libraries/Time/DateStrings.cpp:11:0:
/home/adapttech/sketchbook/libraries/Time/DateStrings.cpp:41:22: error: variable 'monthNames_P' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
PGM_P monthNames_P[] PROGMEM =
                      ^
/home/adapttech/sketchbook/libraries/Time/DateStrings.cpp:58:20: error: variable 'dayNames_P' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
PGM_P dayNames_P[] PROGMEM = { dayStr0,dayStr1,dayStr2,dayStr3,dayStr4,dayStr5,dayStr6,dayStr7};
                    ^
/home/adapttech/sketchbook/libraries/Time/DateStrings.cpp: In function 'const char* monthStr(uint8_t)':
/home/adapttech/sketchbook/libraries/Time/DateStrings.cpp:63:35: error: new declaration 'const char* monthStr(uint8_t)'
const char* monthStr(uint8_t month)
                                   ^
In file included from /home/adapttech/sketchbook/libraries/Time/DateStrings.cpp:21:0:
/home/adapttech/sketchbook/libraries/Time/Time.h:127:7: error: ambiguates old declaration 'char* monthStr(uint8_t)'
char* monthStr(uint8_t month);
       ^
/home/adapttech/sketchbook/libraries/Time/DateStrings.cpp: In function 'const char* monthShortStr(uint8_t)':
/home/adapttech/sketchbook/libraries/Time/DateStrings.cpp:69:40: error: new declaration 'const char* monthShortStr(uint8_t)'
const char* monthShortStr(uint8_t month)
                                        ^
In file included from /home/adapttech/sketchbook/libraries/Time/DateStrings.cpp:21:0:
/home/adapttech/sketchbook/libraries/Time/Time.h:129:7: error: ambiguates old declaration 'char* monthShortStr(uint8_t)'
char* monthShortStr(uint8_t month);
       ^
/home/adapttech/sketchbook/libraries/Time/DateStrings.cpp: In function 'const char* dayStr(uint8_t)':
/home/adapttech/sketchbook/libraries/Time/DateStrings.cpp:77:31: error: new declaration 'const char* dayStr(uint8_t)'
const char* dayStr(uint8_t day)
                               ^
In file included from /home/adapttech/sketchbook/libraries/Time/DateStrings.cpp:21:0:
/home/adapttech/sketchbook/libraries/Time/Time.h:128:7: error: ambiguates old declaration 'char* dayStr(uint8_t)'
char* dayStr(uint8_t day);
       ^
/home/adapttech/sketchbook/libraries/Time/DateStrings.cpp: In function 'const char* dayShortStr(uint8_t)':
/home/adapttech/sketchbook/libraries/Time/DateStrings.cpp:83:36: error: new declaration 'const char* dayShortStr(uint8_t)'
const char* dayShortStr(uint8_t day)
                                    ^
In file included from /home/adapttech/sketchbook/libraries/Time/DateStrings.cpp:21:0:
/home/adapttech/sketchbook/libraries/Time/Time.h:130:7: error: ambiguates old declaration 'char* dayShortStr(uint8_t)'
char* dayShortStr(uint8_t day);




I know for sure my code is alright (this compiles perfectly on Windows), and I've been looking around for answer in the Internet over a week.  Everybody seems to have a suggestion to downgrade gcc-avr, and some other people talk about manually changing the TimeStrings.cpp file.   All of these suggestions are dated a while ago, so, is there any new way to treat this problem?

bperrybap


I know for sure my code is alright (this compiles perfectly on Windows), ...

Not so fast.
Just because it compiles does not mean it is "alright".
The proprietary AVR libC progmem kludge macros that are used to put const data in flash
could be used incorrectly and still work with the older versions of the compiler.
My guess is that you are using a newer version of the compiler on Ubuntu than on Windows.
The newer version of the compiler no longer accepts many of the incorrect declarations
that were being used.
The good news is that if the declarations are done correctly, it works on the newer
version of the compiler as well as older versions of the compiler.

I have no idea which version of the Time library you are using (there are several floating around out there)
or where you got it but it is not properly declaring the progmem data.
While it "works" on older compilers it will not work on the newer compiler.
These incorrect/bad declarations have been being used for quite some time and there are MANY other
libraries that are having issues.
Even the examples for how to use progmem on the Arduino site
are wrong which adds to the problems.
I contacted Michael (the original author) a while back about this.
He updated the library with fixes for this, but you apparently don't have a version with those fixes.
It also appears that the zip file on Pauls Teensy site also does not have these fixes.

The declarations in DateString.cpp you have are:
Code: [Select]

PGM_P  monthNames_P[] PROGMEM =

Code: [Select]
PGM_P  dayNames_P[] PROGMEM =

And they need to be:
Code: [Select]
PGM_P const monthNames_P[] PROGMEM =
Code: [Select]

PGM_P const dayNames_P[] PROGMEM =


You will need to edit the file to correct these declarations.
Once corrected, it should work on the new and the old compilers.

--- bill

AdaptTech

Hello Bill,

Thank you for your answer.

I did what you told me, but now this is what I get:



This is my DateStrings.cpp file:

Code: [Select]

/* DateStrings.cpp
* Definitions for date strings for use with the Time library
*
* No memory is consumed in the sketch if your code does not call any of the string methods
* You can change the text of the strings, make sure the short strings are each exactly 3 characters
* the long strings can be any length up to the constant dt_MAX_STRING_LEN defined in Time.h
*
*/

#if defined(__AVR__)
#include <avr/pgmspace.h>
#else
// for compatiblity with Arduino Due and Teensy 3.0 and maybe others?
#define PROGMEM
#define PGM_P  const char *
#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
#define pgm_read_word(addr) (*(const unsigned char **)(addr))
#define strcpy_P(dest, src) strcpy((dest), (src))
#endif
#include <string.h> // for strcpy_P or strcpy
#include "Time.h"

// the short strings for each day or month must be exactly dt_SHORT_STR_LEN
#define dt_SHORT_STR_LEN  3 // the length of short strings

static char buffer[dt_MAX_STRING_LEN+1];  // must be big enough for longest string and the terminating null

const char monthStr1[] PROGMEM = "January";
const char monthStr2[] PROGMEM = "February";
const char monthStr3[] PROGMEM = "March";
const char monthStr4[] PROGMEM = "April";
const char monthStr5[] PROGMEM = "May";
const char monthStr6[] PROGMEM = "June";
const char monthStr7[] PROGMEM = "July";
const char monthStr8[] PROGMEM = "August";
const char monthStr9[] PROGMEM = "September";
const char monthStr10[] PROGMEM = "October";
const char monthStr11[] PROGMEM = "November";
const char monthStr12[] PROGMEM = "December";

PGM_P const monthNames_P[] PROGMEM =
{
    "",monthStr1,monthStr2,monthStr3,monthStr4,monthStr5,monthStr6,
monthStr7,monthStr8,monthStr9,monthStr10,monthStr11,monthStr12
};

const char monthShortNames_P[] PROGMEM = "ErrJanFebMarAprMayJunJulAugSepOctNovDec";

const char dayStr0[] PROGMEM = "Err";
const char dayStr1[] PROGMEM = "Sunday";
const char dayStr2[] PROGMEM = "Monday";
const char dayStr3[] PROGMEM = "Tuesday";
const char dayStr4[] PROGMEM = "Wednesday";
const char dayStr5[] PROGMEM = "Thursday";
const char dayStr6[] PROGMEM = "Friday";
const char dayStr7[] PROGMEM = "Saturday";

PGM_P const dayNames_P[] PROGMEM = { dayStr0,dayStr1,dayStr2,dayStr3,dayStr4,dayStr5,dayStr6,dayStr7};
char const dayShortNames_P[] PROGMEM = "ErrSunMonTueWedThrFriSat";

/* functions to return date strings */

char* monthStr(uint8_t month)
{
    strcpy_P(buffer, (PGM_P)pgm_read_word(&(monthNames_P[month])));
return buffer;
}

char* monthShortStr(uint8_t month)
{
   for (int i=0; i < dt_SHORT_STR_LEN; i++)     
      buffer[i] = pgm_read_byte(&(monthShortNames_P[i+ (month*dt_SHORT_STR_LEN)])); 
   buffer[dt_SHORT_STR_LEN] = 0;
   return buffer;
}

char* dayStr(uint8_t day)
{
   strcpy_P(buffer, (PGM_P)pgm_read_word(&(dayNames_P[day])));
   return buffer;
}

char* dayShortStr(uint8_t day)
{
   uint8_t index = day*dt_SHORT_STR_LEN;
   for (int i=0; i < dt_SHORT_STR_LEN; i++)     
      buffer[i] = pgm_read_byte(&(dayShortNames_P[index + i])); 
   buffer[dt_SHORT_STR_LEN] = 0;
   return buffer;
}


After running with this file, I get the following errors:

Quote


In file included from /home/adapttech/sketchbook/libraries/Time/DateStrings(fresh original).cpp:11:0:
/home/adapttech/sketchbook/libraries/Time/DateStrings(fresh original).cpp:41:22: error: variable 'monthNames_P' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
PGM_P monthNames_P[] PROGMEM =
                      ^
/home/adapttech/sketchbook/libraries/Time/DateStrings(fresh original).cpp:58:20: error: variable 'dayNames_P' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
PGM_P dayNames_P[] PROGMEM = { dayStr0,dayStr1,dayStr2,dayStr3,dayStr4,dayStr5,dayStr6,dayStr7};
                    ^
/home/adapttech/sketchbook/libraries/Time/DateStrings(fresh original).cpp:59:24: error: variable 'dayShortNames_P' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
char dayShortNames_P[] PROGMEM = "ErrSunMonTueWedThrFriSat";
                        ^
[\quote]

It seems I still have something wrong with the declarations.  I downloaded the [/b]Time[/b] library from here: http://www.pjrc.com/teensy/td_libs_Time.html


AdaptTech

Hello all,

It seems I have finally found the problem (special thanks to Bill for pointing me in the right direction).

The latest code for the StringNames.cpp file (as of the day of this post)  is available here: https://github.com/PaulStoffregen/Time/blob/master/DateStrings.cpp

The changes are:

Code: [Select]
const PROGMEM char * const PROGMEM dayNames_P[] =

And you need to remover all files named somewhat like `StringNames` from the`Time` folder (I left one name "Stringames (fresh original").cpp) .

Thanks a lot guys!

bperrybap

AdapTech,
Any time you mix files and changes from different libraries there can be issues.
The modification I gave was not quite enough to fix the files you had, there was one
more line that needed to be fixed.
As far as grabbing files from the git hub repo, it is best to grab all the files
from the master trunk or at least verify that there are no additional updates
to ensure you get all the files as a complete snapshot.

Are you perhaps using DUE / Teensy 3 ?

I don't fully agree with the way Paul has mapped the PROGMEM stuff and the declarations in that file.
Paul and I have discussed the PROGMEM mapping defines and its related issues in the past.
Some of the declarations in that file are mixing & matching their use of the progmem macros so
their use is a bit inconsistent.
While it might work for both AVR and ARM, there are few declarations that inconsistent.
With this type of stuff, depending on how it is used in declarations, it can end up using
additional RAM.
While it looks like it should work in this case at least for the non AVR processors,
I have not tested / verified that the way they have done it works on all the processors and
ensures no additional RAM overhead.

--- bill

AdaptTech

Hi Bill,

No, I'm using the Arduino UNO.

I hope this could be fix in a later version :).

Thanks again!

glitchsniffer

Ok, so as far as I can tell I have everything working correctly, except changing the time on the alarm.  I can change the time, read out the time and everything works fire.  Except that it doesn't work until I reset the Arduino.  After I do the Alarm.write, I do an Alarm.disable, but it doesn't change the time till the next time it triggers.  Here are my code for writing the alarm after I change it.

Code: [Select]
Alarm.write(AlarmIDOn_0, AlarmHMS(AlarmHourOn_0, AlarmMinOn_0, 0));
Alarm.enable(AlarmIDOn_0);


When I do a Alarm.read right after this, It reads out the correct time, it just doesn't trigger the next time.

Is there anything I'm missing here?  I'm just trying to turn a light on and off on a timer.

Any help would be appreciated.

Clemens

I read this old thread (read only) about the TimeAlarm lib http://forum.arduino.cc/index.php?topic=37693.0 and want to come back to the third posting. ;-)

Quote
Can arduino be put to sleep ...
I phrased it a bit more in detail in this post http://forum.arduino.cc/index.php?topic=291983.0

So the question is still how can we bring the Arduino in sleep as long we are waiting for the next triggered event?

Narcoleptic has a kind of timekeeping function, so it should be possible in theory, but my knowledge about lib programming is not so waterproof to do it on my own. Can someone jump in?

For the meantime this workaround could be possible:
- In case you want to sleep the Arduino check in which time intervall the next event will be,
- sent the Arduino to sleep via Narcoleptic for this intervall minus some ms
- after waking up adjust the time via the millis Narcoleptic has logged and let TimeAlarm work.

But is there a function when the next event is scheduled? E.g. next event in 15678 Sekunds or today 11:15:00 ??

Go Up