Related to my other post, I am currently looking into handling the button interrupts on my own and passing them to the corresponding menuMgr function.
I am having trouble with menuMgr.valueChanged(int value), however. This is my code, which (obviously) is not working:
void onButtonPressedClb(uint8_t pin, bool heldDown) {
switch (pin) {
case UP_BUTTON_GPIO:
menuMgr.valueChanged(-1);
break;
case DOWN_BUTTON_GPIO:
menuMgr.valueChanged(+1);
break;
case LEFT_BUTTON_GPIO:
if(!heldDown) menuMgr.performDirectionMove(true);
break;
case RIGHT_BUTTON_GPIO:
if(!heldDown) menuMgr.performDirectionMove(false);
break;
case A_BUTTON_GPIO:
menuMgr.onMenuSelect(heldDown);
break;
case B_BUTTON_GPIO:
if(!heldDown) menuMgr.performDirectionMove(true);
break;
}
}
After reading through the source code of tcmenu and IoAbstraction, I now understand why simply passing -1 and 1 as values does not work. My idea then was to get the current state of the menu and add or substract 1, but I cannot find a way to get/read the current state of the menu.
Do I have to setup a dummy encoder and manipulate it in my callback? Is there no other way?