FR230: minimum supported timer interval

hi,
i am playing with the AccelMag sample.

the sample implements the following timer:

dataTimer.start(method(:timerCallback), 100, true);

I am writing the ms timer to the console (when i use the simulator) and to the log file (when i sideload the app):
function timerCallback() {
Sys.println(Sys.getTimer());


i have observed that in the simulator i get approximately the 100ms interval. but in the FR230 i get just 2000ms:
1002580
1004572
1006494
1008401
1010337
1012265
1014228


is this really the fastest timer i can use in a FR230? 2 seconds?
  • I seem to be able to go down to 50 ms on 920XT and 735XT for the timer, but for both I seem to get new accelerometer values only every 100 ms.
  • I have a few things that use a 1 sec timer on the 230 and work fine (some that go as fast as 250ms IIR). What might be happening is the Sys.println() for logging on the watch is taking a long time (writing to mass store is not a fast operation) and getting in the way.. Maybe you want to look at displaying what you want to see to the screen, or buffering what you want to write to the log so that you log things infrequently. Maybe just write the log after x times the timer has fired.

    To show the 1 sec works, just set the timer to 1000ms and display the current time with seconds on the screen (Ui.requestUpdate(). You'll see it change every second. Change the timer to 500ms, and display Sys.getTimer() (your eye can probably catch those changes), etc
  • I wrote this simple code to demonstrate the timer, and in this case it fires every 100ms.

    When it fires, I increment a counter and save the time in ms's

    In onUpdate(), I display count and the time between timer events. Note, in both the sim and on a real watch (a 230), it bounces around 100. I see a variation of a few ms acceptable.

    using Toybox.WatchUi as Ui;
    using Toybox.Graphics as Gfx;
    using Toybox.System as Sys;

    class timertestView extends Ui.View {

    var count=0;
    var startMS=0,nowMS=0;
    var width,height;
    var timer;

    function initialize() {
    View.initialize();
    width=Sys.getDeviceSettings().screenWidth;
    height=Sys.getDeviceSettings().screenHeight;
    startMS=Sys.getTimer();
    nowMS=startMS;
    timer= new Timer.Timer();
    timer.start( method(:onTimer), 100, true );
    }

    function onTimer() {
    count++;
    nowMS=Sys.getTimer();
    Ui.requestUpdate();
    }

    // Load your resources here
    function onLayout(dc) {
    }

    // Called when this View is brought to the foreground. Restore
    // the state of this View and prepare it to be shown. This includes
    // loading resources into memory.
    function onShow() {
    }

    // Update the view
    function onUpdate(dc) {
    dc.setColor(Gfx.COLOR_BLACK,Gfx.COLOR_BLACK);
    dc.clear();
    dc.setColor(Gfx.COLOR_WHITE,Gfx.COLOR_TRANSPARENT);

    dc.drawText(width/2,30,Gfx.FONT_SMALL,""+count,Gfx.TEXT_JUSTIFY_CENTER);
    dc.drawText(width/2,60,Gfx.FONT_SMALL,""+(nowMS-startMS),Gfx.TEXT_JUSTIFY_CENTER);
    startMS=nowMS;

    }

    // Called when this View is removed from the screen. Save the
    // state of this View here. This includes freeing resources from
    // memory.
    function onHide() {
    }

    }
  • What might be happening is the Sys.println() for logging on the watch is taking a long time (writing to mass store is not a fast operation) and getting in the way.

    Thanks a lot for the information and the prompt answer. Most probably it has to do wih the println, i will check.
  • Former Member
    Former Member over 8 years ago
    File IO is exceptionally slow on most of our wearables, so you definitely won't be able to accurately time a timer if you are making calls to Toybox.System.println(). The minimum timer interval is 50ms on all devices at this time as far as I know.
  • File IO is exceptionally slow on most of our wearables, so you definitely won't be able to accurately time a timer if you are making calls to Toybox.System.println(). The minimum timer interval is 50ms on all devices at this time as far as I know.

    thanks Brian.
    yesterday i checked, and yes, the problem was the File IO. my idea now is to push data to a queue and empty the queue to the log file when screen is updated.
    thanks all for your support.