Implement Bank Select Buttons and MIDI Buttons (#737)

* Move button config into uibuttons rather than userinterface.cpp

* Implementation of Bank Select buttons and MIDI buttons.

* Fix MIDI button mapping issue.
fx
Kevin 5 days ago committed by GitHub
parent c2cb172baa
commit 1d9639789e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 36
      src/config.cpp
  2. 12
      src/config.h
  3. 8
      src/minidexed.ini
  4. 98
      src/uibuttons.cpp
  5. 35
      src/uibuttons.h
  6. 86
      src/uimenu.cpp
  7. 3
      src/uimenu.h
  8. 40
      src/userinterface.cpp

@ -164,11 +164,15 @@ void CConfig::Load (void)
m_nButtonPinPgmUp = m_Properties.GetNumber ("ButtonPinPgmUp", 0); m_nButtonPinPgmUp = m_Properties.GetNumber ("ButtonPinPgmUp", 0);
m_nButtonPinPgmDown = m_Properties.GetNumber ("ButtonPinPgmDown", 0); m_nButtonPinPgmDown = m_Properties.GetNumber ("ButtonPinPgmDown", 0);
m_nButtonPinBankUp = m_Properties.GetNumber ("ButtonPinBankUp", 0);
m_nButtonPinBankDown = m_Properties.GetNumber ("ButtonPinBankDown", 0);
m_nButtonPinTGUp = m_Properties.GetNumber ("ButtonPinTGUp", 0); m_nButtonPinTGUp = m_Properties.GetNumber ("ButtonPinTGUp", 0);
m_nButtonPinTGDown = m_Properties.GetNumber ("ButtonPinTGDown", 0); m_nButtonPinTGDown = m_Properties.GetNumber ("ButtonPinTGDown", 0);
m_ButtonActionPgmUp = m_Properties.GetString ("ButtonActionPgmUp", ""); m_ButtonActionPgmUp = m_Properties.GetString ("ButtonActionPgmUp", "");
m_ButtonActionPgmDown = m_Properties.GetString ("ButtonActionPgmDown", ""); m_ButtonActionPgmDown = m_Properties.GetString ("ButtonActionPgmDown", "");
m_ButtonActionBankUp = m_Properties.GetString ("ButtonActionBankUp", "");
m_ButtonActionBankDown = m_Properties.GetString ("ButtonActionBankDown", "");
m_ButtonActionTGUp = m_Properties.GetString ("ButtonActionTGUp", ""); m_ButtonActionTGUp = m_Properties.GetString ("ButtonActionTGUp", "");
m_ButtonActionTGDown = m_Properties.GetString ("ButtonActionTGDown", ""); m_ButtonActionTGDown = m_Properties.GetString ("ButtonActionTGDown", "");
@ -182,6 +186,8 @@ void CConfig::Load (void)
m_nMIDIButtonPgmUp = m_Properties.GetNumber ("MIDIButtonPgmUp", 0); m_nMIDIButtonPgmUp = m_Properties.GetNumber ("MIDIButtonPgmUp", 0);
m_nMIDIButtonPgmDown = m_Properties.GetNumber ("MIDIButtonPgmDown", 0); m_nMIDIButtonPgmDown = m_Properties.GetNumber ("MIDIButtonPgmDown", 0);
m_nMIDIButtonBankUp = m_Properties.GetNumber ("MIDIButtonBankUp", 0);
m_nMIDIButtonBankDown = m_Properties.GetNumber ("MIDIButtonBankDown", 0);
m_nMIDIButtonTGUp = m_Properties.GetNumber ("MIDIButtonTGUp", 0); m_nMIDIButtonTGUp = m_Properties.GetNumber ("MIDIButtonTGUp", 0);
m_nMIDIButtonTGDown = m_Properties.GetNumber ("MIDIButtonTGDown", 0); m_nMIDIButtonTGDown = m_Properties.GetNumber ("MIDIButtonTGDown", 0);
@ -561,6 +567,16 @@ unsigned CConfig::GetButtonPinPgmDown (void) const
return m_nButtonPinPgmDown; return m_nButtonPinPgmDown;
} }
unsigned CConfig::GetButtonPinBankUp (void) const
{
return m_nButtonPinBankUp;
}
unsigned CConfig::GetButtonPinBankDown (void) const
{
return m_nButtonPinBankDown;
}
unsigned CConfig::GetButtonPinTGUp (void) const unsigned CConfig::GetButtonPinTGUp (void) const
{ {
return m_nButtonPinTGUp; return m_nButtonPinTGUp;
@ -581,6 +597,16 @@ const char *CConfig::GetButtonActionPgmDown (void) const
return m_ButtonActionPgmDown.c_str(); return m_ButtonActionPgmDown.c_str();
} }
const char *CConfig::GetButtonActionBankUp (void) const
{
return m_ButtonActionBankUp.c_str();
}
const char *CConfig::GetButtonActionBankDown (void) const
{
return m_ButtonActionBankDown.c_str();
}
const char *CConfig::GetButtonActionTGUp (void) const const char *CConfig::GetButtonActionTGUp (void) const
{ {
return m_ButtonActionTGUp.c_str(); return m_ButtonActionTGUp.c_str();
@ -636,6 +662,16 @@ unsigned CConfig::GetMIDIButtonPgmDown (void) const
return m_nMIDIButtonPgmDown; return m_nMIDIButtonPgmDown;
} }
unsigned CConfig::GetMIDIButtonBankUp (void) const
{
return m_nMIDIButtonBankUp;
}
unsigned CConfig::GetMIDIButtonBankDown (void) const
{
return m_nMIDIButtonBankDown;
}
unsigned CConfig::GetMIDIButtonTGUp (void) const unsigned CConfig::GetMIDIButtonTGUp (void) const
{ {
return m_nMIDIButtonTGUp; return m_nMIDIButtonTGUp;

@ -194,12 +194,16 @@ public:
// GPIO pin numbers are chip numbers, not header positions // GPIO pin numbers are chip numbers, not header positions
unsigned GetButtonPinPgmUp (void) const; unsigned GetButtonPinPgmUp (void) const;
unsigned GetButtonPinPgmDown (void) const; unsigned GetButtonPinPgmDown (void) const;
unsigned GetButtonPinBankUp (void) const;
unsigned GetButtonPinBankDown (void) const;
unsigned GetButtonPinTGUp (void) const; unsigned GetButtonPinTGUp (void) const;
unsigned GetButtonPinTGDown (void) const; unsigned GetButtonPinTGDown (void) const;
// Action type for buttons: "click", "doubleclick", "longpress", "" // Action type for buttons: "click", "doubleclick", "longpress", ""
const char *GetButtonActionPgmUp (void) const; const char *GetButtonActionPgmUp (void) const;
const char *GetButtonActionPgmDown (void) const; const char *GetButtonActionPgmDown (void) const;
const char *GetButtonActionBankUp (void) const;
const char *GetButtonActionBankDown (void) const;
const char *GetButtonActionTGUp (void) const; const char *GetButtonActionTGUp (void) const;
const char *GetButtonActionTGDown (void) const; const char *GetButtonActionTGDown (void) const;
@ -215,6 +219,8 @@ public:
// MIDI Button Program and TG Selection // MIDI Button Program and TG Selection
unsigned GetMIDIButtonPgmUp (void) const; unsigned GetMIDIButtonPgmUp (void) const;
unsigned GetMIDIButtonPgmDown (void) const; unsigned GetMIDIButtonPgmDown (void) const;
unsigned GetMIDIButtonBankUp (void) const;
unsigned GetMIDIButtonBankDown (void) const;
unsigned GetMIDIButtonTGUp (void) const; unsigned GetMIDIButtonTGUp (void) const;
unsigned GetMIDIButtonTGDown (void) const; unsigned GetMIDIButtonTGDown (void) const;
@ -303,6 +309,8 @@ private:
unsigned m_nButtonPinShortcut; unsigned m_nButtonPinShortcut;
unsigned m_nButtonPinPgmUp; unsigned m_nButtonPinPgmUp;
unsigned m_nButtonPinPgmDown; unsigned m_nButtonPinPgmDown;
unsigned m_nButtonPinBankUp;
unsigned m_nButtonPinBankDown;
unsigned m_nButtonPinTGUp; unsigned m_nButtonPinTGUp;
unsigned m_nButtonPinTGDown; unsigned m_nButtonPinTGDown;
@ -313,6 +321,8 @@ private:
std::string m_ButtonActionHome; std::string m_ButtonActionHome;
std::string m_ButtonActionPgmUp; std::string m_ButtonActionPgmUp;
std::string m_ButtonActionPgmDown; std::string m_ButtonActionPgmDown;
std::string m_ButtonActionBankUp;
std::string m_ButtonActionBankDown;
std::string m_ButtonActionTGUp; std::string m_ButtonActionTGUp;
std::string m_ButtonActionTGDown; std::string m_ButtonActionTGDown;
@ -328,6 +338,8 @@ private:
unsigned m_nMIDIButtonHome; unsigned m_nMIDIButtonHome;
unsigned m_nMIDIButtonPgmUp; unsigned m_nMIDIButtonPgmUp;
unsigned m_nMIDIButtonPgmDown; unsigned m_nMIDIButtonPgmDown;
unsigned m_nMIDIButtonBankUp;
unsigned m_nMIDIButtonBankDown;
unsigned m_nMIDIButtonTGUp; unsigned m_nMIDIButtonTGUp;
unsigned m_nMIDIButtonTGDown; unsigned m_nMIDIButtonTGDown;

@ -95,12 +95,16 @@ ButtonActionHome=doubleclick
ButtonPinShortcut=11 ButtonPinShortcut=11
# (Shortcut doesn't have an action) # (Shortcut doesn't have an action)
# GPIO Program/TG Selection # GPIO Program/Bank/TG Selection
# Any buttons set to 0 will be ignored # Any buttons set to 0 will be ignored
ButtonPinPgmUp=0 ButtonPinPgmUp=0
ButtonActionPgmUp= ButtonActionPgmUp=
ButtonPinPgmDown=0 ButtonPinPgmDown=0
ButtonActionPgmDown= ButtonActionPgmDown=
ButtonPinBankUp=0
ButtonActionBankUp=
ButtonPinBankDown=0
ButtonActionBankDown=
ButtonPinTGUp=0 ButtonPinTGUp=0
ButtonActionTGUp= ButtonActionTGUp=
ButtonPinTGDown=0 ButtonPinTGDown=0
@ -125,6 +129,8 @@ MIDIButtonSelect=0
MIDIButtonHome=0 MIDIButtonHome=0
MIDIButtonPgmUp=0 MIDIButtonPgmUp=0
MIDIButtonPgmDown=0 MIDIButtonPgmDown=0
MIDIButtonBankUp=0
MIDIButtonBankDown=0
MIDIButtonTGUp=0 MIDIButtonTGUp=0
MIDIButtonTGDown=0 MIDIButtonTGDown=0

@ -257,50 +257,8 @@ CUIButton::BtnTrigger CUIButton::triggerTypeFromString(const char* triggerString
} }
CUIButtons::CUIButtons ( CUIButtons::CUIButtons (CConfig *pConfig)
unsigned prevPin, const char *prevAction, : m_pConfig(pConfig),
unsigned nextPin, const char *nextAction,
unsigned backPin, const char *backAction,
unsigned selectPin, const char *selectAction,
unsigned homePin, const char *homeAction,
unsigned pgmUpPin, const char *pgmUpAction,
unsigned pgmDownPin, const char *pgmDownAction,
unsigned TGUpPin, const char *TGUpAction,
unsigned TGDownPin, const char *TGDownAction,
unsigned doubleClickTimeout, unsigned longPressTimeout,
unsigned notesMidi, unsigned prevMidi, unsigned nextMidi, unsigned backMidi, unsigned selectMidi, unsigned homeMidi,
unsigned pgmUpMidi, unsigned pgmDownMidi, unsigned TGUpMidi, unsigned TGDownMidi
)
: m_doubleClickTimeout(doubleClickTimeout),
m_longPressTimeout(longPressTimeout),
m_prevPin(prevPin),
m_prevAction(CUIButton::triggerTypeFromString(prevAction)),
m_nextPin(nextPin),
m_nextAction(CUIButton::triggerTypeFromString(nextAction)),
m_backPin(backPin),
m_backAction(CUIButton::triggerTypeFromString(backAction)),
m_selectPin(selectPin),
m_selectAction(CUIButton::triggerTypeFromString(selectAction)),
m_homePin(homePin),
m_homeAction(CUIButton::triggerTypeFromString(homeAction)),
m_pgmUpPin(pgmUpPin),
m_pgmUpAction(CUIButton::triggerTypeFromString(pgmUpAction)),
m_pgmDownPin(pgmDownPin),
m_pgmDownAction(CUIButton::triggerTypeFromString(pgmDownAction)),
m_TGUpPin(TGUpPin),
m_TGUpAction(CUIButton::triggerTypeFromString(TGUpAction)),
m_TGDownPin(TGDownPin),
m_TGDownAction(CUIButton::triggerTypeFromString(TGDownAction)),
m_notesMidi(notesMidi),
m_prevMidi(ccToMidiPin(prevMidi)),
m_nextMidi(ccToMidiPin(nextMidi)),
m_backMidi(ccToMidiPin(backMidi)),
m_selectMidi(ccToMidiPin(selectMidi)),
m_homeMidi(ccToMidiPin(homeMidi)),
m_pgmUpMidi(ccToMidiPin(pgmUpMidi)),
m_pgmDownMidi(ccToMidiPin(pgmDownMidi)),
m_TGUpMidi(ccToMidiPin(TGUpMidi)),
m_TGDownMidi(ccToMidiPin(TGDownMidi)),
m_eventHandler (0), m_eventHandler (0),
m_lastTick (0) m_lastTick (0)
{ {
@ -312,6 +270,46 @@ CUIButtons::~CUIButtons (void)
boolean CUIButtons::Initialize (void) boolean CUIButtons::Initialize (void)
{ {
assert (m_pConfig);
// Read the button configuration
m_doubleClickTimeout = m_pConfig->GetDoubleClickTimeout ();
m_longPressTimeout = m_pConfig->GetLongPressTimeout ();
m_prevPin = m_pConfig->GetButtonPinPrev ();
m_prevAction = CUIButton::triggerTypeFromString( m_pConfig->GetButtonActionPrev ());
m_nextPin = m_pConfig->GetButtonPinNext ();
m_nextAction = CUIButton::triggerTypeFromString( m_pConfig->GetButtonActionNext ());
m_backPin = m_pConfig->GetButtonPinBack ();
m_backAction = CUIButton::triggerTypeFromString( m_pConfig->GetButtonActionBack ());
m_selectPin = m_pConfig->GetButtonPinSelect ();
m_selectAction = CUIButton::triggerTypeFromString( m_pConfig->GetButtonActionSelect ());
m_homePin = m_pConfig->GetButtonPinHome ();
m_homeAction = CUIButton::triggerTypeFromString( m_pConfig->GetButtonActionHome ());
m_pgmUpPin = m_pConfig->GetButtonPinPgmUp ();
m_pgmUpAction = CUIButton::triggerTypeFromString( m_pConfig->GetButtonActionPgmUp ());
m_pgmDownPin = m_pConfig->GetButtonPinPgmDown ();
m_pgmDownAction = CUIButton::triggerTypeFromString( m_pConfig->GetButtonActionPgmDown ());
m_BankUpPin = m_pConfig->GetButtonPinBankUp ();
m_BankUpAction = CUIButton::triggerTypeFromString( m_pConfig->GetButtonActionBankUp ());
m_BankDownPin = m_pConfig->GetButtonPinBankDown ();
m_BankDownAction = CUIButton::triggerTypeFromString( m_pConfig->GetButtonActionBankDown ());
m_TGUpPin = m_pConfig->GetButtonPinTGUp ();
m_TGUpAction = CUIButton::triggerTypeFromString( m_pConfig->GetButtonActionTGUp ());
m_TGDownPin = m_pConfig->GetButtonPinTGDown ();
m_TGDownAction = CUIButton::triggerTypeFromString( m_pConfig->GetButtonActionTGDown ());
m_notesMidi = ccToMidiPin( m_pConfig->GetMIDIButtonNotes ());
m_prevMidi = ccToMidiPin( m_pConfig->GetMIDIButtonPrev ());
m_nextMidi = ccToMidiPin( m_pConfig->GetMIDIButtonNext ());
m_backMidi = ccToMidiPin( m_pConfig->GetMIDIButtonBack ());
m_selectMidi = ccToMidiPin( m_pConfig->GetMIDIButtonSelect ());
m_homeMidi = ccToMidiPin( m_pConfig->GetMIDIButtonHome ());
m_pgmUpMidi = ccToMidiPin( m_pConfig->GetMIDIButtonPgmUp ());
m_pgmDownMidi = ccToMidiPin( m_pConfig->GetMIDIButtonPgmDown ());
m_BankUpMidi = ccToMidiPin( m_pConfig->GetMIDIButtonBankUp ());
m_BankDownMidi = ccToMidiPin( m_pConfig->GetMIDIButtonBankDown ());
m_TGUpMidi = ccToMidiPin( m_pConfig->GetMIDIButtonTGUp ());
m_TGDownMidi = ccToMidiPin( m_pConfig->GetMIDIButtonTGDown ());
// First sanity check and convert the timeouts: // First sanity check and convert the timeouts:
// Internally values are in tenths of a millisecond, but config values // Internally values are in tenths of a millisecond, but config values
// are in milliseconds // are in milliseconds
@ -332,16 +330,16 @@ boolean CUIButtons::Initialize (void)
// longpress. We may not initialise all of the buttons. // longpress. We may not initialise all of the buttons.
// MIDI buttons only support a single click. // MIDI buttons only support a single click.
unsigned pins[MAX_BUTTONS] = { unsigned pins[MAX_BUTTONS] = {
m_prevPin, m_nextPin, m_backPin, m_selectPin, m_homePin, m_pgmUpPin, m_pgmDownPin, m_TGUpPin, m_TGDownPin, m_prevPin, m_nextPin, m_backPin, m_selectPin, m_homePin, m_pgmUpPin, m_pgmDownPin, m_BankUpPin, m_BankDownPin, m_TGUpPin, m_TGDownPin,
m_prevMidi, m_nextMidi, m_backMidi, m_selectMidi, m_homeMidi, m_pgmUpMidi, m_pgmDownMidi, m_TGUpMidi, m_TGDownMidi m_prevMidi, m_nextMidi, m_backMidi, m_selectMidi, m_homeMidi, m_pgmUpMidi, m_pgmDownMidi, m_BankUpMidi, m_BankDownMidi, m_TGUpMidi, m_TGDownMidi
}; };
CUIButton::BtnTrigger triggers[MAX_BUTTONS] = { CUIButton::BtnTrigger triggers[MAX_BUTTONS] = {
// Normal buttons // Normal buttons
m_prevAction, m_nextAction, m_backAction, m_selectAction, m_homeAction, m_prevAction, m_nextAction, m_backAction, m_selectAction, m_homeAction,
m_pgmUpAction, m_pgmDownAction, m_TGUpAction, m_TGDownAction, m_pgmUpAction, m_pgmDownAction, m_BankUpAction, m_BankDownAction, m_TGUpAction, m_TGDownAction,
// MIDI Buttons only support a single click (at present) // MIDI Buttons only support a single click (at present)
CUIButton::BtnTriggerClick, CUIButton::BtnTriggerClick, CUIButton::BtnTriggerClick, CUIButton::BtnTriggerClick, CUIButton::BtnTriggerClick, CUIButton::BtnTriggerClick, CUIButton::BtnTriggerClick, CUIButton::BtnTriggerClick, CUIButton::BtnTriggerClick, CUIButton::BtnTriggerClick,
CUIButton::BtnTriggerClick, CUIButton::BtnTriggerClick, CUIButton::BtnTriggerClick, CUIButton::BtnTriggerClick CUIButton::BtnTriggerClick, CUIButton::BtnTriggerClick, CUIButton::BtnTriggerClick, CUIButton::BtnTriggerClick, CUIButton::BtnTriggerClick, CUIButton::BtnTriggerClick
}; };
CUIButton::BtnEvent events[MAX_BUTTONS] = { CUIButton::BtnEvent events[MAX_BUTTONS] = {
// Normal buttons // Normal buttons
@ -352,6 +350,8 @@ boolean CUIButtons::Initialize (void)
CUIButton::BtnEventHome, CUIButton::BtnEventHome,
CUIButton::BtnEventPgmUp, CUIButton::BtnEventPgmUp,
CUIButton::BtnEventPgmDown, CUIButton::BtnEventPgmDown,
CUIButton::BtnEventBankUp,
CUIButton::BtnEventBankDown,
CUIButton::BtnEventTGUp, CUIButton::BtnEventTGUp,
CUIButton::BtnEventTGDown, CUIButton::BtnEventTGDown,
// MIDI buttons // MIDI buttons
@ -362,6 +362,8 @@ boolean CUIButtons::Initialize (void)
CUIButton::BtnEventHome, CUIButton::BtnEventHome,
CUIButton::BtnEventPgmUp, CUIButton::BtnEventPgmUp,
CUIButton::BtnEventPgmDown, CUIButton::BtnEventPgmDown,
CUIButton::BtnEventBankUp,
CUIButton::BtnEventBankDown,
CUIButton::BtnEventTGUp, CUIButton::BtnEventTGUp,
CUIButton::BtnEventTGDown CUIButton::BtnEventTGDown
}; };

@ -27,8 +27,8 @@
#define BUTTONS_UPDATE_NUM_TICKS 100 #define BUTTONS_UPDATE_NUM_TICKS 100
#define DEBOUNCE_TIME 20 #define DEBOUNCE_TIME 20
#define MAX_GPIO_BUTTONS 9 // 5 UI buttons, 4 Program/TG Select buttons #define MAX_GPIO_BUTTONS 11 // 5 UI buttons, 6 Program/Bank/TG Select buttons
#define MAX_MIDI_BUTTONS 9 #define MAX_MIDI_BUTTONS 11
#define MAX_BUTTONS (MAX_GPIO_BUTTONS+MAX_MIDI_BUTTONS) #define MAX_BUTTONS (MAX_GPIO_BUTTONS+MAX_MIDI_BUTTONS)
class CUIButtons; class CUIButtons;
@ -54,9 +54,11 @@ public:
BtnEventHome = 5, BtnEventHome = 5,
BtnEventPgmUp = 6, BtnEventPgmUp = 6,
BtnEventPgmDown = 7, BtnEventPgmDown = 7,
BtnEventTGUp = 8, BtnEventBankUp = 8,
BtnEventTGDown = 9, BtnEventBankDown = 9,
BtnEventUnknown = 10 BtnEventTGUp = 10,
BtnEventTGDown = 11,
BtnEventUnknown = 12
}; };
CUIButton (void); CUIButton (void);
@ -111,20 +113,7 @@ public:
typedef void BtnEventHandler (CUIButton::BtnEvent Event, void *param); typedef void BtnEventHandler (CUIButton::BtnEvent Event, void *param);
public: public:
CUIButtons ( CUIButtons (CConfig *pConfig);
unsigned prevPin, const char *prevAction,
unsigned nextPin, const char *nextAction,
unsigned backPin, const char *backAction,
unsigned selectPin, const char *selectAction,
unsigned homePin, const char *homeAction,
unsigned pgmUpPin, const char *pgmUpAction,
unsigned pgmDownPin, const char *pgmDownAction,
unsigned TGUpPin, const char *TGUpAction,
unsigned TGDownPin, const char *TGDownAction,
unsigned doubleClickTimeout, unsigned longPressTimeout,
unsigned notesMidi, unsigned prevMidi, unsigned nextMidi, unsigned backMidi, unsigned selectMidi, unsigned homeMidi,
unsigned pgmUpMidi, unsigned pgmDownMidi, unsigned TGUpMidi, unsigned TGDownMidi
);
~CUIButtons (void); ~CUIButtons (void);
boolean Initialize (void); boolean Initialize (void);
@ -138,6 +127,8 @@ public:
void BtnMIDICmdHandler (unsigned nMidiCmd, unsigned nMidiData1, unsigned nMidiData2); void BtnMIDICmdHandler (unsigned nMidiCmd, unsigned nMidiData1, unsigned nMidiData2);
private: private:
CConfig *m_pConfig;
// Array of normal GPIO buttons and "MIDI buttons" // Array of normal GPIO buttons and "MIDI buttons"
CUIButton m_buttons[MAX_BUTTONS]; CUIButton m_buttons[MAX_BUTTONS];
@ -163,6 +154,10 @@ private:
CUIButton::BtnTrigger m_pgmUpAction; CUIButton::BtnTrigger m_pgmUpAction;
unsigned m_pgmDownPin; unsigned m_pgmDownPin;
CUIButton::BtnTrigger m_pgmDownAction; CUIButton::BtnTrigger m_pgmDownAction;
unsigned m_BankUpPin;
CUIButton::BtnTrigger m_BankUpAction;
unsigned m_BankDownPin;
CUIButton::BtnTrigger m_BankDownAction;
unsigned m_TGUpPin; unsigned m_TGUpPin;
CUIButton::BtnTrigger m_TGUpAction; CUIButton::BtnTrigger m_TGUpAction;
unsigned m_TGDownPin; unsigned m_TGDownPin;
@ -178,6 +173,8 @@ private:
unsigned m_pgmUpMidi; unsigned m_pgmUpMidi;
unsigned m_pgmDownMidi; unsigned m_pgmDownMidi;
unsigned m_BankUpMidi;
unsigned m_BankDownMidi;
unsigned m_TGUpMidi; unsigned m_TGUpMidi;
unsigned m_TGDownMidi; unsigned m_TGDownMidi;

@ -431,6 +431,11 @@ void CUIMenu::EventHandler (TMenuEvent Event)
PgmUpDownHandler(Event); PgmUpDownHandler(Event);
break; break;
case MenuEventBankUp:
case MenuEventBankDown:
BankUpDownHandler(Event);
break;
case MenuEventTGUp: case MenuEventTGUp:
case MenuEventTGDown: case MenuEventTGDown:
TGUpDownHandler(Event); TGUpDownHandler(Event);
@ -1375,6 +1380,87 @@ void CUIMenu::PgmUpDownHandler (TMenuEvent Event)
} }
} }
void CUIMenu::BankUpDownHandler (TMenuEvent Event)
{
if (m_pMiniDexed->GetParameter (CMiniDexed::ParameterPerformanceSelectChannel) != CMIDIDevice::Disabled)
{
// Bank Up/Down acts on performances
unsigned nLastPerformanceBank = m_pMiniDexed->GetLastPerformanceBank();
unsigned nPerformanceBank = m_nSelectedPerformanceBankID;
unsigned nStartBank = nPerformanceBank;
//LOGNOTE("Performance Bank actual=%d, last=%d", nPerformanceBank, nLastPerformanceBank);
if (Event == MenuEventBankDown)
{
do
{
if (nPerformanceBank == 0)
{
// Wrap around
nPerformanceBank = nLastPerformanceBank;
}
else if (nPerformanceBank > 0)
{
--nPerformanceBank;
}
} while ((m_pMiniDexed->IsValidPerformanceBank(nPerformanceBank) != true) && (nPerformanceBank != nStartBank));
m_nSelectedPerformanceBankID = nPerformanceBank;
// Switch to the new bank and select the first performance voice
m_pMiniDexed->SetParameter (CMiniDexed::ParameterPerformanceBank, nPerformanceBank);
m_pMiniDexed->SetFirstPerformance();
//LOGNOTE("Performance Bank new=%d, last=%d", m_nSelectedPerformanceBankID, nLastPerformanceBank);
}
else // MenuEventBankUp
{
do
{
if (nPerformanceBank == nLastPerformanceBank)
{
// Wrap around
nPerformanceBank = 0;
}
else if (nPerformanceBank < nLastPerformanceBank)
{
++nPerformanceBank;
}
} while ((m_pMiniDexed->IsValidPerformanceBank(nPerformanceBank) != true) && (nPerformanceBank != nStartBank));
m_nSelectedPerformanceBankID = nPerformanceBank;
m_pMiniDexed->SetParameter (CMiniDexed::ParameterPerformanceBank, nPerformanceBank);
m_pMiniDexed->SetFirstPerformance();
//LOGNOTE("Performance Bank new=%d, last=%d", m_nSelectedPerformanceBankID, nLastPerformanceBank);
}
}
else
{
// Bank Up/Down acts on voices within a TG.
// If we're not in the root menu, then see if we are already in a TG menu,
// then find the current TG number. Otherwise assume TG1 (nTG=0).
unsigned nTG = 0;
if (m_MenuStackMenu[0] == s_MainMenu && (m_pCurrentMenu == s_TGMenu) || (m_MenuStackMenu[1] == s_TGMenu)) {
nTG = m_nMenuStackSelection[0];
}
assert (nTG < CConfig::AllToneGenerators);
if (nTG < m_nToneGenerators)
{
int nBank = m_pMiniDexed->GetTGParameter (CMiniDexed::TGParameterVoiceBank, nTG);
assert (Event == MenuEventBankDown || Event == MenuEventBankUp);
if (Event == MenuEventBankDown)
{
//LOGNOTE("BankDown");
nBank = m_pMiniDexed->GetSysExFileLoader ()->GetNextBankDown(nBank);
m_pMiniDexed->SetTGParameter (CMiniDexed::TGParameterVoiceBank, nBank, nTG);
}
else
{
//LOGNOTE("BankUp");
nBank = m_pMiniDexed->GetSysExFileLoader ()->GetNextBankUp(nBank);
m_pMiniDexed->SetTGParameter (CMiniDexed::TGParameterVoiceBank, nBank, nTG);
}
}
}
}
void CUIMenu::TGUpDownHandler (TMenuEvent Event) void CUIMenu::TGUpDownHandler (TMenuEvent Event)
{ {
// This will update the menus to position it for the next TG up or down // This will update the menus to position it for the next TG up or down

@ -48,6 +48,8 @@ public:
MenuEventPressAndStepUp, MenuEventPressAndStepUp,
MenuEventPgmUp, MenuEventPgmUp,
MenuEventPgmDown, MenuEventPgmDown,
MenuEventBankUp,
MenuEventBankDown,
MenuEventTGUp, MenuEventTGUp,
MenuEventTGDown, MenuEventTGDown,
MenuEventUnknown MenuEventUnknown
@ -119,6 +121,7 @@ private:
void OPShortcutHandler (TMenuEvent Event); void OPShortcutHandler (TMenuEvent Event);
void PgmUpDownHandler (TMenuEvent Event); void PgmUpDownHandler (TMenuEvent Event);
void BankUpDownHandler (TMenuEvent Event);
void TGUpDownHandler (TMenuEvent Event); void TGUpDownHandler (TMenuEvent Event);
static void TimerHandler (TKernelTimerHandle hTimer, void *pParam, void *pContext); static void TimerHandler (TKernelTimerHandle hTimer, void *pParam, void *pContext);

@ -162,37 +162,7 @@ bool CUserInterface::Initialize (void)
LOGDBG ("LCD initialized"); LOGDBG ("LCD initialized");
} }
m_pUIButtons = new CUIButtons ( m_pConfig->GetButtonPinPrev (), m_pUIButtons = new CUIButtons ( m_pConfig );
m_pConfig->GetButtonActionPrev (),
m_pConfig->GetButtonPinNext (),
m_pConfig->GetButtonActionNext (),
m_pConfig->GetButtonPinBack (),
m_pConfig->GetButtonActionBack (),
m_pConfig->GetButtonPinSelect (),
m_pConfig->GetButtonActionSelect (),
m_pConfig->GetButtonPinHome (),
m_pConfig->GetButtonActionHome (),
m_pConfig->GetButtonPinPgmUp (),
m_pConfig->GetButtonActionPgmUp (),
m_pConfig->GetButtonPinPgmDown (),
m_pConfig->GetButtonActionPgmDown (),
m_pConfig->GetButtonPinTGUp (),
m_pConfig->GetButtonActionTGUp (),
m_pConfig->GetButtonPinTGDown (),
m_pConfig->GetButtonActionTGDown (),
m_pConfig->GetDoubleClickTimeout (),
m_pConfig->GetLongPressTimeout (),
m_pConfig->GetMIDIButtonNotes (),
m_pConfig->GetMIDIButtonPrev (),
m_pConfig->GetMIDIButtonNext (),
m_pConfig->GetMIDIButtonBack (),
m_pConfig->GetMIDIButtonSelect (),
m_pConfig->GetMIDIButtonHome (),
m_pConfig->GetMIDIButtonPgmUp (),
m_pConfig->GetMIDIButtonPgmDown (),
m_pConfig->GetMIDIButtonTGUp (),
m_pConfig->GetMIDIButtonTGDown ()
);
assert (m_pUIButtons); assert (m_pUIButtons);
if (!m_pUIButtons->Initialize ()) if (!m_pUIButtons->Initialize ())
@ -397,6 +367,14 @@ void CUserInterface::UIButtonsEventHandler (CUIButton::BtnEvent Event)
m_Menu.EventHandler (CUIMenu::MenuEventPgmDown); m_Menu.EventHandler (CUIMenu::MenuEventPgmDown);
break; break;
case CUIButton::BtnEventBankUp:
m_Menu.EventHandler (CUIMenu::MenuEventBankUp);
break;
case CUIButton::BtnEventBankDown:
m_Menu.EventHandler (CUIMenu::MenuEventBankDown);
break;
case CUIButton::BtnEventTGUp: case CUIButton::BtnEventTGUp:
m_Menu.EventHandler (CUIMenu::MenuEventTGUp); m_Menu.EventHandler (CUIMenu::MenuEventTGUp);
break; break;

Loading…
Cancel
Save