From 77030db1d350bdbc9ca43f492facdd2fe12650e6 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Fri, 15 Apr 2016 15:02:26 -0700 Subject: [PATCH] fixing links in docs --- docs/device/crocodile-clips.md | 5 +- docs/device/screen.md | 2 +- docs/device/simulator.md | 0 docs/device/usb.md | 2 +- docs/lessons/beatbox.md | 22 ----- docs/lessons/bop-it/quiz-answers.md | 2 +- docs/lessons/bop-it/quiz.md | 2 +- docs/lessons/buzzer.md | 81 ------------------- .../catch-the-egg-game/quiz-answers.md | 2 +- docs/lessons/classic-beatbox/challenges.md | 2 +- docs/lessons/glowing-pendulum/quiz-answers.md | 2 +- docs/lessons/glowing-sword.md | 30 ------- docs/lessons/headbands.md | 4 +- docs/lessons/magic-8/quiz-answers.md | 2 +- docs/lessons/offset-image/quiz.md | 2 +- docs/lessons/prank-wifi/quiz-answers.md | 2 +- docs/lessons/spinner/quiz-answers.md | 2 +- docs/reference/basic/clear-screen.md | 2 +- docs/reference/comment.md | 38 --------- docs/reference/event-handler.md | 59 ++++++++++++++ docs/reference/game/clear.md | 4 +- docs/reference/images/create-image.md | 4 +- docs/reference/images/pixel.md | 8 +- docs/reference/images/plot-frame.md | 4 +- docs/reference/images/plot-image.md | 4 +- docs/reference/images/scroll-image.md | 4 +- docs/reference/images/set-pixel.md | 8 +- docs/reference/images/show-frame.md | 4 +- docs/reference/images/show-image.md | 6 +- docs/reference/images/width.md | 2 +- docs/reference/led/plot-leds.md | 4 +- docs/reference/led/screenshot.md | 4 +- docs/reference/radio/on-data-received.md | 2 +- docs/reference/radio/send-number.md | 2 +- docs/reference/radio/set-group.md | 4 +- docs/reference/variables/var.md | 77 +++++++++--------- olddocs/js/contents.md | 2 +- olddocs/js/var.md | 64 ++++----------- 38 files changed, 160 insertions(+), 310 deletions(-) create mode 100644 docs/device/simulator.md delete mode 100644 docs/lessons/beatbox.md delete mode 100644 docs/lessons/buzzer.md delete mode 100644 docs/lessons/glowing-sword.md delete mode 100644 docs/reference/comment.md create mode 100644 docs/reference/event-handler.md diff --git a/docs/device/crocodile-clips.md b/docs/device/crocodile-clips.md index c30b2898..01196b32 100644 --- a/docs/device/crocodile-clips.md +++ b/docs/device/crocodile-clips.md @@ -1,8 +1,7 @@ # crocodile clips -The on pin pressed accessories. - -Register an [event handler](/reference/event-handler) that will execute whenever the user attaches one side of the crocodile clip to the `GND` pin, then connects and disconnects the unattached side of the crocodile clip to pin `0`, `1`, or `2`. +The large holes at the bottom of the board are designed to attach alligator/crocodile clips. +Register an event that will execute whenever the user attaches one side of the crocodile clip to the `GND` pin, then connects and disconnects the unattached side of the crocodile clip to pin `0`, `1`, or `2`. ### Example: on pin pressed with random numbers diff --git a/docs/device/screen.md b/docs/device/screen.md index 29f9aee8..3bd569e0 100644 --- a/docs/device/screen.md +++ b/docs/device/screen.md @@ -38,7 +38,7 @@ Use the [point](/led/point) function to find out if a LED is on or off. ### Display images, strings and numbers -Instead of turning individual LEDs on or off, as above, you can display an [image](/reference/image/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. +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. ### The display buffer diff --git a/docs/device/simulator.md b/docs/device/simulator.md new file mode 100644 index 00000000..e69de29b diff --git a/docs/device/usb.md b/docs/device/usb.md index 2bbf84c4..0c8180af 100644 --- a/docs/device/usb.md +++ b/docs/device/usb.md @@ -2,7 +2,7 @@ How to compile, transfer, and run a script on your micro:bit. -While you're writing and testing your Block Editor or Touch Develop scripts, you'll mostly be running scripts in your browser by clicking the `Run` button (see [run code in your browser](/js/simulator) for info about this). +While you're writing and testing your Block Editor or Touch Develop scripts, you'll mostly be running scripts in your browser by clicking the `Run` button (see [run code in your browser](/device/simulator) for info about this). Once your masterpiece is complete, you can compile your script and run it on your micro:bit. diff --git a/docs/lessons/beatbox.md b/docs/lessons/beatbox.md deleted file mode 100644 index 43a7ccef..00000000 --- a/docs/lessons/beatbox.md +++ /dev/null @@ -1,22 +0,0 @@ -# beatbox blocks lesson - -display beautiful images on the BBC micro:bit. - -## Topic - -Music - -## Quick Links - -* [activity](/lessons/beatbox/activity) -* [challenges](/lessons/beatbox/challenges) - - -## Prior learning/place of lesson in scheme of work - -Learn how to make a beatbox music player using pins P1 and P2. We will be learning how to code musical notes using a local variable, for loop, on pin pressed as well as simple commands such as play and notes. - -## Objectives - -* learn how to code music on the BBC micro:bit - diff --git a/docs/lessons/bop-it/quiz-answers.md b/docs/lessons/bop-it/quiz-answers.md index 971e7455..852602bb 100644 --- a/docs/lessons/bop-it/quiz-answers.md +++ b/docs/lessons/bop-it/quiz-answers.md @@ -6,7 +6,7 @@ a game where you have to keep up with the commands. ## Directions -Use this activity document to guide your work in the [bop it tutorial](/lessons/bop-it/tutorial). +Use this activity document to guide your work in the [bop it activity](/lessons/bop-it/activity). Answer the questions while completing the tutorial. Pay attention to the dialogues! diff --git a/docs/lessons/bop-it/quiz.md b/docs/lessons/bop-it/quiz.md index fc6b50c3..5cdc2b68 100644 --- a/docs/lessons/bop-it/quiz.md +++ b/docs/lessons/bop-it/quiz.md @@ -6,7 +6,7 @@ a game where you have to keep up with the commands. ## Directions -Use this activity document to guide your work in the [bop it tutorial](/lessons/bop-it/tutorial). +Use this activity document to guide your work in the [bop it activity](/lessons/bop-it/activity). Answer the questions while completing the tutorial. Pay attention to the dialogues! diff --git a/docs/lessons/buzzer.md b/docs/lessons/buzzer.md deleted file mode 100644 index a84b962e..00000000 --- a/docs/lessons/buzzer.md +++ /dev/null @@ -1,81 +0,0 @@ -# buzzer lesson - -design a blinking image lesson #docs - -## Topic - -Ring - -## Quick Links - -* [activity](/lessons/buzzer/activity) -* [challenges](/lessons/buzzer/challenges) - -## Class - -Year 7 - -## Prior learning / place of lesson in scheme of work - -Learn how to **ring** the buzzer to turn on the sound. We will be learning basic comments such as ring and clear screen. - -## Documentation - -* **ring** : [read more...](/reference/music/ring) -* **clear screen** : [read more...](/reference/basic/clear-screen) -* **on button pressed** : [read more...](/reference/input/on-button-pressed) - -## Objectives - -* learn how to ring the BBC micro:bit -* learn how to clear the screen -* learn how to run code when an input button is pressed - -## Progression Pathways / Computational Thinking Framework - -#### Algorithms - -* Designs solutions (algorithms) that use repetition and two-way selection, ie if, then and else.(AL) -* Uses diagrams to express solutions.(AB) -* Uses logical reasoning to predict outputs, showing an awareness of inputs (AL) -* Recognises that different algorithms exist for the same problem (AL) (GE) -* Represents solutions using a structured notation (AL) (AB) - -#### Programming & Development - -* Creates programs that implement algorithms to achieve given goals (AL) -* Selects the appropriate data types(AL) (AB - -#### Data & Data Representation - -* Understands the difference between data and information(AB) - -#### Hardware & Processing - -* Understands the difference between hardware and application software, and their roles within a computer system (AB) - -#### Communication Networks - -* Demonstrates responsible use of technologies and online services, and knows a range of ways to report concerns (AL) - -#### Information Technology - -* Collects, organizes, and presents data and information in digital content (AB) -* Makes appropriate improvements to solutions based on feedback received, and can comment on the success of the solution (EV) - -Computational Thinking Concept: AB = Abstraction; DE = Decomposition; AL = Algorithmic Thinking; EV = Evaluation; GE = Generalisation - -## Activity - -* time: 20 min. -* [activity](/lessons/buzzer/activity) - -## Extended Activity - -* time: 20 min. -* [challenges](/lessons/buzzer/challenges) - -## Homework - -* Extended Activity: [challenges](/lessons/buzzer/challenges) - diff --git a/docs/lessons/catch-the-egg-game/quiz-answers.md b/docs/lessons/catch-the-egg-game/quiz-answers.md index 4751aa36..08ceeb78 100644 --- a/docs/lessons/catch-the-egg-game/quiz-answers.md +++ b/docs/lessons/catch-the-egg-game/quiz-answers.md @@ -6,7 +6,7 @@ Programming a game of catch the egg using the accelerometer ## Directions -Use this activity document to guide your work in the [catch the egg tutorial](/lessons/catch-the-egg-game/tutorial) +Use this activity document to guide your work in the [catch the egg activity](/lessons/catch-the-egg-game/activity) Answer the questions while completing the tutorial. Pay attention to the dialogues! diff --git a/docs/lessons/classic-beatbox/challenges.md b/docs/lessons/classic-beatbox/challenges.md index 0f98c02e..97d7d8eb 100644 --- a/docs/lessons/classic-beatbox/challenges.md +++ b/docs/lessons/classic-beatbox/challenges.md @@ -4,7 +4,7 @@ Create sounds with variables. ## Before we get started -Complete the [beatbox](/lessons/beatbox/activity) activity and your code will look like this: +Complete the [beatbox](/lessons/classic-beatbox/activity) activity and your code will look like this: ```blocks diff --git a/docs/lessons/glowing-pendulum/quiz-answers.md b/docs/lessons/glowing-pendulum/quiz-answers.md index eb178400..9c6f09a4 100644 --- a/docs/lessons/glowing-pendulum/quiz-answers.md +++ b/docs/lessons/glowing-pendulum/quiz-answers.md @@ -6,7 +6,7 @@ construct a pendulum that glows using acceleration. ## Directions -Use this activity document to guide your work in the [glowing pendulum tutorial](/lessons/glowing-pendulum/tutorial) +Use this activity document to guide your work in the [glowing pendulum activity](/lessons/glowing-pendulum/activity) Answer the questions while completing the tutorial. Pay attention to the dialogues! diff --git a/docs/lessons/glowing-sword.md b/docs/lessons/glowing-sword.md deleted file mode 100644 index 7c701b78..00000000 --- a/docs/lessons/glowing-sword.md +++ /dev/null @@ -1,30 +0,0 @@ -# glowing sword blocks lesson - -make a glowing sword. - -### @video td/videos/glowing-sword-0 - -## Topic - -Fade Out - -## Quick Links - -* [activity](/lessons/glowing-sword/activity) -* [quiz](/lessons/glowing-sword/quiz) -* [quiz answers](/lessons/glowing-sword/quiz-answers) -* [challenges](/lessons/glowing-sword/challenges) - -## Prior learning/place of lesson in scheme of work - -Learn how to manipulate an image through **fade out**, `fade out` to gradually decrease the LED screen brightness until the LED lights are turned off. We will be learning how to fade an image using simple commands, such as image create image, image show image, LED fade out, basic pause, and fade in. - -## Documentation - -* **create image** : [read more...](/reference/images/create-image) -* **show image** : [read more...](/reference/images/show-image) -* **fade out** : [read more...](/reference/led/fade-out) -* **pause** : [read more...](/reference/basic/pause) -* **fade in** : [read more...](/reference/led/fade-in) - - diff --git a/docs/lessons/headbands.md b/docs/lessons/headbands.md index 32fb634f..d6dc4e68 100644 --- a/docs/lessons/headbands.md +++ b/docs/lessons/headbands.md @@ -52,7 +52,7 @@ Learn how to create a charades game with **collections**, ` create -> Collection ## Resources -* Activity: [tutorial](/lessons/headbands/tutorial) +* Activity: [tutorial](/lessons/headbands/activity) * Activity: [quiz](/lessons/headbands/quiz) * Extended Activity: [challenges](/lessons/headbands/challenges) @@ -112,7 +112,7 @@ Computational Thinking Concept: AB = Abstraction; DE = Decomposition; AL = Algor ## Activity * time: 20 min. -* [tutorial](/lessons/headbands/tutorial) +* [tutorial](/lessons/headbands/activity) * [quiz](/lessons/headbands/quiz) ## Extended Activity diff --git a/docs/lessons/magic-8/quiz-answers.md b/docs/lessons/magic-8/quiz-answers.md index cb0dc753..3ae49582 100644 --- a/docs/lessons/magic-8/quiz-answers.md +++ b/docs/lessons/magic-8/quiz-answers.md @@ -6,7 +6,7 @@ create a magic 8 ball on the BBC micro:bit. ## Directions -Use this activity document to guide your work in the [magic 8 tutorial](/lessons/magic-8/tutorial). +Use this activity document to guide your work in the [magic 8 activity](/lessons/magic-8/activity). Answer the questions while completing the tutorial. Pay attention to the dialogues! diff --git a/docs/lessons/offset-image/quiz.md b/docs/lessons/offset-image/quiz.md index ea11e72e..690dd10c 100644 --- a/docs/lessons/offset-image/quiz.md +++ b/docs/lessons/offset-image/quiz.md @@ -6,7 +6,7 @@ shift an image horizontally across the display with offset. ## Directions -Use this activity document to guide your work in the [offset image tutorial](/lessons/offset-image/tutorial). +Use this activity document to guide your work in the [offset image activity](/lessons/offset-image/activity). Answer the questions while completing the tutorial. Pay attention to the dialogues! diff --git a/docs/lessons/prank-wifi/quiz-answers.md b/docs/lessons/prank-wifi/quiz-answers.md index 74ab86ef..50f1bdab 100644 --- a/docs/lessons/prank-wifi/quiz-answers.md +++ b/docs/lessons/prank-wifi/quiz-answers.md @@ -6,7 +6,7 @@ create a fake wifi app to trick your friends. ## Directions -Use this activity document to guide your work in the [prank WiFi tutorial](/lessons/prank-wifi/tutorial) +Use this activity document to guide your work in the [prank WiFi activity](/lessons/prank-wifi/activity) Answer the questions while completing the tutorial. Pay attention to the dialogues! diff --git a/docs/lessons/spinner/quiz-answers.md b/docs/lessons/spinner/quiz-answers.md index 62e091b6..10f7d4bc 100644 --- a/docs/lessons/spinner/quiz-answers.md +++ b/docs/lessons/spinner/quiz-answers.md @@ -6,7 +6,7 @@ a spin the BBC micro:bit game with the input on shake. ## Directions -Use this activity document to guide your work in the [spinner tutorial](/lessons/spinner/tutorial). +Use this activity document to guide your work in the [spinner activity](/lessons/spinner/activity). Answer the questions while completing the tutorial. Pay attention to the dialogues! diff --git a/docs/reference/basic/clear-screen.md b/docs/reference/basic/clear-screen.md index 1af9bf55..0d03227c 100644 --- a/docs/reference/basic/clear-screen.md +++ b/docs/reference/basic/clear-screen.md @@ -27,5 +27,5 @@ basic.clearScreen() ### See also -[set brightness](/reference/led/set-brightness), [unplot](/reference/led/unplot), [plot](/reference/led/plot), [Image](/reference/image/image), [clear](/reference/basic/clear-screen) +[set brightness](/reference/led/set-brightness), [unplot](/reference/led/unplot), [plot](/reference/led/plot), [Image](/reference/images/image), [clear](/reference/basic/clear-screen) diff --git a/docs/reference/comment.md b/docs/reference/comment.md deleted file mode 100644 index f230ae20..00000000 --- a/docs/reference/comment.md +++ /dev/null @@ -1,38 +0,0 @@ -# Comment - -A note in code. - -### @parent blocks/statement - -A comment is a line of code that contains text, usually an explanation or a note. All comments are ignored during script execution. - -### Block - -Right click on any block and add a comment - -### ~hint - -To find out how to insert comments using the Blocks editor, see [the Blocks editor](/blocks/editor). - -### ~ - -### Sample code with comments - -![](/static/mb/blocks/comment-0.png) - -### Commenting out code - -During the debugging process, you may want to comment out a section of your code so that it doesn't run. - -To comment out a block of code: - -1. Right click on any block of code that you want to comment out. - -1. Select add comment - -When you want to uncomment your code, right click the on the comment, and then click delete block. - -### See also - -[Block editor](/blocks/editor) - diff --git a/docs/reference/event-handler.md b/docs/reference/event-handler.md new file mode 100644 index 00000000..426a6b8e --- /dev/null +++ b/docs/reference/event-handler.md @@ -0,0 +1,59 @@ +# event handler + +Event handlers - how they work. + +An event handler is code that is associated with a particular event, such as "button A pressed". You create (or register) the association between an event and an event handler by calling a function named "on ". After registering an event handler with an event, then whenever that event occurs, the event handler code executes. + +### Registering an event handler + +Functions named "on " create an association between an event and the event handler code. For example, the following code registers the event handler (the code between the `do` and `end` keywords) with the event of a press of button A: + +```blocks +input.onButtonPressed(Button.A, () => { + basic.showString("hello", 150) +}) +``` + +After this code executes, then whenever button A is pressed in the future, the string "hello" will be printed. + +### Event handlers are active for the entire program execution + +Once you have registered an event handler for an event, like above, that event handler is active for the rest of the program execution. If you want to stop the string "hello" from printing each time button A is pressed then you need to arrange for the following code to execute: + +```blocks +input.onButtonPressed(Button.A, () => { +}) +``` + +The above code associated an event handler that does nothing with the event of a press of button A. + +### There is only one event handler per event + +The above example also illustrates that there is only one event handler for each event. What is the result of the following code? + +```blocks +input.onButtonPressed(Button.A, () => { + basic.showString("hello", 150) +}) +input.onButtonPressed(Button.A, () => { + basic.showString("goodbye", 150) +}) +``` + +The answer is that whenever button A is pressed, the string "goodbye" will be printed. If you want both the strings "hello" and "goodbye" to be printed, you need to write the code like this: + +```blocks +input.onButtonPressed(Button.A, () => { + basic.showString("hello", 150) + basic.showString("goodbye", 150) +}) +``` + +### To learn more + +To learn more about how the BBC micro:bit queues up and schedules event handlers, see [the BBC micro:bit - a reactive system](/device/reactive) + +### see also + +[on button pressed](/reference/input/on-button-pressed), [on logo up](/functions/on-logo-up), [on logo down](/functions/on-logo-down), [on screen up](/functions/on-screen-up), [on screen down](/functions/on-screen-down), [on shake](/reference/input/on-gesture), [on pin pressed](/reference/input/on-pin-pressed) + diff --git a/docs/reference/game/clear.md b/docs/reference/game/clear.md index d39cbb4f..89717c56 100644 --- a/docs/reference/game/clear.md +++ b/docs/reference/game/clear.md @@ -2,7 +2,7 @@ The clear function for images. -Turn off all the pixels in an [Image](/reference/image/image). +Turn off all the pixels in an [Image](/reference/images/image). ### KindScript @@ -35,5 +35,5 @@ input.onButtonPressed(Button.A, () => { ### See also -[Image](/reference/image/image), [show animation](/reference/basic/show-animation), [show image](/reference/images/show-image), [scroll image](/reference/images/scroll-image), [create image](/reference/images/create-image) +[Image](/reference/images/image), [show animation](/reference/basic/show-animation), [show image](/reference/images/show-image), [scroll image](/reference/images/scroll-image), [create image](/reference/images/create-image) diff --git a/docs/reference/images/create-image.md b/docs/reference/images/create-image.md index bd57b2ab..a2555700 100644 --- a/docs/reference/images/create-image.md +++ b/docs/reference/images/create-image.md @@ -1,6 +1,6 @@ # Create Image -Create an [Image](/reference/image/image) to show on the [LED screen](/device/screen). +Create an [Image](/reference/images/image) to show on the [LED screen](/device/screen). ```sig images.createImage(` @@ -35,5 +35,5 @@ input.onGesture(Gesture.Shake, () => { ### See also -[show animation](/reference/basic/show-animation), [image](/reference/image/image), [show image](/reference/image/show-image), [scroll image](/reference/image/scroll-image) +[show animation](/reference/basic/show-animation), [image](/reference/images/image), [show image](/reference/image/show-image), [scroll image](/reference/image/scroll-image) diff --git a/docs/reference/images/pixel.md b/docs/reference/images/pixel.md index 2e3cadfe..0ca138e8 100644 --- a/docs/reference/images/pixel.md +++ b/docs/reference/images/pixel.md @@ -2,7 +2,7 @@ The pixel function. -Get the state of a pixel in an [Image](/reference/image/image). +Get the state of a pixel in an [Image](/reference/images/image). ### KindScript @@ -12,8 +12,8 @@ export function pixel(_this: micro_bit.Image, x: number, y: number) : boolean ### Parameters -* x - [Number](/reference/types/number); the *x coordinate* or horizontal position of a pixel in an [image](/reference/image/image) -* y - [Number](/reference/types/number); the *y coordinate* or vertical position of a pixel in an [image](/reference/image/image) +* x - [Number](/reference/types/number); the *x coordinate* or horizontal position of a pixel in an [image](/reference/images/image) +* y - [Number](/reference/types/number); the *y coordinate* or vertical position of a pixel in an [image](/reference/images/image) ### x, y coordinates? @@ -47,5 +47,5 @@ let state = img.pixel(0, 0) ### See also -[set pixel](/reference/images/set-pixel), [show image](/reference/images/show-image), [image](/reference/image/image), [create image](/reference/images/create-image), [scroll image](/reference/images/scroll-image) +[set pixel](/reference/images/set-pixel), [show image](/reference/images/show-image), [image](/reference/images/image), [create image](/reference/images/create-image), [scroll image](/reference/images/scroll-image) diff --git a/docs/reference/images/plot-frame.md b/docs/reference/images/plot-frame.md index 19424f63..7c8da246 100644 --- a/docs/reference/images/plot-frame.md +++ b/docs/reference/images/plot-frame.md @@ -2,7 +2,7 @@ The plot frame function. -Display an [Image](/reference/image/image) on the BBC micro:bit's [LED screen](/device/screen) +Display an [Image](/reference/images/image) on the BBC micro:bit's [LED screen](/device/screen) ### KindScript @@ -37,5 +37,5 @@ img.plotFrame(1) ### See also -[create image](/reference/images/create-image), [show animation](/reference/basic/show-animation), [image](/reference/image/image), [show image](/reference/images/show-image), [scroll image](/reference/images/scroll-image) +[create image](/reference/images/create-image), [show animation](/reference/basic/show-animation), [image](/reference/images/image), [show image](/reference/images/show-image), [scroll image](/reference/images/scroll-image) diff --git a/docs/reference/images/plot-image.md b/docs/reference/images/plot-image.md index 4a4f7910..434b8d5e 100644 --- a/docs/reference/images/plot-image.md +++ b/docs/reference/images/plot-image.md @@ -2,7 +2,7 @@ The plot image function. -Display an [Image](/reference/image/image) on the BBC micro:bit's [LED screen](/device/screen) +Display an [Image](/reference/images/image) on the BBC micro:bit's [LED screen](/device/screen) ### KindScript @@ -37,5 +37,5 @@ img.plotImage(0) ### See also -[create image](/reference/images/create-image), [show animation](/reference/basic/show-animation), [image](/reference/image/image), [show image](/reference/images/show-image), [scroll image](/reference/images/scroll-image) +[create image](/reference/images/create-image), [show animation](/reference/basic/show-animation), [image](/reference/images/image), [show image](/reference/images/show-image), [scroll image](/reference/images/scroll-image) diff --git a/docs/reference/images/scroll-image.md b/docs/reference/images/scroll-image.md index 6ece6c17..4e106ca0 100644 --- a/docs/reference/images/scroll-image.md +++ b/docs/reference/images/scroll-image.md @@ -2,7 +2,7 @@ The scroll image function. -Scrolls the frames within an [Image](/reference/image/image) on the [LED screen](/device/screen). +Scrolls the frames within an [Image](/reference/images/image) on the [LED screen](/device/screen). ### Block Editor @@ -69,5 +69,5 @@ img.scrollImage(5, 1000) ### See also -[show image](/reference/images/show-image), [image](/reference/image/image), [create image](/reference/images/create-image), [show animation](/reference/basic/show-animation) +[show image](/reference/images/show-image), [image](/reference/images/image), [create image](/reference/images/create-image), [show animation](/reference/basic/show-animation) diff --git a/docs/reference/images/set-pixel.md b/docs/reference/images/set-pixel.md index a659bea7..f87a413a 100644 --- a/docs/reference/images/set-pixel.md +++ b/docs/reference/images/set-pixel.md @@ -2,7 +2,7 @@ The set pixel function. #set pixel. -Set the on/off state of pixel in an [Image](/reference/image/image). +Set the on/off state of pixel in an [Image](/reference/images/image). ### KindScript @@ -12,8 +12,8 @@ export function setPixel(_this: micro_bit.Image, x: number, y: number, value: bo ### Parameters -* x - [Number](/reference/types/number); the *x coordinate* or horizontal position of a pixel in an [image](/reference/image/image) -* x - [Number](/reference/types/number); the *y coordinate* or vertical position of a pixel in an [image](/reference/image/image) +* x - [Number](/reference/types/number); the *x coordinate* or horizontal position of a pixel in an [image](/reference/images/image) +* x - [Number](/reference/types/number); the *y coordinate* or vertical position of a pixel in an [image](/reference/images/image) * value -[Boolean](/reference/types/boolean); the on/off state of a pixel; `true` for on, `false` for off ### x, y coordinates? @@ -38,5 +38,5 @@ img.showImage(0) ### See also -[pixel](/reference/images/pixel), [show image](/reference/images/show-image), [image](/reference/image/image), [create image](/reference/images/create-image), [scroll image](/reference/images/scroll-image) +[pixel](/reference/images/pixel), [show image](/reference/images/show-image), [image](/reference/images/image), [create image](/reference/images/create-image), [scroll image](/reference/images/scroll-image) diff --git a/docs/reference/images/show-frame.md b/docs/reference/images/show-frame.md index 43e001eb..5ab04967 100644 --- a/docs/reference/images/show-frame.md +++ b/docs/reference/images/show-frame.md @@ -2,7 +2,7 @@ The show frame function. -Display an [Image](/reference/image/image) on the BBC micro:bit's [LED screen](/device/screen) +Display an [Image](/reference/images/image) on the BBC micro:bit's [LED screen](/device/screen) ### KindScript @@ -37,5 +37,5 @@ img.showFrame(1) ### See also -[create image](/reference/images/create-image), [show animation](/reference/basic/show-animation), [image](/reference/image/image), [show image](/reference/images/show-image), [scroll image](/reference/images/scroll-image) +[create image](/reference/images/create-image), [show animation](/reference/basic/show-animation), [image](/reference/images/image), [show image](/reference/images/show-image), [scroll image](/reference/images/scroll-image) diff --git a/docs/reference/images/show-image.md b/docs/reference/images/show-image.md index fd9b2c1a..dc8f2b86 100644 --- a/docs/reference/images/show-image.md +++ b/docs/reference/images/show-image.md @@ -2,7 +2,7 @@ The show image function. -Show an [Image](/reference/image/image) on the [LED screen](/device/screen), followed by a 400ms pause. +Show an [Image](/reference/images/image) on the [LED screen](/device/screen), followed by a 400ms pause. ### Block Editor @@ -20,7 +20,7 @@ export function showImage(_this: micro_bit.Image, xOffset: number) ### Create image and show image -Use the [image editor](/reference/image/image) to create images using the [create image](/reference/image/create-image) function, and then use `show image` like this: +Use the [image editor](/reference/images/image) to create images using the [create image](/reference/image/create-image) function, and then use `show image` like this: ``` let img = images.createImage(` @@ -57,5 +57,5 @@ for (let i = 0; i < 5; i++) { ### See also -[show animation](/reference/basic/show-animation), [image](/reference/image/image), [create image](/reference/images/create-image), [scroll image](/reference/images/scroll-image) +[show animation](/reference/basic/show-animation), [image](/reference/images/image), [create image](/reference/images/create-image), [scroll image](/reference/images/scroll-image) diff --git a/docs/reference/images/width.md b/docs/reference/images/width.md index 49233ecd..0a40b59f 100644 --- a/docs/reference/images/width.md +++ b/docs/reference/images/width.md @@ -2,7 +2,7 @@ The width function. -Get the width of an [Image](/reference/image/image) in columns. +Get the width of an [Image](/reference/images/image) in columns. ### KindScript diff --git a/docs/reference/led/plot-leds.md b/docs/reference/led/plot-leds.md index 85155d45..c57f6061 100644 --- a/docs/reference/led/plot-leds.md +++ b/docs/reference/led/plot-leds.md @@ -1,6 +1,6 @@ # Plot LEDs -Display an [Image](/reference/image/image) on the BBC micro:bit's [LED screen](/device/screen). NOTE: `basic -> plot image` has been replaced by `basic -> show leds`. +Display an [Image](/reference/images/image) on the BBC micro:bit's [LED screen](/device/screen). NOTE: `basic -> plot image` has been replaced by `basic -> show leds`. ### KindScript syntax @@ -36,5 +36,5 @@ basic.plotLeds(` ### See also -[show animation](/reference/basic/show-animation), [image](/reference/image/image), [show image](/reference/images/show-image), [scroll image](/reference/images/scroll-image) +[show animation](/reference/basic/show-animation), [image](/reference/images/image), [show image](/reference/images/show-image), [scroll image](/reference/images/scroll-image) diff --git a/docs/reference/led/screenshot.md b/docs/reference/led/screenshot.md index b320bbaa..8d138c93 100644 --- a/docs/reference/led/screenshot.md +++ b/docs/reference/led/screenshot.md @@ -1,6 +1,6 @@ # Screenshot -Make an [Image](/reference/image/image) out of the current state of the [LED screen](/device/screen). +Make an [Image](/reference/images/image) out of the current state of the [LED screen](/device/screen). ```sig led.screenshot(); @@ -12,7 +12,7 @@ led.screenshot(); ### Returns -* an [Image](/reference/image/image) of what is currently visible on the [LED screen](/device/screen) +* an [Image](/reference/images/image) of what is currently visible on the [LED screen](/device/screen) ### See also diff --git a/docs/reference/radio/on-data-received.md b/docs/reference/radio/on-data-received.md index c6bc1075..433ff5fc 100644 --- a/docs/reference/radio/on-data-received.md +++ b/docs/reference/radio/on-data-received.md @@ -31,5 +31,5 @@ radio.onDataReceived(() => { ### See also -[receive number](/radio/receive-number), [send number](/radio/send-number), [set group](/reference/radio/set-group) +[receive number](/reference/radio/receive-number), [send number](/radio/send-number), [set group](/reference/radio/set-group) diff --git a/docs/reference/radio/send-number.md b/docs/reference/radio/send-number.md index 5ed65bff..5236c969 100644 --- a/docs/reference/radio/send-number.md +++ b/docs/reference/radio/send-number.md @@ -30,5 +30,5 @@ input.onButtonPressed(Button.A, () => { ### See also -[receive number](/input/receive-number), [on data received](/reference/radio/on-data-received) +[receive number](/reference/radio/receive-number), [on data received](/reference/radio/on-data-received) diff --git a/docs/reference/radio/set-group.md b/docs/reference/radio/set-group.md index 475ab1b9..161085d4 100644 --- a/docs/reference/radio/set-group.md +++ b/docs/reference/radio/set-group.md @@ -18,7 +18,7 @@ radio.setGroup(1) ### Parameters -* ``id`` -- a [number](/number) between ``0`` and ``255``. +* ``id`` -- a [number](/reference/types/number) between ``0`` and ``255``. ### Example @@ -30,5 +30,5 @@ radio.setGroup(128) ### See also -[receive number](/radio/receive-number), [send number](/radio/send-number), [on data received](/radio/on-data-received) +[receive number](/reference/radio/receive-number), [send number](/reference/radio/send-number), [on data received](/reference/radio/on-data-received) diff --git a/docs/reference/variables/var.md b/docs/reference/variables/var.md index 4072c247..775fda5b 100644 --- a/docs/reference/variables/var.md +++ b/docs/reference/variables/var.md @@ -4,7 +4,7 @@ How to define and use local variables. ### @parent language -A variable is a place where you can store and retrieve data. Variables have a name, a [type](/blocks/types), and value: +A variable is a place where you can store and retrieve data. Variables have a name, a [type](/reference/types), and value: * *name* is how you'll refer to the variable * *type* refers to the kind of data a variable can store @@ -12,12 +12,15 @@ A variable is a place where you can store and retrieve data. Variables have a na ### Var statement -Use the Block Editor variable statement to create a local variable and the [assignment operator](/reference/variables/assign) to store something in the variable. +Use the Block Editor variable statement to create a variable +and the [assignment operator](/reference/variables/assign) +to store something in the variable. -For example, this code stores the number `2` in the `num1` variable: - -![](/static/mb/blocks/var-0.png) +For example, this code stores the number `2` in the `x` variable: +```blocks +let x = 2; +``` Here's how to define a variable in the Block Editor: 1. Click `variables`. @@ -26,57 +29,53 @@ Here's how to define a variable in the Block Editor: 3. Drag a block type on the right-side of the [assignment operator](/reference/variables/assign) and click the down arrow to change the variable name. -The resulting code should look something like this: - -// string variable - -![](/static/mb/blocks/var-1.png) - -// number variable - -![](/static/mb/blocks/var-2.png) - -// boolean variable - -![](/static/mb/blocks/var-3.png) - -// image variable - -![](/static/mb/blocks/var-4.png) - -See [Image](/blocks/image) for info on creating and using image variables. - -The resulting code should look something like this: - -![](/static/mb/blocks/var-5.png) - A variable is created for the number returned by the [brightness](/reference/led/brightness) function. +```blocks +let b = led.brightness(); +``` + ### Using variables Once you've defined a variable, just use the variable's name whenever you need what's stored in the variable. For example, the following code shows the value stored in `counter` on the LED screen: -![](/static/mb/blocks/var-6.png) +```blocks +let counter = 1; +basic.showNumber(counter); +``` To change the contents of a variable use the assignment operator. The following code sets `counter` to 1 and then increments `counter` by 10: -![](/static/mb/blocks/var-7.png) +```blocks +let counter = 1; +counter = counter + 10; +basic.showNumber(counter); +``` ### Why use variables? -Variables help simplify your code. For example, instead of turning on LEDs one by one like this: +If you want to remember and modify data, you'll need a variable. +A counter is a great example: -![](/static/mb/blocks/var-8.png) - -You can use a variable (`i`) and a [for loop](/reference/loops/for) to plot the same series of points (`i` is incremented by 1, each time the loop repeats): - -![](/static/mb/blocks/var-9.png) +```blocks +let counter = 0; +input.onButtonPressed(Button.A, () => { + counter = counter + 1; + basic.showNumber(counter); +}); +``` ### Local variables Local variables exist only within the function or block of code where they're defined. For example: -![](/static/mb/blocks/comment-0.png) +```blocks +// x does NOT exist here. +if (led.brightness() > 128) { + // x exists here + let x = 0; +} +``` #### Notes @@ -88,5 +87,5 @@ Local variables exist only within the function or block of code where they're de ### See also -[types](/blocks/types), [assignment operator](/reference/variables/assign) +[types](/reference/types), [assignment operator](/reference/variables/assign) diff --git a/olddocs/js/contents.md b/olddocs/js/contents.md index b7726594..424ad025 100644 --- a/olddocs/js/contents.md +++ b/olddocs/js/contents.md @@ -34,7 +34,7 @@ Welcome to the Touch Develop home page for the BBC micro:bit. Below you will fin * [Number](/reference/types/number) * [Boolean](/reference/types/boolean) * [String](/reference/types/string) -* [Image](/reference/image/image) +* [Image](/reference/images/image) ### Statements and control structures diff --git a/olddocs/js/var.md b/olddocs/js/var.md index 1ef513e6..4fe22280 100644 --- a/olddocs/js/var.md +++ b/olddocs/js/var.md @@ -13,45 +13,29 @@ A variable is a place where you can store and retrieve data. Variables have a na ### `var` and `let` statement -Use the Touch Develop *var* statement to create a local variable and the [assignment operator](/reference/variables/assign) `=` to store something in the variable. +The ``var`` keyword declares a global variables that is defined within the entire scope of the function. +The ``let`` keyword defined a block-scoped variable, similarly to other languages like Java, C# or C. For example, this code stores the number `2` in the `num1` variable: -``` +* number variable +```blocks let num1 = 2 ``` -Here's how to define a variable in the Touch Develop editor: - -1. Click `var`. - -2. Change the default variable name if you like. - -3. Click on the right-side of the [assignment operator](/reference/variables/assign) `:=` and type or click what you want to store in the variable. - -The resulting code should look something like this: - -// string variable - -``` +* string variable +```blocks let name = "Mike" ``` -// number variable +* boolean variable -``` -let counter = 1 -``` - -// boolean variable - -``` +```blocks let bool = true ``` -// image variable - -``` +* image variable +```blocks let img = images.createImage(` . . # . . . # # # . @@ -62,34 +46,19 @@ let img = images.createImage(` ``` See [Image](/reference/image/image) for info on creating and using image variables. - -### Store in var button - -Another way to define a variable is to use the `store in var` button. Here's how: - -* in the [Touch Develop editor](/js/editor), click a function button that returns a value (i.e. `led` `->` `brightness`) -* click `store in var` -* click `rename` to change the default variable name - -The resulting code should look something like this: - -``` -let brightness = led.brightness() -``` - -A variable is created for the number returned by the [brightness](/reference/led/brightness) function. - ### Using variables Once you've defined a variable, just use the variable's name whenever you need what's stored in the variable. For example, the following code shows the value stored in `counter` on the LED screen: ``` +let counter = 5; basic.showNumber(counter, 100) ``` To change the contents of a variable use the assignment operator `:=`. The following code sets `counter` to 1 and then increments `counter` by 10: ``` +let counter = 0; counter = 1 counter = counter + 10 ``` @@ -127,12 +96,7 @@ if (led.brightness() > 127) { } ``` -Use [global variables](/js/data) when you need to access a variable in nested code blocks or across multiple functions. - -#### Notes - -* You can use the default variable names if you'd like, however, it's best to use descriptive variable names. To change a variable name in the editor, select the variable and then click `rename`. -* Be careful not to confuse the assignment `:=` operator with the equals `=` operator. +Use **global variables** when you need to access a variable in nested code blocks or across multiple functions. ### Lessons @@ -140,5 +104,5 @@ Use [global variables](/js/data) when you need to access a variable in nested co ### See also -[global variables](/js/data), [types](/js/types), [assignment operator](/reference/variables/assign) +[types](/reference/types), [assignment operator](/reference/variables/assign)