Hey Dave et al.
I'm nearing completion of my project and it has been an absolute pleasure working with these libraries. Everything I've wanted to do has been provided and any bugs I've discovered have been squashed! Thank you!
There are just 3 little things that I would like to tidy up and I can't seem to find good workarounds to 2 of them. The 3rd thing I believe is a bug, which I have shown a workaround for below (but maybe there's just a better way to avoid the issue in the first place). I can provide extra code if my examples aren't clear enough. I would appreciate any insights into these issues at your convenience. All issues are with latest version of TCMenu and compiled with PlatformIO for Teensy 1.57
1, Cannot select the default button in a BaseDialog screen
Not much more to it than that. I can put 0,1,2.... in the final parameter of my setButtons() function, yet the title bar is always highlighted regardless. Maybe something to do with manually controlling menu navigation with my buttons/encoders?
void CALLBACK_FUNCTION onDiscardExit(int id) { // Dialog to confirm exiting menu without saving
BaseDialog* dlg = renderer.getDialog();
dlg->setButtons(BTNTYPE_OK, BTNTYPE_CANCEL, 0); // <-- This number does nothing for me
dlg->show(exitHeader, true, confirmExit);
dlg->copyIntoBuffer("Discard changes?");
}
2, Doubling of highlighted items in BaseDialog screens
Again, using custom functions to navigate the menu. Problem arises when using the following code for a specific button in my onSwitchPressed calledback. If I've got anything other than the OK button (as defined in issue 1 above) highlighted, the OK button becomes highlighted IN ADDITION to whatever was previously highlighted. It's always the OK button, regardless of which I have chosen (as per issue 1.)
Back button snippet:
if (!menuMgr.getCurrentSubMenu()) { // In root menu?
onDiscardExit(1); // Exit without saving?
} else { // In submenu
menuMgr.performDirectionMove(true); // Go up a level (this is what messes up the confirmation screen)
}
3, Overflow issue when pushing big number into increment() while editing Large Number menu items.
Due to issues with needing FAST rotary encoder counting, I have the encoder connected to a secondary device (ATTiny85) which I'm polling over i2c to get my encoder counts when my main program (running on a Teensy4.1) isn't too busy. The function that gets this number uses some multipliers to allow for an accelerated input when turning the wheel fast. The problem comes when these big numbers are used while editing digits in Large Number menu items. I can get some kind of overflow which changes the digit into non-numeric values and even effects adjacent digits (things like: =>;: show up instead of numbers)
The code that was causing issues:
int16_t i = getEncoderAccelerated(); // Get encoder movement from ATTINY85 over i2c (usually around -512 to +512)
if (i!=0) {
switches.getEncoder()->increment(i);
}
The work around (Any better way to handle this?) Seems like it should be constrained internally if big numbers cause this kind of problem.
int16_t i = getEncoderAccelerated(); // Get encoder movement from ATTINY85 over i2c
if (i!=0) {
if (menuMgr.getCurrentEditor()) { // If I don't confirm that I'm editing something the Teensy hard crashes on the next line
if (menuMgr.getCurrentEditor()->getMenuType()==MENUTYPE_LARGENUM_VALUE) { // Check for editing Large Num
i=constrain(i, -1, 1); // Solves bug where large num digits overflow from fast encoder movement.
}
}
switches.getEncoder()->increment(i);
}
I hope this all makes sense and can help you make these great libraries continue to improve. Please let me know if there's anything else I can do to assist in resolving these 3 issues.