File tree Expand file tree Collapse file tree 3 files changed +6
-6
lines changed Expand file tree Collapse file tree 3 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,6 @@ class HardwareI2C : public Stream {
3838 virtual size_t requestFrom (uint8_t address, size_t len) = 0;
3939
4040 // Update base class to use std::function
41- virtual void onReceive (std::function<void (int )>) = 0;
42- virtual void onRequest (std::function<void ()>) = 0;
41+ virtual void onReceive (const std::function<void (int )>& ) = 0;
42+ virtual void onRequest (const std::function<void ()>& ) = 0;
4343};
Original file line number Diff line number Diff line change @@ -596,14 +596,14 @@ void TwoWire::flush() {
596596 // i2cFlush(num); // cleanup
597597}
598598
599- void TwoWire::onReceive (std::function<void (int )> function) {
599+ void TwoWire::onReceive (const std::function<void (int )>& function) {
600600#if SOC_I2C_SUPPORT_SLAVE
601601 user_onReceive = function;
602602#endif
603603}
604604
605605// sets function called on slave read
606- void TwoWire::onRequest (std::function<void ()> function) {
606+ void TwoWire::onRequest (const std::function<void ()>& function) {
607607#if SOC_I2C_SUPPORT_SLAVE
608608 user_onRequest = function;
609609#endif
Original file line number Diff line number Diff line change @@ -112,8 +112,8 @@ class TwoWire : public HardwareI2C {
112112 size_t requestFrom (uint8_t address, size_t len, bool stopBit) override ;
113113 size_t requestFrom (uint8_t address, size_t len) override ;
114114
115- void onReceive (std::function<void (int )>) override ;
116- void onRequest (std::function<void ()>) override ;
115+ void onReceive (const std::function<void (int )>& ) override ;
116+ void onRequest (const std::function<void ()>& ) override ;
117117
118118 // call setPins() first, so that begin() can be called without arguments from libraries
119119 bool setPins (int sda, int scl);
You can’t perform that action at this time.
0 commit comments