Elegant way to code a waiting time to display a text only few ms?

Sorry to ask such basics... 

I understand the asynchronous coding concept, but what is the most elegant way to code a waiting period in order to display a text only half a second or less ?

  • not sure why you'd only want to display a message for such a short time, as I doubt a user would be able to see it/read it, but I'll display messages for say 10 seconds with an associated tone or vibration to let the user know to look.

    Let's say I have a function called showMessage:

    functon showMessage(msg) {

    ..displaySeconds=10;

    ..displayMessage=msg;

    ..makeNoise()

    }

    In widgets and device apps, I usually have a time that runs every decod, to update the display and do other housekeeping, so onTimer looks something like this:

    function onTimer() {

    .. if(displayTimer!=0) { displayTimer--;}

    ..WatchUi,requestUpdate()

    }

    Then in onUpdate, this...

    ..if(displayTimer!=0) {//display the message}

    For a DF, instead of using a timer, the same basic logic can be used in compute()

  • Is this related to the fast response altimeter you're doing for skydiving?  If so, when I was experimenting with reading the rawAmbientPressure value I noticed that the value only changes once per second, no faster.  You can read it as fast as you like, but the value stays the same for a second at a time.

    I'm not sure I understand your question exactly, but I think you may be talking about the timer function, which you specify in milliseconds and it fires repeatedly at that interval.

            timer1 = new Timer.Timer();
            timer1.start(method(:callback1), 1000, true);

  • Thanks for your answer. No, this is not related to the fast descent. Jim_m_58 answered the question very well.