Compare commits

...

18 Commits

Author SHA1 Message Date
953ea31016 0.2.75 2016-04-15 15:27:30 -07:00
9fe27d5f35 Bump pxt-core to 0.2.81 2016-04-15 15:27:28 -07:00
d290aeb2e9 udpated favicon 2016-04-15 15:27:21 -07:00
7fee84678a missing favicon 2016-04-15 15:10:35 -07:00
77030db1d3 fixing links in docs 2016-04-15 15:02:26 -07:00
bb6ae00a49 moving out outdated js docs 2016-04-15 14:37:25 -07:00
6515cc0360 0.2.74 2016-04-15 08:17:45 -07:00
13d09b3e83 Bump pxt-core to 0.2.79 2016-04-15 08:17:43 -07:00
3a434197a3 updated neopixel 2016-04-15 07:42:52 -07:00
8ab0dc450a 0.2.73 2016-04-14 21:42:18 -07:00
4afc887ee5 Bump pxt-core to 0.2.78 2016-04-14 21:42:17 -07:00
db4692843f fixing text scroll on simulator 2016-04-14 21:42:02 -07:00
ad98c1aaa6 0.2.72 2016-04-14 21:15:11 -07:00
6ff9652450 Bump pxt-core to 0.2.77 2016-04-14 21:15:09 -07:00
6182a80f41 0.2.71 2016-04-14 18:26:14 -07:00
06e59c8d02 Bump pxt-core to 0.2.75 2016-04-14 18:25:56 -07:00
b9f17c3143 Re-generate for new DAL 2016-04-14 17:58:10 -07:00
10e3fdf007 upated to 0.1.7. fixing rename issues 2016-04-14 14:29:28 -07:00
200 changed files with 354 additions and 574 deletions

View File

@ -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

View File

@ -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

0
docs/device/simulator.md Normal file
View File

View File

@ -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.

View File

@ -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

View File

@ -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!

View File

@ -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!

View File

@ -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)

View File

@ -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!

View File

@ -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

View File

@ -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!

View File

@ -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)

View File

@ -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

View File

@ -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!

View File

@ -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!

View File

@ -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!

View File

@ -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!

View File

@ -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)

View File

@ -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)

View File

@ -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 <event>". 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 <event>" 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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -1,81 +0,0 @@
# Antenna Library
The events library #docs
The functions in the ``antenna`` namespace allow the BBC micro:bit to communicate with a separate (remote) device, such as a smartphone, over Bluetooth (Smart). The set of supported events will depend on the remote device and the BBC micro:bit apps available for the remote device.
### Remote control
Control the presentation of media content available on a remote device using the `tell remote control to` function
```
export function tellRemoteControlTo(event: string)
```
The remote control specific events include:
* play
* pause
* stop
* next track
* previous track
* forward
* rewind
* volume up
* volume down
### Camera
Access the photo/video-taking functionality of a remote device using the *camera* function:
```
export function tellCameraTo(event: string)
```
The camera-specific events include:
* toggle front-rear
* launch photo mode
* take photo
* stop photo mode
* launch video mode
* start video capture
* stop video capture
* stop video mode
### Alert
Raise an alert on a remote device using the `raise alert to` function
```
export function raiseAlertTo(event: string)
```
The set of alerting-specific events include:
* display toast
* vibrate
* play sound
* play ringtone
* find my phone
* alarm 1
* alarm 2
* alarm 3
* alarm 4
* alarm 5
* alarm 6
### Microphone
Access the audio recording capabilities of the device using the `tell microphone to` function
```
export function tellMicrophoneTo(event: string)
```
The set of audio recorder events include:
* launch
* start capture
* end capture
* stop

View File

@ -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)

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

BIN
docs/static/favicon.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@ -8,10 +8,6 @@ enum class EventCreationMode {
* MicroBitEvent is initialised, and no further processing takes place.
*/
CreateOnly = CREATE_ONLY,
/**
* MicroBitEvent is initialised, and queued on the MicroBitMessageBus.
*/
CreateAndQueue = CREATE_AND_QUEUE,
/**
* MicroBitEvent is initialised, and its event handlers are immediately fired (not suitable for use in interrupts!).
*/
@ -143,10 +139,10 @@ namespace control {
* Raises an event in the event bus.
* @param src ID of the MicroBit Component that generated the event e.g. MICROBIT_ID_BUTTON_A.
* @param value Component specific code indicating the cause of the event.
* @param mode optional definition of how the event should be processed after construction (default is CREATE_AND_QUEUE).
* @param mode optional definition of how the event should be processed after construction (default is CREATE_AND_FIRE).
*/
//% weight=21 blockGap=12 blockId="control_raise_event" block="raise event|from source %src=control_event_source|with value %value=control_event_value" blockExternalInputs=1
//% mode.defl=CREATE_AND_QUEUE
//% mode.defl=CREATE_AND_FIRE
void raiseEvent(int src, int value, EventCreationMode mode) {
MicroBitEvent evt(src, value, (MicroBitEventLaunchMode)mode);
}

336
libs/microbit/dal.d.ts vendored
View File

@ -1,26 +1,9 @@
// Auto-generated. Do not edit.
declare const enum DAL {
// DynamicPwm.h
NO_PWMS = 3,
MICROBIT_DEFAULT_PWM_PERIOD = 20000,
PWM_PERSISTENCE_TRANSIENT = 1,
PWM_PERSISTENCE_PERSISTENT = 2,
// ErrorNo.h
MICROBIT_OK = 0,
MICROBIT_INVALID_PARAMETER = -1001,
MICROBIT_NOT_SUPPORTED = -1002,
MICROBIT_CALIBRATION_IN_PROGRESS = -1003,
MICROBIT_CALIBRATION_REQUIRED = -1004,
MICROBIT_NO_RESOURCES = -1005,
MICROBIT_BUSY = -1006,
MICROBIT_CANCELLED = -1007,
MICROBIT_I2C_ERROR = -1010,
MICROBIT_OOM = 20,
MICROBIT_HEAP_ERROR = 30,
MICROBIT_NULL_DEREFERENCE = 40,
// ExternalEvents.h
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/ExternalEvents.h
MICROBIT_ID_BLE = 1000,
// MESEvents.h
MICROBIT_ID_BLE_UART = 1001,
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MESEvents.h
MES_REMOTE_CONTROL_ID = 1001,
MES_REMOTE_CONTROL_EVT_PLAY = 1,
MES_REMOTE_CONTROL_EVT_PAUSE = 2,
@ -85,20 +68,130 @@ declare const enum DAL {
MES_DPAD_BUTTON_4_DOWN = 15,
MES_DPAD_BUTTON_4_UP = 16,
MES_BROADCAST_GENERAL_ID = 2000,
// ManagedString.h
// ManagedType.h
// Matrix4.h
// MemberFunctionCallback.h
// MicroBit.h
MICROBIT_FLAG_SCHEDULER_RUNNING = 0x00000001,
MICROBIT_FLAG_ACCELEROMETER_RUNNING = 0x00000002,
MICROBIT_FLAG_DISPLAY_RUNNING = 0x00000004,
MICROBIT_FLAG_COMPASS_RUNNING = 0x00000008,
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitAccelerometerService.h
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitBLEManager.h
MICROBIT_BLE_PAIR_REQUEST = 0x01,
MICROBIT_BLE_PAIR_COMPLETE = 0x02,
MICROBIT_BLE_PAIR_PASSCODE = 0x04,
MICROBIT_BLE_PAIR_SUCCESSFUL = 0x08,
MICROBIT_BLE_PAIRING_TIMEOUT = 90,
MICROBIT_BLE_POWER_LEVELS = 8,
MICROBIT_BLE_MAXIMUM_BONDS = 4,
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitButtonService.h
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitDFUService.h
MICROBIT_DFU_OPCODE_START_DFU = 1,
MICROBIT_DFU_HISTOGRAM_WIDTH = 5,
MICROBIT_DFU_HISTOGRAM_HEIGHT = 5,
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitEventService.h
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitIOPinService.h
MICROBIT_IO_PIN_SERVICE_PINCOUNT = 20,
MICROBIT_IO_PIN_SERVICE_DATA_SIZE = 10,
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitLEDService.h
MICROBIT_BLE_MAXIMUM_SCROLLTEXT = 20,
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitMagnetometerService.h
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitTemperatureService.h
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitUARTService.h
MICROBIT_UART_S_DEFAULT_BUF_SIZE = 20,
MICROBIT_UART_S_EVT_DELIM_MATCH = 1,
MICROBIT_UART_S_EVT_HEAD_MATCH = 2,
MICROBIT_UART_S_EVT_RX_FULL = 3,
// built/yt/yotta_modules/microbit-dal/inc//core/ErrorNo.h
MICROBIT_OK = 0,
MICROBIT_INVALID_PARAMETER = -1001,
MICROBIT_NOT_SUPPORTED = -1002,
MICROBIT_CALIBRATION_IN_PROGRESS = -1003,
MICROBIT_CALIBRATION_REQUIRED = -1004,
MICROBIT_NO_RESOURCES = -1005,
MICROBIT_BUSY = -1006,
MICROBIT_CANCELLED = -1007,
MICROBIT_I2C_ERROR = -1010,
MICROBIT_SERIAL_IN_USE = -1011,
MICROBIT_NO_DATA = -1012,
MICROBIT_OOM = 20,
MICROBIT_HEAP_ERROR = 30,
MICROBIT_NULL_DEREFERENCE = 40,
// built/yt/yotta_modules/microbit-dal/inc//core/EventModel.h
// built/yt/yotta_modules/microbit-dal/inc//core/MemberFunctionCallback.h
// built/yt/yotta_modules/microbit-dal/inc//core/MicroBitCompat.h
// built/yt/yotta_modules/microbit-dal/inc//core/MicroBitComponent.h
MICROBIT_ID_BUTTON_A = 1,
MICROBIT_ID_BUTTON_B = 2,
MICROBIT_ID_BUTTON_RESET = 3,
MICROBIT_ID_ACCELEROMETER = 4,
MICROBIT_ID_COMPASS = 5,
MICROBIT_ID_DISPLAY = 6,
MICROBIT_IO_PINS = 20,
MICROBIT_ID_IO_P0 = 7,
MICROBIT_ID_IO_P1 = 8,
MICROBIT_ID_IO_P2 = 9,
MICROBIT_ID_IO_P3 = 10,
MICROBIT_ID_IO_P4 = 11,
MICROBIT_ID_IO_P5 = 12,
MICROBIT_ID_IO_P6 = 13,
MICROBIT_ID_IO_P7 = 14,
MICROBIT_ID_IO_P8 = 15,
MICROBIT_ID_IO_P9 = 16,
MICROBIT_ID_IO_P10 = 17,
MICROBIT_ID_IO_P11 = 18,
MICROBIT_ID_IO_P12 = 19,
MICROBIT_ID_IO_P13 = 20,
MICROBIT_ID_IO_P14 = 21,
MICROBIT_ID_IO_P15 = 22,
MICROBIT_ID_IO_P16 = 23,
MICROBIT_ID_IO_P19 = 24,
MICROBIT_ID_IO_P20 = 25,
MICROBIT_ID_BUTTON_AB = 26,
MICROBIT_ID_GESTURE = 27,
MICROBIT_ID_THERMOMETER = 28,
MICROBIT_ID_RADIO = 29,
MICROBIT_ID_RADIO_DATA_READY = 30,
MICROBIT_ID_MULTIBUTTON_ATTACH = 31,
MICROBIT_ID_SERIAL = 32,
MICROBIT_ID_MESSAGE_BUS_LISTENER = 1021,
MICROBIT_ID_NOTIFY_ONE = 1022,
MICROBIT_ID_NOTIFY = 1023,
MICROBIT_COMPONENT_RUNNING = 0x01,
// built/yt/yotta_modules/microbit-dal/inc//core/MicroBitDevice.h
MICROBIT_NAME_LENGTH = 5,
MICROBIT_NAME_CODE_LETTERS = 5,
NRF51822_RNG_ADDRESS = 0x4000D000,
// MicroBitAccelerometer.h
MICROBIT_ACCEL_PITCH_ROLL_VALID = 0x01,
MICROBIT_PANIC_ERROR_CHARS = 4,
// built/yt/yotta_modules/microbit-dal/inc//core/MicroBitFiber.h
MICROBIT_SCHEDULER_RUNNING = 0x01,
MICROBIT_FIBER_FLAG_FOB = 0x01,
MICROBIT_FIBER_FLAG_PARENT = 0x02,
MICROBIT_FIBER_FLAG_CHILD = 0x04,
MICROBIT_FIBER_FLAG_DO_NOT_PAGE = 0x08,
// built/yt/yotta_modules/microbit-dal/inc//core/MicroBitFont.h
MICROBIT_FONT_WIDTH = 5,
MICROBIT_FONT_HEIGHT = 5,
MICROBIT_FONT_ASCII_START = 32,
MICROBIT_FONT_ASCII_END = 126,
// built/yt/yotta_modules/microbit-dal/inc//core/MicroBitHeapAllocator.h
MICROBIT_MAXIMUM_HEAPS = 2,
MICROBIT_HEAP_BLOCK_FREE = 0x80000000,
// built/yt/yotta_modules/microbit-dal/inc//core/MicroBitListener.h
MESSAGE_BUS_LISTENER_PARAMETERISED = 0x0001,
MESSAGE_BUS_LISTENER_METHOD = 0x0002,
MESSAGE_BUS_LISTENER_BUSY = 0x0004,
MESSAGE_BUS_LISTENER_REENTRANT = 0x0008,
MESSAGE_BUS_LISTENER_QUEUE_IF_BUSY = 0x0010,
MESSAGE_BUS_LISTENER_DROP_IF_BUSY = 0x0020,
MESSAGE_BUS_LISTENER_NONBLOCKING = 0x0040,
MESSAGE_BUS_LISTENER_URGENT = 0x0080,
MESSAGE_BUS_LISTENER_DELETING = 0x8000,
// built/yt/yotta_modules/microbit-dal/inc//core/MicroBitSystemTimer.h
// built/yt/yotta_modules/microbit-dal/inc//core/NotifyEvents.h
MICROBIT_DISPLAY_EVT_FREE = 1,
MICROBIT_SERIAL_EVT_TX_EMPTY = 2,
MICROBIT_UART_S_EVT_TX_EMPTY = 3,
// built/yt/yotta_modules/microbit-dal/inc//drivers/DynamicPwm.h
NO_PWMS = 3,
MICROBIT_DEFAULT_PWM_PERIOD = 20000,
PWM_PERSISTENCE_TRANSIENT = 1,
PWM_PERSISTENCE_PERSISTENT = 2,
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitAccelerometer.h
MICROBIT_ACCEL_PITCH_ROLL_VALID = 0x02,
MICROBIT_ACCEL_ADDED_TO_IDLE = 0x04,
MMA8653_DEFAULT_ADDR = 0x3A,
MMA8653_STATUS = 0x00,
MMA8653_OUT_X_MSB = 0x01,
@ -146,16 +239,7 @@ declare const enum DAL {
GESTURE_6G = 9,
GESTURE_8G = 10,
GESTURE_SHAKE = 11,
// MicroBitAccelerometerService.h
// MicroBitBLEManager.h
MICROBIT_BLE_PAIR_REQUEST = 0x01,
MICROBIT_BLE_PAIR_COMPLETE = 0x02,
MICROBIT_BLE_PAIR_PASSCODE = 0x04,
MICROBIT_BLE_PAIR_SUCCESSFUL = 0x08,
MICROBIT_BLE_PAIRING_TIMEOUT = 90,
MICROBIT_BLE_POWER_LEVELS = 8,
MICROBIT_BLE_MAXIMUM_BONDS = 4,
// MicroBitButton.h
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitButton.h
MICROBIT_BUTTON_EVT_DOWN = 1,
MICROBIT_BUTTON_EVT_UP = 2,
MICROBIT_BUTTON_EVT_CLICK = 3,
@ -175,8 +259,7 @@ declare const enum DAL {
MICROBIT_BUTTON_DOUBLE_CLICK_THRESH = 50,
MICROBIT_BUTTON_SIMPLE_EVENTS = 0,
MICROBIT_BUTTON_ALL_EVENTS = 1,
// MicroBitButtonService.h
// MicroBitCompass.h
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitCompass.h
MAG3110_DEFAULT_ADDR = 0x1D,
MAG_DR_STATUS = 0x00,
MAG_OUT_X_MSB = 0x01,
@ -203,66 +286,17 @@ declare const enum DAL {
MICROBIT_COMPASS_EVT_DATA_UPDATE = 4,
MICROBIT_COMPASS_EVT_CONFIG_NEEDED = 5,
MICROBIT_COMPASS_EVT_CALIBRATE = 6,
MICROBIT_COMPASS_STATUS_CALIBRATED = 1,
MICROBIT_COMPASS_STATUS_CALIBRATING = 2,
MICROBIT_COMPASS_STATUS_CALIBRATED = 2,
MICROBIT_COMPASS_STATUS_CALIBRATING = 4,
MICROBIT_COMPASS_STATUS_ADDED_TO_IDLE = 8,
MAG3110_WHOAMI_VAL = 0xC4,
// MicroBitCompat.h
// MicroBitComponent.h
MICROBIT_ID_BUTTON_A = 1,
MICROBIT_ID_BUTTON_B = 2,
MICROBIT_ID_BUTTON_RESET = 3,
MICROBIT_ID_ACCELEROMETER = 4,
MICROBIT_ID_COMPASS = 5,
MICROBIT_ID_DISPLAY = 6,
MICROBIT_IO_PINS = 20,
MICROBIT_ID_IO_P0 = 7,
MICROBIT_ID_IO_P1 = 8,
MICROBIT_ID_IO_P2 = 9,
MICROBIT_ID_IO_P3 = 10,
MICROBIT_ID_IO_P4 = 11,
MICROBIT_ID_IO_P5 = 12,
MICROBIT_ID_IO_P6 = 13,
MICROBIT_ID_IO_P7 = 14,
MICROBIT_ID_IO_P8 = 15,
MICROBIT_ID_IO_P9 = 16,
MICROBIT_ID_IO_P10 = 17,
MICROBIT_ID_IO_P11 = 18,
MICROBIT_ID_IO_P12 = 19,
MICROBIT_ID_IO_P13 = 20,
MICROBIT_ID_IO_P14 = 21,
MICROBIT_ID_IO_P15 = 22,
MICROBIT_ID_IO_P16 = 23,
MICROBIT_ID_IO_P19 = 24,
MICROBIT_ID_IO_P20 = 25,
MICROBIT_ID_BUTTON_AB = 26,
MICROBIT_ID_GESTURE = 27,
MICROBIT_ID_THERMOMETER = 28,
MICROBIT_ID_RADIO = 29,
MICROBIT_ID_RADIO_DATA_READY = 30,
MICROBIT_ID_MULTIBUTTON_ATTACH = 31,
MICROBIT_ID_MESSAGE_BUS_LISTENER = 1021,
MICROBIT_ID_NOTIFY_ONE = 1022,
MICROBIT_ID_NOTIFY = 1023,
// MicroBitCoordinateSystem.h
RAW = 0,
SIMPLE_CARTESIAN = 1,
NORTH_EAST_DOWN = 2,
// MicroBitDFUService.h
MICROBIT_DFU_OPCODE_START_DFU = 1,
MICROBIT_DFU_OPCODE_START_PAIR = 2,
MICROBIT_DFU_HISTOGRAM_WIDTH = 5,
MICROBIT_DFU_HISTOGRAM_HEIGHT = 5,
// MicroBitDisplay.h
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitCompassCalibrator.h
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitDisplay.h
MICROBIT_DISPLAY_EVT_ANIMATION_COMPLETE = 1,
MICROBIT_DISPLAY_EVT_FREE = 2,
MICROBIT_DISPLAY_EVT_LIGHT_SENSE = 4,
MICROBIT_DISPLAY_WIDTH = 5,
MICROBIT_DISPLAY_HEIGHT = 5,
MICROBIT_DISPLAY_EVT_LIGHT_SENSE = 2,
MICROBIT_DISPLAY_SPACING = 1,
MICROBIT_DISPLAY_ERROR_CHARS = 4,
MICROBIT_DISPLAY_GREYSCALE_BIT_DEPTH = 8,
MICROBIT_DISPLAY_ANIMATE_DEFAULT_POS = -255,
MICROBIT_DISPLAY_ROW_RESET = 0x20,
ANIMATION_MODE_NONE = 0,
ANIMATION_MODE_STOPPED = 1,
ANIMATION_MODE_SCROLL_TEXT = 2,
@ -277,57 +311,21 @@ declare const enum DAL {
MICROBIT_DISPLAY_ROTATION_90 = 1,
MICROBIT_DISPLAY_ROTATION_180 = 2,
MICROBIT_DISPLAY_ROTATION_270 = 3,
// MicroBitEvent.h
CREATE_ONLY = 0,
CREATE_AND_QUEUE = 1,
CREATE_AND_FIRE = 2,
// MicroBitEventService.h
// MicroBitFiber.h
MICROBIT_FLAG_DATA_READY = 0x01,
MICROBIT_FIBER_FLAG_FOB = 0x01,
MICROBIT_FIBER_FLAG_PARENT = 0x02,
MICROBIT_FIBER_FLAG_CHILD = 0x04,
MICROBIT_FIBER_FLAG_DO_NOT_PAGE = 0x08,
// MicroBitFont.h
MICROBIT_FONT_WIDTH = 5,
MICROBIT_FONT_HEIGHT = 5,
MICROBIT_FONT_ASCII_START = 32,
MICROBIT_FONT_ASCII_END = 126,
// MicroBitHeapAllocator.h
MICROBIT_HEAP_COUNT = 2,
MICROBIT_HEAP_BLOCK_FREE = 0x80000000,
// MicroBitI2C.h
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitI2C.h
MICROBIT_I2C_MAX_RETRIES = 9,
// MicroBitIO.h
// MicroBitIOPinService.h
MICROBIT_IO_PIN_SERVICE_PINCOUNT = 20,
MICROBIT_IO_PIN_SERVICE_DATA_SIZE = 10,
// MicroBitImage.h
// MicroBitLEDService.h
// MicroBitLightSensor.h
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitIO.h
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitLightSensor.h
MICROBIT_LIGHT_SENSOR_CHAN_NUM = 3,
MICROBIT_LIGHT_SENSOR_AN_SET_TIME = 4000,
MICROBIT_LIGHT_SENSOR_TICK_PERIOD = 5,
MICROBIT_LIGHT_SENSOR_MAX_VALUE = 338,
MICROBIT_LIGHT_SENSOR_MIN_VALUE = 75,
// MicroBitListener.h
MESSAGE_BUS_LISTENER_PARAMETERISED = 0x0001,
MESSAGE_BUS_LISTENER_METHOD = 0x0002,
MESSAGE_BUS_LISTENER_BUSY = 0x0004,
MESSAGE_BUS_LISTENER_REENTRANT = 0x0008,
MESSAGE_BUS_LISTENER_QUEUE_IF_BUSY = 0x0010,
MESSAGE_BUS_LISTENER_DROP_IF_BUSY = 0x0020,
MESSAGE_BUS_LISTENER_NONBLOCKING = 0x0040,
MESSAGE_BUS_LISTENER_URGENT = 0x0080,
MESSAGE_BUS_LISTENER_DELETING = 0x8000,
// MicroBitMagnetometerService.h
// MicroBitMatrixMaps.h
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitMatrixMaps.h
NO_CONN = 0,
// MicroBitMessageBus.h
MICROBIT_CONTROL_BUS_ID = 0,
MICROBIT_ID_ANY = 0,
MICROBIT_EVT_ANY = 0,
// MicroBitMultiButton.h
MICROBIT_DISPLAY_WIDTH = 5,
MICROBIT_DISPLAY_HEIGHT = 5,
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitMessageBus.h
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitMultiButton.h
MICROBIT_MULTI_BUTTON_STATE_1 = 0x01,
MICROBIT_MULTI_BUTTON_STATE_2 = 0x02,
MICROBIT_MULTI_BUTTON_HOLD_TRIGGERED_1 = 0x04,
@ -335,8 +333,7 @@ declare const enum DAL {
MICROBIT_MULTI_BUTTON_SUPRESSED_1 = 0X10,
MICROBIT_MULTI_BUTTON_SUPRESSED_2 = 0x20,
MICROBIT_MULTI_BUTTON_ATTACHED = 0x40,
// MicroBitPanic.h
// MicroBitPin.h
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitPin.h
IO_STATUS_DIGITAL_IN = 0x01,
IO_STATUS_DIGITAL_OUT = 0x02,
IO_STATUS_ANALOG_IN = 0x04,
@ -350,7 +347,7 @@ declare const enum DAL {
PIN_CAPABILITY_DIGITAL = 0x01,
PIN_CAPABILITY_ANALOG = 0x02,
PIN_CAPABILITY_TOUCH = 0x04,
// MicroBitRadio.h
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitRadio.h
MICROBIT_RADIO_STATUS_INITIALISED = 0x0001,
MICROBIT_RADIO_BASE_ADDRESS = 0x75626974,
MICROBIT_RADIO_DEFAULT_GROUP = 0,
@ -362,17 +359,44 @@ declare const enum DAL {
MICROBIT_RADIO_PROTOCOL_DATAGRAM = 1,
MICROBIT_RADIO_PROTOCOL_EVENTBUS = 2,
MICROBIT_RADIO_EVT_DATAGRAM = 1,
// MicroBitRadioDatagram.h
// MicroBitRadioEvent.h
// MicroBitSerial.h
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitRadioDatagram.h
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitRadioEvent.h
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitSerial.h
MICROBIT_SERIAL_DEFAULT_BAUD_RATE = 115200,
MICROBIT_SERIAL_BUFFER_SIZE = 20,
// MicroBitStorage.h
MICROBIT_STORAGE_CONFIG_MAGIC = 0xCAFECAFE,
// MicroBitTemperatureService.h
// MicroBitThermometer.h
MICROBIT_SERIAL_DEFAULT_BUFFER_SIZE = 20,
MICROBIT_SERIAL_EVT_DELIM_MATCH = 1,
MICROBIT_SERIAL_EVT_HEAD_MATCH = 2,
MICROBIT_SERIAL_EVT_RX_FULL = 3,
MICROBIT_SERIAL_RX_IN_USE = 1,
MICROBIT_SERIAL_TX_IN_USE = 2,
MICROBIT_SERIAL_RX_BUFF_INIT = 4,
MICROBIT_SERIAL_TX_BUFF_INIT = 8,
ASYNC = 0,
SYNC_SPINWAIT = 1,
SYNC_SLEEP = 2,
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitStorage.h
MICROBIT_STORAGE_MAGIC = 0xCAFE,
MICROBIT_STORAGE_BLOCK_SIZE = 48,
MICROBIT_STORAGE_KEY_SIZE = 16,
MICROBIT_STORAGE_STORE_PAGE_OFFSET = 17,
MICROBIT_STORAGE_SCRATCH_PAGE_OFFSET = 19,
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitThermometer.h
MICROBIT_THERMOMETER_PERIOD = 1000,
MICROBIT_THERMOMETER_EVT_UPDATE = 1,
// PacketBuffer.h
// RefCounted.h
MICROBIT_THERMOMETER_ADDED_TO_IDLE = 2,
// built/yt/yotta_modules/microbit-dal/inc//types/ManagedString.h
// built/yt/yotta_modules/microbit-dal/inc//types/ManagedType.h
// built/yt/yotta_modules/microbit-dal/inc//types/Matrix4.h
// built/yt/yotta_modules/microbit-dal/inc//types/MicroBitCoordinateSystem.h
RAW = 0,
SIMPLE_CARTESIAN = 1,
NORTH_EAST_DOWN = 2,
// built/yt/yotta_modules/microbit-dal/inc//types/MicroBitEvent.h
MICROBIT_ID_ANY = 0,
MICROBIT_EVT_ANY = 0,
CREATE_ONLY = 0,
CREATE_AND_FIRE = 1,
// built/yt/yotta_modules/microbit-dal/inc//types/MicroBitImage.h
// built/yt/yotta_modules/microbit-dal/inc//types/PacketBuffer.h
// built/yt/yotta_modules/microbit-dal/inc//types/RefCounted.h
}

View File

@ -119,14 +119,10 @@ declare namespace input {
* MicroBitEvent is initialised, and no further processing takes place.
*/
CreateOnly = 0, // CREATE_ONLY
/**
* MicroBitEvent is initialised, and queued on the MicroBitMessageBus.
*/
CreateAndQueue = 1, // CREATE_AND_QUEUE
/**
* MicroBitEvent is initialised, and its event handlers are immediately fired (not suitable for use in interrupts!).
*/
CreateAndFire = 2, // CREATE_AND_FIRE
CreateAndFire = 1, // CREATE_AND_FIRE
}

View File

@ -105,9 +105,7 @@ namespace input {
* @param body TODO
*/
//% help=input/on-button-pressed weight=85
//% blockId=device_button_event
//% block="on button|%NAME|pressed"
//% icon="\uf192"
//% blockId=device_button_event block="on button|%NAME|pressed" icon="\uf192"
void onButtonPressed(Button button, Action body) {
registerWithDal((int)button, MICROBIT_BUTTON_EVT_CLICK, body);
}

View File

@ -9,7 +9,7 @@ namespace serial {
*/
//%
StringData* readString() {
return uBit.serial.readString().leakData();
return uBit.serial.readUntil(ManagedString("\r\n")).leakData();
}
/**
@ -17,6 +17,6 @@ namespace serial {
*/
//%
void writeString(StringData *text) {
uBit.serial.sendString(ManagedString(text));
uBit.serial.send(ManagedString(text));
}
}

View File

@ -201,9 +201,7 @@ declare namespace input {
* @param body TODO
*/
//% help=input/on-button-pressed weight=85
//% blockId=device_button_event
//% block="on button|%NAME|pressed"
//% icon="\uf192" shim=input::onButtonPressed
//% blockId=device_button_event block="on button|%NAME|pressed" icon="\uf192" shim=input::onButtonPressed
function onButtonPressed(button: Button, body: () => void): void;
/**
@ -332,7 +330,7 @@ declare namespace control {
* Raises an event in the event bus.
* @param src ID of the MicroBit Component that generated the event e.g. MICROBIT_ID_BUTTON_A.
* @param value Component specific code indicating the cause of the event.
* @param mode optional definition of how the event should be processed after construction (default is CREATE_AND_QUEUE).
* @param mode optional definition of how the event should be processed after construction (default is CREATE_AND_FIRE).
*/
//% weight=21 blockGap=12 blockId="control_raise_event" block="raise event|from source %src=control_event_source|with value %value=control_event_value" blockExternalInputs=1
//% mode.defl=1 shim=control::raiseEvent

View File

@ -18,5 +18,5 @@
"dependencies": {
"microbit": "file:../microbit"
},
"installedVersion": "zbhlje"
"installedVersion": "fgluxh"
}

View File

@ -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

Some files were not shown because too many files have changed in this diff Show More