Naguissa / uRTCLib

Really tiny library to basic RTC functionality on Arduino. DS1307, DS3231 and DS3232 RTCs are supported.
https://www.foroelectro.net/librerias-arduino-ide-f29/rtclib-arduino-libreria-simple-y-eficaz-para-rtc-y-t95.html
GNU Lesser General Public License v3.0
87 stars 24 forks source link

Removed Warnings and added an example #11

Closed ArminJo closed 4 years ago

ArminJo commented 4 years ago

Hi Nagussia,

in uRTCLib.cpp I added a few parenthesis in alarmSet() to avoid warnings.

And since it is a wonderful library, I would like to add an example of setting date by Serial Monitor I could no find in any of the other RTC libraries or other sources. It also contains some functions for printing the date in 5 different formats (and 2 languages :-))

It would be very nice if you can merge/add this to your repository, for everyones benefit.

Best regards Armin

P.s. I was not successful to keep the original indentation with my editors, so the diff of uRTCLib.cpp is quite large. Sorry.

ArminJo commented 4 years ago

Hi, if you like I can support you with automated testing by Travis. It is quite easy, if you know how to do :-)

Naguissa commented 4 years ago

Thanks!

It seems perfect; I'll check it on some hardware tomorow and do a new release.

About Travis testing, I have it on my ToDo list, but I've still not checked anything. It seems to consist on any kind of tool integration, right? If it's the case I prefer to do it by myself, because I can apply it to all my projects in the same place.

Anyway, very thanks you!

ArminJo commented 4 years ago

Hi, thanks for merging, so I can delete my fork :-) For travis I started with https://learn.adafruit.com/the-well-automated-arduino-library/travis-ci and used their script for most of my repositories, And maybe you find this counter useful Hit Counter

Good luck Armin

Naguissa commented 4 years ago

Thanks! I was just trying it. Now I'm in my tablet, so I cannot do heavy work, but I can test this kind of things....

About the counter, I have GitHub stats, but it really dones't mind to me; I do these libraries because I need them in my (hobby) projects, and I find them useful, so I ignore about hits, usages, clones, forks... If anyone ask me anything here I try to help, but my "main" work is other.

Cheers!

Naguissa commented 4 years ago

Testing the new example it seems to fail in most platforms due to use of progmem (ssprintf_P, sscanf_P, etc). AVR supports it but most other platforms doesn't.

I'll try to reconvert to standard string before releasing; at the end, that's an example so you don't need to try so hard to reduce memory consumption....

ArminJo commented 4 years ago

I tried to use compiler switches to avoid PROGMEM for other platforms, but I did not carefully test it. Please let the AVR optimisation in it, since I use it in my robot code, and I already have 80% FLASH usage.

ArminJo commented 4 years ago

Changing line 157 to

#if defined(__AVR__)
        sscanf_P(tInputBuffer, PSTR("%2hhu %2hhu %2hhu %2hhu %2hhu %2hhu"), &tHour, &tMinute, &tSecond, &tDayOfMonth, &tMonth,
                &tYear);
#else
        sscanf(tInputBuffer, "%2hhu %2hhu %2hhu %2hhu %2hhu %2hhu", &tHour, &tMinute, &tSecond, &tDayOfMonth, &tMonth,
                &tYear);
#endif

let me compile for esp32 without errors.