-
-
Notifications
You must be signed in to change notification settings - Fork 41
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
[BUG]: Duplicated last activated item after manual refresh #264
Labels
bug
Something isn't working
Comments
mriveralee
added a commit
to mriveralee/LcdMenu
that referenced
this issue
Jan 4, 2025
mriveralee
added a commit
to mriveralee/LcdMenu
that referenced
this issue
Jan 4, 2025
11 tasks
forntoh
added a commit
that referenced
this issue
Jan 4, 2025
## Description This PR fixes #264. I reproduced this bug and have found the issue: `ItemToggle::toggle()` executes its `callback` function before it redraws. When `menu.refresh()` is in the callback function, it changes the cursor row position to the max row. Then ItemToggle calls its draw to duplicate the item on the last visible row. The simple solution here is to move the callback after the redraw. A similar approach is used in ItemInput, `ItemInput::back()`(https://github.com/forntoh/LcdMenu/blob/master/src/ItemInput.h#L189) , which calls `draw(...)` _first_ and then execute the callback. ## How Has This Been Tested? I used the provided code in #264 with an Arduino Nano, LCD Display 4x20 I2C , and Rotary Encoder. I tested by running the code, toggle the first item to trigger the `menu.refresh()` call, and visually verified the problem is resolved. I also tested the individual toggle examples to make sure the behavior works as expected. ## Additional Notes --- ### Checklist <!-- Note: Without all of these items checked the PR will not be reviewed. --> #### General Requirements - [X] I have kept this PR in draft until all the required tasks are completed. - [X] I have reviewed the [contributing guidelines](/CONTRIBUTING.md) for this project. - [X] I have tagged this PR with `breaking-change` if it introduces a breaking change. - [X] I have checked that this PR does not introduce any breaking changes unless explicitly stated. - [X] I have checked that changes generate no new warnings. - [X] I have performed a self-review of my own code - [X] I have built and tested **ALL** the examples to ensure that I haven't broken anything. #### Bug Fix <!-- Delete this section if it doesn't apply to your PR. --> - [X] **This PR is a bug fix.** - [X] I have tagged this PR with `bugfix`. - [X] I have added a link to the bug in the description. - [X] I have added tests that prove my fix is effective. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Summary by CodeRabbit - **Bug Fixes** - Improved toggle state management to ensure logging and drawing operations accurately reflect the updated item state after toggling. - **Chores** - Updated GitHub Actions workflow for lint checking to disable automatic fixes and commits during the linting process. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What happened?
Im not sure if im doing something wrong or not but heres what i have experienced with the following code. I dont feel that it is hardware specific, maybe someone can confirm or deny.
![image](https://private-user-images.githubusercontent.com/15861028/386270653-a4fdf1c6-41e8-4ddb-a9a8-de5b5ba06a38.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk3MDI3NDgsIm5iZiI6MTczOTcwMjQ0OCwicGF0aCI6Ii8xNTg2MTAyOC8zODYyNzA2NTMtYTRmZGYxYzYtNDFlOC00ZGRiLWE5YTgtZGU1YjViYTA2YTM4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE2VDEwNDA0OFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWJlNDVkMDMzYTdiNzQ2NGNmNWNkOTNhODc3YTAzNmIzN2VjMmQ0NThhZjJhYTA5MzEzMGE1NWMwZWZjYzYyZGMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.y6YMslew93w8Za8C5lFSZJd5KAnAkdDC9NmEpCcT25M)
I have 4 toggle items: Start all, Start 0, Start 1, Start 2. i can toggle things individually by Start 1,2,3 or toggle them together by Start all. With Start all i use setIsOn on the display items Start 0 1 2 then call refresh to show the changed items. After refresh the last activated menu item is duplicated on the last line of the lcd, in this case Start all. What should happen is the last line should correctly show Start 2:ON
After i move the cursor the display goes back to its correct state.
Heres what i see on the lcd before and after activation of the first item:
And heres the code:
Version
5.3.1
What environment are you seeing the problem in?
Arduino
Board type
Mega2560
Relevant log output
No response
The text was updated successfully, but these errors were encountered: