Adjust the closures to capture by reference

This commit is contained in:
Rob Giseburt
2023-02-17 02:56:22 +00:00
parent be97a8aa4c
commit be762acafe
4 changed files with 4 additions and 4 deletions

View File

@@ -100,7 +100,7 @@ static stat_t _set_homing_func(stat_t (*func)(int8_t axis)) {
* Will be registered only during homing mode - see gpio.h for more info
*/
gpioDigitalInputHandler _homing_handler {
[&](const bool state, const inputEdgeFlag edge, const uint8_t triggering_pin_number) {
[](const bool state, const inputEdgeFlag edge, const uint8_t triggering_pin_number) {
if (cm->cycle_type != CYCLE_HOMING) { return GPIO_NOT_HANDLED; }
if (triggering_pin_number != hm.homing_input) { return GPIO_NOT_HANDLED; }
if (edge != INPUT_EDGE_LEADING) { return GPIO_NOT_HANDLED; }

View File

@@ -129,7 +129,7 @@ static void _motion_end_callback(float* vect, bool* flag)
* Will be registered only during homing mode - see gpio.h for more info
*/
gpioDigitalInputHandler _probing_handler {
[&](const bool state, const inputEdgeFlag edge, const uint8_t triggering_pin_number) {
[](const bool state, const inputEdgeFlag edge, const uint8_t triggering_pin_number) {
if (cm->cycle_type != CYCLE_PROBE) { return GPIO_NOT_HANDLED; }
if (triggering_pin_number != pb.probe_input) { return GPIO_NOT_HANDLED; }

View File

@@ -116,7 +116,7 @@ extern gpioDigitalInputReader* const in_r[16];
* Example gpioDigitalInputHandler object creation:
gpioDigitalInputHandler limitHandler {
[&](const bool state, const inputEdgeFlag edge, const uint8_t triggering_pin_number) {
[](const bool state, const inputEdgeFlag edge, const uint8_t triggering_pin_number) {
if (edge != INPUT_EDGE_LEADING) { return; }
limit_requested = true; // record that a limit was requested for later processing
return false; // allow others to see this notice

View File

@@ -98,7 +98,7 @@ https://github.com/synthetos/Motate/blob/41e5b92a98de4b268d1804bf6eadf3333298fc7
It's just like a function, and is used as a function pointer.
But the closure part means that whatever variables that were in scope where the
[&](parameters){code} is will be captured by the compiler as references in the generated
[](parameters){code} is will be captured by the compiler as references in the generated
function and used wherever the function gets called. In this particular use, there isn't
anything that wouldn't be available anywhere in that file, but they're not being called
from that file. They're being called by the systick interrupt which is over in SamTmers.cpp