From 287250b32dc18c781e45c103b0b4e3e5917d6c2e Mon Sep 17 00:00:00 2001 From: John Robertson Date: Thu, 19 Nov 2015 22:57:45 -0700 Subject: [PATCH] hcsr04: Pass reference to current object to ISR. This will allow users to call ackEdgeDetected() on the object passed into the function pointer, instead of requiring them to have a global reference to the object. Signed-off-by: JJ Robertson Signed-off-by: Mihai Tudor Panu --- src/hcsr04/hcsr04.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hcsr04/hcsr04.cxx b/src/hcsr04/hcsr04.cxx index b89ee0b5..f30e9d82 100644 --- a/src/hcsr04/hcsr04.cxx +++ b/src/hcsr04/hcsr04.cxx @@ -63,7 +63,7 @@ HCSR04::HCSR04 (uint8_t triggerPin, uint8_t echoPin, void (*fptr)(void *)) { } mraa_gpio_dir(m_echoPinCtx, MRAA_GPIO_IN); - mraa_gpio_isr(m_echoPinCtx, MRAA_GPIO_EDGE_BOTH, fptr, NULL); + mraa_gpio_isr(m_echoPinCtx, MRAA_GPIO_EDGE_BOTH, fptr, (void*)this); } HCSR04::~HCSR04 () {