Skip to content

Commit

Permalink
Try using helper stubs for example code
Browse files Browse the repository at this point in the history
  • Loading branch information
microbit-robert committed Dec 13, 2024
1 parent 69336c5 commit 9f629a9
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion docs/ml_get_event_certainty.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ This example displays the ML model's certainty that the current action is `unkno

```blocks
loops.everyInterval(1000, function () {
basic.showNumber(ml.getCertainty(ml.event.Unknown))
basic.showNumber(ml.getCertainty(ml.event.Clapping))
})
```

```package
machine-learning-help-stubs=github:microbit-foundation/pxt-microbit-ml-help-stubs#v0.0.1
machine-learning=github:microbit-foundation/pxt-microbit-ml#v1.0.2
```
3 changes: 2 additions & 1 deletion docs/ml_is_event_detected.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ This example will show a tick icon on the LED display if the estimated action is

```blocks
basic.forever(function () {
if (ml.isDetected(ml.event.Unknown)) {
if (ml.isDetected(ml.event.Clapping)) {
basic.showIcon(IconNames.Yes)
}
})
```

```package
machine-learning-help-stubs=github:microbit-foundation/pxt-microbit-ml-help-stubs#v0.0.1
machine-learning=github:microbit-foundation/pxt-microbit-ml#v1.0.2
```
3 changes: 2 additions & 1 deletion docs/ml_on_event_start.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ The ML model updates its estimated action several times a second, but this event
This example uses the special `unknown` value and plays a musical melody in the background when no action has a certainty above the recognition point.

```blocks
ml.onStart(ml.event.Unknown, function () {
ml.onStart(ml.event.Clapping, function () {
music._playDefaultBackground(music.builtInPlayableMelody(Melodies.Dadadadum), music.PlaybackMode.InBackground)
})
```

```package
machine-learning-help-stubs=github:microbit-foundation/pxt-microbit-ml-help-stubs#v0.0.1
machine-learning=github:microbit-foundation/pxt-microbit-ml#v1.0.2
```
3 changes: 2 additions & 1 deletion docs/ml_on_event_stop.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ For example, if your start event handler for an action starts music playing in t
This example uses the special `unknown` option and stops playing a musical melody when the estimated action changes to any other action.

```blocks
ml.onStop(ml.event.Unknown, function () {
ml.onStop(ml.event.Clapping, function () {
music.stopMelody(MelodyStopOptions.All)
})
```

```package
machine-learning-help-stubs=github:microbit-foundation/pxt-microbit-ml-help-stubs#v0.0.1
machine-learning=github:microbit-foundation/pxt-microbit-ml#v1.0.2
```
3 changes: 2 additions & 1 deletion docs/ml_on_event_stop_detailed.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ The event handler is passed a `duration` parameter. The duration is the [number]
This example uses the special `unknown` option and shows the duration that `unknown` was the estimated action for in seconds when the estimated action changes to any other action.

```blocks
ml.onStopDetailed(ml.event.Unknown, function (duration) {
ml.onStopDetailed(ml.event.Clapping, function (duration) {
basic.showNumber(duration / 1000)
})
```

```package
machine-learning-help-stubs=github:microbit-foundation/pxt-microbit-ml-help-stubs#v0.0.1
machine-learning=github:microbit-foundation/pxt-microbit-ml#v1.0.2
```

0 comments on commit 9f629a9

Please sign in to comment.