Skip to content

Commit 299b623

Browse files
committed
Change EncoderDetents to EncoderResolution with string values
- Replace numeric parameter with user-friendly strings: full, half, quarter - Add validation with silent fallback to default (full) - Clarify INI documentation Addresses feedback from sourcery-ai bot review.
1 parent 7298db1 commit 299b623

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

src/config.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,26 @@ void CConfig::Load (void)
218218
m_bEncoderEnabled = m_Properties.GetNumber ("EncoderEnabled", 0) != 0;
219219
m_nEncoderPinClock = m_Properties.GetNumber ("EncoderPinClock", 10);
220220
m_nEncoderPinData = m_Properties.GetNumber ("EncoderPinData", 9);
221-
m_nEncoderDetents = m_Properties.GetNumber ("EncoderDetents", 4);
221+
222+
// Parse encoder resolution
223+
const char *pResolution = m_Properties.GetString ("EncoderResolution", "full");
224+
if (strcasecmp (pResolution, "full") == 0)
225+
{
226+
m_nEncoderDetents = 4;
227+
}
228+
else if (strcasecmp (pResolution, "half") == 0)
229+
{
230+
m_nEncoderDetents = 2;
231+
}
232+
else if (strcasecmp (pResolution, "quarter") == 0)
233+
{
234+
m_nEncoderDetents = 1;
235+
}
236+
else
237+
{
238+
// Invalid value, use default
239+
m_nEncoderDetents = 4;
240+
}
222241

223242
m_bMIDIDumpEnabled = m_Properties.GetNumber ("MIDIDumpEnabled", 0) != 0;
224243
m_bProfileEnabled = m_Properties.GetNumber ("ProfileEnabled", 0) != 0;

src/minidexed.ini

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,8 @@ MIDIButtonTGDown=56
151151
EncoderEnabled=1
152152
EncoderPinClock=10
153153
EncoderPinData=9
154-
# Detents per rotation to be recognized:
155-
# 1 = Quarter Step Encoder
156-
# 2 = Half Step Encoder
157-
# 4 = Full Step Encoder (default)
158-
EncoderDetents=4
154+
# Encoder resolution: full, half, or quarter (default: full)
155+
EncoderResolution=full
159156

160157
# Debug
161158
MIDIDumpEnabled=0

0 commit comments

Comments
 (0)