Skip to content

Commit c220651

Browse files
Tweaks to the README and commets.
1 parent 81e6d96 commit c220651

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

README.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
[![MakeCode Project](https://github.com/microbit-foundation/pxt-microbit-ml-runner/actions/workflows/makecode.yml/badge.svg)](https://github.com/microbit-foundation/pxt-microbit-ml-runner/actions/workflows/makecode.yml)
44
[![Header Generator Tests](https://github.com/microbit-foundation/pxt-microbit-ml-runner/actions/workflows/header-gen.yml/badge.svg)](https://github.com/microbit-foundation/pxt-microbit-ml-runner/actions/workflows/header-gen.yml)
55

6-
This project includes [ML4F](https://github.com/microsoft/ml4f) and a wrapper
7-
to invoke a known type of model. It is left slim to be able to be import it
8-
in other MakeCode extensions and a MicroPython module.
6+
This project wraps [ML4F](https://github.com/microsoft/ml4f) to invoke a known
7+
type of model that requires some data pre-processing.
8+
The wrapper is provided as a slim library to be able to be import it
9+
into other MakeCode extensions and as a MicroPython module.
910

1011

11-
## How to use your ML4F model with this extension
12+
## How to use external ML4F model with this extension
1213

1314
The ML4F wrapper library can be found in the `mlrunner` folder.
1415
This repository also includes a pre-compiled model (inclusion can be controlled
@@ -51,33 +52,34 @@ cd pxt-microbit-ml-runner
5152
npm install pxt --no-save
5253
npx pxt target microbit --no-save
5354
npx pxt install
54-
PXT_FORCE_LOCAL=1 PXT_NODOCKER=1 npx pxt
55+
PXT_FORCE_LOCAL=1 npx pxt
5556
```
5657

5758
For the V1 build Yotta can hit the GitHub rate limits quite easily if the
5859
project is built from a clean state more than once.
59-
A V2-only build can be performed with the `PXT_COMPILE_SWITCHES=csv---mbcodal`
60+
A V2-only build can be triggered with the `PXT_COMPILE_SWITCHES=csv---mbcodal`
6061
environmental variable.
6162

6263
```
6364
PXT_FORCE_LOCAL=1 PXT_NODOCKER=1 PXT_COMPILE_SWITCHES=csv---mbcodal npx pxt
6465
```
6566

6667
> [!CAUTION]
67-
> **When updating to this repository, do NOT push changes to the `enums.d.ts`
68+
> **When updating this repository, do NOT push changes to the `enums.d.ts`
6869
> or `shims.d.ts` files.**
6970
>
7071
> These are autogenerated by MakeCode to contain the enums and function shims
71-
> from the C++ code to be accessible by TypeScript. However, these are only
72-
> needed for the test code, and should **not** be shipped.
72+
> from the C++ code to be accessible via TypeScript. However, these are only
73+
> needed for the test code, and should **not** be shipped as it will affect
74+
> its usage as a MakeCode extension.
7375
>
74-
> So, it's recommended to use: `git update-index --skip-worktree <file>`
76+
> It's recommended to run locally: `git update-index --skip-worktree <file>`
7577
>
7678
> Unfortunately, adding `enums.d.ts` and `shims.d.ts` to the `testFiles` entry
7779
> in `pxt.json` does not work, and they need to be added to `files` (so they
78-
> are included with the extension files, not just the test files), and so they
79-
> should be kept empty. Building the project locally includes the test files
80-
> and will add code in there that should never be pushed.
80+
> end up included with the extension) and so, they should be kept empty.
81+
> Building the project locally compiles all the test files, will add code
82+
> to these `.d.ts` files, which should not be pushed.
8183
8284

8385
## Build flags

mlrunner/mlrunner.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ int ml_calcPrediction(const ml_actions_t *actions, const float* predictions, con
255255
if (max_index < 0) {
256256
return -1;
257257
}
258-
// If the max predictionn is 0, then none were above the threshold
258+
// If the max prediction is 0, then none were above the threshold
259259
if (predictions_above_threshold[max_index] == 0.0f) {
260260
max_index = -1;
261261
}

testextension.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ namespace testrunner {
7979

8080
unsigned int time_start = system_timer_current_time_us();
8181

82-
int32_t ticks_start = ticks_cpu() & 0x7FFFFFFF;
82+
uint32_t ticks_start = ticks_cpu();
8383
float *modelData = mlDataProcessor.getProcessedData();
84-
int32_t ticks_end = ticks_cpu() & 0x7FFFFFFF;
84+
uint32_t ticks_end = ticks_cpu();
8585
if (modelData == NULL) {
8686
DEBUG_PRINT("Failed to processed data for the model\n");
8787
uBit.panic(TEST_RUNNER_ERROR + 21);

0 commit comments

Comments
 (0)