UI fix for Tempo display

pull/764/head
Javier Nonis 6 months ago
parent d7336ee180
commit bf30d1a1c9
  1. 10
      src/minidexed.cpp
  2. 4
      src/minidexed.h
  3. 79
      src/uimenu.cpp
  4. 1
      src/uimenu.h

@ -778,6 +778,16 @@ void CMiniDexed::setTempo(unsigned nValue)
}
bool CMiniDexed::isPlaying(void)
{
return m_bPlaying;
}
void CMiniDexed::setPlaying(bool bValue)
{
m_bPlaying = bValue;
}
void CMiniDexed::handleClock (void)
{
if (m_nClockCounter == 0)

@ -86,6 +86,9 @@ public:
void setTempo(unsigned nValue);
void handleClock(void);
bool isPlaying(void);
void setPlaying(bool bValue);
void keyup (int16_t pitch, unsigned nTG);
void keydown (int16_t pitch, uint8_t velocity, unsigned nTG);
@ -367,6 +370,7 @@ private:
unsigned m_nClockCounter;
unsigned long m_mClockTime;
unsigned m_nTempo; // Tempo in BPM
bool m_bPlaying = false;
};
#endif

@ -35,7 +35,7 @@ LOGMODULE ("uimenu");
const CUIMenu::TMenuItem CUIMenu::s_MenuRoot[] =
{
{"MiniDexed", MenuHandler, s_MainMenu},
{"MiniDexed", MainMenuHandler, s_MainMenu},
{0}
};
@ -649,6 +649,81 @@ void CUIMenu::EventHandler (TMenuEvent Event)
}
}
void CUIMenu::MainMenuHandler (CUIMenu *pUIMenu, TMenuEvent Event)
{
bool menuChange = false;
switch (Event)
{
case MenuEventUpdate:
break;
case MenuEventSelect: // push menu
assert (pUIMenu->m_nCurrentMenuDepth < MaxMenuDepth);
pUIMenu->m_MenuStackParent[pUIMenu->m_nCurrentMenuDepth] = pUIMenu->m_pParentMenu;
pUIMenu->m_MenuStackMenu[pUIMenu->m_nCurrentMenuDepth] = pUIMenu->m_pCurrentMenu;
pUIMenu->m_nMenuStackItem[pUIMenu->m_nCurrentMenuDepth]
= pUIMenu->m_nCurrentMenuItem;
pUIMenu->m_nMenuStackSelection[pUIMenu->m_nCurrentMenuDepth]
= pUIMenu->m_nCurrentSelection;
pUIMenu->m_nMenuStackParameter[pUIMenu->m_nCurrentMenuDepth]
= pUIMenu->m_nCurrentParameter;
pUIMenu->m_nCurrentMenuDepth++;
pUIMenu->m_pParentMenu = pUIMenu->m_pCurrentMenu;
pUIMenu->m_nCurrentParameter =
pUIMenu->m_pCurrentMenu[pUIMenu->m_nCurrentSelection].Parameter;
pUIMenu->m_pCurrentMenu =
pUIMenu->m_pCurrentMenu[pUIMenu->m_nCurrentSelection].MenuItem;
pUIMenu->m_nCurrentMenuItem = pUIMenu->m_nCurrentSelection;
pUIMenu->m_nCurrentSelection = 0;
menuChange = true;
break;
case MenuEventStepDown:
if (pUIMenu->m_nCurrentSelection > 0)
{
pUIMenu->m_nCurrentSelection--;
}
break;
case MenuEventStepUp:
++pUIMenu->m_nCurrentSelection;
if (!pUIMenu->m_pCurrentMenu[pUIMenu->m_nCurrentSelection].Name) // more entries?
{
pUIMenu->m_nCurrentSelection--;
}
break;
default:
return;
}
if (pUIMenu->m_pCurrentMenu) // if this is another menu?
{
string strTempo;
if (menuChange)
{
strTempo = "";
}
else
{
strTempo = (pUIMenu->m_pMiniDexed->isPlaying() ? ">" : "#") +
to_string(pUIMenu->m_pMiniDexed->getTempo());
}
pUIMenu->m_pUI->DisplayWrite (
pUIMenu->m_pParentMenu[pUIMenu->m_nCurrentMenuItem].Name,
strTempo.c_str(),
pUIMenu->m_pCurrentMenu[pUIMenu->m_nCurrentSelection].Name,
pUIMenu->m_nCurrentSelection > 0,
!!pUIMenu->m_pCurrentMenu[pUIMenu->m_nCurrentSelection+1].Name);
}
else
{
pUIMenu->EventHandler (MenuEventUpdate); // no, update parameter display
}
}
void CUIMenu::MenuHandler (CUIMenu *pUIMenu, TMenuEvent Event)
{
switch (Event)
@ -700,7 +775,7 @@ void CUIMenu::MenuHandler (CUIMenu *pUIMenu, TMenuEvent Event)
{
pUIMenu->m_pUI->DisplayWrite (
pUIMenu->m_pParentMenu[pUIMenu->m_nCurrentMenuItem].Name,
to_string(pUIMenu->m_pMiniDexed->getTempo()).c_str(),
"",
pUIMenu->m_pCurrentMenu[pUIMenu->m_nCurrentSelection].Name,
pUIMenu->m_nCurrentSelection > 0,
!!pUIMenu->m_pCurrentMenu[pUIMenu->m_nCurrentSelection+1].Name);

@ -79,6 +79,7 @@ private:
};
private:
static void MainMenuHandler (CUIMenu *pUIMenu, TMenuEvent Event);
static void MenuHandler (CUIMenu *pUIMenu, TMenuEvent Event);
static void EditGlobalParameter (CUIMenu *pUIMenu, TMenuEvent Event);
static void EditVoiceBankNumber (CUIMenu *pUIMenu, TMenuEvent Event);

Loading…
Cancel
Save