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

The function isEncoderButtonDown() returns an incorrect value when areEncoderPinsPulldown_forEsp32=false #83

Closed
kr4fty opened this issue Aug 4, 2024 · 1 comment

Comments

@kr4fty
Copy link

kr4fty commented Aug 4, 2024

if arEncoderPinsPulldown_forEsp32 = true, the button will always read a LOW. Then isEncoderButtonDown() returns a FALSE, which is correct.

button UP -----> isEncoderButtonDown() returns FALSE
button DOWN ----> isEncoderButtonDown() returns TRUE

Now if areEncoderPinsPulldown_forEsp32 = false (center pin connected to GND), if we read the button state without having it pressed, it would give me a HIGH state. Then isEncoderButtonDown() returns a TRUE, but it should be FALSE

button UP -----> isEncoderButtonDown() returns TRUE, it should be FALSE
button DOWN ----> isEncoderButtonDown() returns FALSE, it should be TRUE

The function should be something like:

bool AiEsp32RotaryEncoder::isEncoderButtonDown()
{
	if(!areEncoderPinsPulldownforEsp32)
		return digitalRead(encoderButtonPin) ? false : true;
	else
		return digitalRead(encoderButtonPin) ? true : false;
}
@kr4fty kr4fty changed the title Wrong output with EncoderPinsPulldown_forEsp32=false The function isEncoderButtonDown() returns an incorrect value when areEncoderPinsPulldown_forEsp32=false Aug 4, 2024
@igorantolic
Copy link
Owner

igorantolic commented Aug 6, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants