From 4ee179927101f05893c480459549a006056996f0 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Fri, 15 Apr 2016 15:40:55 -0700 Subject: [PATCH] more docs --- docs/device/screen.md | 20 ++++++++++++++++---- docs/device/simulator.md | 25 +++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/docs/device/screen.md b/docs/device/screen.md index 3bd569e0..5454d2a7 100644 --- a/docs/device/screen.md +++ b/docs/device/screen.md @@ -2,7 +2,9 @@ The micro:bit LED screen -![](/static/mb/device/screen-0.png) +```sim +basic.showString(" "); +``` The micro:bit LED screen consists of 25 red LED lights arranged in a 5X5 grid (5 LEDs across by 5 LEDs down). @@ -32,10 +34,20 @@ Since the row and column numbers start at 0, an easy way to figure out the x, y Use [plot](/led/plot) and [unplot](/led/unplot) to turn a LED on or off +```blocks +led.plot(0,0) +led.unplot(0,0) +``` + ### Is a LED on/off? Use the [point](/led/point) function to find out if a LED is on or off. +```blocks +if(led.point(0,0)) { +} +``` + ### Display images, strings and numbers Instead of turning individual LEDs on or off, as above, you can display an [image](/reference/images/image) directly to the screen or show text/numbers on screen using the [show number](/reference/basic/show-number)/[show string](/reference/basic/show-string) function. @@ -44,14 +56,14 @@ Instead of turning individual LEDs on or off, as above, you can display an [imag The micro:bit runtime keeps an in-memory representation of the state of all 25 LEDS. This state is known as the "display buffer" and controls which LEDS are on and which are off. The plot/unplot/point functions access the display buffer directly. On the other hand, the functions that show an image, number or string overwrite the buffer completely. To illustrate, first try running this code sequence -``` -basic.showString("d", 150) +```blocks +basic.showString("d") led.plot(0, 0) ``` You will see the letter "d" displayed as well as the LED in position `0,0` lit up. Now try reversing the order of the two statements above: -``` +```blocks led.plot(0, 0) basic.showString("d", 150) ``` diff --git a/docs/device/simulator.md b/docs/device/simulator.md index e69de29b..e517e900 100644 --- a/docs/device/simulator.md +++ b/docs/device/simulator.md @@ -0,0 +1,25 @@ +# Simulator + +The JavaScript simulator allows to test and execute most BBC micro:bit programs in the browser. +It allows to emulate sensor data or user interactions. + +```sim +input.onButtonPressed(Button.A, () => { + basic.showString("A"); +}); +input.onButtonPressed(Button.B, () => { + basic.showString("B"); +}); +input.onPinPressed(TouchPin.P0, () => { + basic.showString("0"); +}); +input.onPinPressed(TouchPin.P1, () => { + basic.showString("1"); +}); +input.onPinPressed(TouchPin.P2, () => { + basic.showString("2"); +}); +input.temperature() +input.compassHeading() +input.lightLevel() +``` \ No newline at end of file