Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: TimeLib now()

  1. #1
    Junior Member
    Join Date
    Jan 2015
    Posts
    6

    TimeLib now()

    I originally believed that the timeStatus() would return timeNeedsSync if the time since the last sync was longer than the syncInterval. I wrote my code to check the return value of timeStatus() when the GPS received a valid time and if the returned value was not timeSet, it would call setTime to set the time. I believe this is better than pointing to a function to update the time as it is possible that the GPS does not have a valid time. If the time is invalid, what should the function pointed to by the getTimePtr pointer return?

    I found that the timeStatus() only returns timeNeedsSync if the getTimePtr pointer is set. I rewrote the now() method so that the Status is set to timeNeedsSync regardless if the pointer to the set time function is set or not. I think it is more useful this way. I will fork the code, check in the changes, and do a pull request. If Paul believes the change will be useful for others that would be great. If I'm missing something and there is a better way to point to a setter function using GPS, I'm willing to learn. I did look at the TimeGPS example but it did not make use of setSyncProvider or timeStatus.

    On a separate note, I get a strange error on line 70 of TimeLib.h. I will get that sorted out but it is strange and does not make sense. I comment out that line and all is fine.
    Code:
    In file included from C:\Users\richt\AppData\Local\Temp\arduino_build_546908\sketch\SD_Card.h:6:0,
                     from D:\Users\richt\OneDrive\Documents\Projects\PocketGPS\sketch_sep11b_gps\sketch_sep11b_gps.ino:2:
    C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Time/TimeLib.h:70:32: error: expected ')' before '(' token
     #define DAYS_PER_WEEK ((time_t)(7UL))
                                    ^
    D:\Users\richt\OneDrive\Documents\Arduino\libraries\NeoGPS\src/NeoTime.h:44:16: note: in expansion of macro 'DAYS_PER_WEEK'
     const uint8_t  DAYS_PER_WEEK      = 7;
                    ^~~~~~~~~~~~~
    Error compiling for board Teensy 2.0.

  2. #2
    Member
    Join Date
    Aug 2018
    Location
    Brisbane, Australia
    Posts
    79
    After expanding the macro, the problem line is
    Code:
    const uint8_t  ((time_t)(7UL))      = 7;
    which is obviously bogus. I agree that the error message does not make sense.

  3. #3
    Junior Member
    Join Date
    Jan 2015
    Posts
    6
    Yes, I think I have done something else in my code that is causing the error. I just created an example with my changes at https://github.com/richteel/Time. The example TimeGPS_Neo does not cause the error. It may be possible that something else in the display library or SD library is causing the issue. I'll get it sorted eventually.

    UPDATE: I just reread my post and it is obvious that NeoGPS is causing an issue. I saw an issue in TimeLib listed about a conflict with NeoGPS. I'll have to go back and read the issue.

  4. #4

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •