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

Configurable GPIO buttons #274

Merged
merged 20 commits into from
Jul 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
c27da61
First attempt at button user interface instead of a rotary encoder. …
diyelectromusic May 24, 2022
2c614f5
First attempt at button user interface to replace rotary encoder. Ve…
diyelectromusic May 24, 2022
91fb643
Merge branch 'buttongpio' of github.com:diyelectromusic/MiniDexed int…
diyelectromusic May 24, 2022
5c71f91
Rename buttons to prev-next-back-select-home and fix a few things too.
diyelectromusic May 25, 2022
5c9bab0
Merge remote-tracking branch 'upstream/main' into steve_buttongpio
stevelittlefish Jun 5, 2022
1ad0560
Fixed assertion on startup due to uninitialised variable
stevelittlefish Jun 5, 2022
74d2dc6
Removed ButtonEnabled from config
stevelittlefish Jun 5, 2022
a894f94
Use 0 instead of 255 to disable buttons in ini file
stevelittlefish Jun 5, 2022
4179d07
Buttons can have click, double click and long press events
stevelittlefish Jun 6, 2022
c050e04
Removed encoder button support
stevelittlefish Jun 6, 2022
37ad81b
Better click behaviour when no double click is mapped
stevelittlefish Jun 6, 2022
1a9edda
Revert "Removed encoder button support"
stevelittlefish Jun 11, 2022
393ced1
Removed single, double and triple click handlers from encoder
stevelittlefish Jun 11, 2022
8d3fb5f
Encoder shortcut resets button presses
stevelittlefish Jun 13, 2022
b2167d8
Adjusted timing variables for UI Buttons
stevelittlefish Jun 14, 2022
ef92fd9
Renamed EncoderPinSwitch to ButtonPinShortcut
stevelittlefish Jun 27, 2022
96ad7ec
Double click triggered by release instead of keypress
stevelittlefish Jun 27, 2022
a8fd1da
Long press and double click timeouts in config
stevelittlefish Jun 27, 2022
5dac051
Removed debug
stevelittlefish Jun 29, 2022
24d1fd7
Changed default config
stevelittlefish Jul 13, 2022
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,7 @@ MiniDexed*
sdcard
*.zip
*.img

# Editor related files
*.swp
*.swo
2 changes: 1 addition & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ CMSIS_DIR = ../CMSIS_5/CMSIS
OBJS = main.o kernel.o minidexed.o config.o userinterface.o uimenu.o \
mididevice.o midikeyboard.o serialmididevice.o pckeyboard.o \
sysexfileloader.o performanceconfig.o perftimer.o \
effect_compressor.o effect_platervbstereo.o
effect_compressor.o effect_platervbstereo.o uibuttons.o

OPTIMIZE = -O3

Expand Down
87 changes: 81 additions & 6 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,25 @@ void CConfig::Load (void)
m_nLCDPinData7 = m_Properties.GetNumber ("LCDPinData7", 25);
m_nLCDI2CAddress = m_Properties.GetNumber ("LCDI2CAddress", 0);

m_nButtonPinPrev = m_Properties.GetNumber ("ButtonPinPrev", 0);
m_nButtonPinNext = m_Properties.GetNumber ("ButtonPinNext", 0);
m_nButtonPinBack = m_Properties.GetNumber ("ButtonPinBack", 11);
m_nButtonPinSelect = m_Properties.GetNumber ("ButtonPinSelect", 11);
m_nButtonPinHome = m_Properties.GetNumber ("ButtonPinHome", 11);
m_nButtonPinShortcut = m_Properties.GetNumber ("ButtonPinShortcut", 11);

m_ButtonActionPrev = m_Properties.GetString ("ButtonActionPrev", "");
m_ButtonActionNext = m_Properties.GetString ("ButtonActionNext", "");
m_ButtonActionBack = m_Properties.GetString ("ButtonActionBack", "doubleclick");
m_ButtonActionSelect = m_Properties.GetString ("ButtonActionSelect", "click");
m_ButtonActionHome = m_Properties.GetString ("ButtonActionHome", "longpress");

m_nDoubleClickTimeout = m_Properties.GetNumber ("DoubleClickTimeout", 400);
m_nLongPressTimeout = m_Properties.GetNumber ("LongPressTimeout", 600);

m_bEncoderEnabled = m_Properties.GetNumber ("EncoderEnabled", 0) != 0;
m_nEncoderPinClock = m_Properties.GetNumber ("EncoderPinClock", 10);
m_nEncoderPinData = m_Properties.GetNumber ("EncoderPinData", 9);
m_nEncoderPinSwitch = m_Properties.GetNumber ("EncoderPinSwitch", 11);

m_bMIDIDumpEnabled = m_Properties.GetNumber ("MIDIDumpEnabled", 0) != 0;
m_bProfileEnabled = m_Properties.GetNumber ("ProfileEnabled", 0) != 0;
Expand Down Expand Up @@ -180,6 +195,71 @@ unsigned CConfig::GetLCDI2CAddress (void) const
return m_nLCDI2CAddress;
}

unsigned CConfig::GetButtonPinPrev (void) const
{
return m_nButtonPinPrev;
}

unsigned CConfig::GetButtonPinNext (void) const
{
return m_nButtonPinNext;
}

unsigned CConfig::GetButtonPinBack (void) const
{
return m_nButtonPinBack;
}

unsigned CConfig::GetButtonPinSelect (void) const
{
return m_nButtonPinSelect;
}

unsigned CConfig::GetButtonPinHome (void) const
{
return m_nButtonPinHome;
}

unsigned CConfig::GetButtonPinShortcut (void) const
{
return m_nButtonPinShortcut;
}

const char *CConfig::GetButtonActionPrev (void) const
{
return m_ButtonActionPrev.c_str();
}

const char *CConfig::GetButtonActionNext (void) const
{
return m_ButtonActionNext.c_str();
}

const char *CConfig::GetButtonActionBack (void) const
{
return m_ButtonActionBack.c_str();
}

const char *CConfig::GetButtonActionSelect (void) const
{
return m_ButtonActionSelect.c_str();
}

const char *CConfig::GetButtonActionHome (void) const
{
return m_ButtonActionHome.c_str();
}

unsigned CConfig::GetDoubleClickTimeout (void) const
{
return m_nDoubleClickTimeout;
}

unsigned CConfig::GetLongPressTimeout (void) const
{
return m_nLongPressTimeout;
}

bool CConfig::GetEncoderEnabled (void) const
{
return m_bEncoderEnabled;
Expand All @@ -195,11 +275,6 @@ unsigned CConfig::GetEncoderPinData (void) const
return m_nEncoderPinData;
}

unsigned CConfig::GetEncoderPinSwitch (void) const
{
return m_nEncoderPinSwitch;
}

bool CConfig::GetMIDIDumpEnabled (void) const
{
return m_bMIDIDumpEnabled;
Expand Down
38 changes: 36 additions & 2 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,32 @@ class CConfig // Configuration for MiniDexed
unsigned GetLCDPinData6 (void) const;
unsigned GetLCDPinData7 (void) const;
unsigned GetLCDI2CAddress (void) const;

// GPIO Button Navigation
// GPIO pin numbers are chip numbers, not header positions
unsigned GetButtonPinPrev (void) const;
unsigned GetButtonPinNext (void) const;
unsigned GetButtonPinBack (void) const;
unsigned GetButtonPinSelect (void) const;
unsigned GetButtonPinHome (void) const;
unsigned GetButtonPinShortcut (void) const;

// Action type for buttons: "click", "doubleclick", "longpress", ""
const char *GetButtonActionPrev (void) const;
const char *GetButtonActionNext (void) const;
const char *GetButtonActionBack (void) const;
const char *GetButtonActionSelect (void) const;
const char *GetButtonActionHome (void) const;

// Timeouts for button events in milliseconds
unsigned GetDoubleClickTimeout (void) const;
unsigned GetLongPressTimeout (void) const;

// KY-040 Rotary Encoder
// GPIO pin numbers are chip numbers, not header positions
bool GetEncoderEnabled (void) const;
unsigned GetEncoderPinClock (void) const;
unsigned GetEncoderPinData (void) const;
unsigned GetEncoderPinSwitch (void) const;

// Debug
bool GetMIDIDumpEnabled (void) const;
Expand Down Expand Up @@ -122,11 +141,26 @@ class CConfig // Configuration for MiniDexed
unsigned m_nLCDPinData6;
unsigned m_nLCDPinData7;
unsigned m_nLCDI2CAddress;

unsigned m_nButtonPinPrev;
unsigned m_nButtonPinNext;
unsigned m_nButtonPinBack;
unsigned m_nButtonPinSelect;
unsigned m_nButtonPinHome;
unsigned m_nButtonPinShortcut;

std::string m_ButtonActionPrev;
std::string m_ButtonActionNext;
std::string m_ButtonActionBack;
std::string m_ButtonActionSelect;
std::string m_ButtonActionHome;

unsigned m_nDoubleClickTimeout;
unsigned m_nLongPressTimeout;

bool m_bEncoderEnabled;
unsigned m_nEncoderPinClock;
unsigned m_nEncoderPinData;
unsigned m_nEncoderPinSwitch;

bool m_bMIDIDumpEnabled;
bool m_bProfileEnabled;
Expand Down
2 changes: 1 addition & 1 deletion src/mididevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,6 @@ void CMIDIDevice::SendSystemExclusiveVoice(uint8_t nVoice, const unsigned nCable
for(Iterator = s_DeviceMap.begin(); Iterator != s_DeviceMap.end(); ++Iterator)
{
Iterator->second->Send (voicedump, sizeof(voicedump)*sizeof(uint8_t));
LOGDBG("Send SYSEX voice dump %u to \"%s\"",nVoice,Iterator->first.c_str());
// LOGDBG("Send SYSEX voice dump %u to \"%s\"",nVoice,Iterator->first.c_str());
}
}
20 changes: 19 additions & 1 deletion src/minidexed.ini
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,29 @@ LCDPinData6=24
LCDPinData7=25
LCDI2CAddress=0x00

# GPIO Button Navigation
# Any buttons set to 0 will be ignored
ButtonPinPrev=0
ButtonActionPrev=
ButtonPinNext=0
ButtonActionNext=
ButtonPinBack=11
ButtonActionBack=longpress
ButtonPinSelect=11
ButtonActionSelect=click
ButtonPinHome=11
ButtonActionHome=doubleclick
ButtonPinShortcut=11
# (Shortcut doesn't have an action)

# Timeouts in milliseconds for double click and long press
DoubleClickTimeout=400
LongPressTimeout=400

# KY-040 Rotary Encoder
EncoderEnabled=1
EncoderPinClock=10
EncoderPinData=9
EncoderPinSwitch=11

# Debug
MIDIDumpEnabled=0
Expand Down
Loading