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

Thread: adjustTime(number) problem when adding seconds

  1. #1
    Junior Member
    Join Date
    Jul 2020
    Location
    Netherlands
    Posts
    3

    adjustTime(number) problem when adding seconds

    As you can see, I added some test code to the existing example TimeTeensy3. With test set to HIGH you can see that the clock doesn't advance beyond 5 minutes or so.

    With test set to LOW the clock advances OKE.

    Seems that there is a problem with adjustTime?

    Click image for larger version. 

Name:	adjustTime.jpg 
Views:	16 
Size:	79.3 KB 
ID:	20834 Click image for larger version. 

Name:	setTime.jpg 
Views:	14 
Size:	82.0 KB 
ID:	20835

    >>> Added code <<<<
    boolean test=HIGH;
    if (test) {
    adjustTime(120); // Does not work beyond 5 min. when test=HIGH
    } else {
    setTime(now()+120); // Works perfect when test=LOW
    }

  2. #2
    Junior Member
    Join Date
    Jul 2020
    Location
    Netherlands
    Posts
    3
    I forgot to tell that this is done on a Teensy 3.6.

    The example sourcecode is on Github examples/TimeTeensy3/TimeTeensy3.ino

  3. #3
    Senior Member
    Join Date
    May 2017
    Posts
    106
    Hello,

    with adjusttime() you set timelib object but not the RTC on Tennsy 3.x.
    In setup() you have set syncronisation of timelib with teensy-RTC by "setSyncProvider(getTeensy3Time)". Default time for sync is 300 seconds (5 minutes). You can change this by "setSyncInterval(seconds)".
    So after 5 minutes your before adjusted time in timelib (+120) ist resyncronised with RTC an set with value of RTC.
    Bear in mind timelib and RTC are two independent objects.
    Of course you can also adjust RTC with "Teensy3Clock.set(t)".

  4. #4
    Junior Member
    Join Date
    Jul 2020
    Location
    Netherlands
    Posts
    3
    Thanks for the great and quick reply.

    That explains a lot!!

Posting Permissions

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