-
Notifications
You must be signed in to change notification settings - Fork 1
tests: Add board qualification tests for A/B/Menu buttons. #92
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
Merged
nedseb
merged 4 commits into
feature/board-qualification-framework
from
feature/board-buttons
Mar 13, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6cc871e
tests: Add board qualification tests for A/B/Menu buttons.
nedseb fd3334d
tests: Add released-state check and use wait false for button tests.
nedseb 5d137c8
tests: Add interrupt tests and rename existing to polling for buttons.
nedseb 14f786d
tests: Add D-PAD buttons and timeout on release-wait loops.
nedseb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,283 @@ | ||
| type: board | ||
| name: "board_buttons" | ||
|
|
||
| # --- Polling tests (one per button) --- | ||
| # LED_GREEN signals when the board is ready to read the button. | ||
|
|
||
| tests: | ||
| - name: "Button A press (polling)" | ||
| action: hardware_script | ||
|
nedseb marked this conversation as resolved.
|
||
| pre_prompt: "Test polling boutons : appuyez sur chaque bouton quand la LED verte s'allume (5s). Commençons par A." | ||
| wait: false | ||
| script: | | ||
| from machine import Pin | ||
| from time import sleep_ms, ticks_ms, ticks_diff | ||
| led = Pin("LED_GREEN", Pin.OUT) | ||
| btn = Pin("A_BUTTON", Pin.IN, Pin.PULL_UP) | ||
| t_rel = ticks_ms() | ||
| while btn.value() == 0: | ||
| if ticks_diff(ticks_ms(), t_rel) > 3000: | ||
| break | ||
| sleep_ms(20) | ||
|
nedseb marked this conversation as resolved.
|
||
| led.on() | ||
| detected = False | ||
| t0 = ticks_ms() | ||
| while ticks_diff(ticks_ms(), t0) < 5000: | ||
| if btn.value() == 0: | ||
| detected = True | ||
| break | ||
|
nedseb marked this conversation as resolved.
|
||
| sleep_ms(20) | ||
| led.off() | ||
| result = detected | ||
| expect_true: true | ||
| mode: [hardware] | ||
|
|
||
| - name: "Button B press (polling)" | ||
| action: hardware_script | ||
| pre_prompt: "Bouton B" | ||
| wait: false | ||
| script: | | ||
| from machine import Pin | ||
| from time import sleep_ms, ticks_ms, ticks_diff | ||
| led = Pin("LED_GREEN", Pin.OUT) | ||
| btn = Pin("B_BUTTON", Pin.IN, Pin.PULL_UP) | ||
| t_rel = ticks_ms() | ||
| while btn.value() == 0: | ||
| if ticks_diff(ticks_ms(), t_rel) > 3000: | ||
| break | ||
| sleep_ms(20) | ||
|
nedseb marked this conversation as resolved.
|
||
| led.on() | ||
| detected = False | ||
| t0 = ticks_ms() | ||
| while ticks_diff(ticks_ms(), t0) < 5000: | ||
| if btn.value() == 0: | ||
| detected = True | ||
| break | ||
|
nedseb marked this conversation as resolved.
|
||
| sleep_ms(20) | ||
| led.off() | ||
| result = detected | ||
| expect_true: true | ||
| mode: [hardware] | ||
|
|
||
| - name: "Button MENU press (polling)" | ||
| action: hardware_script | ||
| pre_prompt: "Bouton MENU" | ||
| wait: false | ||
| script: | | ||
| from machine import Pin | ||
| from time import sleep_ms, ticks_ms, ticks_diff | ||
| led = Pin("LED_GREEN", Pin.OUT) | ||
| btn = Pin("MENU_BUTTON", Pin.IN, Pin.PULL_UP) | ||
| t_rel = ticks_ms() | ||
| while btn.value() == 0: | ||
| if ticks_diff(ticks_ms(), t_rel) > 3000: | ||
| break | ||
| sleep_ms(20) | ||
|
nedseb marked this conversation as resolved.
|
||
| led.on() | ||
| detected = False | ||
| t0 = ticks_ms() | ||
| while ticks_diff(ticks_ms(), t0) < 5000: | ||
| if btn.value() == 0: | ||
| detected = True | ||
| break | ||
| sleep_ms(20) | ||
|
nedseb marked this conversation as resolved.
|
||
| led.off() | ||
| result = detected | ||
| expect_true: true | ||
| mode: [hardware] | ||
|
|
||
| # --- D-PAD buttons via MCP23009E (I2C 0x20, GPIO register 0x09) --- | ||
| # Read directly via I2C without importing the driver. | ||
| # Bit mapping: UP=bit7, DOWN=bit5, LEFT=bit6, RIGHT=bit4. | ||
|
|
||
| - name: "D-PAD UP press (polling)" | ||
| action: hardware_script | ||
| pre_prompt: "Test polling D-PAD : appuyez sur chaque bouton quand la LED verte s'allume (5s). Commençons par UP." | ||
| wait: false | ||
| script: | | ||
| from machine import Pin, I2C | ||
| from time import sleep_ms, ticks_ms, ticks_diff | ||
| led = Pin("LED_GREEN", Pin.OUT) | ||
| i2c = I2C(1) | ||
| bit = 7 | ||
| led.on() | ||
| detected = False | ||
| t0 = ticks_ms() | ||
| while ticks_diff(ticks_ms(), t0) < 5000: | ||
| gpio = i2c.readfrom_mem(0x20, 0x09, 1)[0] | ||
| if not (gpio & (1 << bit)): | ||
| detected = True | ||
| break | ||
| sleep_ms(20) | ||
| led.off() | ||
| result = detected | ||
| expect_true: true | ||
| mode: [hardware] | ||
|
|
||
| - name: "D-PAD DOWN press (polling)" | ||
| action: hardware_script | ||
| pre_prompt: "Bouton DOWN" | ||
| wait: false | ||
| script: | | ||
| from machine import Pin, I2C | ||
| from time import sleep_ms, ticks_ms, ticks_diff | ||
| led = Pin("LED_GREEN", Pin.OUT) | ||
| i2c = I2C(1) | ||
| bit = 5 | ||
| led.on() | ||
| detected = False | ||
| t0 = ticks_ms() | ||
| while ticks_diff(ticks_ms(), t0) < 5000: | ||
| gpio = i2c.readfrom_mem(0x20, 0x09, 1)[0] | ||
| if not (gpio & (1 << bit)): | ||
| detected = True | ||
| break | ||
| sleep_ms(20) | ||
| led.off() | ||
| result = detected | ||
| expect_true: true | ||
| mode: [hardware] | ||
|
|
||
| - name: "D-PAD LEFT press (polling)" | ||
| action: hardware_script | ||
| pre_prompt: "Bouton LEFT" | ||
| wait: false | ||
| script: | | ||
| from machine import Pin, I2C | ||
| from time import sleep_ms, ticks_ms, ticks_diff | ||
| led = Pin("LED_GREEN", Pin.OUT) | ||
| i2c = I2C(1) | ||
| bit = 6 | ||
| led.on() | ||
| detected = False | ||
| t0 = ticks_ms() | ||
| while ticks_diff(ticks_ms(), t0) < 5000: | ||
| gpio = i2c.readfrom_mem(0x20, 0x09, 1)[0] | ||
| if not (gpio & (1 << bit)): | ||
| detected = True | ||
| break | ||
| sleep_ms(20) | ||
| led.off() | ||
| result = detected | ||
| expect_true: true | ||
| mode: [hardware] | ||
|
|
||
| - name: "D-PAD RIGHT press (polling)" | ||
| action: hardware_script | ||
| pre_prompt: "Bouton RIGHT" | ||
| wait: false | ||
| script: | | ||
| from machine import Pin, I2C | ||
| from time import sleep_ms, ticks_ms, ticks_diff | ||
| led = Pin("LED_GREEN", Pin.OUT) | ||
| i2c = I2C(1) | ||
| bit = 4 | ||
| led.on() | ||
| detected = False | ||
| t0 = ticks_ms() | ||
| while ticks_diff(ticks_ms(), t0) < 5000: | ||
| gpio = i2c.readfrom_mem(0x20, 0x09, 1)[0] | ||
| if not (gpio & (1 << bit)): | ||
| detected = True | ||
| break | ||
| sleep_ms(20) | ||
| led.off() | ||
| result = detected | ||
| expect_true: true | ||
| mode: [hardware] | ||
|
|
||
| # --- Interrupt tests (GPIO direct buttons) --- | ||
| # LED_GREEN signals when the board is ready; uses Pin.irq() to detect press. | ||
|
|
||
| - name: "Button A press (interrupt)" | ||
| action: hardware_script | ||
| pre_prompt: "Test interrupt boutons : appuyez brièvement sur chaque bouton quand la LED verte s'allume (5s). Commençons par A." | ||
| wait: false | ||
| script: | | ||
| from machine import Pin | ||
| from time import sleep_ms, ticks_ms, ticks_diff | ||
| led = Pin("LED_GREEN", Pin.OUT) | ||
| btn = Pin("A_BUTTON", Pin.IN, Pin.PULL_UP) | ||
| t_rel = ticks_ms() | ||
| while btn.value() == 0: | ||
| if ticks_diff(ticks_ms(), t_rel) > 3000: | ||
| break | ||
| sleep_ms(20) | ||
|
nedseb marked this conversation as resolved.
|
||
| detected = False | ||
| def on_press(pin): | ||
| global detected | ||
| detected = True | ||
| btn.irq(trigger=Pin.IRQ_FALLING, handler=on_press) | ||
| led.on() | ||
| t0 = ticks_ms() | ||
| while ticks_diff(ticks_ms(), t0) < 5000: | ||
| if detected: | ||
| break | ||
| sleep_ms(20) | ||
| btn.irq(handler=None) | ||
| led.off() | ||
| result = detected | ||
| expect_true: true | ||
| mode: [hardware] | ||
|
|
||
| - name: "Button B press (interrupt)" | ||
| action: hardware_script | ||
| pre_prompt: "Bouton B" | ||
| wait: false | ||
| script: | | ||
| from machine import Pin | ||
| from time import sleep_ms, ticks_ms, ticks_diff | ||
| led = Pin("LED_GREEN", Pin.OUT) | ||
| btn = Pin("B_BUTTON", Pin.IN, Pin.PULL_UP) | ||
| t_rel = ticks_ms() | ||
| while btn.value() == 0: | ||
| if ticks_diff(ticks_ms(), t_rel) > 3000: | ||
| break | ||
| sleep_ms(20) | ||
|
nedseb marked this conversation as resolved.
|
||
| detected = False | ||
| def on_press(pin): | ||
| global detected | ||
| detected = True | ||
| btn.irq(trigger=Pin.IRQ_FALLING, handler=on_press) | ||
| led.on() | ||
| t0 = ticks_ms() | ||
| while ticks_diff(ticks_ms(), t0) < 5000: | ||
| if detected: | ||
| break | ||
| sleep_ms(20) | ||
| btn.irq(handler=None) | ||
| led.off() | ||
| result = detected | ||
| expect_true: true | ||
| mode: [hardware] | ||
|
|
||
| - name: "Button MENU press (interrupt)" | ||
| action: hardware_script | ||
| pre_prompt: "Bouton MENU" | ||
| wait: false | ||
| script: | | ||
| from machine import Pin | ||
| from time import sleep_ms, ticks_ms, ticks_diff | ||
| led = Pin("LED_GREEN", Pin.OUT) | ||
| btn = Pin("MENU_BUTTON", Pin.IN, Pin.PULL_UP) | ||
| t_rel = ticks_ms() | ||
| while btn.value() == 0: | ||
| if ticks_diff(ticks_ms(), t_rel) > 3000: | ||
| break | ||
| sleep_ms(20) | ||
|
nedseb marked this conversation as resolved.
|
||
| detected = False | ||
| def on_press(pin): | ||
| global detected | ||
| detected = True | ||
| btn.irq(trigger=Pin.IRQ_FALLING, handler=on_press) | ||
| led.on() | ||
| t0 = ticks_ms() | ||
| while ticks_diff(ticks_ms(), t0) < 5000: | ||
| if detected: | ||
| break | ||
| sleep_ms(20) | ||
| btn.irq(handler=None) | ||
| led.off() | ||
| result = detected | ||
| expect_true: true | ||
| mode: [hardware] | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.