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

ShiftRegisterKeys key_count value was wrong #9719

Merged
merged 1 commit into from
Oct 15, 2024

Conversation

dhalbert
Copy link
Collaborator

When keypad.ShiftRegisterKeys(..., key_count=some_integer, ...) had an integer argument, the argument was not correctly converted to an integer. This error was inadvertently introduced by #8143.

Testing:

import board
import keypad

keys = keypad.ShiftRegisterKeys(
    data               = board.GP0,
   clock              = board.GP1,
   latch              = board.GP2,
   key_count          = 8,
   value_when_pressed = True,
   value_to_latch     = True,
   )

The bug is that .u_int was used instead of .u_obj. When the bug is present, keys.key_count produces 17 (which is the encoded micropython representation of 8). This fix returns 8 correctly.

@dhalbert
Copy link
Collaborator Author

@aseanwatson, the reporter in #9718, has tested and confirms it's a fix.

Copy link
Member

@jepler jepler left a comment

Choose a reason for hiding this comment

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

thank you!

@dhalbert dhalbert merged commit 7107369 into adafruit:main Oct 15, 2024
470 checks passed
@dhalbert dhalbert deleted the shiftregisterkeys-key_count-fix branch October 15, 2024 14:27
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.

keypad.ShiftRegisterKeys has wrong key_count
2 participants