Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
6 changes: 3 additions & 3 deletions src/kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ bool CKernel::Initialize (void)
}
m_Config.SetUSBGadgetMode(bUSBGadgetMode);

if (!m_pUSB->Initialize ())
{
if (!m_pUSB->Initialize ())
{
return FALSE;
}
}

m_pDexed = new CMiniDexed (&m_Config, &mInterrupt, &m_GPIOManager, &m_I2CMaster, m_pSPIMaster,
&mFileSystem);
Expand Down
16 changes: 11 additions & 5 deletions src/minidexed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ CMiniDexed::CMiniDexed (CConfig *pConfig, CInterruptSystem *pInterrupt,
m_WPASupplicant(nullptr),
m_bNetworkReady(false),
m_bNetworkInit(false),
m_lastNetworkUpdate(0),
m_UDPMIDI(nullptr),
m_pmDNSPublisher (nullptr),
m_bSavePerformance (false),
Expand Down Expand Up @@ -395,7 +396,6 @@ void CMiniDexed::Process (bool bPlugAndPlayUpdated)
m_pMIDIKeyboard[i]->Process (bPlugAndPlayUpdated);
pScheduler->Yield();
}

m_PCKeyboard.Process (bPlugAndPlayUpdated);

if (m_bUseSerial)
Expand Down Expand Up @@ -461,9 +461,16 @@ void CMiniDexed::Process (bool bPlugAndPlayUpdated)
m_GetChunkTimer.Dump ();
pScheduler->Yield();
}
#define NETWORK_UPDATE_NUM_TICKS 1000000
if (m_pNet) {
UpdateNetwork();
unsigned currentTick = CTimer::GetClockTicks();
if (currentTick - m_lastNetworkUpdate > NETWORK_UPDATE_NUM_TICKS)
{
m_lastNetworkUpdate = currentTick;
UpdateNetwork();
}
}

// Allow other tasks to run
pScheduler->Yield();
}
Expand Down Expand Up @@ -2264,9 +2271,8 @@ void CMiniDexed::UpdateNetwork()
}

bool bNetIsRunning = m_pNet->IsRunning();
if (m_pNetDevice->GetType() == NetDeviceTypeEthernet)
bNetIsRunning &= m_pNetDevice->IsLinkUp();
else if (m_pNetDevice->GetType() == NetDeviceTypeWLAN)

if (m_pNetDevice->GetType() == NetDeviceTypeWLAN)
bNetIsRunning &= (m_WPASupplicant && m_WPASupplicant->IsConnected());
Comment thread
sourcery-ai[bot] marked this conversation as resolved.

if (!m_bNetworkInit && bNetIsRunning)
Expand Down
1 change: 1 addition & 0 deletions src/minidexed.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ class CMiniDexed
CWPASupplicant* m_WPASupplicant; // Changed to pointer
bool m_bNetworkReady;
bool m_bNetworkInit;
unsigned m_lastNetworkUpdate;
CUDPMIDIDevice* m_UDPMIDI; // Changed to pointer
CFTPDaemon* m_pFTPDaemon;
CmDNSPublisher *m_pmDNSPublisher;
Expand Down
15 changes: 8 additions & 7 deletions src/uibuttons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ unsigned CUIButton::getPinNumber(void)
return m_pinNumber;
}

CUIButton::BtnTrigger CUIButton::ReadTrigger (void)
CUIButton::BtnTrigger CUIButton::ReadTrigger (unsigned interval)
{
unsigned value;
if (isMidiPin(m_pinNumber))
Expand All @@ -130,15 +130,15 @@ CUIButton::BtnTrigger CUIButton::ReadTrigger (void)
}

if (m_timer < m_longPressTimeout) {
m_timer++;
m_timer+=interval;

if (m_timer == m_doubleClickTimeout && m_lastValue == 1 && m_numClicks == 1) {
if (m_timer >= m_doubleClickTimeout && m_lastValue == 1 && m_numClicks == 1) {
// The user has clicked and released the button once within the
// timeout - this must be a single click
reset();
return BtnTriggerClick;
}
if (m_timer == m_longPressTimeout) {
if (m_timer >= m_longPressTimeout) {
if (m_lastValue == 0 && m_numClicks == 1) {
// Single long press
reset();
Expand Down Expand Up @@ -219,8 +219,8 @@ void CUIButton::Write (unsigned nValue) {
}
}

CUIButton::BtnEvent CUIButton::Read (void) {
BtnTrigger trigger = ReadTrigger();
CUIButton::BtnEvent CUIButton::Read (unsigned interval) {
BtnTrigger trigger = ReadTrigger(interval);

if (trigger == BtnTriggerClick) {
return m_clickEvent;
Expand Down Expand Up @@ -471,10 +471,11 @@ void CUIButtons::Update (void)
return;
}

m_interval = (currentTick - m_lastTick)/BUTTONS_UPDATE_NUM_TICKS;
m_lastTick = currentTick;

for (unsigned i=0; i<MAX_BUTTONS; i++) {
CUIButton::BtnEvent event = m_buttons[i].Read();
CUIButton::BtnEvent event = m_buttons[i].Read(m_interval);
if (event != CUIButton::BtnEventNone) {
// LOGDBG("Event: %u", event);
(*m_eventHandler) (event, m_eventParam);
Expand Down
5 changes: 3 additions & 2 deletions src/uibuttons.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ class CUIButton

unsigned getPinNumber(void);

BtnTrigger ReadTrigger (void);
BtnEvent Read (void);
BtnTrigger ReadTrigger (unsigned interval);
BtnEvent Read (unsigned interval);
void Write (unsigned nValue); // MIDI buttons only!

static BtnTrigger triggerTypeFromString(const char* triggerString);
Expand Down Expand Up @@ -182,6 +182,7 @@ class CUIButtons
void *m_eventParam;

unsigned m_lastTick;
unsigned m_interval;

void bindButton(unsigned pinNumber, CUIButton::BtnTrigger trigger, CUIButton::BtnEvent event);
};
Expand Down
Loading