Argument order of time.ticks_diff()
-
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
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