boot.py 951 B

12345678910111213141516171819202122232425
  1. # boot.py -- runs on boot-up
  2. # Let's you choose which script to run.
  3. # > To run 'datalogger.py':
  4. # * press reset and do nothing else
  5. # > To run 'cardreader.py':
  6. # * press reset
  7. # * press user switch and hold until orange LED goes out
  8. import pyb
  9. pyb.LED(3).on() # indicate we are waiting for switch press
  10. pyb.delay(2000) # wait for user to maybe press the switch
  11. switch_value = pyb.Switch()() # sample the switch at end of delay
  12. pyb.LED(3).off() # indicate that we finished waiting for the switch
  13. pyb.LED(4).on() # indicate that we are selecting the mode
  14. if switch_value:
  15. pyb.usb_mode('VCP+MSC')
  16. pyb.main('cardreader.py') # if switch was pressed, run this
  17. else:
  18. pyb.usb_mode('VCP+HID')
  19. pyb.main('datalogger.py') # if switch wasn't pressed, run this
  20. pyb.LED(4).off() # indicate that we finished selecting the mode