Encoder shortcut resets button presses

pull/274/head
Stephen Brown 3 years ago
parent 393ced10d6
commit 8d3fb5ff1e
  1. 8
      src/uibuttons.cpp
  2. 2
      src/uibuttons.h
  3. 21
      src/userinterface.cpp

@ -364,3 +364,11 @@ void CUIButtons::Update (void)
}
}
void CUIButtons::ResetButton (unsigned pinNumber)
{
for (unsigned i=0; i<MAX_BUTTONS; i++) {
if (m_buttons[i].getPinNumber() == pinNumber) {
m_buttons[i].reset();
}
}
}

@ -113,6 +113,8 @@ public:
void RegisterEventHandler (BtnEventHandler *handler, void *param = 0);
void Update (void);
void ResetButton (unsigned pinNumber);
private:
// Up to 5 buttons can be defined

@ -224,13 +224,26 @@ void CUserInterface::EncoderEventHandler (CKY040::TEvent Event)
break;
case CKY040::EventClockwise:
m_Menu.EventHandler (m_bSwitchPressed ? CUIMenu::MenuEventPressAndStepUp
: CUIMenu::MenuEventStepUp);
if (m_bSwitchPressed) {
// We must reset the encoder switch button to prevent events from being
// triggered after the encoder is rotated
m_pUIButtons->ResetButton(m_pConfig->GetEncoderPinSwitch());
m_Menu.EventHandler(CUIMenu::MenuEventPressAndStepUp);
}
else {
m_Menu.EventHandler(CUIMenu::MenuEventStepUp);
}
break;
case CKY040::EventCounterclockwise:
m_Menu.EventHandler (m_bSwitchPressed ? CUIMenu::MenuEventPressAndStepDown
: CUIMenu::MenuEventStepDown);
if (m_bSwitchPressed) {
m_pUIButtons->ResetButton(m_pConfig->GetEncoderPinSwitch());
m_Menu.EventHandler(CUIMenu::MenuEventPressAndStepDown);
}
else {
m_Menu.EventHandler(CUIMenu::MenuEventStepDown);
}
break;
case CKY040::EventSwitchHold:

Loading…
Cancel
Save