MajicDesigns / MD_UISwitch

Uniformly encapsulate different types of switches as user input devices
GNU Lesser General Public License v2.1
40 stars 17 forks source link

Navigation problem with ADKeyboard Module v2 DFRobot #5

Closed meditant closed 6 years ago

meditant commented 6 years ago

Hello,

The navigation doesn't work correctly with this component some button work but randomly, i try to change the debounce time but nothing change, the solution is to add a delay(50) in the MD_UISwitch::keyResult_t MD_UISwitch_Analog::read(void) function, and with this, all work fine.

// work out what key this is for (uint8_t i = 0; i < _ktSize; i++) { if ((v >= (_kt[i].adcThreshold - _kt[i].adcTolerance)) && (v <= (_kt[i].adcThreshold + _kt[i].adcTolerance))) { idx = i; UI_PRINTS("\nV : "); UI_PRINTS(v); UI_PRINTS("\nACT : "); UI_PRINTS(_kt[i].adcThreshold); delay(50); // Ajout d'un délai pour éviter le bug des boutons qui fonctionne mal break; } }

The programme works fine without this delay modification with the DFRobot shield LCD Keyshield 1.1 (after change the key value of course).

Best regards

MajicDesigns commented 6 years ago

Your solution does not make sense to me. You have added a delay in a loop that reads memory variables (ie, no interaction with the I/O or ADC converter) and this fixes some unknown problem. I suspect that you have masked the real problem occurring somewhere else in your code, but if that works for you, great.