Vor 2 jahren habe ich mal eine kleine Blinkklasse geschrieben die u.A. auch once_ms der Tickerklasse nutzt. Diese habe ich auf Github gestellt.
Ich benutze diese Klasse auch selbst bei mir fuer ein ESPNow Gateway. Jetzt wollte ich den Gateway Code nach laengerer Zeit updaten und bekomme ploetzlich die Klasse nicht mehr compiliert Es ist ein ESP32.
Konkret geht es um diese Zeile. Der Compiler wirft eine mir leider unverstaendliche Fehlermeldung aus . Da dort auch eine Lambda Funktion genutzt wird und zu meiner Zeit als ich mit C++ gearbeitet hatte noch keine Lamdas gab bin ich da ziemlich unbeleckt und aufgeschmissen. __deets__ hatte mir damals geholfen . Leider ist er nicht mehr im Forum
Die Compilefehlemeldung sieht wie folgt aus:
/libraries/local/BlinkNotification.cpp -o /tmp/arduino_build_479715/libraries/local/BlinkNotification.cpp.o
/home/framp/Arduino/libraries/local/BlinkNotification.cpp: In member function 'void framp::BlinkNotification::flipLED()':
/home/framp/Arduino/libraries/local/BlinkNotification.cpp:58:70: error: no matching function for call to 'Ticker::once_ms(unsigned int&, framp::BlinkNotification::flipLED()::<lambda()>)'
this->ticker.once_ms(this->onTime, [this] { this-> flipLED(); });
^
In file included from /home/framp/Arduino/libraries/local/BlinkNotification.h:31:0,
from /home/framp/Arduino/libraries/local/BlinkNotification.cpp:28:
/home/framp/.arduino15/packages/esp32/hardware/esp32/1.0.6/libraries/Ticker/src/Ticker.h:74:8: note: candidate: void Ticker::once_ms(uint32_t, Ticker::callback_t)
void once_ms(uint32_t milliseconds, callback_t callback)
^
/home/framp/.arduino15/packages/esp32/hardware/esp32/1.0.6/libraries/Ticker/src/Ticker.h:74:8: note: no known conversion for argument 2 from 'framp::BlinkNotification::flipLED()::<lambda()>' to 'Ticker::callback_t {aka void (*)()}'
/home/framp/.arduino15/packages/esp32/hardware/esp32/1.0.6/libraries/Ticker/src/Ticker.h:88:8: note: candidate: template<class TArg> void Ticker::once_ms(uint32_t, void (*)(TArg), TArg)
void once_ms(uint32_t milliseconds, void (*callback)(TArg), TArg arg)
^
/home/framp/.arduino15/packages/esp32/hardware/esp32/1.0.6/libraries/Ticker/src/Ticker.h:88:8: note: template argument deduction/substitution failed:
/home/framp/Arduino/libraries/local/BlinkNotification.cpp:58:70: note: mismatched types 'void (*)(TArg)' and 'framp::BlinkNotification::flipLED()::<lambda()>'
this->ticker.once_ms(this->onTime, [this] { this-> flipLED(); });
^
Alles anzeigen
Hat jemand eine Idee was die Ursache sein kann und wie ich es fixen kann? Den Fehler bekomme ich auf zwei Systemen wo der Compile frueher ohne Probleme durchlief. Es scheint mir so dass irgendwann mal bei einem Update des Arduinos oder des C++ Compilers das Problem reingekommen ist. Ich schaetze der C++ Compiler wurde geaendert.
Ich hatte die Zeile mal wie folgt geaendert:
void oncePrint() {
Serial.println("printing in once function.");
}
void BlinkNotification::flipLED() {
...
// this->ticker.once_ms(this->onTime, [this] { this-> flipLED(); });
this->ticker.once_ms(this->onTime, oncePrint );
...
Alles anzeigen
Und da ging der Compile durch. Leider macht der Code dann natuerlich nicht das was ich moechte. Aber es liegt ziemlich sicher irgendwie an der genutzen Lambda Funktion