From c25049ee5f9efa476a82bef802e9e3e827aa3cfb Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Fri, 25 Mar 2016 21:13:09 -0700 Subject: [PATCH] adding control blocks --- docs/reference/control/in-background.md | 8 ++++---- libs/microbit/control.ts | 5 ++++- libs/microbit/serial.ts | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/docs/reference/control/in-background.md b/docs/reference/control/in-background.md index cae98c00..b8077647 100644 --- a/docs/reference/control/in-background.md +++ b/docs/reference/control/in-background.md @@ -2,7 +2,7 @@ Run code in the background as a separate process or thread; for more information on this advanced construct, see [the micro:bit - a reactive system](/microbit/device/reactive). -``` +```sig control.inBackground(() => { }) ``` @@ -11,7 +11,7 @@ control.inBackground(() => { The example below shows how a background process can be used to display the current value of the global variable `num`, while code (like the `on button pressed` handler) can change the value of the variable. -``` +```blocks let num = 0 control.inBackground(() => { while (true) { @@ -26,7 +26,7 @@ input.onButtonPressed("A", () => { The code below using the `forever` loop is equivalent to the code above -``` +```blocks let num = 0 basic.forever(() => { basic.showNumber(num, 150) @@ -40,7 +40,7 @@ input.onButtonPressed("A", () => { If you have multiple processes that each show something on the LED screen, you may get unexpected results. Try, for example: -``` +```blocks basic.forever(() => { basic.showNumber(6789, 150) }) diff --git a/libs/microbit/control.ts b/libs/microbit/control.ts index 31e5040d..3fe08d5c 100644 --- a/libs/microbit/control.ts +++ b/libs/microbit/control.ts @@ -1,13 +1,16 @@ +//% weight=1 color="#333333" namespace control { /** * Schedules code that run in the background. - //% help=control/in-background shim=micro_bit::runInBackground */ + //% help=control/in-background shim=micro_bit::runInBackground + //% blockId="control_in_background" block="run in background" export function inBackground(body: Action): void { } /** * Resets the BBC micro:bit. */ //% weight=1 shim=uBit.reset async help=control/reset + //% blockId="control_reset" block="reset" export function reset() : void { } } diff --git a/libs/microbit/serial.ts b/libs/microbit/serial.ts index 26e5a2a5..5c270799 100644 --- a/libs/microbit/serial.ts +++ b/libs/microbit/serial.ts @@ -1,4 +1,4 @@ -//% weight=1 +//% weight=2 namespace serial { /** * Prints a line of text to the serial