Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add shortcut for changing the TG in parameter edit #70

Merged
merged 1 commit into from
Apr 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 57 additions & 2 deletions src/uimenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const CUIMenu::TMenuItem CUIMenu::s_MenuRoot[] =
{0}
};

// inserting menu items before "TG1" affect TGShortcutHandler()
const CUIMenu::TMenuItem CUIMenu::s_MainMenu[] =
{
{"TG1", MenuHandler, s_TGMenu, 0},
Expand Down Expand Up @@ -316,8 +317,7 @@ void CUIMenu::MenuHandler (CUIMenu *pUIMenu, TMenuEvent Event)
break;

default:
assert (0);
break;
return;
}

if (pUIMenu->m_pCurrentMenu) // if this is another menu?
Expand Down Expand Up @@ -410,6 +410,11 @@ void CUIMenu::EditVoiceBankNumber (CUIMenu *pUIMenu, TMenuEvent Event)
CMiniDexed::TGParameterVoiceBank, nValue, nTG);
break;

case MenuEventPressAndStepDown:
case MenuEventPressAndStepUp:
pUIMenu->TGShortcutHandler (Event);
return;

default:
return;
}
Expand Down Expand Up @@ -453,6 +458,11 @@ void CUIMenu::EditProgramNumber (CUIMenu *pUIMenu, TMenuEvent Event)
pUIMenu->m_pMiniDexed->SetTGParameter (CMiniDexed::TGParameterProgram, nValue, nTG);
break;

case MenuEventPressAndStepDown:
case MenuEventPressAndStepUp:
pUIMenu->TGShortcutHandler (Event);
return;

default:
return;
}
Expand Down Expand Up @@ -500,6 +510,11 @@ void CUIMenu::EditTGParameter (CUIMenu *pUIMenu, TMenuEvent Event)
pUIMenu->m_pMiniDexed->SetTGParameter (Param, nValue, nTG);
break;

case MenuEventPressAndStepDown:
case MenuEventPressAndStepUp:
pUIMenu->TGShortcutHandler (Event);
return;

default:
return;
}
Expand Down Expand Up @@ -547,6 +562,11 @@ void CUIMenu::EditVoiceParameter (CUIMenu *pUIMenu, TMenuEvent Event)
pUIMenu->m_pMiniDexed->SetVoiceParameter (nParam, nValue, CMiniDexed::NoOP, nTG);
break;

case MenuEventPressAndStepDown:
case MenuEventPressAndStepUp:
pUIMenu->TGShortcutHandler (Event);
return;

default:
return;
}
Expand Down Expand Up @@ -595,6 +615,11 @@ void CUIMenu::EditOPParameter (CUIMenu *pUIMenu, TMenuEvent Event)
pUIMenu->m_pMiniDexed->SetVoiceParameter (nParam, nValue, nOP, nTG);
break;

case MenuEventPressAndStepDown:
case MenuEventPressAndStepUp:
pUIMenu->TGShortcutHandler (Event);
return;

default:
return;
}
Expand Down Expand Up @@ -796,3 +821,33 @@ string CUIMenu::ToOscillatorDetune (int nValue)

return Result;
}

void CUIMenu::TGShortcutHandler (TMenuEvent Event)
{
assert (m_nCurrentMenuDepth >= 2);
assert (m_MenuStackMenu[0] = s_MainMenu);
unsigned nTG = m_nMenuStackSelection[0];
assert (nTG < CConfig::ToneGenerators);
assert (m_nMenuStackItem[1] == nTG);
assert (m_nMenuStackParameter[1] == nTG);

assert ( Event == MenuEventPressAndStepDown
|| Event == MenuEventPressAndStepUp);
if (Event == MenuEventPressAndStepDown)
{
nTG--;
}
else
{
nTG++;
}

if (nTG < CConfig::ToneGenerators)
{
m_nMenuStackSelection[0] = nTG;
m_nMenuStackItem[1] = nTG;
m_nMenuStackParameter[1] = nTG;

EventHandler (MenuEventUpdate);
}
}
4 changes: 4 additions & 0 deletions src/uimenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class CUIMenu
MenuEventHome,
MenuEventStepDown,
MenuEventStepUp,
MenuEventPressAndStepDown,
MenuEventPressAndStepUp,
MenuEventUnknown
};

Expand Down Expand Up @@ -98,6 +100,8 @@ class CUIMenu
static std::string ToOscillatorMode (int nValue);
static std::string ToOscillatorDetune (int nValue);

void TGShortcutHandler (TMenuEvent Event);

private:
CUserInterface *m_pUI;
CMiniDexed *m_pMiniDexed;
Expand Down
25 changes: 18 additions & 7 deletions src/userinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ CUserInterface::CUserInterface (CMiniDexed *pMiniDexed, CGPIOManager *pGPIOManag
m_pLCD (0),
m_pLCDBuffered (0),
m_pRotaryEncoder (0),
m_bSwitchPressed (false),
m_Menu (this, pMiniDexed)
{
}
Expand Down Expand Up @@ -177,12 +178,22 @@ void CUserInterface::EncoderEventHandler (CKY040::TEvent Event)
{
switch (Event)
{
case CKY040::EventSwitchDown:
m_bSwitchPressed = true;
break;

case CKY040::EventSwitchUp:
m_bSwitchPressed = false;
break;

case CKY040::EventClockwise:
m_Menu.EventHandler (CUIMenu::MenuEventStepUp);
m_Menu.EventHandler (m_bSwitchPressed ? CUIMenu::MenuEventPressAndStepUp
: CUIMenu::MenuEventStepUp);
break;

case CKY040::EventCounterclockwise:
m_Menu.EventHandler (CUIMenu::MenuEventStepDown);
m_Menu.EventHandler (m_bSwitchPressed ? CUIMenu::MenuEventPressAndStepDown
: CUIMenu::MenuEventStepDown);
break;

case CKY040::EventSwitchClick:
Expand All @@ -193,17 +204,17 @@ void CUserInterface::EncoderEventHandler (CKY040::TEvent Event)
m_Menu.EventHandler (CUIMenu::MenuEventSelect);
break;

case CKY040::EventSwitchTripleClick:
m_Menu.EventHandler (CUIMenu::MenuEventHome);
break;

case CKY040::EventSwitchHold:
if (m_pRotaryEncoder->GetHoldSeconds () >= 3)
if (m_pRotaryEncoder->GetHoldSeconds () >= 10)
{
delete m_pLCD; // reset LCD

reboot ();
}
else
{
m_Menu.EventHandler (CUIMenu::MenuEventHome);
}
break;

default:
Expand Down
1 change: 1 addition & 0 deletions src/userinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class CUserInterface
CWriteBufferDevice *m_pLCDBuffered;

CKY040 *m_pRotaryEncoder;
bool m_bSwitchPressed;

CUIMenu m_Menu;
};
Expand Down