Skip to content

Add button_e_pressed property and make any_button_pressed dynamic - #99

Open
nikitashiwach2000 wants to merge 2 commits into
adafruit:mainfrom
nikitashiwach2000:add-button-e-properties
Open

nikitashiwach2000 wants to merge 2 commits into
adafruit:mainfrom
nikitashiwach2000:add-button-e-properties

Conversation

@nikitashiwach2000

Copy link
Copy Markdown

Fixes #98

Description of Changes

  • Added the missing button_e_pressed property for the BOOT0 button.
  • Refactored any_button_pressed to dynamically iterate through the self.buttons list using a list comprehension instead of using a hardcoded range. This prevents future bugs if more buttons are added to the hardware.

Testing Done

  • Verified the core logic locally by running a custom python unit test script using unittest.mock.MagicMock to simulate the hardware peripheral states. All logic passed successfully.

return not self.buttons[3].value

@property
def button_e_pressed(self) -> bool:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would be in favor of naming this more descriptively to match the skilkscreen. There is no label "e" on the boot button. Granted there also don't appear to be labels a-d on the other buttons, but the four of them being in a row makes them a little easier to to match up with the letters a-d.

Can you rename the property to button_boot_pressed? That way it is immediately clear when reading it which physical button it's referring to.

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.

magtag.peripherals.buttons list has a fifth element for button e (BOOT0), but not button_e_pressed; ALSO button e missing from any_button_pressed.

3 participants