Jakoś nie mogę tego ogarnąć. Znalazłem też takie rozwiązanie
https://stackoverflow.com/questions/340 ... rent-class
SuplaOled.h:
Code: Select all
class SuplaOled : public Supla::Element {
public:
SuplaOled();
private:
void drawFrame1(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y);
void drawFrame2(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y);
std::function<FrameCallback()> frames[2];
};
SuplaOled.cpp
Code: Select all
SuplaOled::SuplaOled() {
frames[0] = std::bind(&SuplaOled::drawFrame1, this);
frames[1] = std::bind(&SuplaOled::drawFrame2, this);
}
void SuplaOled::drawFrame1(OLEDDisplay* display, OLEDDisplayUiState* state, int16_t x, int16_t y) {}
void SuplaOled::drawFrame2(OLEDDisplay* display, OLEDDisplayUiState* state, int16_t x, int16_t y) {}
dostaję błąd kompilacji
Code: Select all
src\SuplaOled.cpp:7:13: error: no match for 'operator=' (operand types are 'std::function<void (*())(OLEDDisplay*, OLEDDisplayUiState*, short int, short int)>' and 'std::_Bind_helper<false, void (SuplaOled::*)(OLEDDisplay*, OLEDDisplayUiState*, short int, short int), SuplaOled* const>::type {aka std::_Bind<std::_Mem_fn<void (SuplaOled::*)(OLEDDisplay*, OLEDDisplayUiState*, short int, short int)>(SuplaOled*)>}')
frames[0] = std::bind(&SuplaOled::drawFrame1, this);
^
src\SuplaOled.cpp:7:13: note: candidates are:
In file included from c:\users\kryst\.platformio\packages\toolchain-xtensa\xtensa-lx106-elf\include\c++\4.8.2\bits\stl_algo.h:66:0,
from c:\users\kryst\.platformio\packages\toolchain-xtensa\xtensa-lx106-elf\include\c++\4.8.2\algorithm:62,
from C:\Users\kryst\.platformio\packages\framework-arduinoespressif8266\cores\esp8266/Arduino.h:238,
from .pio\libdeps\GUI_Generic_1M\ESP8266 and ESP32 OLED driver for SSD1306 displays\src/OLEDDisplay.h:36,
from .pio\libdeps\GUI_Generic_1M\ESP8266 and ESP32 OLED driver for SSD1306 displays\src/SH1106Wire.h:34,
from src\SuplaOled.h:9,
from src\SuplaOled.cpp:1:
c:\users\kryst\.platformio\packages\toolchain-xtensa\xtensa-lx106-elf\include\c++\4.8.2\functional:2266:7: note: std::function<_Res(_ArgTypes ...)>& std::function<_Res(_ArgTypes ...)>::operator=(const std::function<_Res(_ArgTypes ...)>&) [with _Res = void (*)(OLEDDisplay*, OLEDDisplayUiState*, short int, short int); _ArgTypes = {}]
operator=(const function& __x)
^
c:\users\kryst\.platformio\packages\toolchain-xtensa\xtensa-lx106-elf\include\c++\4.8.2\functional:2266:7: note: no known conversion for argument 1 from 'std::_Bind_helper<false, void (SuplaOled::*)(OLEDDisplay*, OLEDDisplayUiState*, short int, short int), SuplaOled* const>::type {aka std::_Bind<std::_Mem_fn<void (SuplaOled::*)(OLEDDisplay*, OLEDDisplayUiState*, short int, short int)>(SuplaOled*)>}' to 'const std::function<void (*())(OLEDDisplay*, OLEDDisplayUiState*, short int, short int)>&'
c:\users\kryst\.platformio\packages\toolchain-xtensa\xtensa-lx106-elf\include\c++\4.8.2\functional:2284:7: note: std::function<_Res(_ArgTypes ...)>& std::function<_Res(_ArgTypes ...)>::operator=(std::function<_Res(_ArgTypes ...)>&&) [with _Res = void (*)(OLEDDisplay*, OLEDDisplayUiState*, short int, short int); _ArgTypes = {}]
operator=(function&& __x)
^
c:\users\kryst\.platformio\packages\toolchain-xtensa\xtensa-lx106-elf\include\c++\4.8.2\functional:2284:7: note: no known conversion for argument 1 from 'std::_Bind_helper<false, void (SuplaOled::*)(OLEDDisplay*, OLEDDisplayUiState*, short int, short int), SuplaOled* const>::type {aka std::_Bind<std::_Mem_fn<void (SuplaOled::*)(OLEDDisplay*, OLEDDisplayUiState*, short int, short int)>(SuplaOled*)>}' to 'std::function<void (*())(OLEDDisplay*, OLEDDisplayUiState*, short int, short int)>&&'
c:\users\kryst\.platformio\packages\toolchain-xtensa\xtensa-lx106-elf\include\c++\4.8.2\functional:2298:7: note: std::function<_Res(_ArgTypes ...)>& std::function<_Res(_ArgTypes ...)>::operator=(std::nullptr_t) [with _Res = void (*)(OLEDDisplay*, OLEDDisplayUiState*, short int, short int); _ArgTypes = {}; std::nullptr_t = std::nullptr_t]
operator=(nullptr_t)
^
c:\users\kryst\.platformio\packages\toolchain-xtensa\xtensa-lx106-elf\include\c++\4.8.2\functional:2298:7: note: no known conversion for argument 1 from 'std::_Bind_helper<false, void (SuplaOled::*)(OLEDDisplay*, OLEDDisplayUiState*, short int, short int), SuplaOled* const>::type {aka std::_Bind<std::_Mem_fn<void (SuplaOled::*)(OLEDDisplay*, OLEDDisplayUiState*, short int, short int)>(SuplaOled*)>}' to 'std::nullptr_t'
c:\users\kryst\.platformio\packages\toolchain-xtensa\xtensa-lx106-elf\include\c++\4.8.2\functional:2327:2: note: template<class _Functor> std::function<_Res(_ArgTypes ...)>::_Requires<std::__or_<std::is_void<_Tp>, std::is_convertible<std::function<_Res(_ArgTypes ...)>::_Invoke<_Functor>, _Res> >, std::function<_Res(_ArgTypes ...)>&> std::function<_Res(_ArgTypes ...)>::operator=(_Functor&&) [with _Functor =
_Functor; _Res = void (*)(OLEDDisplay*, OLEDDisplayUiState*, short int, short int); _ArgTypes = {}]
operator=(_Functor&& __f)
^
c:\users\kryst\.platformio\packages\toolchain-xtensa\xtensa-lx106-elf\include\c++\4.8.2\functional:2327:2: note: template argument deduction/substitution failed:
c:\users\kryst\.platformio\packages\toolchain-xtensa\xtensa-lx106-elf\include\c++\4.8.2\functional:2336:2: note: template<class _Functor> std::function<_Res(_ArgTypes ...)>& std::function<_Res(_ArgTypes ...)>::operator=(std::reference_wrapper<_Tp>) [with _Functor = _Functor; _Res = void (*)(OLEDDisplay*, OLEDDisplayUiState*, short int, short int); _ArgTypes = {}]
operator=(reference_wrapper<_Functor> __f) noexcept
^
c:\users\kryst\.platformio\packages\toolchain-xtensa\xtensa-lx106-elf\include\c++\4.8.2\functional:2336:2: note: template argument deduction/substitution failed:
src\SuplaOled.cpp:7:13: note: 'std::_Bind<std::_Mem_fn<void (SuplaOled::*)(OLEDDisplay*, OLEDDisplayUiState*, short int, short int)>(SuplaOled*)>' is not derived from 'std::reference_wrapper<_Tp>'
frames[0] = std::bind(&SuplaOled::drawFrame1, this);