ESP32 + TickTwo library: variable in parameters

Hello - I'm using the Ticker library that's been updated for ESP usage (called TickTwo) and trying to setup a timer with a variable containing the milliseconds so that it can be updated later.

A simple example of the issue:

#include <TickTwo.h>

void timer_update() {
  Serial.println("Timer finished");
  };
  
unsigned long timer_ms;
TickTwo timer3(timer_update, timer_ms, 1);
  
void setup() {
  timer_ms = 2000;
  Serial.begin(115200);
  timer3.start();
};

void loop() {
  timer3.update();
};

Since the TickTwo parameter has been established with a value of zero from the start, that's what I get in spite of updating the variable later. I can't find any documentation that allows me to update this parameter after the fact (I found this instructional for the original Ticker library that uses a command ".attach_ms", but it isn't recognized in this TickTwo library).

I tried creating the TickTwo object later on in the code, but it won't compile due to references to it existing in other areas. Just wondering if anyone knows a better approach to this. Thank you.

It seems you can update the interval time.

1 Like

I am not a smart man.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.