Chat here about code rewrites, mods, etc... with respect to the github project https://github.com/esp8266/Arduino

Moderator: igrr

User avatar
By gheber
#35227 Hello,
I have two problems with the Ticker.h library.
First problem:
how can I attach a member function of my class to the Ticker? I get this errormessage:
test.h error no matching function for call to 'Ticker::attach_ms(int,<unresolved overloaded function type>)'
my member function is declared public. I tried to attach this->test or this.test

Second Problem:
I can solve this, but I want to understand it.

<code>
#include <ticker.h>
Ticker myTicker;
int steps_left = 50;
void setup(){
TickerRoutine();
Serial.begin(115200);
}
void loop(){}
void TickerRoutine(){
delay(0); // because of soft reset Esp8266
if ( steps_left == 512 ){
myTicker.attach_ms( 10 , TickerRoutine);
}
Serial.println( steps_left );
steps_left--;
if( steps_left < 0 ){
Serial.println("detach");
myTicker.detach();
Serial.println("pause");
delay(10000);// 10 seconds
myTicker.atach_ms( 10 , TickerRoutine);
Serial.println("attach");
}
}
</code>
What happens? It counts down to 0, writes detach, pause and attach and starts counting down from 50, but where is my delay?
I can solve this by attaching my routine with 10000 ms, this works fine... but why is that so?

greetings
Gerd