From a894f948f80b38ea2dfaa0317d820f882597d24f Mon Sep 17 00:00:00 2001 From: Stephen Brown Date: Sun, 5 Jun 2022 23:12:09 +0100 Subject: [PATCH] Use 0 instead of 255 to disable buttons in ini file --- .gitignore | 4 ++++ src/config.cpp | 10 +++++----- src/config.h | 3 --- src/minidexed.ini | 2 +- src/uibuttons.cpp | 2 +- src/uibuttons.h | 2 +- 6 files changed, 12 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 62c5120..6303c46 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,7 @@ MiniDexed* sdcard *.zip *.img + +# Editor related files +*.swp +*.swo diff --git a/src/config.cpp b/src/config.cpp index 5211cf2..d1a86ef 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -81,11 +81,11 @@ void CConfig::Load (void) m_nLCDPinData7 = m_Properties.GetNumber ("LCDPinData7", 25); m_nLCDI2CAddress = m_Properties.GetNumber ("LCDI2CAddress", 0); - m_nButtonPinPrev = m_Properties.GetNumber ("ButtonPinPrev", NOPIN); - m_nButtonPinNext = m_Properties.GetNumber ("ButtonPinNext", NOPIN); - m_nButtonPinBack = m_Properties.GetNumber ("ButtonPinBack", NOPIN); - m_nButtonPinSelect = m_Properties.GetNumber ("ButtonPinSelect", NOPIN); - m_nButtonPinHome = m_Properties.GetNumber ("ButtonPinHome", NOPIN); + m_nButtonPinPrev = m_Properties.GetNumber ("ButtonPinPrev", 0); + m_nButtonPinNext = m_Properties.GetNumber ("ButtonPinNext", 0); + m_nButtonPinBack = m_Properties.GetNumber ("ButtonPinBack", 0); + m_nButtonPinSelect = m_Properties.GetNumber ("ButtonPinSelect", 0); + m_nButtonPinHome = m_Properties.GetNumber ("ButtonPinHome", 0); m_bEncoderEnabled = m_Properties.GetNumber ("EncoderEnabled", 0) != 0; m_nEncoderPinClock = m_Properties.GetNumber ("EncoderPinClock", 10); diff --git a/src/config.h b/src/config.h index 44d5ba5..8c6e47f 100644 --- a/src/config.h +++ b/src/config.h @@ -28,9 +28,6 @@ #include #include -// This has to match the value mentioned in minidexed.ini -#define NOPIN 255 - class CConfig // Configuration for MiniDexed { public: diff --git a/src/minidexed.ini b/src/minidexed.ini index 80fded9..847f015 100644 --- a/src/minidexed.ini +++ b/src/minidexed.ini @@ -32,7 +32,7 @@ LCDI2CAddress=0x00 # 5 Buttons based on an "arrow keypad" with a "home" # 2 Buttons "back" and "select" for use in addition to a rotary encoder # -# Although actually any buttons set to 255 will be ignored +# Any buttons set to 0 will be ignored # ButtonPinPrev=16 ButtonPinNext=20 diff --git a/src/uibuttons.cpp b/src/uibuttons.cpp index c54cb1a..df28e2e 100644 --- a/src/uibuttons.cpp +++ b/src/uibuttons.cpp @@ -45,7 +45,7 @@ boolean CUIButton::Initialize (void) { assert (!m_pPin); - if (m_nPin != NOPIN) + if (m_nPin != 0) { m_pPin = new CGPIOPin (m_nPin, GPIOModeInputPullUp); } diff --git a/src/uibuttons.h b/src/uibuttons.h index 5870ec3..c8c57b7 100644 --- a/src/uibuttons.h +++ b/src/uibuttons.h @@ -59,7 +59,7 @@ public: typedef void TBtnEventHandler (TBtnEvent Event, void *pParam); public: - CUIButtons (unsigned nPrevPin = NOPIN, unsigned nNextPin = NOPIN, unsigned nBackPin = NOPIN, unsigned nSelectPin = NOPIN, unsigned nHomePin = NOPIN); + CUIButtons (unsigned nPrevPin = 0, unsigned nNextPin = 0, unsigned nBackPin = 0, unsigned nSelectPin = 0, unsigned nHomePin = 0); ~CUIButtons (void); boolean Initialize (void);