-
I am trying to use the 1 button already on my esp32 (as to not add more unneeded hardware), however I can't figure out how to navigate the menus as the documentation on it seems lacking? const auto press_type = PollButton();
static uint8_t last_press_type = 0xFF;
if (press_type != last_press_type) {
last_press_type = press_type;
switch (press_type) {
case none:
Serial.println("No Press Detected");
menuMgr.onMenuSelect(false);
break;
case single_press:
Serial.println("Single Press Detected");
menuMgr.performDirectionMove(false);
break;
case double_press:
Serial.println("Double Press Detected");
menuMgr.onMenuSelect(true);
break;
case long_press:
Serial.println("Long Press Detected");
menuMgr.performDirectionMove(true);
break;
default:
break;
}
} This is what I am currently trying given the info I can scrape up but nothing is happening in the menu however the serial output is correct so I know it is being called. EDIT: To be clear is there not just a simple method to call to advance the menu or select an item etc where we can handle the input on our own and just call a whatever method we need for x input? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 10 replies
-
So there's a couple of things here, firstly you're better off trying to do something similar to the Up Down button encoder class that's in SwitchInput.cpp/h. This provides the RotaryEncoder interface support that's needed by the menu system these days. It should be fairly simple to implement the above logic in that way. If you look at the 4 way joystick support that will give you ideas how to handle all actions at once within the same class. |
Beta Was this translation helpful? Give feedback.
Don't know if you noticed but one button shipped in 4.3? I've tried it and although not ideal, it does work for very simple menu structures.