|
|
@ -36,6 +36,8 @@ CUIButton::CUIButton (void) |
|
|
|
m_clickEvent(BtnEventNone), |
|
|
|
m_clickEvent(BtnEventNone), |
|
|
|
m_doubleClickEvent(BtnEventNone), |
|
|
|
m_doubleClickEvent(BtnEventNone), |
|
|
|
m_longPressEvent(BtnEventNone), |
|
|
|
m_longPressEvent(BtnEventNone), |
|
|
|
|
|
|
|
m_decEvent(BtnEventNone), |
|
|
|
|
|
|
|
m_incEvent(BtnEventNone), |
|
|
|
m_doubleClickTimeout(0), |
|
|
|
m_doubleClickTimeout(0), |
|
|
|
m_longPressTimeout(0) |
|
|
|
m_longPressTimeout(0) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -101,6 +103,16 @@ void CUIButton::setLongPressEvent(BtnEvent longPressEvent) |
|
|
|
m_longPressEvent = longPressEvent; |
|
|
|
m_longPressEvent = longPressEvent; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CUIButton::setDecEvent(BtnEvent decEvent) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
m_decEvent = decEvent; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CUIButton::setIncEvent(BtnEvent incEvent) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
m_incEvent = incEvent; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
unsigned CUIButton::getPinNumber(void) |
|
|
|
unsigned CUIButton::getPinNumber(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return m_pinNumber; |
|
|
|
return m_pinNumber; |
|
|
@ -109,6 +121,7 @@ unsigned CUIButton::getPinNumber(void) |
|
|
|
CUIButton::BtnTrigger CUIButton::ReadTrigger (void) |
|
|
|
CUIButton::BtnTrigger CUIButton::ReadTrigger (void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
unsigned value; |
|
|
|
unsigned value; |
|
|
|
|
|
|
|
unsigned raw = 0; |
|
|
|
if (isMidiPin(m_pinNumber)) |
|
|
|
if (isMidiPin(m_pinNumber)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!m_midipin) |
|
|
|
if (!m_midipin) |
|
|
@ -117,6 +130,7 @@ CUIButton::BtnTrigger CUIButton::ReadTrigger (void) |
|
|
|
return BtnTriggerNone; |
|
|
|
return BtnTriggerNone; |
|
|
|
} |
|
|
|
} |
|
|
|
value = m_midipin->Read(); |
|
|
|
value = m_midipin->Read(); |
|
|
|
|
|
|
|
raw = m_midipin->ReadRaw(); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
@ -128,6 +142,21 @@ CUIButton::BtnTrigger CUIButton::ReadTrigger (void) |
|
|
|
value = m_pin->Read(); |
|
|
|
value = m_pin->Read(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (m_decEvent && 60 < raw && raw < 64) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
reset(); |
|
|
|
|
|
|
|
// reset value to trigger only once
|
|
|
|
|
|
|
|
m_midipin->Write(0); |
|
|
|
|
|
|
|
return BtnTriggerDec; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (m_incEvent && 64 < raw && raw < 68) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
reset(); |
|
|
|
|
|
|
|
// reset value to trigger only once
|
|
|
|
|
|
|
|
m_midipin->Write(0); |
|
|
|
|
|
|
|
return BtnTriggerInc; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (m_timer < m_longPressTimeout) { |
|
|
|
if (m_timer < m_longPressTimeout) { |
|
|
|
m_timer++; |
|
|
|
m_timer++; |
|
|
|
|
|
|
|
|
|
|
@ -230,6 +259,12 @@ CUIButton::BtnEvent CUIButton::Read (void) { |
|
|
|
else if (trigger == BtnTriggerLongPress) { |
|
|
|
else if (trigger == BtnTriggerLongPress) { |
|
|
|
return m_longPressEvent; |
|
|
|
return m_longPressEvent; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else if (trigger == BtnTriggerDec) { |
|
|
|
|
|
|
|
return m_decEvent; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (trigger == BtnTriggerInc) { |
|
|
|
|
|
|
|
return m_incEvent; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
assert (trigger == BtnTriggerNone); |
|
|
|
assert (trigger == BtnTriggerNone); |
|
|
|
|
|
|
|
|
|
|
@ -250,6 +285,12 @@ CUIButton::BtnTrigger CUIButton::triggerTypeFromString(const char* triggerString |
|
|
|
else if (strcmp(triggerString, "longpress") == 0) { |
|
|
|
else if (strcmp(triggerString, "longpress") == 0) { |
|
|
|
return BtnTriggerLongPress; |
|
|
|
return BtnTriggerLongPress; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else if (strcmp(triggerString, "dec") == 0) { |
|
|
|
|
|
|
|
return BtnTriggerDec; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (strcmp(triggerString, "inc") == 0) { |
|
|
|
|
|
|
|
return BtnTriggerInc; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
LOGERR("Invalid action: %s", triggerString); |
|
|
|
LOGERR("Invalid action: %s", triggerString); |
|
|
|
|
|
|
|
|
|
|
@ -347,7 +388,7 @@ boolean CUIButtons::Initialize (void) |
|
|
|
|
|
|
|
|
|
|
|
// Each normal button can be assigned up to 3 actions: click, doubleclick and
|
|
|
|
// Each normal button can be assigned up to 3 actions: click, doubleclick and
|
|
|
|
// longpress. We may not initialise all of the buttons.
|
|
|
|
// longpress. We may not initialise all of the buttons.
|
|
|
|
// MIDI buttons can be assigned to click, doubleclick, lopngpress
|
|
|
|
// MIDI buttons can be assigned to click, doubleclick, lopngpress, dec ,inc
|
|
|
|
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_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_TGUpMidi, m_TGDownMidi |
|
|
@ -454,6 +495,12 @@ void CUIButtons::bindButton(unsigned pinNumber, CUIButton::BtnTrigger trigger, C |
|
|
|
else if (trigger == CUIButton::BtnTriggerLongPress) { |
|
|
|
else if (trigger == CUIButton::BtnTriggerLongPress) { |
|
|
|
m_buttons[i].setLongPressEvent(event); |
|
|
|
m_buttons[i].setLongPressEvent(event); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else if (trigger == CUIButton::BtnTriggerDec) { |
|
|
|
|
|
|
|
m_buttons[i].setDecEvent(event); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (trigger == CUIButton::BtnTriggerInc) { |
|
|
|
|
|
|
|
m_buttons[i].setIncEvent(event); |
|
|
|
|
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
assert (trigger == CUIButton::BtnTriggerNone); |
|
|
|
assert (trigger == CUIButton::BtnTriggerNone); |
|
|
|
} |
|
|
|
} |
|
|
|