Added option to invert rotary encoder CLK/DATA pins to reverse operation for certain encoders (Issue#185)
This commit is contained in:
parent
4cf352d70e
commit
46381430e1
6 changed files with 33 additions and 5 deletions
|
@ -132,9 +132,13 @@ GraphIEC = 1
|
||||||
//
|
//
|
||||||
// Please see dmRotary.h for full implementation details.
|
// Please see dmRotary.h for full implementation details.
|
||||||
//
|
//
|
||||||
//RotaryEncoderEnable = 1
|
// Updated to address issue #185 and allow for inversion of rotary operation
|
||||||
|
// for certain encoders. - 08/13/2020 by Geo...
|
||||||
|
//
|
||||||
|
RotaryEncoderEnable = 1
|
||||||
|
RotaryEncoderInvert = 1
|
||||||
|
|
||||||
// This option will display the temperature of the Pi's CPU.
|
// This option will display the temperature of the Pi's CPU.
|
||||||
// It should be about 52°C anything above 65°C is bad and there is something wrong with your hardware
|
// It should be about 52<EFBFBD>C anything above 65<36>C is bad and there is something wrong with your hardware
|
||||||
//DisplayTemperature = 1
|
//DisplayTemperature = 1
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,8 @@ unsigned IEC_Bus::gplev0;
|
||||||
//ROTARY: Added for rotary encoder support - 09/05/2019 by Geo...
|
//ROTARY: Added for rotary encoder support - 09/05/2019 by Geo...
|
||||||
RotaryEncoder IEC_Bus::rotaryEncoder;
|
RotaryEncoder IEC_Bus::rotaryEncoder;
|
||||||
bool IEC_Bus::rotaryEncoderEnable;
|
bool IEC_Bus::rotaryEncoderEnable;
|
||||||
|
//ROTARY: Added for rotary encoder inversion (Issue#185) - 08/13/2020 by Geo...
|
||||||
|
bool IEC_Bus::rotaryEncoderInvert;
|
||||||
|
|
||||||
void IEC_Bus::ReadGPIOUserInput( int buttonCount)
|
void IEC_Bus::ReadGPIOUserInput( int buttonCount)
|
||||||
{
|
{
|
||||||
|
|
|
@ -365,9 +365,17 @@ public:
|
||||||
|
|
||||||
//ROTARY: Added for rotary encoder support - 09/05/2019 by Geo...
|
//ROTARY: Added for rotary encoder support - 09/05/2019 by Geo...
|
||||||
if (IEC_Bus::rotaryEncoderEnable == true)
|
if (IEC_Bus::rotaryEncoderEnable == true)
|
||||||
|
{
|
||||||
|
//ROTARY: Added for rotary encoder inversion (Issue#185) - 08/13/2020 by Geo...
|
||||||
|
if (IEC_Bus::rotaryEncoderInvert == true)
|
||||||
|
{
|
||||||
|
IEC_Bus::rotaryEncoder.Initialize(RPI_GPIO23, RPI_GPIO22, RPI_GPIO27);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
IEC_Bus::rotaryEncoder.Initialize(RPI_GPIO22, RPI_GPIO23, RPI_GPIO27);
|
IEC_Bus::rotaryEncoder.Initialize(RPI_GPIO22, RPI_GPIO23, RPI_GPIO27);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -661,6 +669,12 @@ public:
|
||||||
rotaryEncoderEnable = value;
|
rotaryEncoderEnable = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//ROTARY: Added for rotary encoder inversion (Issue#185) - 08/13/2020 by Geo...
|
||||||
|
static inline void SetRotaryEncoderInvert(bool value)
|
||||||
|
{
|
||||||
|
rotaryEncoderInvert = value;
|
||||||
|
}
|
||||||
|
|
||||||
// CA1 input ATN
|
// CA1 input ATN
|
||||||
// If CA1 is ever set to output
|
// If CA1 is ever set to output
|
||||||
// - CA1 will start to drive pb7
|
// - CA1 will start to drive pb7
|
||||||
|
@ -728,6 +742,8 @@ private:
|
||||||
//ROTARY: Added for rotary encoder support - 09/05/2019 by Geo...
|
//ROTARY: Added for rotary encoder support - 09/05/2019 by Geo...
|
||||||
static RotaryEncoder rotaryEncoder;
|
static RotaryEncoder rotaryEncoder;
|
||||||
static bool rotaryEncoderEnable;
|
static bool rotaryEncoderEnable;
|
||||||
|
//ROTARY: Added for rotary encoder inversion (Issue#185) - 08/13/2020 by Geo...
|
||||||
|
static bool rotaryEncoderInvert;
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1940,6 +1940,8 @@ extern "C"
|
||||||
IEC_Bus::SetIgnoreReset(options.IgnoreReset());
|
IEC_Bus::SetIgnoreReset(options.IgnoreReset());
|
||||||
//ROTARY: Added for rotary encoder support - 09/05/2019 by Geo...
|
//ROTARY: Added for rotary encoder support - 09/05/2019 by Geo...
|
||||||
IEC_Bus::SetRotaryEncoderEnable(options.RotaryEncoderEnable());
|
IEC_Bus::SetRotaryEncoderEnable(options.RotaryEncoderEnable());
|
||||||
|
//ROTARY: Added for rotary encoder inversion (Issue#185) - 08/13/2020 by Geo...
|
||||||
|
IEC_Bus::SetRotaryEncoderInvert(options.RotaryEncoderInvert());
|
||||||
#if not defined(EXPERIMENTALZERO)
|
#if not defined(EXPERIMENTALZERO)
|
||||||
if (!options.SoundOnGPIO())
|
if (!options.SoundOnGPIO())
|
||||||
{
|
{
|
||||||
|
|
|
@ -159,7 +159,7 @@ Options::Options(void)
|
||||||
, buttonBack(4)
|
, buttonBack(4)
|
||||||
, buttonInsert(5)
|
, buttonInsert(5)
|
||||||
, rotaryEncoderEnable(0) //ROTARY:
|
, rotaryEncoderEnable(0) //ROTARY:
|
||||||
|
, rotaryEncoderInvert(0) //ROTARY:
|
||||||
{
|
{
|
||||||
autoMountImageName[0] = 0;
|
autoMountImageName[0] = 0;
|
||||||
strcpy(ROMFontName, "chargen");
|
strcpy(ROMFontName, "chargen");
|
||||||
|
@ -251,6 +251,7 @@ void Options::Process(char* buffer)
|
||||||
ELSE_CHECK_DECIMAL_OPTION(buttonBack)
|
ELSE_CHECK_DECIMAL_OPTION(buttonBack)
|
||||||
ELSE_CHECK_DECIMAL_OPTION(buttonInsert)
|
ELSE_CHECK_DECIMAL_OPTION(buttonInsert)
|
||||||
ELSE_CHECK_DECIMAL_OPTION(rotaryEncoderEnable) //ROTARY:
|
ELSE_CHECK_DECIMAL_OPTION(rotaryEncoderEnable) //ROTARY:
|
||||||
|
ELSE_CHECK_DECIMAL_OPTION(rotaryEncoderInvert) //ROTARY:
|
||||||
else if ((strcasecmp(pOption, "AutoBaseName") == 0))
|
else if ((strcasecmp(pOption, "AutoBaseName") == 0))
|
||||||
{
|
{
|
||||||
strncpy(autoBaseName, pValue, 255);
|
strncpy(autoBaseName, pValue, 255);
|
||||||
|
|
|
@ -109,6 +109,8 @@ public:
|
||||||
|
|
||||||
//ROTARY: Added for rotary encoder support - 09/05/2019 by Geo...
|
//ROTARY: Added for rotary encoder support - 09/05/2019 by Geo...
|
||||||
inline unsigned int RotaryEncoderEnable() const { return rotaryEncoderEnable; }
|
inline unsigned int RotaryEncoderEnable() const { return rotaryEncoderEnable; }
|
||||||
|
//ROTARY: Added for rotary encoder inversion (Issue#185) - 08/13/2020 by Geo...
|
||||||
|
inline unsigned int RotaryEncoderInvert() const { return rotaryEncoderInvert; }
|
||||||
|
|
||||||
// Page up and down will jump a different amount based on the maximum number rows displayed.
|
// Page up and down will jump a different amount based on the maximum number rows displayed.
|
||||||
// Perhaps we should use some keyboard modifier to the the other screen?
|
// Perhaps we should use some keyboard modifier to the the other screen?
|
||||||
|
@ -191,6 +193,8 @@ private:
|
||||||
|
|
||||||
//ROTARY: Added for rotary encoder support - 09/05/2019 by Geo...
|
//ROTARY: Added for rotary encoder support - 09/05/2019 by Geo...
|
||||||
unsigned int rotaryEncoderEnable;
|
unsigned int rotaryEncoderEnable;
|
||||||
|
//ROTARY: Added for rotary encoder inversion (Issue#185) - 08/13/2020 by Geo...
|
||||||
|
unsigned int rotaryEncoderInvert;
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue