Copyright ©

Mongoose OS Forum

ATTENTION! This forum has moved to:

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() {
}, 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?


  • 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.