File tree Expand file tree Collapse file tree 2 files changed +12
-7
lines changed
Expand file tree Collapse file tree 2 files changed +12
-7
lines changed Original file line number Diff line number Diff line change 88
99import pyb
1010
11- pyb .LED (3 ).on ()
12- pyb .delay (2000 )
13- pyb .LED (4 ).on ()
14- pyb .LED (3 ).off ()
15- switch = pyb .Switch () # check if switch was pressed decision phase
11+ pyb .LED (3 ).on () # indicate we are waiting for switch press
12+ pyb .delay (2000 ) # wait for user to maybe press the switch
13+ switch_value = pyb .Switch ()() # sample the switch at end of delay
14+ pyb .LED (3 ).off () # indicate that we finished waiting for the switch
1615
17- if switch ():
16+ pyb .LED (4 ).on () # indicate that we are selecting the mode
17+
18+ if switch_value :
1819 pyb .usb_mode ('CDC+MSC' )
1920 pyb .main ('cardreader.py' ) # if switch was pressed, run this
2021else :
2122 pyb .usb_mode ('CDC+HID' )
2223 pyb .main ('datalogger.py' ) # if switch wasn't pressed, run this
2324
24- pyb .LED (4 ).off ()
25+ pyb .LED (4 ).off () # indicate that we finished selecting the mode
Original file line number Diff line number Diff line change 1111# loop
1212while True :
1313
14+ # wait for interrupt
15+ # this reduces power consumption while waiting for switch press
16+ pyb .wfi ()
17+
1418 # start if switch is pressed
1519 if switch ():
1620 pyb .delay (200 ) # delay avoids detection of multiple presses
You can’t perform that action at this time.
0 commit comments