Compare commits
28 Commits
Author | SHA1 | Date | |
---|---|---|---|
c9d4807f25 | |||
5f4ff08c09 | |||
b99be68ea5 | |||
c639cc3f83 | |||
cd56181703 | |||
5b1a807443 | |||
e604b27c4f | |||
4727b105c4 | |||
4063b5aac8 | |||
ee8505b4f1 | |||
ab4e2c458a | |||
126c236b14 | |||
532abadb6b | |||
eea179e07c | |||
f94015803f | |||
f085253306 | |||
6de2f22542 | |||
3051e09bcf | |||
bd835a8a6e | |||
f75a034a3f | |||
71b3b6bb22 | |||
b868bd1e09 | |||
02e48f196c | |||
742eb7ea2f | |||
f1904143b6 | |||
e621252f3b | |||
3633d39f57 | |||
21bbf8fc86 |
@ -24,24 +24,23 @@ npm install
|
||||
|
||||
### Running
|
||||
|
||||
Run this command to open a local web server:
|
||||
Run this command to open a local web server (add ``sudo`` for Mac/Linux shells)
|
||||
```
|
||||
pxt serve
|
||||
```
|
||||
If the local server opens in the wrong browser, make sure to copy the URL containing the local token.
|
||||
Otherwise, the editor will not be able to load the projects.
|
||||
|
||||
If you need modify the `.cpp` files, turn on yotta compilation with the ``-yt`` flag:
|
||||
If you need modify the `.cpp` files, turn on yotta compilation with the ``-yt`` flag (add ``sudo`` for Mac/Linux shells):
|
||||
```
|
||||
pxt serve -yt
|
||||
```
|
||||
|
||||
To make sure you're running the latest tools, run
|
||||
To make sure you're running the latest tools, run (add ``sudo`` for Mac/Linux shells)
|
||||
```
|
||||
npm update
|
||||
pxt update
|
||||
```
|
||||
|
||||
|
||||
More instructions at https://github.com/Microsoft/pxt#running-a-target-from-localhost
|
||||
|
||||
## Universal Windows App
|
||||
|
@ -34,7 +34,7 @@ Just like Arduino, the micro:bit can be connected to and interact with sensors,
|
||||
The student can program the BBC micro:bit using [visual blocks](http://www.github.com/Google/blockly) or JavaScript.
|
||||
|
||||
```blocks
|
||||
basic.showString("BBC micro:bit!");
|
||||
basic.showString("Hi!");
|
||||
```
|
||||
|
||||
## Compile and Flash
|
||||
@ -54,5 +54,10 @@ The simulator has support for the LED screen, buttons, as well as compass, accel
|
||||
|
||||
The [C++ BBC micro:bit runtime](http://lancaster-university.github.io/microbit-docs/), created at [Lancaster University](http://www.lancaster.ac.uk/), provides access to the hardware functions of the micro:bit,
|
||||
as well as a set of helper functions (such as displaying a number/image/string on the LED screen).
|
||||
|
||||
The JavaScript micro:bit library mirrors the functions of the C++ library.
|
||||
When code is compiled to ARM machine code, the calls to JavaScript micro:bit functions are replaced with calls to the corresponding C++ functions.
|
||||
|
||||
## Open Source
|
||||
|
||||
The editor for the BBC micro:bit is [open source](/open-source) on GitHub. Contributors are welcome!
|
||||
|
@ -1,7 +1,5 @@
|
||||
# micro:bit - the device
|
||||
|
||||
The micro:bit device
|
||||
|
||||
The micro:bit is a very capable device with many components:
|
||||
|
||||
* [the USB connector](/device/usb)
|
||||
|
@ -1,7 +1,5 @@
|
||||
# The micro:bit - a reactive system
|
||||
|
||||
The micro:bit is a reactive system.
|
||||
|
||||
### Computing systems
|
||||
|
||||
What sort of a *computing system* is the micro:bit?
|
||||
|
@ -11,16 +11,35 @@ input.onButtonPressed(Button.A, () => {
|
||||
})
|
||||
```
|
||||
|
||||
Data is also automatically streamed to serial by the ** bar graph** block
|
||||
and picked up by the editor. This data can be streamed to the cloud as well.
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
led.plotBarGraph(input.acceleration(Dimension.X), 0);
|
||||
});
|
||||
```
|
||||
|
||||
## How to read the micro:bit's serial output from your computer
|
||||
|
||||
Unfortunately, using the serial library requires quite a bit of a setup.
|
||||
|
||||
### BBC micro:bit Chrome Extension
|
||||
|
||||
If you are using the Google Chrome browser, you can use our extension to get serial data streaming in the editor.
|
||||
|
||||
* Install the [Extension for BBC micro:bit](https://chrome.google.com/webstore/detail/extension-for-bbc-microbi/cihhkhnngbjlhahcfmhekmbnnjcjdbge?hl=en-US) on the Chrome Web Store.
|
||||
* Restart Chrome and open the web editor.
|
||||
|
||||
### Windows
|
||||
|
||||
You must install a device driver (for the computer to recognize the serial interface of the micro:bit); then, you must also install a terminal emulator (which is going to connect to the micro:bit and read its output). Here's how to do it:
|
||||
|
||||
* Follow instructions at https://developer.mbed.org/handbook/Windows-serial-configuration in order to install the device driver
|
||||
* Install a terminal emulator; we recommend [Tera Term](https://ttssh2.osdn.jp/index.html.en). At the time of this writing, the latest version is 4.88 and can be downloaded [from here](http://en.osdn.jp/frs/redir.php?m=jaist&f=%2Fttssh2%2F63767%2Fteraterm-4.88.exe). Follow the instructions from the installer.
|
||||
|
||||
#### Windows > Tera Term
|
||||
|
||||
* Install the terminal emulator [Tera Term](https://ttssh2.osdn.jp/index.html.en). At the time of this writing, the latest version is 4.88 and can be downloaded [from here](http://en.osdn.jp/frs/redir.php?m=jaist&f=%2Fttssh2%2F63767%2Fteraterm-4.88.exe). Follow the instructions from the installer.
|
||||
|
||||
Once both the driver and the terminal emulator are installed, plug in the micro:bit and wait until the device is fully setup. Then, open TeraTerm.
|
||||
|
||||
@ -32,7 +51,7 @@ You should be good. Feel free to hit `Setup` > `Save Setup` in the menus to eras
|
||||
|
||||
Please note that Windows will assign you a different COM port if you plug in another micro:bit. If you're juggling between micro:bits, you'll have to change the COM port every time.
|
||||
|
||||
### Alternative Windows setup with Putty
|
||||
#### Windows > Putty
|
||||
|
||||
If you prefer another terminal emulator (such as [PuTTY](http://www.putty.org/)), here are some instructions.
|
||||
|
||||
|
@ -195,7 +195,7 @@ metal stripe at the bottom of the micro:bit board.) For example, hold
|
||||
the ``GND`` button with one hand and touch the ``0`` pin (called
|
||||
``P0``) with your other hand to tell the micro:bit you're pressing it.
|
||||
|
||||
Unscramble the blocks in the editor to show a heart when you press
|
||||
Unscramble the blocks in the editor to show a heart when you touch
|
||||
pin ``P0``.
|
||||
|
||||
```shuffle
|
||||
@ -212,19 +212,96 @@ Click **Compile** to move your program to the BBC micro:bit!
|
||||
|
||||
## ~hint
|
||||
|
||||
Try this experiment: find a friend and hold hands together. Press the ``GND`` button
|
||||
while your friend pressed the ``P0`` button. You should see the heart! The electric current is going through your bodies and accross your handshake
|
||||
to make it happen!
|
||||
Try this experiment: find a friend and hold hands. Touch the ``GND``
|
||||
pin while your friend presses the ``P0`` pin. You should see the
|
||||
heart! The electric current is going through your bodies and across
|
||||
your handshake to make it happen!
|
||||
|
||||
## ~
|
||||
|
||||
## The amazing coin flipper
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
Are you trying to choose whether to play soccer or go to the movies
|
||||
instead, or which toppings to have on your pizza? Build a coin
|
||||
flipping machine with the BBC micro:bit to choose for you!
|
||||
|
||||
### ~
|
||||
|
||||
Here are the blocks to make your coin flipper. When you press button
|
||||
`B`, the coin flipper will show either `H` for heads or `T` for tails
|
||||
on the LED screen.
|
||||
|
||||
```blocks
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
if (Math.randomBoolean()) {
|
||||
basic.showString("H");
|
||||
} else {
|
||||
basic.showString("T");
|
||||
}
|
||||
});
|
||||
```
|
||||
### ~hint
|
||||
|
||||
The ``pick random true or false`` block randomly tells the ``if``
|
||||
block `true` or `false`. If the ``pick`` block picked `true`, the
|
||||
``if`` block shows the letter `H`. Otherwise, it shows the letter `T`.
|
||||
|
||||
That's it!
|
||||
|
||||
### ~
|
||||
|
||||
### Keeping score
|
||||
|
||||
#### ~avatar
|
||||
|
||||
To keep track out of how many guesses you've won,
|
||||
add these blocks to your coin flipper:
|
||||
|
||||
#### ~
|
||||
|
||||
```blocks
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
game.addScore(1);
|
||||
});
|
||||
input.onButtonPressed(Button.AB, () => {
|
||||
basic.showNumber(game.score());
|
||||
});
|
||||
```
|
||||
|
||||
These blocks mean that if you press button `A`, you will add `1` to
|
||||
your score, and if you press `A` and `B` together, the micro:bit will
|
||||
show your score.
|
||||
|
||||
When you're done, your coin flipping program should look like this:
|
||||
|
||||
```blocks
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
if (Math.randomBoolean()) {
|
||||
basic.showString("H");
|
||||
} else {
|
||||
basic.showString("T");
|
||||
}
|
||||
});
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
game.addScore(1);
|
||||
});
|
||||
input.onButtonPressed(Button.AB, () => {
|
||||
basic.showNumber(game.score());
|
||||
});
|
||||
```
|
||||
|
||||
Flip until your thumbs get tired!
|
||||
|
||||
## Let's play Rock Paper Scissors!
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
Build a Rock Paper Scissors game with the BBC micro:bit!
|
||||
You can play the game with a friend who has it on a micro:bit.
|
||||
You can also play it with friends who are just using their hands.
|
||||
Build a Rock Paper Scissors game with the BBC micro:bit! You can play
|
||||
the game with a friend who has it on a micro:bit. You can also play
|
||||
it with friends who are just using their hands. (The game is built
|
||||
like a coin flipper, but with three choices instead of two.)
|
||||
|
||||
### ~
|
||||
|
||||
|
@ -4,6 +4,6 @@ The editor is open source on GitHub under the MIT license. Contributions are wel
|
||||
|
||||
### Repos
|
||||
|
||||
* [microsoft/pxt-microbit](https://github.com/Microsoft/pxt-microbit), PXT target for BBC micro:bit, also includes the documentation.
|
||||
* [microbit/pxt](https://github.com/Microsoft/pxt), programming experience toolkit (PXT)
|
||||
* [microsoft/pxt-microbit](https://github.com/Microsoft/pxt-microbit), PXT target for BBC micro:bit
|
||||
* [microsoft/pxt-microbit-core](https://github.com/Microsoft/pxt-microbit-core), Yotta module used to build the BBC micro:bit runtime
|
||||
|
@ -1,27 +1,35 @@
|
||||
# Magnetic Force
|
||||
|
||||
Get the magnetic force (micro Teslas), in one of three specified dimensions.
|
||||
Find the amount of magnetic force (the strength of a magnet) in the direction you say.
|
||||
|
||||
```sig
|
||||
input.magneticForce(Dimension.X);
|
||||
```
|
||||
|
||||
## ~hint
|
||||
|
||||
The micro:bit measures magnetic force with **microteslas**.
|
||||
|
||||
## ~
|
||||
|
||||
|
||||
### Parameters
|
||||
|
||||
* dimension : [String](/reference/types/string) - one of three values specifying the axis of the force: ``x`` (left/right); ``y`` (forward/backwards); ``z`` (up/down); ``strength`` (the length of the vector)
|
||||
* a [string](/reference/types/string) that says which direction the micro:bit should measure magnetic force in: either `x` (the left-right direction), `y` (the forward/backward direction), or `z` (the up/down direction)
|
||||
|
||||
### Returns
|
||||
|
||||
* [Number](/reference/types/number) - magnetic force, in micro-Teslas.
|
||||
* a [number](/reference/types/number) of microteslas that means the strength of the magnet
|
||||
|
||||
### Example: metal detector
|
||||
|
||||
The following example uses the `magnetic force` to control the brightness of the screen. When the magnetic force increases, the center LED will appear brighter.
|
||||
This program makes the center LED of the micro:bit get brighter when
|
||||
the magnetic force is stronger, and dimmer when it is weaker.
|
||||
|
||||
```blocks
|
||||
led.plot(2, 2)
|
||||
basic.forever(() => {
|
||||
let f = input.magneticForce(Dimension.X)
|
||||
let f = input.magneticForce("x")
|
||||
led.setBrightness(f / 2000)
|
||||
})
|
||||
```
|
||||
@ -29,4 +37,3 @@ basic.forever(() => {
|
||||
### See also
|
||||
|
||||
[compass heading](/reference/input/compass-heading)
|
||||
|
||||
|
@ -1,19 +1,17 @@
|
||||
# On Gesture
|
||||
|
||||
Register an [event handler](/reference/event-handler) that will execute whenever the user executes a gesture withthe BBC micro:bit.
|
||||
Start an [event handler](/reference/event-handler) (part of the
|
||||
program that will run when something happens) This handler works when
|
||||
you do a **gesture** (like shake, tilt, or drop the micro:bit).
|
||||
|
||||
```sig
|
||||
input.onGesture(Gesture.Shake,() => {
|
||||
})
|
||||
```
|
||||
|
||||
## Gestures
|
||||
## Example: random number
|
||||
|
||||
|
||||
|
||||
### Example: random number
|
||||
|
||||
The following example displays a number from 0-9 on the screen when you shake the BBC micro:bit.
|
||||
This program shows a number from `0` to `9` when you shake the micro:bit.
|
||||
|
||||
```blocks
|
||||
input.onGesture(Gesture.Shake,() => {
|
||||
@ -22,24 +20,7 @@ input.onGesture(Gesture.Shake,() => {
|
||||
})
|
||||
```
|
||||
|
||||
### Example: rock, paper, scissors
|
||||
## Lessons
|
||||
|
||||
The following example shows one of three images (rock, paper, or scissors) when you shake the BBC micro:bit.
|
||||
|
||||
```blocks
|
||||
input.onGesture(Gesture.Shake,() => {
|
||||
let img = images.createImage(`
|
||||
. . . . . # # # # # . . . . #
|
||||
. # # # . # . . . # # # . # .
|
||||
. # # # . # . . . # . # # . .
|
||||
. # # # . # . . . # # # . # .
|
||||
. . . . . # # # # # . . . . #
|
||||
`)
|
||||
img.showFrame(Math.random(3))
|
||||
})
|
||||
```
|
||||
|
||||
### Lessons
|
||||
|
||||
[bounce image](/lessons/bounce-image), [rock paper scissors](/lessons/rock-paper-scissors)
|
||||
[bounce image](/lessons/bounce-image)
|
||||
|
||||
|
@ -1,24 +1,33 @@
|
||||
# Pin Is Pressed
|
||||
|
||||
Gets the pin state (pressed or not pressed), by detecting when the user holds the `GND` pin with one hand, and presses pin `0`, `1`, or `2` with the other hand, thus completing a circuit.
|
||||
Find whether the pin you say is pressed or not pressed.
|
||||
|
||||
*Note* that this function works best when the BBC micro:bit is powered by AAA battery.
|
||||
If you hold the `GND` pin with one hand and touch pin `0`, `1`, or `2` with the other,
|
||||
a very small (safe) amount of electricity will flow through your body and back into
|
||||
the micro:bit. This is called **completing a circuit**. It's like you're a big wire!
|
||||
|
||||
```sig
|
||||
input.pinIsPressed(TouchPin.P0);
|
||||
```
|
||||
|
||||
## ~hint
|
||||
|
||||
This function works best when the BBC:microbit is using batteries for power,
|
||||
instead of the USB cable.
|
||||
|
||||
## ~
|
||||
|
||||
### Parameters
|
||||
|
||||
* name - [String](/reference/types/string); the pin name ("P0", "P1", or "P2")
|
||||
* a [string](/reference/types/string) that holds the pin name (**P0**, **P1**, or **P2**)
|
||||
|
||||
### returns
|
||||
|
||||
* [Boolean](/reference/types/boolean) - `true` if pressed, `false` if not pressed
|
||||
* a [boolean](/reference/types/boolean) that means whether the pin you say is pressed (`true` or `false`)
|
||||
|
||||
### Example
|
||||
|
||||
This example displays 1 if P0 is pressed, and 0 if P0 is not pressed:
|
||||
This program shows `1` if `P0` is pressed, and `0` if `P0` is not pressed:
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
|
@ -1,10 +1,11 @@
|
||||
# Change Tempo By
|
||||
|
||||
Change the tempo by the specified amount
|
||||
Makes the [tempo](/reference/music/tempo) (speed of a piece of music)
|
||||
faster or slower by the amount you say.
|
||||
|
||||
## Simulator
|
||||
|
||||
Simulation of this function is available in many, but not all browsers.
|
||||
This function only works on the micro:bit and in some browsers.
|
||||
|
||||
```sig
|
||||
music.changeTempoBy(20)
|
||||
@ -12,7 +13,21 @@ music.changeTempoBy(20)
|
||||
|
||||
### Parameters
|
||||
|
||||
* `bpm` : [Number](/reference/types/number) - change the tempo by beats per minute
|
||||
* a [number](/reference/types/number) that says how much to change the bpm (beats per minute, or number of beats in a minute of the music that the micro:bit is playing).
|
||||
|
||||
### Examples
|
||||
|
||||
This program makes the music faster by 12 bpm.
|
||||
|
||||
```blocks
|
||||
music.changeTempoBy(12)
|
||||
```
|
||||
|
||||
This program makes the music _slower_ by 12 bpm.
|
||||
|
||||
```blocks
|
||||
music.changeTempoBy(-12)
|
||||
```
|
||||
|
||||
### See also
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
# Rest
|
||||
|
||||
Rests (plays nothing) for a specified time through pin PO.
|
||||
Rest (play no sound) through pin `PO` for the amount of time you say.
|
||||
|
||||
## Simulator
|
||||
|
||||
Simulation of this function is available in many, but not all browsers.
|
||||
This function only works on the micro:bit and in some browsers.
|
||||
|
||||
```sig
|
||||
music.rest(400)
|
||||
@ -12,7 +12,7 @@ music.rest(400)
|
||||
|
||||
### Parameters
|
||||
|
||||
* `ms`: [Number](/reference/types/number) - the duration of the rest (milliseconds)
|
||||
* a [number](/reference/types/number) saying how many milliseconds the micro:bit should rest. One second is 1000 milliseconds.
|
||||
|
||||
## Example
|
||||
|
||||
|
@ -1,14 +1,17 @@
|
||||
# Set Tempo
|
||||
|
||||
Sets the tempo to the specified amount
|
||||
Makes the tempo (speed of a piece of music) as fast or slow as you say.
|
||||
|
||||
```sig
|
||||
music.setTempo(60)
|
||||
```
|
||||
## Simulator
|
||||
|
||||
This function only works on the micro:bit and in some browsers.
|
||||
|
||||
### Parameters
|
||||
|
||||
* Returns : [Number](/reference/types/number) - sets the tempo in beats per minute
|
||||
* a [number](/reference/types/number) that means the bpm you want (beats per minute, or number of beats in a minute of the music that the micro:bit is playing).
|
||||
|
||||
### See also
|
||||
|
||||
|
36
docs/reference/radio/received-signal-strength.md
Normal file
36
docs/reference/radio/received-signal-strength.md
Normal file
@ -0,0 +1,36 @@
|
||||
# Received Signal Strength
|
||||
|
||||
Find how strong the ``radio`` signal is, from `255` to `0`.
|
||||
(`255` means a weak signal and `0` means a strong one.)
|
||||
|
||||
The micro:bit finds the signal strength by checking how strong it was
|
||||
the last time it ran the
|
||||
[receive number](/reference/radio/receive-number) function. That means
|
||||
it needs to run **receive number** first.
|
||||
|
||||
### Returns
|
||||
|
||||
* a [number](/reference/types/number) between `255` and `0` that means
|
||||
how strong the signal is.
|
||||
|
||||
## Simulator
|
||||
|
||||
This function only works on the micro:bit, not in browsers.
|
||||
|
||||
### Example
|
||||
|
||||
This example shows how strong the radio signal of the
|
||||
[light level sender example](/reference/input/send-number) is.
|
||||
|
||||
```blocks
|
||||
let x = 0;
|
||||
radio.setGroup(99);
|
||||
basic.forever(() => {
|
||||
x = radio.receiveNumber();
|
||||
basic.showNumber(radio.receivedSignalStrength());
|
||||
});
|
||||
```
|
||||
|
||||
### See also
|
||||
|
||||
[receive number](/reference/radio/receive-number), [send number](/reference/radio/send-number), [on data received](/reference/radio/on-data-received)
|
@ -129,7 +129,7 @@ namespace devices {
|
||||
|
||||
/**
|
||||
* Sends a ``camera`` command to the parent device.
|
||||
* @param event TODO
|
||||
* @param event event description
|
||||
*/
|
||||
//% weight=30 help=devices/tell-camera-to
|
||||
//% blockId=devices_camera icon="\uf030" block="tell camera to|%property" blockGap=8
|
||||
@ -139,7 +139,7 @@ namespace devices {
|
||||
|
||||
/**
|
||||
* Sends a ``remote control`` command to the parent device.
|
||||
* @param event TODO
|
||||
* @param event event description
|
||||
*/
|
||||
//% weight=29 help=devices/tell-remote-control-to
|
||||
//% blockId=devices_remote_control block="tell remote control to|%property" blockGap=14 icon="\uf144"
|
||||
@ -149,7 +149,7 @@ namespace devices {
|
||||
|
||||
/**
|
||||
* Sends an ``alert`` command to the parent device.
|
||||
* @param event TODO
|
||||
* @param event event description
|
||||
*/
|
||||
//% weight=27 help=devices/raise-alert-to
|
||||
//% blockId=devices_alert block="raise alert to|%property" icon="\uf0f3"
|
||||
@ -159,19 +159,19 @@ namespace devices {
|
||||
|
||||
/**
|
||||
* Registers code to run when the device notifies about a particular event.
|
||||
* @param event TODO
|
||||
* @param body TODO
|
||||
* @param event event description
|
||||
* @param body code handler when event is triggered
|
||||
*/
|
||||
//% help=devices/on-notified weight=26
|
||||
//% blockId=devices_device_info_event block="on notified" icon="\uf10a"
|
||||
//% blockId=devices_device_info_event block="on notified|%event" icon="\uf10a"
|
||||
void onNotified(MesDeviceInfo event, Action body) {
|
||||
registerWithDal(MES_DEVICE_INFO_ID, (int)event, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register code to run when the micro:bit receives a command from the paired gamepad.
|
||||
* @param name TODO
|
||||
* @param body TODO
|
||||
* @param name button name
|
||||
* @param body code to run when button is pressed
|
||||
*/
|
||||
//% help=devices/on-gamepad-button weight=40
|
||||
//% weight=25
|
||||
@ -188,7 +188,7 @@ namespace devices {
|
||||
static void initSignalStrength() {
|
||||
if (_signalStrength < 0) {
|
||||
_signalStrength = 0;
|
||||
uBit.MessageBus.listen(MES_SIGNAL_STRENGTH_ID, MICROBIT_EVT_ANY, signalStrengthHandler);
|
||||
uBit.messageBus.listen(MES_SIGNAL_STRENGTH_ID, MICROBIT_EVT_ANY, signalStrengthHandler);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,5 +20,5 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"installedVersion": "zakvul"
|
||||
"installedVersion": "ljipgq"
|
||||
}
|
||||
|
16
libs/microbit-devices/shims.d.ts
vendored
16
libs/microbit-devices/shims.d.ts
vendored
@ -7,7 +7,7 @@ declare namespace devices {
|
||||
|
||||
/**
|
||||
* Sends a ``camera`` command to the parent device.
|
||||
* @param event TODO
|
||||
* @param event event description
|
||||
*/
|
||||
//% weight=30 help=devices/tell-camera-to
|
||||
//% blockId=devices_camera icon="\uf030" block="tell camera to|%property" blockGap=8 shim=devices::tellCameraTo
|
||||
@ -15,7 +15,7 @@ declare namespace devices {
|
||||
|
||||
/**
|
||||
* Sends a ``remote control`` command to the parent device.
|
||||
* @param event TODO
|
||||
* @param event event description
|
||||
*/
|
||||
//% weight=29 help=devices/tell-remote-control-to
|
||||
//% blockId=devices_remote_control block="tell remote control to|%property" blockGap=14 icon="\uf144" shim=devices::tellRemoteControlTo
|
||||
@ -23,7 +23,7 @@ declare namespace devices {
|
||||
|
||||
/**
|
||||
* Sends an ``alert`` command to the parent device.
|
||||
* @param event TODO
|
||||
* @param event event description
|
||||
*/
|
||||
//% weight=27 help=devices/raise-alert-to
|
||||
//% blockId=devices_alert block="raise alert to|%property" icon="\uf0f3" shim=devices::raiseAlertTo
|
||||
@ -31,17 +31,17 @@ declare namespace devices {
|
||||
|
||||
/**
|
||||
* Registers code to run when the device notifies about a particular event.
|
||||
* @param event TODO
|
||||
* @param body TODO
|
||||
* @param event event description
|
||||
* @param body code handler when event is triggered
|
||||
*/
|
||||
//% help=devices/on-notified weight=26
|
||||
//% blockId=devices_device_info_event block="on notified" icon="\uf10a" shim=devices::onNotified
|
||||
//% blockId=devices_device_info_event block="on notified|%event" icon="\uf10a" shim=devices::onNotified
|
||||
function onNotified(event: MesDeviceInfo, body: () => void): void;
|
||||
|
||||
/**
|
||||
* Register code to run when the micro:bit receives a command from the paired gamepad.
|
||||
* @param name TODO
|
||||
* @param body TODO
|
||||
* @param name button name
|
||||
* @param body code to run when button is pressed
|
||||
*/
|
||||
//% help=devices/on-gamepad-button weight=40
|
||||
//% weight=25
|
||||
|
@ -9,9 +9,13 @@
|
||||
"testFiles": [
|
||||
"neotest.ts"
|
||||
],
|
||||
"microbit": {
|
||||
"yotta": {
|
||||
"config": {
|
||||
"MICROBIT_BLE_ENABLED": "0"
|
||||
"microbit-dal": {
|
||||
"bluetooth": {
|
||||
"enabled": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"public": true,
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "pxt-microbit",
|
||||
"version": "0.2.152",
|
||||
"version": "0.2.157",
|
||||
"description": "BBC micro:bit target for PXT",
|
||||
"keywords": [
|
||||
"JavaScript",
|
||||
@ -29,6 +29,6 @@
|
||||
"typescript": "^1.8.7"
|
||||
},
|
||||
"dependencies": {
|
||||
"pxt-core": "0.2.163"
|
||||
"pxt-core": "0.2.170"
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,9 @@
|
||||
"corepkg": "microbit",
|
||||
"bundleddirs": [
|
||||
"libs/microbit",
|
||||
"libs/microbit-radio"
|
||||
"libs/microbit-radio",
|
||||
"libs/microbit-devices",
|
||||
"libs/neopixel"
|
||||
],
|
||||
"cloud": {
|
||||
"workspace": false,
|
||||
@ -105,10 +107,6 @@
|
||||
{
|
||||
"name": "Lessons",
|
||||
"path": "/lessons"
|
||||
},
|
||||
{
|
||||
"name": "Device",
|
||||
"path": "/device"
|
||||
}
|
||||
],
|
||||
"sideDoc": "getting-started"
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>microbit simulator</title>
|
||||
<title>BBC micro:bit simulator</title>
|
||||
<style>
|
||||
html {
|
||||
height: 100%;
|
||||
@ -13,11 +13,10 @@ html {
|
||||
|
||||
body {
|
||||
height: 100%;
|
||||
width:100%;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
margin: 0;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
overflow-scrolling: touch;
|
||||
}
|
||||
</style>
|
||||
<script src="/cdn/bluebird.min.js"></script>
|
||||
|
@ -188,7 +188,7 @@ namespace pxsim.micro_bit {
|
||||
if (text) text.textContent = (pin.period ? "~" : "") + (pin.value || 0) + "";
|
||||
}
|
||||
else if (pin.mode & PinFlags.Digital) {
|
||||
v = pin.value > 0 ? '0%' : '100%';
|
||||
v = pin.value > 0 ? "0%" : "100%";
|
||||
if (text) text.textContent = pin.value > 0 ? "1" : "0";
|
||||
}
|
||||
else if (pin.mode & PinFlags.Touch) {
|
||||
@ -382,7 +382,13 @@ svg.sim.grayscale {
|
||||
stroke:grey;
|
||||
stroke-width: 3px;
|
||||
}
|
||||
|
||||
.sim-button-nut {
|
||||
fill:#704A4A;
|
||||
pointer-events:none;
|
||||
}
|
||||
.sim-button-nut:hover {
|
||||
stroke:1px solid #704A4A;
|
||||
}
|
||||
.sim-pin:hover {
|
||||
stroke:#D4AF37;
|
||||
stroke-width:2px;
|
||||
@ -564,17 +570,29 @@ svg.sim.grayscale {
|
||||
return lg;
|
||||
})
|
||||
|
||||
this.pinTexts = [67, 165, 275].map(x => <SVGTextElement>svg.child(this.g, "text", { class: 'sim-text-pin', x: x, y: 345 }));
|
||||
|
||||
this.pinTexts = [67, 165, 275].map(x => <SVGTextElement>svg.child(this.g, "text", { class: "sim-text-pin", x: x, y: 345 }));
|
||||
this.buttonsOuter = []; this.buttons = [];
|
||||
this.buttonsOuter.push(svg.path(this.g, "sim-button-outer", "M82.1,232.6H25.9c-0.5,0-1-0.4-1-1v-56.2c0-0.5,0.4-1,1-1h56.2c0.5,0,1,0.4,1,1v56.2C83,232.2,82.6,232.6,82.1,232.6", "A"));
|
||||
|
||||
const outerBtn = (left: number, top: number) => {
|
||||
const btnr = 4;
|
||||
const btnw = 56.2;
|
||||
const btnn = 6;
|
||||
const btnnm = 10
|
||||
this.buttonsOuter.push(svg.child(this.g, "rect", { class: "sim-button-outer", x: left, y: top, rx: btnr, ry: btnr, width: btnw, height: btnw }));
|
||||
svg.child(this.g, "circle", { class: "sim-button-nut", cx: left + btnnm, cy: top + btnnm, r: btnn });
|
||||
svg.child(this.g, "circle", { class: "sim-button-nut", cx: left + btnnm, cy: top + btnw - btnnm, r: btnn });
|
||||
svg.child(this.g, "circle", { class: "sim-button-nut", cx: left + btnw - btnnm, cy: top + btnw - btnnm, r: btnn });
|
||||
svg.child(this.g, "circle", { class: "sim-button-nut", cx: left + btnw - btnnm, cy: top + btnnm, r: btnn });
|
||||
}
|
||||
|
||||
outerBtn(25.9, 176.4);
|
||||
this.buttons.push(svg.path(this.g, "sim-button", "M69.7,203.5c0,8.7-7,15.7-15.7,15.7s-15.7-7-15.7-15.7c0-8.7,7-15.7,15.7-15.7S69.7,194.9,69.7,203.5"));
|
||||
this.buttonsOuter.push(svg.path(this.g, "sim-button-outer", "M474.3,232.6h-56.2c-0.5,0-1-0.4-1-1v-56.2c0-0.5,0.4-1,1-1h56.2c0.5,0,1,0.4,1,1v56.2C475.3,232.2,474.8,232.6,474.3,232.6", "B"));
|
||||
outerBtn(418.1, 176.4);
|
||||
this.buttons.push(svg.path(this.g, "sim-button", "M461.9,203.5c0,8.7-7,15.7-15.7,15.7c-8.7,0-15.7-7-15.7-15.7c0-8.7,7-15.7,15.7-15.7C454.9,187.8,461.9,194.9,461.9,203.5"));
|
||||
this.buttonsOuter.push(svg.child(this.g, "rect", { class: "sim-button-outer", x: 417, y: 250, width: 58, height: 58, rx: 1, ry: 1, title: "A+B" }));
|
||||
outerBtn(417, 250);
|
||||
this.buttons.push(svg.child(this.g, "circle", { class: "sim-button", cx: 446, cy: 278, r: 16.5 }));
|
||||
(<any>this.buttonsOuter[2]).style.visibility = 'hidden';
|
||||
(<any>this.buttons[2]).style.visibility = 'hidden';
|
||||
(<any>this.buttonsOuter[2]).style.visibility = "hidden";
|
||||
(<any>this.buttons[2]).style.visibility = "hidden";
|
||||
|
||||
svg.path(this.g, "sim-label", "M35.7,376.4c0-2.8,2.1-5.1,5.5-5.1c3.3,0,5.5,2.4,5.5,5.1v4.7c0,2.8-2.2,5.1-5.5,5.1c-3.3,0-5.5-2.4-5.5-5.1V376.4zM43.3,376.4c0-1.3-0.8-2.3-2.2-2.3c-1.3,0-2.1,1.1-2.1,2.3v4.7c0,1.2,0.8,2.3,2.1,2.3c1.3,0,2.2-1.1,2.2-2.3V376.4z");
|
||||
svg.path(this.g, "sim-label", "M136.2,374.1c2.8,0,3.4-0.8,3.4-2.5h2.9v14.3h-3.4v-9.5h-3V374.1z");
|
||||
|
@ -17,6 +17,8 @@
|
||||
<Application Id="App" StartPage="https://m.pxt.io/">
|
||||
<uap:ApplicationContentUriRules>
|
||||
<uap:Rule Match="https://m.pxt.io/" Type="include" WindowsRuntimeAccess="all" />
|
||||
<uap:Rule Match="https://codemicrobit.com/" Type="include" WindowsRuntimeAccess="all" />
|
||||
<uap:Rule Match="https://codethemicrobit.com/" Type="include" WindowsRuntimeAccess="all" />
|
||||
</uap:ApplicationContentUriRules>
|
||||
<uap:VisualElements DisplayName="m.pxt.io" Description="Code editors for the BBC micro:bit" BackgroundColor="white" Square150x150Logo="images\Square150x150Logo.png" Square44x44Logo="images\Square44x44Logo.png">
|
||||
<uap:DefaultTile Wide310x150Logo="images\Wide310x150Logo.png" ShortName="m.pxt.io">
|
||||
|
Reference in New Issue
Block a user