Hello Paul Stoffregen,
I have tested your version of Time and it's remotely to be ported for Due. Actually I already did the time_t variable name change, but that is not the only thing that need to be modified (I did it as bperrybap suggest thought).
#include <machine/types.h>
#ifndef __time_t_defined
//typedef unsigned long time_t; // original library typedef.
typedef _TIME_T_ time_t;
#define __time_t_defined
#endif
After that I have been through several compiling errors I would like to bring them here.
First with setTime function, it seems that overloading that function bothers the compiler
previous declaration 'void setTime(atime_t)' here
I decide to remove (comment out) the version with more arguments as you can use the makeTime to have time_t from individual values.
I also have to remove from Time Folder the file DateStrings.cpp.
After all that I make a simple test file like this
#include <Wire.h>
#include <Time.h>
void setup() {
Wire.begin();
Serial.begin(9600);
Serial.println("setup RTC test");
tmElements_t t;
t.Second = 0;
t.Minute = 30;
t.Hour = 19;
t.Wday = 3;
t.Day = 16;
t.Month = 1;
t.Year = y2kYearToTm(13);
Serial.println("setup makeTime");
makeTime(t);
// setTime(makeTime(t));
Serial.println("how come ");
}
void loop()
{
digitalClockDisplay();
delay(1000);
}
void digitalClockDisplay(){
// digital clock display of the time
time_t t = now();
Serial.print(hour(t));
printDigits(minute(t));
printDigits(second(t));
Serial.print(" ");
Serial.print(day(t));
Serial.print(" ");
Serial.print(month(t));
Serial.print(" ");
Serial.print(year(t));
Serial.println();
}
void printDigits(int digits){
// utility function for digital clock display: prints preceding colon and leading 0
Serial.print(":");
if(digits < 10)
Serial.print('0');
Serial.print(digits);
}
the good thing is that it compiles but the bad is that a warning appears
test_time.cpp.o: In function setup':* *C:\...\arduino-1.5.1r2/test_time.ino:24: warning: undefined reference to
makeTime(tmElements_t&)'
Binary sketch size: 25,856 bytes (of a 524,288 byte maximum)
I recently discover that if you put the Time.h include at the beginning of the import section it produces the above error and the Due hangs before it can print "how come".
If you put any other import before Time.h it compiles cleanly and run without problems.
Maybe it have to do with
Then the STUPID IDE also has an issue that rears it ugly head again that breaks this.
The IDE inserts its prologue which includes
Code:
#include "Arduino.h"
in the middle of the sketch .cpp file so it ends up after the
Code:
#include <Time.h>
So the system version of time_t doesn't get typed before the library Time.h looks at the define.
You have to insert some dummy code to coerce the silly IDE to put the prologue at the top of the .cpp file
I added this to the example sketch:
Code:
int dummy = 0;
right at the top of the sketch.
I found another issue, in file Time.h the line
typedef time_t(*getExternalTime)();
should be
typedef time_t(*getExternalTime)(void);
Best,