Copyright © https://mongoose-os.com

Mongoose OS Forum

frame
ATTENTION! This forum has moved to:

https://community.mongoose-os.com

Do not post any new messages.

Timer with variable repeat time

Hi there,

Is it possible to set up a Timer and set the repetition time depending on a variable? Like this:

let tset = 1000;
Timer.set(tset, Timer.REPEAT, function() {
   //stuff
}, null);

When trying this, on a ESP32 board, it do compiles but when I flash it, it crashes on the process of encrypting.
Is it possible to do this?

Comments

  • SergeySergey Dublin, Ireland

    The code looks good, but note that the timer will be set up only once, with the variable value tset at the time of the Timer.set call. the interval won't be changing over time.

  • Thank you so much @Sergey . So, it is not possible to dinamically change the value of the Timer?

  • SergeySergey Dublin, Ireland
    edited September 2018

    Nope! What you can do is to run the fast-ticking timer, and either pass, or do something depending on the condition.

Sign In or Register to comment.