Addition of getRows(n, k) and getNumberOfRows(n) to the datalogger. #431
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.
I have added two new functions to \source\MicroBitLog.cpp & \inc\MicroBitLog.h
These two functions allow for the access of the contents of the datalogger in a relatively abstract manner. They mean that a user can read back data from the datalogger directly from the microbit - without needing to upload the MY_DATA.HTM file. This is useful for building more complex microbit applications - such as with MicroData: https://github.com/KierPalin/MicroData - which is an application that uses the Microbit and an ArcadeShield to help teach data & physical sciences. In the case of MicroData the user can record data using the Microbit's onboard & Jacdac sensors, and then read that data back in a tabular or graphical format on the ArcadeShield's screen - without the need of a PC. I believe there are many other cases where the ability to read back rows of data or the number of rows may be useful though.
I have verified the proper functionality of these two new functions via 10 tests that can be found here:
https://github.com/KierPalin/MicroData/blob/codal_testing/tests.ts
Pertinent edge-cases:
getNumberOfRows(n) where n is greater than number of rows in the datalogger -> 0
getNumberOfRows(n) where n is negative -> n becomes 0
(case 3 takes precedence from case 4 if n is too great)
getRows(n, k) when new columns are added after logging rows -> Returns rows normally, then a row with all of the columns (new and old), then the rows of data again. This is true even when adding more columns, then more columns again. For example:
Input:
Add 5 rows of data.
Add additional column
Add another additional column
Output:
1 row of the headers used by the original data
5 rows of data
1 row of headers - including the additional column
1 row of headers - including both of the additional columns