Compare commits
40 Commits
Author | SHA1 | Date | |
---|---|---|---|
d2f6d51c19 | |||
92b60a251d | |||
de9f2d7e67 | |||
4de5e3bd11 | |||
86a33e8f65 | |||
89010b6a8a | |||
48d4668a7a | |||
a2755dc4d2 | |||
52e67c6bfc | |||
5a6f23a7d0 | |||
d1b36f2022 | |||
284579181b | |||
20fcb05538 | |||
e1a2074ef5 | |||
fa3e33dab9 | |||
300a98b858 | |||
5986671bcb | |||
efd5c46143 | |||
62c1a1da35 | |||
ebbc7c983d | |||
173fc4bf7b | |||
47f1eadd27 | |||
8c06277a92 | |||
395f482f11 | |||
bbd21a84d6 | |||
fcf680e9bd | |||
8ac848c812 | |||
dd591af224 | |||
e5a7a81198 | |||
7a5228a5d0 | |||
fe5c8e520a | |||
96d354a8a8 | |||
02480b1c54 | |||
4fd321cccf | |||
4641c9456f | |||
3469ad6f8d | |||
cfc3eae77c | |||
438b745d32 | |||
30211aa006 | |||
efca68672a |
2
clients/electron/.gitignore
vendored
2
clients/electron/.gitignore
vendored
@ -1,2 +0,0 @@
|
||||
node_modules
|
||||
projects
|
@ -1,5 +0,0 @@
|
||||
# PXT micro:bit Electron app
|
||||
|
||||
A very basic wrapper around the web app. To install, copy the contents of this
|
||||
directory to somewhere outside the main `pxt-microbit` repository. Then run `npm
|
||||
install && npm start`.
|
@ -1,15 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>code the micro:bit</title>
|
||||
</head>
|
||||
<body>
|
||||
<webview id="webview" style="position:absolute; left:0; top:0; right:0; bottom:0"/>
|
||||
<script>
|
||||
const webview = document.getElementById("webview")
|
||||
const url = `http://localhost:3232/${window.location.hash}`
|
||||
webview.src = url
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,39 +0,0 @@
|
||||
const {app, BrowserWindow, Menu} = require('electron')
|
||||
const pxt = require('pxt-core')
|
||||
const path = require('path')
|
||||
|
||||
let win
|
||||
|
||||
const cliPath = path.join(process.cwd(), "node_modules/pxt-microbit")
|
||||
|
||||
function startServerAndCreateWindow() {
|
||||
pxt.mainCli(cliPath, ["serve", "-no-browser"])
|
||||
createWindow()
|
||||
}
|
||||
|
||||
function createWindow () {
|
||||
win = new BrowserWindow({
|
||||
width: 800,
|
||||
height: 600,
|
||||
title: "code the micro:bit"
|
||||
})
|
||||
Menu.setApplicationMenu(null)
|
||||
win.loadURL(`file://${__dirname}/index.html#local_token=${pxt.globalConfig.localToken}`)
|
||||
win.on('closed', () => {
|
||||
win = null
|
||||
})
|
||||
}
|
||||
|
||||
app.on('ready', startServerAndCreateWindow)
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit()
|
||||
}
|
||||
})
|
||||
|
||||
app.on('activate', () => {
|
||||
if (win === null) {
|
||||
createWindow()
|
||||
}
|
||||
})
|
@ -1,14 +0,0 @@
|
||||
{
|
||||
"name" : "code-the-microbit",
|
||||
"version" : "1.0.0",
|
||||
"description": "Blocks / Javascript editor",
|
||||
"author": "Microsoft",
|
||||
"main" : "main.js",
|
||||
"scripts": {
|
||||
"start": "node_modules/.bin/electron ."
|
||||
},
|
||||
"devDependencies": {
|
||||
"electron": "*",
|
||||
"pxt-microbit": "*"
|
||||
}
|
||||
}
|
@ -11,4 +11,4 @@ Math.random(5);
|
||||
|
||||
## See Also
|
||||
|
||||
[logic](/blocks/logic), [loops](/blocks/loops), [math](/blocks/math), [variables](/blocks/variables)
|
||||
[logic](/blocks/logic), [loops](/blocks/loops), [math](/blocks/math), [variables](/blocks/variables), [on-start](/blocks/on-start)
|
@ -86,12 +86,14 @@ if (led.point(1,1) && led.point(2,2)) {
|
||||
When you compare two Numbers, you get a Boolean value, such as the comparison `x < 5` in the code below:
|
||||
|
||||
```blocks
|
||||
let x = Math.random(5)
|
||||
if(x < 5) {
|
||||
basic.showString("low");
|
||||
} else {
|
||||
basic.showString("high");
|
||||
}
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
let x = Math.random(5)
|
||||
if(x < 5) {
|
||||
basic.showString("low");
|
||||
} else {
|
||||
basic.showString("high");
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
See the documentation on [Numbers](/reference/types/number) for more information on comparing two Numbers. You can also [compare strings](/reference/types/string-functions) using the `equals` function.
|
||||
|
@ -14,13 +14,15 @@ Click on the dark blue gear icon (see above) to add an *else* or *if* to the cur
|
||||
|
||||
### Example: adjusting screen brightness
|
||||
|
||||
```blocks
|
||||
if(input.lightLevel()<100){
|
||||
led.setBrightness(255);
|
||||
}
|
||||
```
|
||||
If the [light level](/reference/input/light-level) is `< 100`, this code sets the brightness to `255` when the button A is pressed:
|
||||
|
||||
If the [light level](/reference/input/light-level) is `< 100`, this code sets the brightness to `255`:
|
||||
```blocks
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
if(input.lightLevel()<100){
|
||||
led.setBrightness(255);
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### See also
|
||||
|
||||
|
@ -4,14 +4,21 @@
|
||||
|
||||
Run part of the program the number of times you say.
|
||||
|
||||
```block
|
||||
for(let i = 0; i <= 4; ++i) {
|
||||
}
|
||||
```
|
||||
|
||||
### Example: Count to 4
|
||||
|
||||
This program will show the numbers 0, 1, 2, 3, and 4 one after another on the LED screen.
|
||||
|
||||
```blocks
|
||||
for(let i = 0; i < 5; ++i) {
|
||||
basic.showNumber(i)
|
||||
}
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
for(let i = 0; i < 5; ++i) {
|
||||
basic.showNumber(i)
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### See also
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
Repeat code while a [Boolean](/blocks/logic/boolean) `condition` is true.
|
||||
|
||||
```blocks
|
||||
```block
|
||||
while(true) {
|
||||
}
|
||||
```
|
||||
@ -16,11 +16,13 @@ The condition is tested before any code runs. Which means that if the condition
|
||||
The following example uses a while loop to make a diagonal line on the LED screen (points `0, 0`, `1, 1`, `2, 2`, `3, 3`, `4, 4`).
|
||||
|
||||
```blocks
|
||||
let index = 4;
|
||||
while(index >= 0) {
|
||||
led.plot(index, index);
|
||||
index--;
|
||||
}
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
let index = 4;
|
||||
while(index >= 0) {
|
||||
led.plot(index, index);
|
||||
index--;
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### See also
|
||||
|
22
docs/blocks/on-start.md
Normal file
22
docs/blocks/on-start.md
Normal file
@ -0,0 +1,22 @@
|
||||
# On Start
|
||||
|
||||
An event that runs when the program starts.
|
||||
|
||||
The ``on start`` is a special event that runs when the program starts, before any other event.
|
||||
Use this event to initialize your program.
|
||||
|
||||
## Example
|
||||
|
||||
In this example, ``on start`` sets a dimmer brightness on the screen and the button handler shows a string.
|
||||
|
||||
```blocks
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
basic.showString("Hello!")
|
||||
})
|
||||
led.setBrightness(50)
|
||||
```
|
||||
|
||||
|
||||
## What about JavaScript?
|
||||
|
||||
``on-start`` only exists in the block editor. In JavaScript, all code executes sequentially from the first line.
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"appref": "v0.6.13"
|
||||
"appref": "v0.6.36"
|
||||
}
|
||||
|
@ -10,7 +10,9 @@ Let's start by adding a variable where you can store data. Then rename the varia
|
||||
|
||||
|
||||
```blocks
|
||||
let light = input.lightLevel();
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
let light = input.lightLevel();
|
||||
});
|
||||
```
|
||||
|
||||
We want to play music on button pressed in order to register an event handler that will execute whenever when you run a script and click on button pressed on the simulator. We must start by opening the Input drawer and adding `on button pressed` A. Then add a block `rest` to plays nothing for a `1/16` beat. Modify your code so that your code looks like this.
|
||||
|
@ -37,7 +37,7 @@ input.onButtonPressed(Button.B, () => {
|
||||
|
||||
We will use the @boardname@'s compass to detect the magnet. Compass's tell us what direction we are pointing by detecting the Earth's magnetic field but they can also detect any other magnet nearby. We will use that to check if our magnet is next to the @boardname@ by using the [magnetic force](/reference/input/magnetic-force) block found in the input menu's 'more' section. As we only want to measure the strength we change the drop down to select 'strength':
|
||||
|
||||
```blocks
|
||||
```block
|
||||
input.magneticForce(Dimension.Strength)
|
||||
```
|
||||
|
||||
@ -50,16 +50,19 @@ If you have ever played with magnets you know they have two ends, often called a
|
||||
So in the code below we will check if the absolute value of our magnetic field strength reading is more than 100 and save the result of that check in a new variable called 'isSwitched':
|
||||
|
||||
```blocks
|
||||
let isSwitched = Math.abs(input.magneticForce(Dimension.Strength)) > 100
|
||||
let force = Math.abs(input.magneticForce(Dimension.Strength));
|
||||
let isSwitched = force > 100
|
||||
```
|
||||
## Step 4: running our 'magnet nearby' check all the time
|
||||
|
||||
At the moment our code to detect the magnet being nearby will only run once so we need to put it into a [forever](/reference/basic/forever) block so that it keeps getting run again and again checking for the magnet to come near to the @boardname@. We should also make sure 'isSwitched' is false when our program starts.
|
||||
|
||||
```blocks
|
||||
let force = 0;
|
||||
let isSwitched = false;
|
||||
basic.forever(() => {
|
||||
let isSwitched = Math.abs(input.magneticForce(Dimension.Strength)) > 100
|
||||
force = Math.abs(input.magneticForce(Dimension.Strength));
|
||||
isSwitched = force > 100
|
||||
})
|
||||
```
|
||||
|
||||
@ -68,10 +71,11 @@ basic.forever(() => {
|
||||
Now we can check the value of our variable 'isSwitched' whenever we want and we will know that the magnet is nearby if it's value is 'true'. Let's use that to change how the buttons work and complete the code for our trick. We will add an 'if, else' block to each button's code and check if we should swap over what each button displays because 'isSwitched' is equal to true:
|
||||
|
||||
```blocks
|
||||
|
||||
let force = 0;
|
||||
let isSwitched = false;
|
||||
basic.forever(() => {
|
||||
isSwitched = Math.abs(input.magneticForce(Dimension.Strength)) > 100
|
||||
force = Math.abs(input.magneticForce(Dimension.Strength));
|
||||
isSwitched = force > 100
|
||||
})
|
||||
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
|
@ -23,7 +23,7 @@ bluetooth.advertiseUrl("https://pxt.microbit.org/", 7, true);
|
||||
|
||||
### Parameters
|
||||
|
||||
* ``url`` - a [string](/reference/types/string) containing the URL to broadcast, at most 18 characters long
|
||||
* ``url`` - a [string](/reference/types/string) containing the URL to broadcast, at most 17 characters long, excluding the protocol (eg: ``https://``) which gets encoded as 1 byte.
|
||||
* ``power`` - a [number](/reference/types/number) representing the power level between 0 (short) and 7 (maximum range).
|
||||
|
||||
### Example: Broadcast a secret code
|
||||
@ -38,4 +38,4 @@ bluetooth.advertiseUrl("https://pxt.io?secret=42", 7, true);
|
||||
|
||||
```package
|
||||
bluetooth
|
||||
```
|
||||
```
|
||||
|
14
electron/product.json
Normal file
14
electron/product.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"applicationName": "pxt-microbit-oss",
|
||||
"dataFolderName": ".pxt-microbit-oss",
|
||||
"darwinBundleIdentifier": "com.microsoft.pxtmicrobitoss",
|
||||
"nameShort": "PXT Microbit - OSS",
|
||||
"nameLong": "PXT Microbit - OSS",
|
||||
"targetId": "pxt-microbit",
|
||||
"win32AppId": "{{92db071a-6f58-4938-8c97-13c873f4da13}",
|
||||
"win32AppUserModelId": "Microsoft.PXTMicrobitOss",
|
||||
"win32DirName": "Microsoft PXT-Microbit - OSS",
|
||||
"win32MutexName": "pxtmicrobitoss",
|
||||
"win32NameVersion": "Microsoft PXT-Microbit-OSS",
|
||||
"win32RegValueName": "PXTMicrobitOss"
|
||||
}
|
@ -1,62 +1,3 @@
|
||||
<xml xmlns="http://www.w3.org/1999/xhtml">
|
||||
<block type="device_forever">
|
||||
<statement name="HANDLER">
|
||||
<block type="device_show_leds">
|
||||
<field name="LED00">FALSE</field>
|
||||
<field name="LED10">FALSE</field>
|
||||
<field name="LED20">FALSE</field>
|
||||
<field name="LED30">FALSE</field>
|
||||
<field name="LED40">FALSE</field>
|
||||
<field name="LED01">FALSE</field>
|
||||
<field name="LED11">TRUE</field>
|
||||
<field name="LED21">FALSE</field>
|
||||
<field name="LED31">TRUE</field>
|
||||
<field name="LED41">FALSE</field>
|
||||
<field name="LED02">FALSE</field>
|
||||
<field name="LED12">FALSE</field>
|
||||
<field name="LED22">FALSE</field>
|
||||
<field name="LED32">FALSE</field>
|
||||
<field name="LED42">FALSE</field>
|
||||
<field name="LED03">TRUE</field>
|
||||
<field name="LED13">FALSE</field>
|
||||
<field name="LED23">FALSE</field>
|
||||
<field name="LED33">FALSE</field>
|
||||
<field name="LED43">TRUE</field>
|
||||
<field name="LED04">FALSE</field>
|
||||
<field name="LED14">TRUE</field>
|
||||
<field name="LED24">TRUE</field>
|
||||
<field name="LED34">TRUE</field>
|
||||
<field name="LED44">FALSE</field>
|
||||
<next>
|
||||
<block type="device_show_leds">
|
||||
<field name="LED00">FALSE</field>
|
||||
<field name="LED10">FALSE</field>
|
||||
<field name="LED20">FALSE</field>
|
||||
<field name="LED30">FALSE</field>
|
||||
<field name="LED40">FALSE</field>
|
||||
<field name="LED01">FALSE</field>
|
||||
<field name="LED11">FALSE</field>
|
||||
<field name="LED21">FALSE</field>
|
||||
<field name="LED31">FALSE</field>
|
||||
<field name="LED41">FALSE</field>
|
||||
<field name="LED02">FALSE</field>
|
||||
<field name="LED12">FALSE</field>
|
||||
<field name="LED22">FALSE</field>
|
||||
<field name="LED32">FALSE</field>
|
||||
<field name="LED42">FALSE</field>
|
||||
<field name="LED03">FALSE</field>
|
||||
<field name="LED13">FALSE</field>
|
||||
<field name="LED23">FALSE</field>
|
||||
<field name="LED33">FALSE</field>
|
||||
<field name="LED43">FALSE</field>
|
||||
<field name="LED04">FALSE</field>
|
||||
<field name="LED14">FALSE</field>
|
||||
<field name="LED24">FALSE</field>
|
||||
<field name="LED34">FALSE</field>
|
||||
<field name="LED44">FALSE</field>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</statement>
|
||||
</block>
|
||||
<block type="pxtStart"></block>
|
||||
</xml>
|
@ -1,16 +1 @@
|
||||
basic.forever(() => {
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
# . # . #
|
||||
# . . . #
|
||||
. # . # .
|
||||
. . # . .
|
||||
`)
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
`)
|
||||
})
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"bluetooth": "Support for additional Bluetooth services.",
|
||||
"bluetooth": "Support for additional Bluetooth services.\n\nSupport for additional Bluetooth services.",
|
||||
"bluetooth.advertiseUrl": "Advertise an Eddystone URL",
|
||||
"bluetooth.advertiseUrl|param|connectable": "true to keep bluetooth connectable for other services, false otherwise.",
|
||||
"bluetooth.advertiseUrl|param|power": "power level between 0 and 7, eg: 7",
|
||||
|
@ -1,62 +1,3 @@
|
||||
<xml xmlns="http://www.w3.org/1999/xhtml">
|
||||
<block type="device_forever">
|
||||
<statement name="HANDLER">
|
||||
<block type="device_show_leds">
|
||||
<field name="LED00">FALSE</field>
|
||||
<field name="LED10">FALSE</field>
|
||||
<field name="LED20">FALSE</field>
|
||||
<field name="LED30">FALSE</field>
|
||||
<field name="LED40">FALSE</field>
|
||||
<field name="LED01">FALSE</field>
|
||||
<field name="LED11">TRUE</field>
|
||||
<field name="LED21">FALSE</field>
|
||||
<field name="LED31">TRUE</field>
|
||||
<field name="LED41">FALSE</field>
|
||||
<field name="LED02">FALSE</field>
|
||||
<field name="LED12">FALSE</field>
|
||||
<field name="LED22">FALSE</field>
|
||||
<field name="LED32">FALSE</field>
|
||||
<field name="LED42">FALSE</field>
|
||||
<field name="LED03">TRUE</field>
|
||||
<field name="LED13">FALSE</field>
|
||||
<field name="LED23">FALSE</field>
|
||||
<field name="LED33">FALSE</field>
|
||||
<field name="LED43">TRUE</field>
|
||||
<field name="LED04">FALSE</field>
|
||||
<field name="LED14">TRUE</field>
|
||||
<field name="LED24">TRUE</field>
|
||||
<field name="LED34">TRUE</field>
|
||||
<field name="LED44">FALSE</field>
|
||||
<next>
|
||||
<block type="device_show_leds">
|
||||
<field name="LED00">FALSE</field>
|
||||
<field name="LED10">FALSE</field>
|
||||
<field name="LED20">FALSE</field>
|
||||
<field name="LED30">FALSE</field>
|
||||
<field name="LED40">FALSE</field>
|
||||
<field name="LED01">FALSE</field>
|
||||
<field name="LED11">FALSE</field>
|
||||
<field name="LED21">FALSE</field>
|
||||
<field name="LED31">FALSE</field>
|
||||
<field name="LED41">FALSE</field>
|
||||
<field name="LED02">FALSE</field>
|
||||
<field name="LED12">FALSE</field>
|
||||
<field name="LED22">FALSE</field>
|
||||
<field name="LED32">FALSE</field>
|
||||
<field name="LED42">FALSE</field>
|
||||
<field name="LED03">FALSE</field>
|
||||
<field name="LED13">FALSE</field>
|
||||
<field name="LED23">FALSE</field>
|
||||
<field name="LED33">FALSE</field>
|
||||
<field name="LED43">FALSE</field>
|
||||
<field name="LED04">FALSE</field>
|
||||
<field name="LED14">FALSE</field>
|
||||
<field name="LED24">FALSE</field>
|
||||
<field name="LED34">FALSE</field>
|
||||
<field name="LED44">FALSE</field>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</statement>
|
||||
</block>
|
||||
<block type="pxtStart"></block>
|
||||
</xml>
|
@ -1,16 +1 @@
|
||||
basic.forever(() => {
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
# . # . #
|
||||
# . . . #
|
||||
. # . # .
|
||||
. . # . .
|
||||
`)
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
`)
|
||||
})
|
||||
|
||||
|
@ -97,26 +97,28 @@
|
||||
"input.acceleration": "Get the acceleration value in milli-gravitys (when the board is laying flat with the screen up, x=0, y=0 and z=-1024)",
|
||||
"input.acceleration|param|dimension": "TODO",
|
||||
"input.buttonIsPressed": "Get the button state (pressed or not) for ``A`` and ``B``.",
|
||||
"input.buttonIsPressed|param|button": "the button to query the request, eg: Button.A",
|
||||
"input.calibrate": "Obsolete, compass calibration is automatic.",
|
||||
"input.compassHeading": "Get the current compass heading in degrees.",
|
||||
"input.lightLevel": "Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright.",
|
||||
"input.magneticForce": "Get the magnetic force value in ``micro-Teslas`` (``µT``). This function is not supported in the simulator.",
|
||||
"input.magneticForce|param|dimension": "TODO",
|
||||
"input.onButtonPressed": "Do something when a button (``A``, ``B`` or both ``A+B``) is pressed",
|
||||
"input.onButtonPressed|param|body": "TODO",
|
||||
"input.onButtonPressed|param|button": "TODO",
|
||||
"input.onButtonPressed|param|body": "code to run when event is raised",
|
||||
"input.onButtonPressed|param|button": "the button that needs to be pressed",
|
||||
"input.onGesture": "Do something when when a gesture is done (like shaking the micro:bit).",
|
||||
"input.onGesture|param|body": "TODO",
|
||||
"input.onGesture|param|body": "code to run when gesture is raised",
|
||||
"input.onGesture|param|gesture": "the type of gesture to track, eg: Gesture.Shake",
|
||||
"input.onLogoDown": "Attaches code to run when the logo is oriented downwards and the board is vertical.",
|
||||
"input.onLogoDown|param|body": "TODO",
|
||||
"input.onLogoUp": "Attaches code to run when the logo is oriented upwards and the board is vertical.",
|
||||
"input.onLogoUp|param|body": "TODO",
|
||||
"input.onPinPressed": "Do something when a pin is pressed.",
|
||||
"input.onPinPressed|param|body": "the code to run when the pin is pressed",
|
||||
"input.onPinPressed|param|name": "the pin that needs to be pressed",
|
||||
"input.onPinPressed|param|name": "the pin that needs to be pressed, eg: TouchPin.P0",
|
||||
"input.onPinReleased": "Do something when a pin is released.",
|
||||
"input.onPinReleased|param|body": "the code to run when the pin is released",
|
||||
"input.onPinReleased|param|name": "the pin that needs to be released",
|
||||
"input.onPinReleased|param|name": "the pin that needs to be released, eg: TouchPin.P0",
|
||||
"input.onScreenDown": "Attaches code to run when the screen is facing down.",
|
||||
"input.onScreenDown|param|body": "TODO",
|
||||
"input.onScreenUp": "Attaches code to run when the screen is facing up.",
|
||||
@ -124,7 +126,7 @@
|
||||
"input.onShake": "Attaches code to run when the device is shaken.",
|
||||
"input.onShake|param|body": "TODO",
|
||||
"input.pinIsPressed": "Get the pin state (pressed or not). Requires to hold the ground to close the circuit.",
|
||||
"input.pinIsPressed|param|name": "pin used to detect the touch",
|
||||
"input.pinIsPressed|param|name": "pin used to detect the touch, eg: TouchPin.P0",
|
||||
"input.rotation": "The pitch or roll of the device, rotation along the ``x-axis`` or ``y-axis``, in degrees.",
|
||||
"input.rotation|param|kind": "TODO",
|
||||
"input.runningTime": "Gets the number of milliseconds elapsed since power on.",
|
||||
@ -166,7 +168,7 @@
|
||||
"music.changeTempoBy": "Change the tempo by the specified amount",
|
||||
"music.changeTempoBy|param|bpm": "The change in beats per minute to the tempo, eg: 20",
|
||||
"music.noteFrequency": "Gets the frequency of a note.",
|
||||
"music.noteFrequency|param|name": "the note name",
|
||||
"music.noteFrequency|param|name": "the note name, eg: Note.C",
|
||||
"music.playTone": "Plays a tone through pin ``P0`` for the given duration.",
|
||||
"music.playTone|param|frequency": "pitch of the tone to play in Hertz (Hz)",
|
||||
"music.playTone|param|ms": "tone duration in milliseconds (ms)",
|
||||
@ -182,21 +184,21 @@
|
||||
"pins.analogPitch|param|frequency": "frequency to modulate in Hz.",
|
||||
"pins.analogPitch|param|ms": "duration of the pitch in milli seconds.",
|
||||
"pins.analogReadPin": "Read the connector value as analog, that is, as a value comprised between 0 and 1023.",
|
||||
"pins.analogReadPin|param|name": "pin to write to",
|
||||
"pins.analogReadPin|param|name": "pin to write to, eg: AnalogPin.P0",
|
||||
"pins.analogSetPeriod": "Configures the Pulse-width modulation (PWM) of the analog output to the given value in **microseconds** or `1/1000` milliseconds.\nIf this pin is not configured as an analog output (using `analog write pin`), the operation has no effect.",
|
||||
"pins.analogSetPeriod|param|micros": "period in micro seconds. eg:20000",
|
||||
"pins.analogSetPeriod|param|name": "analog pin to set period to",
|
||||
"pins.analogSetPeriod|param|name": "analog pin to set period to, eg: AnalogPin.P0",
|
||||
"pins.analogSetPitchPin": "Sets the pin used when using `analog pitch` or music.",
|
||||
"pins.analogSetPitchPin|param|name": "pin to modulate pitch from",
|
||||
"pins.analogWritePin": "Set the connector value as analog. Value must be comprised between 0 and 1023.",
|
||||
"pins.analogWritePin|param|name": "pin name to write to",
|
||||
"pins.analogWritePin|param|name": "pin name to write to, eg: AnalogPin.P0",
|
||||
"pins.analogWritePin|param|value": "value to write to the pin between ``0`` and ``1023``. eg:1023,0",
|
||||
"pins.createBuffer": "Create a new zero-initialized buffer.",
|
||||
"pins.createBuffer|param|size": "number of bytes in the buffer",
|
||||
"pins.digitalReadPin": "Read the specified pin or connector as either 0 or 1",
|
||||
"pins.digitalReadPin|param|name": "pin to read from",
|
||||
"pins.digitalReadPin|param|name": "pin to read from, eg: DigitalPin.P0",
|
||||
"pins.digitalWritePin": "Set a pin or connector value to either 0 or 1.",
|
||||
"pins.digitalWritePin|param|name": "pin to write to",
|
||||
"pins.digitalWritePin|param|name": "pin to write to, eg: DigitalPin.P0",
|
||||
"pins.digitalWritePin|param|value": "value to set on the pin, 1 eg,0",
|
||||
"pins.i2cReadBuffer": "Read `size` bytes from a 7-bit I2C `address`.",
|
||||
"pins.i2cReadNumber": "Read one number from 7-bit I2C address.",
|
||||
@ -209,19 +211,21 @@
|
||||
"pins.map|param|toLow": "the lower bound of the value's target range",
|
||||
"pins.map|param|value": "value to map in ranges",
|
||||
"pins.onPulsed": "Configures this pin to a digital input, and generates events where the timestamp is the duration that this pin was either ``high`` or ``low``.",
|
||||
"pins.onPulsed|param|name": "digital pin to register to, eg: DigitalPin.P0",
|
||||
"pins.onPulsed|param|pulse": "the value of the pulse, eg: PulseValue.High",
|
||||
"pins.pulseDuration": "Gets the duration of the last pulse in micro-seconds. This function should be called from a ``onPulsed`` handler.",
|
||||
"pins.pulseIn": "Returns the duration of a pulse in microseconds",
|
||||
"pins.pulseIn|param|name": "the pin which measures the pulse",
|
||||
"pins.pulseIn|param|value": "the value of the pulse (default high)",
|
||||
"pins.pulseIn|param|name": "the pin which measures the pulse, eg: DigitalPin.P0",
|
||||
"pins.pulseIn|param|value": "the value of the pulse, eg: PulseValue.High",
|
||||
"pins.servoSetPulse": "Configures this IO pin as an analog/pwm output, configures the period to be 20 ms, and sets the pulse width, based on the value it is given **microseconds** or `1/1000` milliseconds.",
|
||||
"pins.servoSetPulse|param|micros": "pulse duration in micro seconds, eg:1500",
|
||||
"pins.servoSetPulse|param|name": "pin name",
|
||||
"pins.servoWritePin": "Writes a value to the servo, controlling the shaft accordingly. On a standard servo, this will set the angle of the shaft (in degrees), moving the shaft to that orientation. On a continuous rotation servo, this will set the speed of the servo (with ``0`` being full-speed in one direction, ``180`` being full speed in the other, and a value near ``90`` being no movement).",
|
||||
"pins.servoWritePin|param|name": "pin to write to",
|
||||
"pins.servoWritePin|param|name": "pin to write to, eg: AnalogPin.P0",
|
||||
"pins.servoWritePin|param|value": "angle or rotation speed, eg:180,90,0",
|
||||
"pins.setPull": "Configures the pull of this pin.",
|
||||
"pins.setPull|param|name": "pin to set the pull mode on",
|
||||
"pins.setPull|param|pull": "one of the mbed pull configurations: PullUp, PullDown, PullNone ",
|
||||
"pins.setPull|param|name": "pin to set the pull mode on, eg: DigitalPin.P0",
|
||||
"pins.setPull|param|pull": "one of the mbed pull configurations, eg: PinPullMode.PullUp",
|
||||
"pins.sizeOf": "Get the size in bytes of specified number format.",
|
||||
"pins.spiWrite": "Write to the SPI slave and return the response",
|
||||
"pins.spiWrite|param|value": "Data to be sent to the SPI slave",
|
||||
@ -232,8 +236,9 @@
|
||||
"serial.readUntil": "Reads a line of text from the serial port and returns the buffer when the delimiter is met.",
|
||||
"serial.readUntil|param|delimiter": "text delimiter that separates each text chunk",
|
||||
"serial.redirect": "Dynamically configuring the serial instance to use pins other than USBTX and USBRX.",
|
||||
"serial.redirect|param|rx": "the new reception pin",
|
||||
"serial.redirect|param|tx": "the new transmission pins",
|
||||
"serial.redirect|param|rate": "the new baud rate. eg: 115200",
|
||||
"serial.redirect|param|rx": "the new reception pin, eg: SerialPin.P1",
|
||||
"serial.redirect|param|tx": "the new transmission pins, eg: SerialPin.P0",
|
||||
"serial.writeLine": "Prints a line of text to the serial",
|
||||
"serial.writeNumber": "Prints a numeric value to the serial",
|
||||
"serial.writeString": "Sends a piece of text through Serial connection.",
|
||||
|
@ -123,7 +123,7 @@
|
||||
"input.magneticForce|block": "magnetic force (µT)|%NAME",
|
||||
"input.onButtonPressed|block": "on button|%NAME|pressed",
|
||||
"input.onGesture|block": "on |%NAME",
|
||||
"input.onPinPressed|block": "on pin %NAME|pressed",
|
||||
"input.onPinPressed|block": "on pin %name|pressed",
|
||||
"input.onPinReleased|block": "on pin %NAME|released",
|
||||
"input.pinIsPressed|block": "pin %NAME|is pressed",
|
||||
"input.rotation|block": "rotation (°)|%NAME",
|
||||
|
@ -112,7 +112,7 @@ namespace basic {
|
||||
* Repeats the code forever in the background. On each iteration, allows other codes to run.
|
||||
* @param body code to execute
|
||||
*/
|
||||
//% help=basic/forever weight=55 blockGap=8
|
||||
//% help=basic/forever weight=55 blockGap=8 blockAllowMultiple=1
|
||||
//% blockId=device_forever block="forever" icon="\uf01e"
|
||||
void forever(Action a) {
|
||||
if (a != 0) {
|
||||
|
@ -121,7 +121,7 @@ namespace control {
|
||||
/**
|
||||
* Schedules code that run in the background.
|
||||
*/
|
||||
//% help=control/in-background
|
||||
//% help=control/in-background blockAllowMultiple=1
|
||||
//% blockId="control_in_background" block="run in background" blockGap=8
|
||||
void inBackground(Action a) {
|
||||
runInBackground(a);
|
||||
|
@ -31,7 +31,7 @@ namespace control {
|
||||
/**
|
||||
* If the condition is false, display msg on serial console, and panic with code 098.
|
||||
*/
|
||||
export function assert(condition: boolean, msg ?: string) {
|
||||
export function assert(condition: boolean, msg?: string) {
|
||||
if (!condition) {
|
||||
console.log("ASSERTION FAILED")
|
||||
if (msg != null) {
|
||||
|
@ -111,8 +111,8 @@ enum class Gesture {
|
||||
namespace input {
|
||||
/**
|
||||
* Do something when a button (``A``, ``B`` or both ``A+B``) is pressed
|
||||
* @param button TODO
|
||||
* @param body TODO
|
||||
* @param button the button that needs to be pressed
|
||||
* @param body code to run when event is raised
|
||||
*/
|
||||
//% help=input/on-button-pressed weight=85 blockGap=8
|
||||
//% blockId=device_button_event block="on button|%NAME|pressed" icon="\uf192"
|
||||
@ -123,7 +123,8 @@ namespace input {
|
||||
|
||||
/**
|
||||
* Do something when when a gesture is done (like shaking the micro:bit).
|
||||
* @param body TODO
|
||||
* @param gesture the type of gesture to track, eg: Gesture.Shake
|
||||
* @param body code to run when gesture is raised
|
||||
*/
|
||||
//% help=input/on-gesture weight=84 blockGap=8
|
||||
//% blockId=device_gesture_event block="on |%NAME" icon="\uf135"
|
||||
@ -138,11 +139,11 @@ namespace input {
|
||||
|
||||
/**
|
||||
* Do something when a pin is pressed.
|
||||
* @param name the pin that needs to be pressed
|
||||
* @param name the pin that needs to be pressed, eg: TouchPin.P0
|
||||
* @param body the code to run when the pin is pressed
|
||||
*/
|
||||
//% help=input/on-pin-pressed weight=83
|
||||
//% blockId=device_pin_event block="on pin %NAME|pressed" icon="\uf094"
|
||||
//% blockId=device_pin_event block="on pin %name|pressed" icon="\uf094"
|
||||
void onPinPressed(TouchPin name, Action body) {
|
||||
auto pin = getPin((int)name);
|
||||
if (!pin) return;
|
||||
@ -154,7 +155,7 @@ namespace input {
|
||||
|
||||
/**
|
||||
* Do something when a pin is released.
|
||||
* @param name the pin that needs to be released
|
||||
* @param name the pin that needs to be released, eg: TouchPin.P0
|
||||
* @param body the code to run when the pin is released
|
||||
*/
|
||||
//% help=input/on-pin-released weight=6 blockGap=8
|
||||
@ -171,6 +172,7 @@ namespace input {
|
||||
|
||||
/**
|
||||
* Get the button state (pressed or not) for ``A`` and ``B``.
|
||||
* @param button the button to query the request, eg: Button.A
|
||||
*/
|
||||
//% help=input/button-is-pressed weight=60
|
||||
//% block="button|%NAME|is pressed"
|
||||
@ -189,7 +191,7 @@ namespace input {
|
||||
|
||||
/**
|
||||
* Get the pin state (pressed or not). Requires to hold the ground to close the circuit.
|
||||
* @param name pin used to detect the touch
|
||||
* @param name pin used to detect the touch, eg: TouchPin.P0
|
||||
*/
|
||||
//% help=input/pin-is-pressed weight=58
|
||||
//% blockId="device_pin_is_pressed" block="pin %NAME|is pressed" icon="\uf094"
|
||||
|
@ -170,7 +170,7 @@ namespace music {
|
||||
|
||||
/**
|
||||
* Gets the frequency of a note.
|
||||
* @param name the note name
|
||||
* @param name the note name, eg: Note.C
|
||||
*/
|
||||
//% weight=50 help=music/note-frequency
|
||||
//% blockId=device_note block="%note"
|
||||
|
@ -92,7 +92,7 @@ namespace pins {
|
||||
|
||||
/**
|
||||
* Read the specified pin or connector as either 0 or 1
|
||||
* @param name pin to read from
|
||||
* @param name pin to read from, eg: DigitalPin.P0
|
||||
*/
|
||||
//% help=pins/digital-read-pin weight=30
|
||||
//% blockId=device_get_digital_pin block="digital read|pin %name" blockGap=8
|
||||
@ -102,7 +102,7 @@ namespace pins {
|
||||
|
||||
/**
|
||||
* Set a pin or connector value to either 0 or 1.
|
||||
* @param name pin to write to
|
||||
* @param name pin to write to, eg: DigitalPin.P0
|
||||
* @param value value to set on the pin, 1 eg,0
|
||||
*/
|
||||
//% help=pins/digital-write-pin weight=29
|
||||
@ -113,7 +113,7 @@ namespace pins {
|
||||
|
||||
/**
|
||||
* Read the connector value as analog, that is, as a value comprised between 0 and 1023.
|
||||
* @param name pin to write to
|
||||
* @param name pin to write to, eg: AnalogPin.P0
|
||||
*/
|
||||
//% help=pins/analog-read-pin weight=25
|
||||
//% blockId=device_get_analog_pin block="analog read|pin %name" blockGap="8"
|
||||
@ -123,7 +123,7 @@ namespace pins {
|
||||
|
||||
/**
|
||||
* Set the connector value as analog. Value must be comprised between 0 and 1023.
|
||||
* @param name pin name to write to
|
||||
* @param name pin name to write to, eg: AnalogPin.P0
|
||||
* @param value value to write to the pin between ``0`` and ``1023``. eg:1023,0
|
||||
*/
|
||||
//% help=pins/analog-write-pin weight=24
|
||||
@ -135,7 +135,7 @@ namespace pins {
|
||||
/**
|
||||
* Configures the Pulse-width modulation (PWM) of the analog output to the given value in **microseconds** or `1/1000` milliseconds.
|
||||
* If this pin is not configured as an analog output (using `analog write pin`), the operation has no effect.
|
||||
* @param name analog pin to set period to
|
||||
* @param name analog pin to set period to, eg: AnalogPin.P0
|
||||
* @param micros period in micro seconds. eg:20000
|
||||
*/
|
||||
//% help=pins/analog-set-period weight=23 blockGap=8
|
||||
@ -146,6 +146,8 @@ namespace pins {
|
||||
|
||||
/**
|
||||
* Configures this pin to a digital input, and generates events where the timestamp is the duration that this pin was either ``high`` or ``low``.
|
||||
* @param name digital pin to register to, eg: DigitalPin.P0
|
||||
* @param pulse the value of the pulse, eg: PulseValue.High
|
||||
*/
|
||||
//% help=pins/on-pulsed weight=22 blockGap=8 advanced=true
|
||||
//% blockId=pins_on_pulsed block="on|pin %pin|pulsed %pulse"
|
||||
@ -169,8 +171,8 @@ namespace pins {
|
||||
|
||||
/**
|
||||
* Returns the duration of a pulse in microseconds
|
||||
* @param name the pin which measures the pulse
|
||||
* @param value the value of the pulse (default high)
|
||||
* @param name the pin which measures the pulse, eg: DigitalPin.P0
|
||||
* @param value the value of the pulse, eg: PulseValue.High
|
||||
* @param maximum duration in micro-seconds
|
||||
*/
|
||||
//% blockId="pins_pulse_in" block="pulse in (µs)|pin %name|pulsed %value"
|
||||
@ -198,7 +200,7 @@ namespace pins {
|
||||
|
||||
/**
|
||||
* Writes a value to the servo, controlling the shaft accordingly. On a standard servo, this will set the angle of the shaft (in degrees), moving the shaft to that orientation. On a continuous rotation servo, this will set the speed of the servo (with ``0`` being full-speed in one direction, ``180`` being full speed in the other, and a value near ``90`` being no movement).
|
||||
* @param name pin to write to
|
||||
* @param name pin to write to, eg: AnalogPin.P0
|
||||
* @param value angle or rotation speed, eg:180,90,0
|
||||
*/
|
||||
//% help=pins/servo-write-pin weight=20
|
||||
@ -260,8 +262,8 @@ namespace pins {
|
||||
|
||||
/**
|
||||
* Configures the pull of this pin.
|
||||
* @param name pin to set the pull mode on
|
||||
* @param pull one of the mbed pull configurations: PullUp, PullDown, PullNone
|
||||
* @param name pin to set the pull mode on, eg: DigitalPin.P0
|
||||
* @param pull one of the mbed pull configurations, eg: PinPullMode.PullUp
|
||||
*/
|
||||
//% help=pins/set-pull weight=3 advanced=true
|
||||
//% blockId=device_set_pull block="set pull|pin %pin|to %pull"
|
||||
|
@ -83,9 +83,9 @@ namespace serial {
|
||||
|
||||
/**
|
||||
* Dynamically configuring the serial instance to use pins other than USBTX and USBRX.
|
||||
* @param tx the new transmission pins
|
||||
* @param rx the new reception pin
|
||||
* @param baud the new baud rate. eg: 115200
|
||||
* @param tx the new transmission pins, eg: SerialPin.P0
|
||||
* @param rx the new reception pin, eg: SerialPin.P1
|
||||
* @param rate the new baud rate. eg: 115200
|
||||
*/
|
||||
//% weight=10
|
||||
//% help=serial/redirect-to
|
||||
|
48
libs/core/shims.d.ts
vendored
48
libs/core/shims.d.ts
vendored
@ -195,7 +195,7 @@ declare namespace basic {
|
||||
* Repeats the code forever in the background. On each iteration, allows other codes to run.
|
||||
* @param body code to execute
|
||||
*/
|
||||
//% help=basic/forever weight=55 blockGap=8
|
||||
//% help=basic/forever weight=55 blockGap=8 blockAllowMultiple=1
|
||||
//% blockId=device_forever block="forever" icon="\uf01e" shim=basic::forever
|
||||
function forever(a: () => void): void;
|
||||
|
||||
@ -216,8 +216,8 @@ declare namespace input {
|
||||
|
||||
/**
|
||||
* Do something when a button (``A``, ``B`` or both ``A+B``) is pressed
|
||||
* @param button TODO
|
||||
* @param body TODO
|
||||
* @param button the button that needs to be pressed
|
||||
* @param body code to run when event is raised
|
||||
*/
|
||||
//% help=input/on-button-pressed weight=85 blockGap=8
|
||||
//% blockId=device_button_event block="on button|%NAME|pressed" icon="\uf192"
|
||||
@ -226,7 +226,8 @@ declare namespace input {
|
||||
|
||||
/**
|
||||
* Do something when when a gesture is done (like shaking the micro:bit).
|
||||
* @param body TODO
|
||||
* @param gesture the type of gesture to track, eg: Gesture.Shake
|
||||
* @param body code to run when gesture is raised
|
||||
*/
|
||||
//% help=input/on-gesture weight=84 blockGap=8
|
||||
//% blockId=device_gesture_event block="on |%NAME" icon="\uf135"
|
||||
@ -235,16 +236,16 @@ declare namespace input {
|
||||
|
||||
/**
|
||||
* Do something when a pin is pressed.
|
||||
* @param name the pin that needs to be pressed
|
||||
* @param name the pin that needs to be pressed, eg: TouchPin.P0
|
||||
* @param body the code to run when the pin is pressed
|
||||
*/
|
||||
//% help=input/on-pin-pressed weight=83
|
||||
//% blockId=device_pin_event block="on pin %NAME|pressed" icon="\uf094" shim=input::onPinPressed
|
||||
//% blockId=device_pin_event block="on pin %name|pressed" icon="\uf094" shim=input::onPinPressed
|
||||
function onPinPressed(name: TouchPin, body: () => void): void;
|
||||
|
||||
/**
|
||||
* Do something when a pin is released.
|
||||
* @param name the pin that needs to be released
|
||||
* @param name the pin that needs to be released, eg: TouchPin.P0
|
||||
* @param body the code to run when the pin is released
|
||||
*/
|
||||
//% help=input/on-pin-released weight=6 blockGap=8
|
||||
@ -254,6 +255,7 @@ declare namespace input {
|
||||
|
||||
/**
|
||||
* Get the button state (pressed or not) for ``A`` and ``B``.
|
||||
* @param button the button to query the request, eg: Button.A
|
||||
*/
|
||||
//% help=input/button-is-pressed weight=60
|
||||
//% block="button|%NAME|is pressed"
|
||||
@ -264,7 +266,7 @@ declare namespace input {
|
||||
|
||||
/**
|
||||
* Get the pin state (pressed or not). Requires to hold the ground to close the circuit.
|
||||
* @param name pin used to detect the touch
|
||||
* @param name pin used to detect the touch, eg: TouchPin.P0
|
||||
*/
|
||||
//% help=input/pin-is-pressed weight=58
|
||||
//% blockId="device_pin_is_pressed" block="pin %NAME|is pressed" icon="\uf094"
|
||||
@ -360,7 +362,7 @@ declare namespace control {
|
||||
/**
|
||||
* Schedules code that run in the background.
|
||||
*/
|
||||
//% help=control/in-background
|
||||
//% help=control/in-background blockAllowMultiple=1
|
||||
//% blockId="control_in_background" block="run in background" blockGap=8 shim=control::inBackground
|
||||
function inBackground(a: () => void): void;
|
||||
|
||||
@ -512,7 +514,7 @@ declare namespace pins {
|
||||
|
||||
/**
|
||||
* Read the specified pin or connector as either 0 or 1
|
||||
* @param name pin to read from
|
||||
* @param name pin to read from, eg: DigitalPin.P0
|
||||
*/
|
||||
//% help=pins/digital-read-pin weight=30
|
||||
//% blockId=device_get_digital_pin block="digital read|pin %name" blockGap=8 shim=pins::digitalReadPin
|
||||
@ -520,7 +522,7 @@ declare namespace pins {
|
||||
|
||||
/**
|
||||
* Set a pin or connector value to either 0 or 1.
|
||||
* @param name pin to write to
|
||||
* @param name pin to write to, eg: DigitalPin.P0
|
||||
* @param value value to set on the pin, 1 eg,0
|
||||
*/
|
||||
//% help=pins/digital-write-pin weight=29
|
||||
@ -529,7 +531,7 @@ declare namespace pins {
|
||||
|
||||
/**
|
||||
* Read the connector value as analog, that is, as a value comprised between 0 and 1023.
|
||||
* @param name pin to write to
|
||||
* @param name pin to write to, eg: AnalogPin.P0
|
||||
*/
|
||||
//% help=pins/analog-read-pin weight=25
|
||||
//% blockId=device_get_analog_pin block="analog read|pin %name" blockGap="8" shim=pins::analogReadPin
|
||||
@ -537,7 +539,7 @@ declare namespace pins {
|
||||
|
||||
/**
|
||||
* Set the connector value as analog. Value must be comprised between 0 and 1023.
|
||||
* @param name pin name to write to
|
||||
* @param name pin name to write to, eg: AnalogPin.P0
|
||||
* @param value value to write to the pin between ``0`` and ``1023``. eg:1023,0
|
||||
*/
|
||||
//% help=pins/analog-write-pin weight=24
|
||||
@ -547,7 +549,7 @@ declare namespace pins {
|
||||
/**
|
||||
* Configures the Pulse-width modulation (PWM) of the analog output to the given value in **microseconds** or `1/1000` milliseconds.
|
||||
* If this pin is not configured as an analog output (using `analog write pin`), the operation has no effect.
|
||||
* @param name analog pin to set period to
|
||||
* @param name analog pin to set period to, eg: AnalogPin.P0
|
||||
* @param micros period in micro seconds. eg:20000
|
||||
*/
|
||||
//% help=pins/analog-set-period weight=23 blockGap=8
|
||||
@ -556,6 +558,8 @@ declare namespace pins {
|
||||
|
||||
/**
|
||||
* Configures this pin to a digital input, and generates events where the timestamp is the duration that this pin was either ``high`` or ``low``.
|
||||
* @param name digital pin to register to, eg: DigitalPin.P0
|
||||
* @param pulse the value of the pulse, eg: PulseValue.High
|
||||
*/
|
||||
//% help=pins/on-pulsed weight=22 blockGap=8 advanced=true
|
||||
//% blockId=pins_on_pulsed block="on|pin %pin|pulsed %pulse" shim=pins::onPulsed
|
||||
@ -571,8 +575,8 @@ declare namespace pins {
|
||||
|
||||
/**
|
||||
* Returns the duration of a pulse in microseconds
|
||||
* @param name the pin which measures the pulse
|
||||
* @param value the value of the pulse (default high)
|
||||
* @param name the pin which measures the pulse, eg: DigitalPin.P0
|
||||
* @param value the value of the pulse, eg: PulseValue.High
|
||||
* @param maximum duration in micro-seconds
|
||||
*/
|
||||
//% blockId="pins_pulse_in" block="pulse in (µs)|pin %name|pulsed %value"
|
||||
@ -581,7 +585,7 @@ declare namespace pins {
|
||||
|
||||
/**
|
||||
* Writes a value to the servo, controlling the shaft accordingly. On a standard servo, this will set the angle of the shaft (in degrees), moving the shaft to that orientation. On a continuous rotation servo, this will set the speed of the servo (with ``0`` being full-speed in one direction, ``180`` being full speed in the other, and a value near ``90`` being no movement).
|
||||
* @param name pin to write to
|
||||
* @param name pin to write to, eg: AnalogPin.P0
|
||||
* @param value angle or rotation speed, eg:180,90,0
|
||||
*/
|
||||
//% help=pins/servo-write-pin weight=20
|
||||
@ -617,8 +621,8 @@ declare namespace pins {
|
||||
|
||||
/**
|
||||
* Configures the pull of this pin.
|
||||
* @param name pin to set the pull mode on
|
||||
* @param pull one of the mbed pull configurations: PullUp, PullDown, PullNone
|
||||
* @param name pin to set the pull mode on, eg: DigitalPin.P0
|
||||
* @param pull one of the mbed pull configurations, eg: PinPullMode.PullUp
|
||||
*/
|
||||
//% help=pins/set-pull weight=3 advanced=true
|
||||
//% blockId=device_set_pull block="set pull|pin %pin|to %pull" shim=pins::setPull
|
||||
@ -685,9 +689,9 @@ declare namespace serial {
|
||||
|
||||
/**
|
||||
* Dynamically configuring the serial instance to use pins other than USBTX and USBRX.
|
||||
* @param tx the new transmission pins
|
||||
* @param rx the new reception pin
|
||||
* @param baud the new baud rate. eg: 115200
|
||||
* @param tx the new transmission pins, eg: SerialPin.P0
|
||||
* @param rx the new reception pin, eg: SerialPin.P1
|
||||
* @param rate the new baud rate. eg: 115200
|
||||
*/
|
||||
//% weight=10
|
||||
//% help=serial/redirect-to
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "pxt-microbit",
|
||||
"version": "0.6.35",
|
||||
"version": "0.6.46",
|
||||
"description": "micro:bit target for PXT",
|
||||
"keywords": [
|
||||
"JavaScript",
|
||||
@ -34,6 +34,6 @@
|
||||
"semantic-ui-less": "^2.2.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"pxt-core": "0.5.98"
|
||||
"pxt-core": "0.7.1"
|
||||
}
|
||||
}
|
||||
|
@ -43,11 +43,25 @@
|
||||
"microbit-serial": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "missingPackage",
|
||||
"map": {
|
||||
"radio\\s*\\.": "radio",
|
||||
"bluetooth\\s*\\.": "bluetooth",
|
||||
"devices\\s*\\.": "devices"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "api",
|
||||
"map": {
|
||||
"bluetooth\\.uartRead\\((.*?)\\)": "bluetooth.uartReadUntil($1)",
|
||||
"bluetooth\\.uartWrite\\((.*?)\\)": "bluetooth.uartWriteUntil($1)"
|
||||
"bluetooth\\s*\\.uartRead\\s*\\((.*?)\\)": "bluetooth.uartReadUntil($1)",
|
||||
"bluetooth\\s*\\.uartWrite\\s*\\((.*?)\\)": "bluetooth.uartWriteUntil($1)"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "blockId",
|
||||
"map": {
|
||||
"device_get_acceleration": "device_acceleration"
|
||||
}
|
||||
}
|
||||
]
|
||||
@ -56,7 +70,9 @@
|
||||
"mathBlocks": true,
|
||||
"loopsBlocks": true,
|
||||
"logicBlocks": true,
|
||||
"variablesBlocks": true
|
||||
"variablesBlocks": true,
|
||||
"onStartColor": "#0078D7",
|
||||
"onStartNamespace": "basic"
|
||||
},
|
||||
"simulator": {
|
||||
"autoRun": true,
|
||||
@ -315,6 +331,7 @@
|
||||
],
|
||||
"invertedMenu": true,
|
||||
"coloredToolbox": true,
|
||||
"monacoToolbox": true,
|
||||
"blocklyOptions": {
|
||||
"grid": {
|
||||
"spacing": 45,
|
||||
|
@ -11908,62 +11908,111 @@
|
||||
:10071000F19501004198010039B1010099B901003A
|
||||
:10072000D5C901009D26020061270200C180010099
|
||||
:10073000708E3B92C615A841C49866C975EE519754
|
||||
:100740002D0CF6CB4FCF31AA3852319F38B256E537
|
||||
:100740002D0CF6CB4FCF31AA187FF87FFC58A9E9C2
|
||||
:100750000000000000000000000000000000000099
|
||||
:1007600000B5002001B4002001B4002001B4002035
|
||||
:1007700000028C30024602BC01BCE8F745FC01B423
|
||||
:10078000E8F7CAFC01BCF9F731FA0098F9F72EFA3C
|
||||
:1007900001B000BD00B5002001B4069801B4069870
|
||||
:1007A000014601BCF8F759FE01B4039801B405985D
|
||||
:1007B000014601BCF8F751FE014601BCF8F753FEB3
|
||||
:1007C00001B4059801B40798014601BCF8F745FE4D
|
||||
:1007D000014601BCF8F743FE01B40498014601BC90
|
||||
:1007E000F8F739FE0090FFE7009801B000BD00B5B2
|
||||
:1007F000002001B4002000900298002802D0FF20C1
|
||||
:100800000090FFE7059801B4F9F7C9F9059801B41C
|
||||
:10081000059801B40398034604BC02BC0098F9F79C
|
||||
:100820000AF901BCF9F7E2F90598F9F7DFF901B027
|
||||
:1008300000BD00B5002001B40020E8F77DFB00906A
|
||||
:10084000FFE7009801B000BDFFFF000020B50D4696
|
||||
:1008500000200002A83001B40120000290300146BF
|
||||
:1008600001BCE8F70FFA00200002B83001B4012003
|
||||
:1008700000029030014601BCE8F704FA20BD0000F8
|
||||
:10088000FFFF05000500000000000000010001005E
|
||||
:100890000000000000000000000000010101002A2B
|
||||
:1008A000FFFF050005000000000000000000000040
|
||||
:1008B0000000000000000000000000000000002A0E
|
||||
:1008C00041140E2FB82FA2BB4C00A3010000000062
|
||||
:1008D0007B22636F6D7072657373696F6E223A224B
|
||||
:1008E0004C5A4D41222C2268656164657253697AC5
|
||||
:1008F00065223A3133392C227465787453697A65EC
|
||||
:10090000223A323439342C226E616D65223A2262E9
|
||||
:100910006C6F636B73626C696E6B227D5D0000802F
|
||||
:1009200000490A000000000000003D888867041CA0
|
||||
:10093000BCC1C8A25578869B4D69261C354501422D
|
||||
:100940001948E37B0692B2DBE3A99A218E18EFA542
|
||||
:100950006421FF3A50DF5CB84D25B831BC1D9BD0F7
|
||||
:10096000A3720BD23F36166C9FFADA84711D2EB338
|
||||
:100970003291D1DEB646B0BE0FFADE6FD7AD7C1134
|
||||
:10098000573353851403078AD6AEE9A5C8D021B2E0
|
||||
:100990007FFAB45E1D9AF8C10C1AEF12B167A5C2B6
|
||||
:1009A000329D2DC02570F67BAF4E1FC2923CE042B7
|
||||
:1009B00028E478417276160D1F06CE6E0CCBD84C0B
|
||||
:1009C000B456FF79CC0DE99E98FE0D65BED6F7842E
|
||||
:1009D000890D2B69552360DED35DCD22F579D8E4EE
|
||||
:1009E000F214F5717F1C2CEF0D59E583D995AC807D
|
||||
:1009F0000624B660B3E376A4C5A4C62BC0B1766066
|
||||
:100A00005B5E6DBBD94336CEF28C58753EF5E6176A
|
||||
:100A10000D454E5EA91A60E7F9BAA6413CFDB93210
|
||||
:100A2000CC8DC16D25BCBA7ECF28A19D88036FAD4A
|
||||
:100A30008EF21F6085E68BBD74D011870E15C5320E
|
||||
:100A4000CAB0F268C6FF6A8E3DB568FF545C98A5CF
|
||||
:100A5000041DFD9090BB3978F3995097661EE126EE
|
||||
:100A60000993D095AB665AE4626AC471DC13A6D4CC
|
||||
:100A700012F078262A98D778E53BE920E252773DB4
|
||||
:100A8000206C0C9FA0E8589826BD5F95814AC5BE92
|
||||
:100A90007BC997717460085C806C1CD9B85CCD33DD
|
||||
:100AA0000016DD6FD865555605505938E15B941135
|
||||
:100AB000D2FAC2F686783310D2E2FF86A151000046
|
||||
:1007600000B5002001B401B401B401B401B401200A
|
||||
:1007700001B4002001B4002001B400200002F630D2
|
||||
:10078000024602BC01BCE8F73FFC014601BC02B4D2
|
||||
:10079000F9F7B0FC01BCF9F729FA022001B40020F6
|
||||
:1007A00001B4002001B4012000021A30024602BC4C
|
||||
:1007B00001BCE8F729FC014601BC02B4F9F79AFC38
|
||||
:1007C00001BCF9F713FA002001B4002001B40120A4
|
||||
:1007D00000024030024602BC01BCE8F715FC01B43F
|
||||
:1007E000E8F79AFC01BCF9F701FA02209621E7F735
|
||||
:1007F00021FF01200002483001B4012000029030A6
|
||||
:10080000014601BCE8F73EFA012000025830E8F743
|
||||
:10081000CDF801B4962001460098F9F72FF901BCF4
|
||||
:10082000F9F7E4F90120E7F73FFEE7F785FDE8F780
|
||||
:1008300065FAE7F7AFFE0020E7F71CFEE7F784FD57
|
||||
:100840000020E7F7F9FD0020E7F714FE0020E7F7A6
|
||||
:1008500083FD0098F9F7CAF90298F9F7C7F90498E7
|
||||
:10086000F9F7C4F905B000BD00B5002001B4069841
|
||||
:1008700001B40698014601BCF8F7EFFD01B40398F6
|
||||
:1008800001B40598014601BCF8F7E7FD014601BC3B
|
||||
:10089000F8F7E9FD01B4059801B40798014601BCD9
|
||||
:1008A000F8F7DBFD014601BCF8F7D9FD01B4049867
|
||||
:1008B000014601BCF8F7CFFD0090FFE7009801B0BA
|
||||
:1008C00000BD00B5002001B400200090029800286F
|
||||
:1008D00002D0FF200090FFE7059801B4F9F75FF917
|
||||
:1008E000059801B4059801B40398034604BC02BC02
|
||||
:1008F0000098F9F7A0F801BCF9F778F90598F9F72D
|
||||
:1009000075F901B000BD00B5002001B40020E8F782
|
||||
:1009100013FB0090FFE7009801B000BDFFFF00004F
|
||||
:1009200020B50D46002001B401B404200190002040
|
||||
:100930000090009801B40298014601BCF8F767FDE9
|
||||
:10094000002805D000980121F8F785FD0090F0E718
|
||||
:1009500000200021F8F75BFD002800D0FFE702B07F
|
||||
:1009600020BD0000FFFF000020B50D46002001B4AF
|
||||
:1009700001B40120002819D004200121F8F76BFDF3
|
||||
:10098000019000200090009801B40298014601BC3B
|
||||
:10099000F8F73DFD002805D000980121F8F75BFD30
|
||||
:1009A0000090F0E71420E7F79BFDE2E702B020BDDE
|
||||
:1009B000FFFF000020B50D466420E7F791FD20BD44
|
||||
:1009C000FFFF05000500000000000000010001001D
|
||||
:1009D0000000000000010000000100010101002AE8
|
||||
:1009E000FFFF060048656C6C6F21000000000000EE
|
||||
:1009F00041140E2FB82FA2BB55006F03000000005A
|
||||
:100A00007B22636F6D7072657373696F6E223A2219
|
||||
:100A10004C5A4D41222C2268656164657253697A93
|
||||
:100A200065223A3133352C227465787453697A65BE
|
||||
:100A3000223A343236362C226E616D65223A2261BA
|
||||
:100A400077652D696E73706972696E672073637262
|
||||
:100A5000697074227D5D000080003111000000008B
|
||||
:100A60000000003D888867041CBCC1C8A255788678
|
||||
:100A70009B4D69261C354501421948E37B0692B21D
|
||||
:100A8000DBE3A99A218E18EFA56421FF3A50DF5CC1
|
||||
:100A9000B84D25B831BC1D9BD0A3720BD23F361682
|
||||
:100AA0006C9FFADA84711D2EC9AC893737C3C8E24E
|
||||
:100AB0003144571FA844D7A3963E762405463739BC
|
||||
:100AC000562C2741749E7ADF8947F2C0F16D27E6E4
|
||||
:100AD000671D21D7B68962CD4A32EB0C6D831DCEDE
|
||||
:100AE000D938679D3E575063D676C5D1AD67714AF8
|
||||
:100AF000DF5E908FB74BF1BA71BE31AF0D068F211B
|
||||
:100B000042E1428B1A26AEB037DFB75E85844F6F65
|
||||
:100B10007EFD07E78A8E10F0509394D2D3D10F89CF
|
||||
:100B200079E24994B05EC5B4191F8F8732BA2EADF1
|
||||
:100B3000BDA33AEA6B799E8F238650EED8A213129A
|
||||
:100B40004CE8DBDF1CBC54075FAB965AB71F196437
|
||||
:100B500057356BE317D9558961C31B5E7A253D8BE9
|
||||
:100B6000101FCAEA6E9334AFDEB378209D13B0B283
|
||||
:100B7000BBD03BC203BE98A78036163F9B529787D7
|
||||
:100B800047E2EBB8DB41A6C2DE8D0437572CBDC867
|
||||
:100B900070C5D57E332A3633384DAC966B5EE0F89F
|
||||
:100BA0001A4FFBEE3BD5FE46C1FF358742209871B8
|
||||
:100BB000585520F96EAAEF9324E9B1252895D54719
|
||||
:100BC0006CFC464A13EB3A3899E7D46BA3C2027B1C
|
||||
:100BD0008A502E8AA3F91A7AFD6DD225F44D72102F
|
||||
:100BE00013FB3F888E41786D06AA9C6CBC12DB4DCE
|
||||
:100BF000FCEAB9619A1C30A75D2426231876ED041F
|
||||
:100C0000E1F6A1976F1202A06C6DA23FB9ED17B982
|
||||
:100C10004661EAE80727E90B820F1648E858286B77
|
||||
:100C2000C4312974DA972D1A5681A72E31DA22FFA2
|
||||
:100C3000C68CE7BBCBACAA9EBD6FF5C91D62E4B9FB
|
||||
:100C40009C1B6E664633ECFCC88C169A8DF048539C
|
||||
:100C50009687FAB48B5DD1A1CC7568CBA05DBDC27F
|
||||
:100C6000E485A7A1BA020C34F54A5876D5793EF24C
|
||||
:100C7000240921FA568D22B801545A7140A289D50F
|
||||
:100C8000C96E7F553E45B8911C762CA743E18DDF98
|
||||
:100C90007FDB0D260FF7DC95B1454CB8B4A06BEEA9
|
||||
:100CA000BBAB7A21557231ADDA411E05EDAD8E7ABE
|
||||
:100CB000FCE220D686E36BD35922FC6BDA31BDD43B
|
||||
:100CC000FF06648ED8A908BADFF63CE91A3B5874CF
|
||||
:100CD00070836F6C9461A68A19299865D6BA06B894
|
||||
:100CE00063C874A840820066F1BD40FC0816A4F8F1
|
||||
:100CF000B8505B1E18047413CFA130569896E37950
|
||||
:100D0000941201C53A972167887F1258FB9D85B3DD
|
||||
:100D1000D1111EFAFB63E87B849CE3166143E8F281
|
||||
:100D2000B3EA7C8B03B40E241F13F43DD24309ECC9
|
||||
:100D30000B7F066F94CC1DFC0606F9B2284BA2BDB2
|
||||
:100D4000BBBA5A03F54A5646DB56956B1D5CEC9FC1
|
||||
:100D50005112F313C27CED0D7921A38A36C35D01D4
|
||||
:100D6000485A30A244E32C82C52EEB6C9F260F51CB
|
||||
:100D700076E9E1C367F794A852FDAC99CA3B1364C6
|
||||
:100D80006F4F839EA694170E8339279977896845FC
|
||||
:100D900011BD5F9646D7966E61E47FCF282FBD4C7C
|
||||
:100DA0001709BFF597D59E441D6CDB5B74C44A1DC3
|
||||
:100DB000C29F9A9190DFE13600061A2252F094FF0A
|
||||
:100DC000BEF48D7000000000000000000000000074
|
||||
:10C00000903C002061DC030073DC030075DC03005E
|
||||
:10C010000000000000000000000000000000000020
|
||||
:10C0200000000000000000000000000069C10300E3
|
||||
|
@ -74,12 +74,12 @@
|
||||
}
|
||||
|
||||
/* Blockly Toolbox Buttons */
|
||||
#blocklyToolboxButtons .blocklyAddPackageButton {
|
||||
.blocklyToolboxButtons .blocklyAddPackageButton {
|
||||
&:extend(.ui.inverted.pink.button all);
|
||||
&:extend(.circular all);
|
||||
}
|
||||
|
||||
#blocklyToolboxButtons .blocklyUndoButton {
|
||||
.blocklyToolboxButtons .blocklyUndoButton {
|
||||
&:extend(.ui.inverted.blue.button all);
|
||||
&:extend(.circular all);
|
||||
}
|
||||
@ -92,12 +92,17 @@
|
||||
background: #ecf0f1;
|
||||
}
|
||||
|
||||
.monacoDraggableBlock {
|
||||
background: #ecf0f1;
|
||||
border: solid 3px #ecf0f1;
|
||||
}
|
||||
|
||||
.monaco-editor-background {
|
||||
background: #ecf0f1;
|
||||
}
|
||||
|
||||
.monacoFlyout {
|
||||
background: rgba(82, 90, 103, 0.8);
|
||||
background: rgba(82, 90, 103, 0.5);
|
||||
}
|
||||
|
||||
|
||||
@ -117,7 +122,7 @@
|
||||
top: auto;
|
||||
}
|
||||
/* Blockly Toolbox buttons */
|
||||
#blocklyToolboxButtons {
|
||||
#blocklyToolboxButtons, #monacoToolboxButtons {
|
||||
margin-right: 0.5rem;
|
||||
margin-left: 0.5rem;
|
||||
}
|
||||
@ -129,7 +134,7 @@
|
||||
top: auto;
|
||||
}
|
||||
/* Blockly Toolbox buttons */
|
||||
#blocklyToolboxButtons {
|
||||
#blocklyToolboxButtons, #monacoToolboxButtons {
|
||||
margin-right: 1rem;
|
||||
margin-left: 1rem;
|
||||
}
|
||||
@ -142,7 +147,7 @@
|
||||
padding-left: 1rem;
|
||||
}
|
||||
/* Blockly Toolbox buttons */
|
||||
#blocklyToolboxButtons {
|
||||
#blocklyToolboxButtons, #monacoToolboxButtons {
|
||||
margin-right: 2rem;
|
||||
margin-left: 2rem;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@
|
||||
@dimmer : 'default';
|
||||
@dropdown : 'default';
|
||||
@embed : 'default';
|
||||
@modal : 'default';
|
||||
@modal : 'pxt';
|
||||
@nag : 'default';
|
||||
@popup : 'default';
|
||||
@progress : 'default';
|
||||
|
Reference in New Issue
Block a user