@bko and anyone else. I’m getting a compile error with this library as automatically imported in the web IDE. If I comment out the include line, it compiles perfectly. I haven’t even tried to set up any alarms yet, just include and hit compile. The following is the tail of the error log. Please let me know if you need more:
^
In file included from doorbell.cpp:2:0:
doorbell.cpp: In function 'void setup()':
TimeAlarms/TimeAlarms.h:14:15: error: expected unqualified-id before '(' token
#define now() (Time.now()+time_zone_cache)
^
doorbell.cpp:55:38: note: in expansion of macro 'now'
digitalWrite(doorbellPin, LOW);
^
doorbell.cpp: In function 'void processSchedule()':
doorbell.cpp:143:52: warning: NULL used in arithmetic [-Wpointer-arith]
}
^
In file included from doorbell.cpp:2:0:
TimeAlarms/TimeAlarms.h:14:15: error: expected unqualified-id before '(' token
#define now() (Time.now()+time_zone_cache)
^
doorbell.cpp:147:60: note: in expansion of macro 'now'
void processSchedule() {
^
doorbell.cpp:145:13: warning: unused variable 'workingTime' [-Wunused-variable]
^
make: *** [doorbell.o] Error 1
Error: Could not compile. Please review your code.
I would like to use this, as apparently writing a recurring scheduler from scratch is hard indeed, and I can probably use this without a problem. Thanks for taking a look.
EDIT: If I comment out all calls to Time.now() this compiles fine. Which Time library must I use, if not the one provided in the core of spark?
EDIT 2: (Workaround) If I rename all instances of Time.now() to just now() it seems to compile fine, flash fine, and the code seems to work. This is nice and all, but it breaks the convention of using Time.now() doesn’t it?
EDIT 3: So I may have figured out the problem with now() vs Time.now(). I don’t know how to solve it, unfortunately, but this can help someone that does know how:
This exists in TimeAlarms.h:
extern time_t time_zone_cache; // from spark_wiring_time.cpp
#define now() (Time.now()+time_zone_cache)
So in my ino file, when I type:
Time.now()
it is getting replaced in the compiler with:
Time.(Time.now()+time_zone_cache)
Because Time class has no (Time.now()+time_zone_cache) method (even if it did, that syntax is invalid), it gives a compiler error and refuses to compile.
By replacing all references of Time.now() with just now() I get a compiling program, but the times are all whacky. For instance, when I call Time.zone(-5) to set my timezone to central time, the spark reports the time as 20:41 when in fact it is 01:41.
Anyone have an idea? Am I doing this wrong, or is there a bug in the library?