Pages: [1]   Go Down
Author Topic: Everything for time missing from avr-libc  (Read 947 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 1
Posts: 48
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You may (or may not have) noticed that everything for time missing from avr-libc.
Who made this wonderful decision?
In any case, I have a complete compatible fix.
https://github.com/xxxajk/RTClib
It wasn't really rocket science to add it in, but why is something so fundamental missing?
What if, for example, I wanted to attach a telescope and have it controlled?
This is yet another one of those decisions that don't make any sense.

Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 135
Posts: 6763
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Presumably the avr-libc folks (who are different from the Arduino folks, BTW) didn't include the (posix) time functions because a bare avr doesn't have inherent RTC capabilities.

If I happen to need the phase of the moon, I'm sure I'll be happy to compile the 40+ files in your addition, vs the 1 file in the original jeelabs RTCLIB...
Logged

0
Offline Offline
Edison Member
*
Karma: 64
Posts: 1639
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Presumably the avr-libc folks (who are different from the Arduino folks, BTW) didn't include the (posix) time functions because a bare avr doesn't have inherent RTC capabilities.
These files are being committed to a future version of avr-libc!    http://lists.nongnu.org/archive/html/avr-libc-commit/2013-03/msg00010.html

Much of the code is extremely inefficient on avr and better date algorithms were published over 100 years ago. Zeller's congruence was published in 1882.  Many of the classic data/time algorithms have efficient implementations on avr and other small processors and should be used in a time library.

Quote
If I happen to need the phase of the moon, I'm sure I'll be happy to compile the 40+ files in your addition
This version is not very useful but moon_phase is simple and might work.  There is not good support for time zones and DST.  You need lat/long for many of the functions and there is no interface to set these.

The included version of RTClib is out of date and is not compatible with the JeeLabs version.

For example JeeLabs version:
Code:
class RTC_DS1307 {
public:
    static void begin() {}

This version:
Code:
class RTC_DS1307 {
public:
    static uint8_t begin(const DateTime& dt);


Logged

0
Offline Offline
Newbie
*
Karma: 1
Posts: 29
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I was very interested in the time functions (core C functions, that is).  However, they do not appear to be working very well.  I tried to use some of the standard functions like ctime and asctime functions to convert an epoch based time to human readable text, but was getting bogus results.

For instance, using the epoch for today, I was generating dates in the year 2043!

I was able to use [basically] the same code and compile against gcc to test my implementation of the functions and was getting the correct output in Linux.
Logged

Pages: [1]   Go Up
Jump to: