Register / Login | Desktop view |
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?");
}
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)
}
int16_t i = getEncoderAccelerated(); // Get encoder movement from ATTINY85 over i2c (usually around -512 to +512)
if (i!=0) {
switches.getEncoder()->increment(i);
}
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);
}
Filename | indicator.jpg |
Description | No description given |
Filesize | 130 Kbytes |
Downloaded | 294 time(s) |
Download |
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)
MenuPadding titlePadding(5); // Custom padding
MenuPadding itemPadding(3,10,2,2); // Custom padding
Filename | FreeSansMod12pt7b.h |
Description | No description given |
Filesize | 17 Kbytes |
Downloaded | 288 time(s) |
Download |