Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Argument order of time.ticks_diff()

    Scheduled Pinned Locked Moved Discussion
    ticksdiffv1.20.0rcx
    1 Posts 1 Posters 236 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • robert-hhR Offline
      robert-hh
      last edited by robert-hh

      The release candidate branch of the firmware implements a silent change of time.ticks_diff() since Nov 8, 2018. The argument order has been swapped. it is now time.ticks_diff(new, old). That is good and bad.

      Good, in that it matches what the uasyncio library expects and
      Good in that it is now compatible with the micropython.org branch.
      Bad, since existing code for the Pycom devices which make use of this call now breaks.

      Code can be made resilient to that order, e.g by using:

      # get the sign of ticks_diff, e.g. in init code.
      ticks_sign = time.ticks_diff(1, 2)
      # and later in the code, when using ticks_diff:
      elapsed_ticks = time.ticks_diff(time1, time2)  * ticks_sign
      
      1 Reply Last reply Reply Quote 4

      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

      With your input, this post could be even better 💗

      Register Login
      • 1 / 1
      • First post
        Last post

      Pycom on Twitter

      Pycom