new widget: Adjust Clock (BETA)

Posted on
  • I'm making a widget which adjusts Bangle.js 2 clock continually in the background to counter clock drift.

    Widget doesn't attempt to determine clock drift in anyway. You need to measure clock drift yourself and then enter that value to the widget.

    Beta version is available from my app loader for now as this still needs more testing before adding to main app loader.

    I'll also publish source a bit later in GitHub as there are still few things I want to fix first. Of course code is available in my app loader (widget.js) if you want to see it. (Code includes some initial support for temperature correction but that isn't enabled yet.)

    ps. Update interval setting doesn't do anything yet, interval is currently fixed to 10 seconds. That is the next bug I'll fix. (EDIT: Fixed in version v0.00-beta-018)

  • Basic logic of how this widget reaches under 10 ms accuracy with setTime (in version v0.00-beta-026):

    • Internal clock error counter is updated periodically according to given clock drift.
    • If clock error exceeds given threshold then clock update is attempted.
    • setTime can only set time to full seconds. To set time more accurately
      a short delay is done until next full second, and then setTime is used.
    • Sometimes this delay can be longer than intented, e.g. if watch is
      busy doing something else. In this case setTime after too long delay
      would be inaccurate and so it is skipped and retried again later.
  • To others: I am testing this widget. It is working well.

  • @malaire just to add you mention:

    setTime can only set time to full seconds

    But it actually works to 1/32768 second. Even so, reducing the amount of times you call it is probably good practice since it'll affect when timers get called

  • But the documentation of setTime says that

    Set the current system time in seconds (to the nearest second).

    i.e. it discards fractional part of the given value and only uses integer seconds

  • oh wow, looks like documentation is completely wrong and setTime actually does set fractional seconds also - this completely changes how this widget should use setTime.

    I didn't even think of testing this before as I trusted documentation.

  • I'll update the docs for the next release. Generally the docs are fine but occasionally they do end up out of date, which I think is what must have happened here.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

new widget: Adjust Clock (BETA)

Posted by Avatar for malaire @malaire