I’m working on a project where I’m setting up GPIO interrupts on a Raspberry Pi Pico using the Pico SDK. I have a class lcdmenu with a constructor that initializes a GPIO interrupt using gpio_set_irq_enabled_with_callback.
lcdmenu::lcdmenu(command **list, int length)
{
gpio_set_irq_enabled_with_callback(pinb, GPIO_IRQ_EDGE_FALL, true, &lcdmenu::control);
numitems = length;
items = list;
render();
}
void lcdmenu::control(uint gpio, uint32_t events){
if(gpio_get(pina)){
this->up();
printf("yay");
}
else{
this->down();
}
}
Where I am getting the error
error: cannot convert 'void (lcdmenu::*)(unsigned int, long unsigned int)' to 'gpio_irq_callback_t' {aka 'void (*)(unsigned int, long unsigned int)'}
I’m currently limited in my options because making the lcdmenu::control
method static removes access to the member variables essential for lcdmenu::up()
and lcdmenu::down()
.
I also experimented with making control a global function and passing the instance as an argument, but this approach would involve modifying the Pico SDK to enable passing the instance. Any ideas of alternate solutions would be greatly appreciated.
3