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 {
38
38
virtual size_t requestFrom (uint8_t address, size_t len) = 0;
39
39
40
40
// 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;
43
43
};
Original file line number Diff line number Diff line change @@ -596,14 +596,14 @@ void TwoWire::flush() {
596
596
// i2cFlush(num); // cleanup
597
597
}
598
598
599
- void TwoWire::onReceive (std::function<void (int )> function) {
599
+ void TwoWire::onReceive (const std::function<void (int )>& function) {
600
600
#if SOC_I2C_SUPPORT_SLAVE
601
601
user_onReceive = function;
602
602
#endif
603
603
}
604
604
605
605
// sets function called on slave read
606
- void TwoWire::onRequest (std::function<void ()> function) {
606
+ void TwoWire::onRequest (const std::function<void ()>& function) {
607
607
#if SOC_I2C_SUPPORT_SLAVE
608
608
user_onRequest = function;
609
609
#endif
Original file line number Diff line number Diff line change @@ -112,8 +112,8 @@ class TwoWire : public HardwareI2C {
112
112
size_t requestFrom (uint8_t address, size_t len, bool stopBit) override ;
113
113
size_t requestFrom (uint8_t address, size_t len) override ;
114
114
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 ;
117
117
118
118
// call setPins() first, so that begin() can be called without arguments from libraries
119
119
bool setPins (int sda, int scl);
You can’t perform that action at this time.
0 commit comments