Skip to content

Commit

Permalink
Adding fr with prefixed strings to test help mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
microbit-robert committed Nov 21, 2024
1 parent 62ab8f9 commit bf86b1c
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 3 deletions.
96 changes: 96 additions & 0 deletions _locales/fr/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Microsoft MakeCode extension for use with micro:bit CreateAI

FR - This extension is leveraged by micro:bit CreateAI which creates suitable blocks based on the machine learning model you build in the app. It is not useful separate from micro:bit CreateAI.

## Building locally

Ensure you have the required toolchain to build for V1 and V2
(arm-none-eabi-gcc, python, yotta, cmake, ninja, srec_cat) or docker.

```bash
git clone https://github.com/microbit-foundation/pxt-microbit-ml
cd pxt-microbit-ml
npm install pxt --no-save
npx pxt target microbit --no-save
npx pxt install
PXT_FORCE_LOCAL=1 PXT_NODOCKER=1 npx pxt
```

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

```
PXT_FORCE_LOCAL=1 PXT_NODOCKER=1 PXT_COMPILE_SWITCHES=csv---mbcodal npx pxt
```

## Build flags

### Model predictions per second

By default the model will run every 250 ms, to change this value the
`ML_INFERENCE_PERIOD_MS` config can be modified.

```json
{
"yotta": {
"config": {
"ML_INFERENCE_PERIOD_MS": 250
}
}
}
```

### Model events

By default this extension configures the Model prediction events to not be
queued for the same event.
So if an event raised when its handler is still running it will be dropped.

```json
{
"yotta": {
"config": {
"ML_EVENT_LISTENER_DEFAULT_FLAGS": 32
}
}
}
```

The values are defined in the
[codal-core/inc/core/CodalListener.h](https://github.com/lancaster-university/codal-core/blob/df05db9e15499bd8906618192a4d482e3836c62f/inc/core/CodalListener.h#L36-L40)
file:

```cpp
#define MESSAGE_BUS_LISTENER_REENTRANT 0x0008
#define MESSAGE_BUS_LISTENER_QUEUE_IF_BUSY 0x0010
#define MESSAGE_BUS_LISTENER_DROP_IF_BUSY 0x0020
#define MESSAGE_BUS_LISTENER_NONBLOCKING 0x0040
#define MESSAGE_BUS_LISTENER_URGENT 0x0080
```

### Debug messages

To enable debug print from this extension, add the following into your
pxt.json file:

```json
{
"yotta": {
"config": {
"ML_DEBUG_PRINT": 1
}
}
}
```

## License

This software made available under the MIT open source license.

[SPDX-License-Identifier: MIT](/LICENSE)

## Code of Conduct

Trust, partnership, simplicity and passion are our core values we live and breathe in our daily work life and within our projects. Our open-source projects are no exception. We have an active community which spans the globe and we welcome and encourage participation and contributions to our projects by everyone. We work to foster a positive, open, inclusive and supportive environment and trust that our community respects the micro:bit code of conduct. Please see our [code of conduct](https://www.microbit.org/safeguarding/) which outlines our expectations for all those that participate in our community and details on how to report any concerns and what would happen should breaches occur.
7 changes: 7 additions & 0 deletions _locales/fr/machine-learning-jsdoc-strings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"mlrunner.customOnEvent": "FR - Register a TypeScript function to run when an event is raised.\n* This custom version of the MakeCode onEvent function is needed due to:\nhttps://github.com/microsoft/pxt-microbit/issues/5709\n*",
"mlrunner.customOnEvent|param|flags": "FR - The specified event flags are ignored and configured via pxt.json.",
"mlrunner.customOnEvent|param|handler": "FR - The function to call when the event is detected.",
"mlrunner.customOnEvent|param|src": "FR - The ID of the component to listen to.",
"mlrunner.customOnEvent|param|value": "FR - The event value to listen to from that component."
}
13 changes: 13 additions & 0 deletions _locales/fr/machine-learning-strings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"ml.event.Unknown|block": "FR - unknown",
"ml.getCertainty|block": "FR - certainty (\\%) ML $event",
"ml.isDetected|block": "FR - is ML $event detected",
"ml.onStart|block": "FR - on ML $event start",
"ml.onStopDetailed|block": "FR - on ML $event stop $duration (ms)",
"ml.onStop|block": "FR - on ML $event stop",
"mlrunner|block": "FR - mlrunner",
"{id:category}Ml": "FR - Ml",
"{id:category}MlEvent": "FR - MlEvent",
"{id:category}Mlrunner": "FR - Mlrunner",
"{id:group}micro:bit (V2)": "FR - micro:bit (V2)"
}
3 changes: 3 additions & 0 deletions _locales/fr/onstart.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Testing block docs

FR - You use it like this...
3 changes: 3 additions & 0 deletions docs/onstart.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Testing block docs

You use it like this...
6 changes: 5 additions & 1 deletion pxt.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
"shims.d.ts",
"enums.d.ts",
"pxtextension.ts",
"pxtextension.cpp"
"pxtextension.cpp",
"_locales/fr/machine-learning-jsdoc-strings.json",
"_locales/fr/machine-learning-strings.json",
"_locales/fr/README.md",
"_locales/fr/onstart.md"
],
"testFiles": [
"autogenerated.ts",
Expand Down
3 changes: 1 addition & 2 deletions pxtextension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace ml {
//% weight=50
//% parts="v2"
//% group="micro:bit (V2)"
//% help=none
//% help=github:pxt-microbit-ml/docs/onstart
export function onStart(event: MlEvent, body: () => void): void {
event.onStartHandler = body;
const wrappedBody = () => {
Expand All @@ -80,7 +80,6 @@ namespace ml {
//% weight=40
//% parts="v2"
//% group="micro:bit (V2)"
//% help=none
export function onStop(event: MlEvent, body: () => void): void {
if (!isRunning()) {
startRunning();
Expand Down

0 comments on commit bf86b1c

Please sign in to comment.