Skip to content

Conversation

@RKBoss6
Copy link
Contributor

@RKBoss6 RKBoss6 commented Sep 17, 2025

Just checks if the button is released, then cancel the check for long press, to avoid users pressing once, then once more and the screen turns on.

@RKBoss6 RKBoss6 marked this pull request as ready for review September 17, 2025 21:50
Copy link
Collaborator

@bobrippling bobrippling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find, thanks! Just a couple of little things

@RKBoss6 RKBoss6 marked this pull request as draft September 18, 2025 11:59
@RKBoss6
Copy link
Contributor Author

RKBoss6 commented Oct 14, 2025

This doesn't work, and if you press, release, and then press quickly, it still checks for the button and lights up the screen, even with the checks in place. @bobrippling do you have any idea why that could be?

Comment on lines +25 to 27
longPressTimer=setTimeout(() => {
if (digitalRead(BTN1)) {
//set brightness until. locked.
Copy link
Collaborator

@bobrippling bobrippling Oct 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work, and if you press, release, and then press quickly, it still checks for the button and lights up the screen, even with the checks in place. @bobrippling do you have any idea why that could be?

I don't think my below suggestion is right unless there's a race between 'clearTimeout()` and the invocation of the timeout func.

If you add debug logs to both the timeout function (each arm of the if) and the setWatch callback, what gets printed?

Suggested change
longPressTimer=setTimeout(() => {
if (digitalRead(BTN1)) {
//set brightness until. locked.
longPressTimer=setTimeout(() => {
if (longPressTimer == null) {
// cancelled, ignore
return;
}
if (digitalRead(BTN1)) {
//set brightness until. locked.

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

Successfully merging this pull request may close these issues.

2 participants