|
| 1 | +type: board |
| 2 | +name: "board_buttons" |
| 3 | + |
| 4 | +tests: |
| 5 | + - name: "Button A press detection" |
| 6 | + action: hardware_script |
| 7 | + pre_prompt: "Appuyez sur le bouton A quand la LED verte s'allume (5s)." |
| 8 | + script: | |
| 9 | + from machine import Pin |
| 10 | + from time import sleep_ms, ticks_ms, ticks_diff |
| 11 | + led = Pin("LED_GREEN", Pin.OUT) |
| 12 | + btn = Pin("A_BUTTON", Pin.IN, Pin.PULL_UP) |
| 13 | + led.on() |
| 14 | + detected = False |
| 15 | + t0 = ticks_ms() |
| 16 | + while ticks_diff(ticks_ms(), t0) < 5000: |
| 17 | + if btn.value() == 0: |
| 18 | + detected = True |
| 19 | + break |
| 20 | + sleep_ms(20) |
| 21 | + led.off() |
| 22 | + result = detected |
| 23 | + expect_true: true |
| 24 | + mode: [hardware] |
| 25 | + |
| 26 | + - name: "Button B press detection" |
| 27 | + action: hardware_script |
| 28 | + pre_prompt: "Appuyez sur le bouton B quand la LED verte s'allume (5s)." |
| 29 | + script: | |
| 30 | + from machine import Pin |
| 31 | + from time import sleep_ms, ticks_ms, ticks_diff |
| 32 | + led = Pin("LED_GREEN", Pin.OUT) |
| 33 | + btn = Pin("B_BUTTON", Pin.IN, Pin.PULL_UP) |
| 34 | + led.on() |
| 35 | + detected = False |
| 36 | + t0 = ticks_ms() |
| 37 | + while ticks_diff(ticks_ms(), t0) < 5000: |
| 38 | + if btn.value() == 0: |
| 39 | + detected = True |
| 40 | + break |
| 41 | + sleep_ms(20) |
| 42 | + led.off() |
| 43 | + result = detected |
| 44 | + expect_true: true |
| 45 | + mode: [hardware] |
| 46 | + |
| 47 | + - name: "Button MENU press detection" |
| 48 | + action: hardware_script |
| 49 | + pre_prompt: "Appuyez sur le bouton MENU quand la LED verte s'allume (5s)." |
| 50 | + script: | |
| 51 | + from machine import Pin |
| 52 | + from time import sleep_ms, ticks_ms, ticks_diff |
| 53 | + led = Pin("LED_GREEN", Pin.OUT) |
| 54 | + btn = Pin("MENU_BUTTON", Pin.IN, Pin.PULL_UP) |
| 55 | + led.on() |
| 56 | + detected = False |
| 57 | + t0 = ticks_ms() |
| 58 | + while ticks_diff(ticks_ms(), t0) < 5000: |
| 59 | + if btn.value() == 0: |
| 60 | + detected = True |
| 61 | + break |
| 62 | + sleep_ms(20) |
| 63 | + led.off() |
| 64 | + result = detected |
| 65 | + expect_true: true |
| 66 | + mode: [hardware] |
0 commit comments