Skip to content
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

Addition of getRows(n, k) and getNumberOfRows(n) to the datalogger. #431

Merged

Conversation

KierPalin
Copy link
Contributor

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

  1. getRows(n, k) where n is negative -> empty string
  2. getRows(n, k) where k is 0 or negative -> empty string
  3. getRows(n, k) where n is greater than number of rows in the datalogger (start row is never reached) -> empty string
  4. getRows(n, k) where k is greater than number of rows in the datalogger -> All rows from n
    (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

@KierPalin
Copy link
Contributor Author

I re-ran the tests (including the stress test) & expanded coverage after commit cc0f4ed - which fixed a bug associated with the behaviour change of the prior commit.

@finneyj
Copy link
Contributor

finneyj commented Jul 16, 2024

Thanks @KierPalin! Looks good.

@finneyj finneyj merged commit 96faa85 into lancaster-university:master Jul 16, 2024
@microbit-carlos microbit-carlos added this to the v0.2.67 milestone Jul 16, 2024
@KierPalin KierPalin deleted the feature/datalogger-get-rows branch August 17, 2024 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants