summaryrefslogtreecommitdiff
path: root/examples/SDdatalogger
diff options
context:
space:
mode:
authorDan Halbert <halbert@halwitz.org>2018-02-27 22:03:52 -0500
committerGitHub <noreply@github.com>2018-02-27 22:03:52 -0500
commit568c04e6afa8016062f685b2198c0209f62827f4 (patch)
treed07b76119f715add462983b335797adf64b61249 /examples/SDdatalogger
parent6a2379fd0bfe10017d8abc5c36ef1d470c0d9b27 (diff)
parentea633117d01d94e8d56ed94344e4b3e46b4eef03 (diff)
Merge pull request #650 from tannewt/merge_2x3.0.0-alpha.2
Merge in commits from 2.x branch.
Diffstat (limited to 'examples/SDdatalogger')
-rw-r--r--examples/SDdatalogger/README.md4
-rw-r--r--examples/SDdatalogger/boot.py25
-rw-r--r--examples/SDdatalogger/cardreader.py2
-rw-r--r--examples/SDdatalogger/datalogger.py33
4 files changed, 0 insertions, 64 deletions
diff --git a/examples/SDdatalogger/README.md b/examples/SDdatalogger/README.md
deleted file mode 100644
index 24e69c87e..000000000
--- a/examples/SDdatalogger/README.md
+++ /dev/null
@@ -1,4 +0,0 @@
-This is a SDdatalogger, to log data from the accelerometer to the SD-card. It also functions as card reader, so you can easily get the data on your PC.
-
-To run, put the boot.py, cardreader.py and datalogger.py files on either the flash or the SD-card of your pyboard.
-Upon reset, the datalogger script is run and logs the data. If you press the user button after reset and hold it until the orange LED goes out, you enter the cardreader mode and the filesystem is mounted to your PC.
diff --git a/examples/SDdatalogger/boot.py b/examples/SDdatalogger/boot.py
deleted file mode 100644
index 4ac94bbaa..000000000
--- a/examples/SDdatalogger/boot.py
+++ /dev/null
@@ -1,25 +0,0 @@
-# boot.py -- runs on boot-up
-# Let's you choose which script to run.
-# > To run 'datalogger.py':
-# * press reset and do nothing else
-# > To run 'cardreader.py':
-# * press reset
-# * press user switch and hold until orange LED goes out
-
-import pyb
-
-pyb.LED(3).on() # indicate we are waiting for switch press
-pyb.delay(2000) # wait for user to maybe press the switch
-switch_value = pyb.Switch()() # sample the switch at end of delay
-pyb.LED(3).off() # indicate that we finished waiting for the switch
-
-pyb.LED(4).on() # indicate that we are selecting the mode
-
-if switch_value:
- pyb.usb_mode('VCP+MSC')
- pyb.main('cardreader.py') # if switch was pressed, run this
-else:
- pyb.usb_mode('VCP+HID')
- pyb.main('datalogger.py') # if switch wasn't pressed, run this
-
-pyb.LED(4).off() # indicate that we finished selecting the mode
diff --git a/examples/SDdatalogger/cardreader.py b/examples/SDdatalogger/cardreader.py
deleted file mode 100644
index 98d7a3792..000000000
--- a/examples/SDdatalogger/cardreader.py
+++ /dev/null
@@ -1,2 +0,0 @@
-# cardread.py
-# This is called when the user enters cardreader mode. It does nothing.
diff --git a/examples/SDdatalogger/datalogger.py b/examples/SDdatalogger/datalogger.py
deleted file mode 100644
index 0690c20bb..000000000
--- a/examples/SDdatalogger/datalogger.py
+++ /dev/null
@@ -1,33 +0,0 @@
-# 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('/sd/log.csv', 'w') # open file on SD (SD: '/sd/', flash: '/flash/)
-
- # 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