diff --git a/docs/device/reactive.md b/docs/device/reactive.md index 2c990415..02fccec7 100644 --- a/docs/device/reactive.md +++ b/docs/device/reactive.md @@ -48,21 +48,21 @@ The micro:bit’s *scheduler* provides the capability to concurrently execute di The first job of the scheduler is to allow multiple *subprograms* to be queued up for later execution . For our purposes, a subprogram is just a statement or sequence of statements in the context of a larger program. Consider the Touch Develop program below for counting button presses. -``` +```blocks export function countButtonPresses() { + let count = 0 input.onButtonPressed(Button.A, () => { count = count + 1 }) basic.forever(() => { basic.showNumber(count, 150) }) - count = 0 } ``` The program above contains three statements that execute in order from top to bottom. The first statement -``` +```blocks input.onButtonPressed(Button.A, () => { count = count + 1 }) @@ -70,7 +70,7 @@ input.onButtonPressed(Button.A, () => { informs the scheduler that on each and every event of the A button being pressed, a subprogram (called the event handler) should be queued for execution. The event handler is demarcated by the do/end keywords; it increments the global variable `count` by one. The second statement -``` +```blocks basic.forever(() => { basic.showNumber(count, 150) }) @@ -78,7 +78,7 @@ basic.forever(() => { queues a `forever` loop for later execution by the scheduler; the body of this loop (between the do/end keywords) displays the current value of global variable `count` on the LED screen. The third statement -``` +```blocks count = 0 ``` @@ -128,7 +128,7 @@ Through this example, we have seen that the micro:bit scheduler enables you to c As a result, you can easily add a new capability to the micro:bit by just adding a new subprogram. For example, if you want to add a reset feature to the counter program, all you need to do is add a new event handler for a press of button B that sets the global variable "count" to zero, as shown below: -``` +```blocks export function countButtonPressesWithReset() { input.onButtonPressed(Button.A, () => { count = count + 1 diff --git a/docs/lessons/happy-birthday/challenges.md b/docs/lessons/happy-birthday/challenges.md index d07a613e..a31a1cde 100644 --- a/docs/lessons/happy-birthday/challenges.md +++ b/docs/lessons/happy-birthday/challenges.md @@ -34,8 +34,7 @@ Let's code the third part of Happy Birthday! To do this, you need to add blocks after the last line of the `play` blocks. We want to continue to adding musical chords with the `play` block. Then insert the appropriate chord blocks `G`, `E`, `C`, `B`, `A` to complete the third part of the song. Modify your code so that your code looks like this. -``` blocks - +```blocks music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quater)); music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quater)); music.playTone(music.noteFrequency(Note.D), music.beat(BeatFraction.Quater)); @@ -57,8 +56,7 @@ music.playTone(music.noteFrequency(Note.F), music.beat(BeatFraction.Quater)); music.playTone(music.noteFrequency(Note.E), music.beat(BeatFraction.Quater)); music.playTone(music.noteFrequency(Note.D), music.beat(BeatFraction.Quater)); basic.pause(100); - -``` +``` * click *run * to see if the code works as expected. diff --git a/docs/reference/basic/show-animation.md b/docs/reference/basic/show-animation.md index cc8c68fb..f8daaf46 100644 --- a/docs/reference/basic/show-animation.md +++ b/docs/reference/basic/show-animation.md @@ -23,7 +23,7 @@ In this animation, each row is 15 spaces wide because there are three frames in the animation, and each frame is five spaces wide, just like the screen on the BBC micro:bit. -``` +```blocks basic.showAnimation(` . . # . . . # # # . . # # # . . # # . . . . . # . . . . # . @@ -47,7 +47,7 @@ In this animation, each row is 30 spaces wide because there are six frames in the animation, and each frame is five spaces wide, just like the screen. -``` +```blocks basic.showAnimation(` . . . . . # . . . . . . . . . . . . . # . . . . . # . . . . . . # . . . . . . . . . # . . . . . . . . . # . . . . . . . diff --git a/docs/reference/devices/on-signal-strength-changed.md b/docs/reference/devices/on-signal-strength-changed.md index a66fb00c..8584a497 100644 --- a/docs/reference/devices/on-signal-strength-changed.md +++ b/docs/reference/devices/on-signal-strength-changed.md @@ -23,7 +23,7 @@ devices.onSignalStrengthChanged(() => {}) Display the signal strength on screen: -``` +```blocks devices.onSignalStrengthChanged(() => { basic.showNumber(devices.signalStrength(), 150) }) diff --git a/docs/reference/game/clear.md b/docs/reference/game/clear.md index d3d8d265..4ced5a51 100644 --- a/docs/reference/game/clear.md +++ b/docs/reference/game/clear.md @@ -6,7 +6,7 @@ Turn off all the pixels in an [Image](/reference/images/image). ### JavaScript -``` +```sig export function clear(img: micro_bit.Image) ``` @@ -18,7 +18,7 @@ export function clear(img: micro_bit.Image) The following example turns off the pixels of `img` when the A input button is pressed: -``` +```blocks let img = images.createImage(` . . . . . . # # # . diff --git a/docs/reference/game/position.md b/docs/reference/game/position.md index 3694d413..1aea7256 100644 --- a/docs/reference/game/position.md +++ b/docs/reference/game/position.md @@ -2,12 +2,12 @@ Reports the x position of a sprite on the LED screen -``` +```sig export function x(_this: micro_bitSprites.LedSprite) : number ``` Reports the y position of a sprite on the LED screen -``` +```sig export function y(_this: micro_bitSprites.LedSprite) : number ``` diff --git a/docs/reference/game/reports.md b/docs/reference/game/reports.md index cd7e48ed..b2853b75 100644 --- a/docs/reference/game/reports.md +++ b/docs/reference/game/reports.md @@ -4,24 +4,24 @@ Reports the x or y position, the current direction of a sprite, or the brightne Reports the x position of a sprite on the LED screen -``` +```sig export function x(_this: micro_bitSprites.LedSprite) : number ``` Reports the y position of a sprite on the LED screen -``` +```sig export function y(_this: micro_bitSprites.LedSprite) : number ``` Reports the brightness of a sprite on the LED screen -``` +```sig export function brightness(_this: micro_bitSprites.LedSprite) : number ``` Reports the current direction of a sprite on the LED screen -``` +```sig export function direction(_this: micro_bitSprites.LedSprite) : number ``` diff --git a/docs/reference/images/pixel.md b/docs/reference/images/pixel.md index 9cada335..df103276 100644 --- a/docs/reference/images/pixel.md +++ b/docs/reference/images/pixel.md @@ -6,7 +6,7 @@ Get the state of a pixel in an [Image](/reference/images/image). ### JavaScript -``` +```sig export function pixel(_this: micro_bit.Image, x: number, y: number) : boolean ``` @@ -29,7 +29,7 @@ This example gets the state of pixel `0, 0` in the `img` variable: ### ~hide -``` +```blocks let img = images.createImage(` . . # . . . . . . . . # . # . . . # . . @@ -41,7 +41,7 @@ let img = images.createImage(` ### ~ -``` +```blocks let state = img.pixel(0, 0) ``` diff --git a/docs/reference/images/show-frame.md b/docs/reference/images/show-frame.md index 24633ada..0c2b11bc 100644 --- a/docs/reference/images/show-frame.md +++ b/docs/reference/images/show-frame.md @@ -6,7 +6,7 @@ Display an [Image](/reference/images/image) on the BBC micro:bit's [LED screen]( ### JavaScript -``` +```sig export function showFrame(img: micro_bit.Image, frame: number) ``` @@ -20,7 +20,7 @@ The `show frame` function is the same as [plot frame](/reference/images/plot-fra ### Example -``` +```blocks let img = images.createImage(` # . . . # # . . . # . # . # . . # # # . diff --git a/docs/reference/images/width.md b/docs/reference/images/width.md index 41d1f6e0..9bf90763 100644 --- a/docs/reference/images/width.md +++ b/docs/reference/images/width.md @@ -20,7 +20,7 @@ The following example gets the width of `img` and stores it in the `w` variable: ### ~hide -``` +```blocks let img = images.createImage(` . . # . . . . . . . . # . # . . . # . . @@ -32,7 +32,7 @@ let img = images.createImage(` ### ~ -``` +```blocks let w = img.width() ``` @@ -40,7 +40,7 @@ let w = img.width() The following example uses the `width` function with a [for](/blocks/loops/for) loop to show each image frame on the screen: -``` +```blocks let img2 = images.createImage(` . . # . . . # # # # . # # # . . # # . . . . . . # . . . # . diff --git a/docs/reference/pins/analog-pitch.md b/docs/reference/pins/analog-pitch.md index d42308b9..ede05f69 100644 --- a/docs/reference/pins/analog-pitch.md +++ b/docs/reference/pins/analog-pitch.md @@ -13,7 +13,7 @@ pins.analogPitch(440, 300) ### Example -``` +```blocks pins.analogSetPitchPin("P0") let frequency1 = 440 let duration = 1000 diff --git a/docs/reference/pins/analog-set-pitch-pin.md b/docs/reference/pins/analog-set-pitch-pin.md index f28f1815..1e11e35e 100644 --- a/docs/reference/pins/analog-set-pitch-pin.md +++ b/docs/reference/pins/analog-set-pitch-pin.md @@ -12,7 +12,7 @@ pins.analogSetPitchPin(AnalogPin.P0) ### Example -``` +```blocks pins.analogSetPitchPin(AnalogPin.P0) let frequency = 440 let duration = 1000