forked from bbcmicrobit/micropython
-
Notifications
You must be signed in to change notification settings - Fork 0
docs: Update data logging. #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
7e6bac6
docs: Fix formatting for log docs.
microbit-carlos c6ee83f
docs: Update data logging content.
microbit-carlos ecaa719
docs: Move log.rst code into a script in the examples folder.
microbit-carlos e8069e4
docs: Update with review comments.
microbit-carlos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
docs: Update data logging content.
- Loading branch information
commit c6ee83f7fcb5dc4626dffe4b4e57c9b1523da66b
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,111 +1,144 @@ | ||||||
| Data logging **V2** | ||||||
| Data Logging **V2** | ||||||
| ******************* | ||||||
|
|
||||||
| .. py:module:: log | ||||||
|
|
||||||
| This module lets you log data to a ``MY_DATA`` file saved on a | ||||||
| micro:bit **V2**. | ||||||
| This module lets you log data to a ``MY_DATA`` file saved on a micro:bit | ||||||
| **V2** ``MICROBIT`` USB drive. | ||||||
|
|
||||||
| Further guidance on the feature can be found on the | ||||||
| .. image:: log-my_data.png | ||||||
|
|
||||||
| The data is structured in a table format and it can be viewed and plotted with | ||||||
| a browser. | ||||||
|
|
||||||
| .. image:: log-html-view.jpeg | ||||||
|
|
||||||
| Further guidance on this feature can be found on the | ||||||
| `data logging page of the microbit.org website | ||||||
| <https://microbit.org/get-started/user-guide/data-logging/>`_. | ||||||
|
|
||||||
| Functions | ||||||
| ========= | ||||||
|
|
||||||
| .. py:function:: set_labels(value, timestamp=log.MILLISECONDS) | ||||||
| .. py:function:: set_labels(*labels, timestamp=log.SECONDS) | ||||||
|
|
||||||
| Set up the log file header. | ||||||
|
|
||||||
| Each call to this function with positional arguments will generate a new | ||||||
| header entry into the log file. | ||||||
| This function accepts any number of positional arguments, each creates | ||||||
| a column header, e.g. ``log.set_labels("X", "Y", "Z")``. | ||||||
|
|
||||||
| Ideally this function should be called a single time, before any data is | ||||||
| logged, to configure the data table header once. | ||||||
|
|
||||||
| If the programme starts and a log file already exists it will compare the | ||||||
| labels setup by this function call to the last headers declared in the | ||||||
| file. If the headers are different it will add a new header entry at the | ||||||
| end of the file. | ||||||
| If a log file already exists when the programme starts, or if this function | ||||||
| is called multiple times, it will check the labels already defined in the | ||||||
| log file. | ||||||
| If this function call contains any new labels not already present, it will | ||||||
| generate a new header row with the additional columns. | ||||||
|
|
||||||
| * **value**: Positional arguments used to generate the log headers, | ||||||
| which go on the first line of the CSV file. For example, | ||||||
| ``set_labels("A","B","C")`` will create three column headers titled | ||||||
| ``A``, ``B`` and ``C`` in that order. | ||||||
| * **timestamp**: Select the timestamp unit that will be automatically | ||||||
| added as the first column in every row. Timestamp values can be one of | ||||||
| ``MILLISECONDS``, ``SECONDS``, ``MINUTES``, ``HOURS``, ``DAYS`` or | ||||||
| ``None`` to disable the timestamp. | ||||||
| By default the first column contains a time stamp for each row. The time | ||||||
| unit can be selected via the ``timestamp`` argument, e.g. | ||||||
| ``log.set_labels("temp", timestamp=log.MINUTES)`` | ||||||
|
|
||||||
| .. py:function:: set_mirroring(value) | ||||||
| :param \*labels: Any number of positional arguments, each corresponding to | ||||||
| an entry in the log header. | ||||||
| :param timestamp: Select the timestamp unit that will be automatically | ||||||
| added as the first column in every row. Timestamp values can be one of | ||||||
| ``log.MILLISECONDS``, ``log.SECONDS``, ``log.MINUTES``, ``log.HOURS``, | ||||||
| ``log.DAYS`` or ``None`` to disable the timestamp. The default value | ||||||
| is ``log.SECONDS``. | ||||||
|
|
||||||
| Mirrors the datalogging activity to the serial output. | ||||||
| Serial mirroring is off by default. | ||||||
| .. py:function:: set_mirroring(serial) | ||||||
|
|
||||||
| * **value**: Boolean. ``True`` will enable mirroring data to the serial | ||||||
| output. | ||||||
| Configure mirroring of the data logging activity to the serial output. | ||||||
|
|
||||||
| Serial mirroring is disabled by default. When enabled, it will print to | ||||||
| serial each row logged into the log file. | ||||||
|
|
||||||
| :param serial: ``True`` enables mirroring data to the serial output. | ||||||
|
|
||||||
| .. py:function:: delete(full=False) | ||||||
|
|
||||||
| Deletes the contents of the log, including headers. | ||||||
| To add the log headers the ``set_labels`` function has to be called again | ||||||
| after this. | ||||||
| Delete the contents of the log, including headers. | ||||||
|
|
||||||
| To add the log headers again the ``set_labels`` function should to be | ||||||
| called after this function. | ||||||
|
|
||||||
| There are two erase modes, "full" completely removes the data from the | ||||||
| physical storage, and the "fast" method only invalidates the data. | ||||||
|
|
||||||
| * **full**: Selects a "full" erase format that removes the data from the | ||||||
| flash storage. If set to ``False`` it uses a "fast" method, | ||||||
| which invalidates the data instead of performing a slower | ||||||
| full erase. | ||||||
| :param full: ``True`` selects a "full erase" and ``False`` selects the | ||||||
|
||||||
| :param full: ``True`` selects a "full erase" and ``False`` selects the | |
| :param full: ``True`` selects a "full" erase and ``False`` selects the "fast" erase method. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this is more explicit about the two modes?