Skip to content
Snippets Groups Projects
Select Git revision
  • 4d7be7df9d41f769a4c783604dc15d88c7dcddaa
  • master default protected
  • bme680_demoapp
  • bme680
  • rahix/simple_menu
  • genofire/ble-rewrite
  • rahix/batt
  • schneider/bonding2
  • renze/safe_mode
  • renze/hatchery_apps
  • schneider/fundamental-test
  • koalo/factory-reset
  • ios-workarounds
  • msgctl/gfx_rle
  • msgctl/faultscreen
  • msgctl/textbuffer_api
  • schneider/bonding
  • schneider/bootloader-update-9a0d158
  • schneider/bsec
  • rahix/bma
  • rahix/bhi
  • v1.1
  • v1.0
  • release-1
  • bootloader-v1
  • v0.0
26 results

init.gdb

Blame
  • Forked from card10 / firmware
    Source project has a limited visibility.
    datalogger.py 1.13 KiB
    # datalogger.py
    # Logs the data from the acceleromter to a file on the SD-card
    
    import pyb
    
    # creating objects
    accel = pyb.Accel()
    blue = pyb.LED(4)
    switch = pyb.Switch()
    
    # loop
    while True:
    
        # wait for interrupt
        # this reduces power consumption while waiting for switch press
        pyb.wfi()
    
        # start if switch is pressed
        if switch():
            pyb.delay(200)                      # delay avoids detection of multiple presses
            blue.on()                           # blue LED indicates file open
            log = open('1:/log.csv', 'w')       # open file on SD (SD: '1:/', flash: '0/)
    
            # until switch is pressed again
            while not switch():
                t = pyb.millis()                            # get time
                x, y, z = accel.filtered_xyz()              # get acceleration data
                log.write('{},{},{},{}\n'.format(t,x,y,z))  # write data to file
    
            # end after switch is pressed again
            log.close()                         # close file
            blue.off()                          # blue LED indicates file closed
            pyb.delay(200)                      # delay avoids detection of multiple presses