Compare commits

...

62 Commits

Author SHA1 Message Date
498b5ec095 0.6.35 2016-12-09 11:57:34 -08:00
912be2ddfd Bump pxt-core to 0.5.98 2016-12-09 11:57:32 -08:00
6d7f8c5841 0.6.34 2016-12-09 11:15:51 -08:00
a782f4731a Bump pxt-core to 0.5.97 2016-12-09 11:15:48 -08:00
6e067bffd5 using built-deploy deployment features
deploy to drives has been migrated to PXT
2016-12-08 21:10:46 -08:00
4a4007ba41 fixing uploader link 2016-12-08 12:33:31 -08:00
c9db08a2c6 0.6.33 2016-12-08 12:18:56 -08:00
5ec303b95c Bump pxt-core to 0.5.96 2016-12-08 12:18:53 -08:00
3d0523a298 fix for roll/pitch in simulator.
fix for https://github.com/Microsoft/pxt/issues/893
2016-12-08 12:14:34 -08:00
d791738d84 fixing y values in accelerometer simulator
fix for https://github.com/Microsoft/pxt/issues/893
2016-12-08 11:57:17 -08:00
355c341d36 0.6.32 2016-12-08 10:56:49 -08:00
1adb4a2bac Bump pxt-core to 0.5.95 2016-12-08 10:56:46 -08:00
03c0339e9a fixing docs snippets 2016-12-08 09:16:27 -08:00
1649811015 expose "delete" in blocks.
fix for https://github.com/Microsoft/pxt/issues/870
2016-12-08 08:54:05 -08:00
14f16f9b2c expose game.setScore in blocks
fix for https://github.com/Microsoft/pxt/issues/881
2016-12-08 08:51:18 -08:00
66d3c6c7e8 fix for https://github.com/Microsoft/pxt/issues/549 2016-12-08 08:28:28 -08:00
7f27432222 Merge branch 'master' of https://github.com/Microsoft/pxt-microbit 2016-12-08 00:12:49 -08:00
870b26a85a updated lessons to use radio 2016-12-08 00:10:00 -08:00
aa6cb58dca Merge pull request #320 from Microsoft/delete
Placement new occurances need explicit delete
2016-12-07 18:09:35 -08:00
6398a42dad Placement new occurances need explicit delete 2016-12-07 18:00:03 -08:00
21473f5b9b Fixing array deallocation leak (#317)
* Fixing array deallocation leak

* Moving delete down to the individual destroy methods
2016-12-07 15:44:35 -08:00
c85b6f9507 using calibrated powers for Eddystone 2016-12-07 11:37:33 -08:00
019b00209e moving blocks to advanced 2016-12-07 09:49:19 -08:00
6c11dbcdf4 added setTransmitPower in BLE 2016-12-07 09:05:03 -08:00
91197c5cec updated BLE settings 2016-12-07 08:07:08 -08:00
9e5d9787c7 linking to pxt issue tracker 2016-12-06 21:51:51 -08:00
1c11a4823b adjusting the blockly flyout opacity. 2016-12-06 21:48:21 -08:00
d457c3e8d0 exposing delete in blocks 2016-12-06 16:19:35 -08:00
2ae21efb7b Moving blockly toolbox button margins to target. 2016-12-06 15:06:16 -08:00
485a42758c 0.6.31 2016-12-06 11:32:24 -08:00
0da5a5a349 Bump pxt-core to 0.5.91 2016-12-06 11:32:22 -08:00
41ce2f66fa removing add package less variable 2016-12-05 23:55:46 -08:00
9393fc166e Styling add package and undo blockly buttons 2016-12-05 21:24:57 -08:00
cfb4382941 support for monaco toolbox 2016-12-05 19:01:14 -08:00
aaca24ff5b using add package color less variable 2016-12-05 18:09:23 -08:00
0ce9be1a2b removing toolbox right border. 2016-12-05 17:59:20 -08:00
a88eb7fe02 Changing main menu color, primary color and adding tiny borders around blockly toolbox 2016-12-05 17:30:04 -08:00
06e4f7fb5c Updated BLE project settings 2016-12-05 15:33:40 -08:00
1b36485208 0.6.30 2016-12-05 15:10:13 -08:00
3b54cefa95 Merge branch 'master' of https://github.com/Microsoft/pxt-microbit 2016-12-05 15:02:51 -08:00
52857c9541 added beacon configuration 2016-12-05 15:02:39 -08:00
d10c2a20bd More IE fixes. Using important to override blocky related CSS. 2016-12-05 13:43:57 -08:00
e2482cdf91 0.6.29 2016-12-05 13:22:06 -08:00
c045d87e4c Bump pxt-core to 0.5.90 2016-12-05 13:22:03 -08:00
34e23934b0 better bluetooth settings 2016-12-05 13:02:11 -08:00
354196e01e missing block annotation on led.enable 2016-12-05 09:17:42 -08:00
bb2e8d0aef 'devices' depends on 'bluetooth' 2016-12-05 09:05:54 -08:00
90f4e895d4 0.6.28 2016-12-03 23:22:42 -08:00
58c554caa6 Bump pxt-core to 0.5.88 2016-12-03 23:22:40 -08:00
6c688a7e59 Fix Edge / IE issue where the blockly toolbox background isn't respected. 2016-12-02 18:33:42 -08:00
71244065bb 0.6.27 2016-12-02 13:20:00 -08:00
bbb1bc3dd7 Merge pull request #314 from Microsoft/pr/theming
Theming the microbit target
2016-12-02 13:18:10 -08:00
806d0e2cff 0.6.26 2016-12-02 12:58:15 -08:00
e0c4af1cae Bump pxt-core to 0.5.87 2016-12-02 12:58:13 -08:00
475821564e fixing justworks support 2016-12-02 09:45:59 -08:00
9d65dd605b Monaco editor theming. 2016-12-01 22:05:37 -08:00
67eec44411 Minor fixes. 2016-12-01 21:58:16 -08:00
280b555f86 Theming the microbit target 2016-12-01 18:35:10 -08:00
2fcd32de0d 0.6.25 2016-11-30 23:36:40 -08:00
78694e86a2 0.6.24 2016-11-30 16:07:34 -08:00
aeaa3d7bc1 updated localization files 2016-11-30 16:07:04 -08:00
af8ce3fccf allow for double, breve note durations 2016-11-30 16:06:17 -08:00
34 changed files with 534 additions and 251 deletions

View File

@ -7,6 +7,10 @@ PXT ([Microsoft Programming Experience Toolkit](https://github.com/Microsoft/pxt
[![Build Status](https://travis-ci.org/Microsoft/pxt-microbit.svg?branch=master)](https://travis-ci.org/Microsoft/pxt-microbit) [![Build Status](https://travis-ci.org/Microsoft/pxt-microbit.svg?branch=master)](https://travis-ci.org/Microsoft/pxt-microbit)
## Issue tracking
All issue tracking for this repo happens at https://github.com/Microsoft/pxt, see you there!
## Local server ## Local server
The local server allows to run the editor and the documentation from your computer. The local server allows to run the editor and the documentation from your computer.

View File

@ -1,60 +0,0 @@
/// <reference path="../node_modules/pxt-core/typings/node/node.d.ts"/>
/// <reference path="../node_modules/pxt-core/built/pxtlib.d.ts" />
import * as fs from "fs";
import * as path from "path";
import * as child_process from "child_process";
let writeFileAsync: any = Promise.promisify(fs.writeFile)
let execAsync: (cmd: string, options?: { cwd?: string }) => Promise<Buffer> = Promise.promisify(child_process.exec)
let readDirAsync = Promise.promisify(fs.readdir)
export function deployCoreAsync(res: ts.pxtc.CompileResult) {
return getBitDrivesAsync()
.then(drives => {
if (drives.length == 0) {
console.log("cannot find any drives to deploy to");
return Promise.resolve(0);
}
console.log(`copy ${ts.pxtc.BINARY_HEX} to ` + drives.join(", "));
let writeHexFile = (filename: string) => {
return writeFileAsync(filename + ts.pxtc.BINARY_HEX, res.outfiles[ts.pxtc.BINARY_HEX])
.then(() => console.log("wrote hex file to " + filename));
};
return Promise.map(drives, d => writeHexFile(d))
.then(() => drives.length);
});
}
function getBitDrivesAsync(): Promise<string[]> {
if (process.platform == "win32") {
const rx = new RegExp("^([A-Z]:).* " + pxt.appTarget.compile.deployDrives)
return execAsync("wmic PATH Win32_LogicalDisk get DeviceID, VolumeName, FileSystem")
.then(buf => {
let res: string[] = []
buf.toString("utf8").split(/\n/).forEach(ln => {
let m = rx.exec(ln)
if (m) {
res.push(m[1] + "/")
}
})
return res
})
}
else if (process.platform == "darwin") {
const rx = new RegExp(pxt.appTarget.compile.deployDrives)
return readDirAsync("/Volumes")
.then(lst => lst.filter(s => rx.test(s)).map(s => "/Volumes/" + s + "/"))
} else if (process.platform == "linux") {
const rx = new RegExp(pxt.appTarget.compile.deployDrives)
const user = process.env["USER"]
return readDirAsync(`/media/${user}`)
.then(lst => lst.filter(s => rx.test(s)).map(s => `/media/${user}/${s}/`))
} else {
return Promise.resolve([])
}
}

View File

@ -1,3 +1,6 @@
/// <reference path="../node_modules/pxt-core/typings/node/node.d.ts"/>
/// <reference path="../node_modules/pxt-core/built/pxtlib.d.ts" />
import * as path from "path"; import * as path from "path";
export let pxtCore = require("pxt-core"); export let pxtCore = require("pxt-core");
// require.resolve() gives path to [pxt dir]/built/pxt.js, so move up twice to get pxt root dir // require.resolve() gives path to [pxt dir]/built/pxt.js, so move up twice to get pxt root dir

View File

@ -10,12 +10,10 @@ Welcome! This guided tutorial will show you how to program a script that display
### ~ ### ~
## Step 1 ## Step 1
Create a loop that will continuously update the reading of the compass. Create a loop that will continuously update the reading of the compass.
```blocks ```blocks
basic.forever(() => { basic.forever(() => {

View File

@ -2,8 +2,7 @@
### ~avatar avatar ### ~avatar avatar
Use the LEDs to display a flashing heart, and then create Use the LEDs to display a flashing heart!
an animation of a broken heart. :(
### ~ ### ~
@ -38,19 +37,19 @@ basic.clearScreen();
## Step 3 ## Step 3
Put a [forever loop](/reference/basic/forever) around it. Put a [forever loop](/reference/basic/forever) around it to repeat the animation.
```blocks ```blocks
basic.forever(() => { basic.forever(() => {
basic.showLeds(` basic.showLeds(`
. # . # . . # . # .
# # # # # # # # # #
# # # # # # # # # #
. # # # . . # # # .
. . # . .` . . # . .`
); );
basic.pause(500); basic.pause(500);
basic.clearScreen(); basic.clearScreen();
}) })
``` ```
@ -60,45 +59,50 @@ Add a [pause](/reference/basic/pause) to wait after clearing the screen.
```blocks ```blocks
basic.forever(() => { basic.forever(() => {
basic.showLeds(` basic.showLeds(`
. # . # . . # . # .
# # # # # # # # # #
# # # # # # # # # #
. # # # . . # # # .
. . # . .` . . # . .`
); );
basic.pause(500); basic.pause(500);
basic.clearScreen(); basic.clearScreen();
basic.pause(500); basic.pause(500);
}) })
``` ```
## Step 5 ## Send your heartbeats over radio!
Add a second image of a broken heart. Do you have a second @boardname@ at hand? You could use radio and send your heartbeats to other
@boardname@ and show a heart when you receive one.
* move the code in the **forever** inside
a [on data packet received](/reference/radio/on-data-packet-received) handler.
The handler will run whenever a message is received from another @boardname@.
* use [send number](/reference/radio/send-number) and [pause](/reference/basic/pause)
to broadcast a packet of data every second.
```blocks ```blocks
basic.forever(() => { basic.forever(() => {
basic.showLeds(` radio.sendNumber(0)
. # . # . basic.pause(1000)
# # # # # })
# # # # # radio.onDataPacketReceived(({receivedNumber}) => {
. # # # . basic.showLeds(`
. . # . .` . # . # .
); # # # # #
basic.pause(500); # # # # #
basic.clearScreen(); . # # # .
basic.pause(500); . . # . .`);
basic.showLeds(` basic.pause(500)
. # . # . basic.clearScreen()
# . # # # basic.pause(500)
# . . . #
. # # # .
. . # . .`
);
basic.pause(500);
basic.clearScreen();
basic.pause(500);
}) })
``` ```
Download the .hex file onto both @boardname@ and try it out!
```package
radio
```

View File

@ -12,8 +12,8 @@ Use [show leds](/reference/basic/show-leds) to make a smiley face:
```blocks ```blocks
basic.showLeds(` basic.showLeds(`
. # . # . # # . # #
. # . # . # # . # #
. . . . . . . . . .
# . . . # # . . . #
. # # # .` . # # # .`
@ -22,56 +22,93 @@ basic.showLeds(`
## Step 2 ## Step 2
Add an input block for when [button A is pressed](/reference/input/button-is-pressed), and put a Add an input block for when [button A is pressed](/reference/input/button-is-pressed),
frowny face inside it: and **move** the smiley face inside it:
```blocks ```blocks
basic.showLeds(`
. # . # .
. # . # .
. . . . .
# . . . #
. # # # .`
);
input.onButtonPressed(Button.A, () => { input.onButtonPressed(Button.A, () => {
basic.showLeds(` basic.showLeds(`
. # . # . # # . # #
. # . # . # # . # #
. . . . .
. # # # .
# . . . #`
);
});
```
## Step 3
Now add blocks so that when [button B is pressed](/reference/input/button-is-pressed), a smiley appears:
```blocks
basic.showLeds(`
. # . # .
. # . # .
. . . . .
# . . . #
. # # # .`
);
input.onButtonPressed(Button.A, () => {
basic.showLeds(`
. # . # .
. # . # .
. . . . .
. # # # .
# . . . #`
);
});
input.onButtonPressed(Button.B, () => {
basic.showLeds(`
. # . # .
. # . # .
. . . . . . . . . .
# . . . # # . . . #
. # # # .` . # # # .`
); );
}); });
``` ```
Try pressing button A!
## Step 3
Now add blocks so that when [button B is pressed](/reference/input/on-button-pressed),
a frowney appears:
```blocks
input.onButtonPressed(Button.A, () => {
basic.showLeds(`
# # . # #
# # . # #
. . . . .
# . . . #
. # # # .`
);
});
input.onButtonPressed(Button.B, () => {
basic.showLeds(`
# # . # #
# # . # #
. . . . .
. # # # .
# . . . #`
);
});
```
Try pressing ``A`` or ``B``!
## Send your smileys over radio
Do you have a second @boardname@ at hand? You could use radio and send your smileys or frownies to other
@boardname@.
Since radio can send numbers, we decide that ``0`` is the code for displaying a smiley
and ``1`` is the code for a frowney.
Change your code as follows:
* [radio send number](/reference/radio/send-number) sends a number
to any other @boardname@ in range
* [radio on data packet received](/reference/radio/on-data-packet-received) runs code
when data is received over radio
```blocks
input.onButtonPressed(Button.A, () => {
radio.sendNumber(0)
})
input.onButtonPressed(Button.B, () => {
radio.sendNumber(1)
})
radio.onDataPacketReceived(({receivedNumber}) => {
if (receivedNumber == 0) {
basic.showLeds(`
# # . # #
# # . # #
. . . . .
# . . . #
. # # # .
`)
} else {
basic.showLeds(`
# # . # #
# # . # #
. . . . .
. # # # .
# . . . #
`)
}
})
```
```package
radio
```

View File

@ -19,6 +19,7 @@ bluetooth.startMagnetometerService();
bluetooth.startTemperatureService(); bluetooth.startTemperatureService();
bluetooth.onBluetoothConnected(() => {}); bluetooth.onBluetoothConnected(() => {});
bluetooth.onBluetoothDisconnected(() => {}); bluetooth.onBluetoothDisconnected(() => {});
bluetooth.setTransmitPower(7);
``` ```
## UART ## UART

View File

@ -18,7 +18,7 @@ Read more at https://lancaster-university.github.io/microbit-docs/ble/eddystone/
## ~ ## ~
```sig ```sig
bluetooth.advertiseUrl("https://pxt.microbit.org/", 7); bluetooth.advertiseUrl("https://pxt.microbit.org/", 7, true);
``` ```
### Parameters ### Parameters
@ -29,7 +29,7 @@ bluetooth.advertiseUrl("https://pxt.microbit.org/", 7);
### Example: Broadcast a secret code ### Example: Broadcast a secret code
```blocks ```blocks
bluetooth.advertiseUrl("https://pxt.io?secret=42", 7); bluetooth.advertiseUrl("https://pxt.io?secret=42", 7, true);
``` ```
## See Also ## See Also

View File

@ -0,0 +1,26 @@
# Bluetooth Set Transmit Power
### ~hint
![](/static/bluetooth/Bluetooth_SIG.png)
For another device like a smartphone to use any of the Bluetooth "services" which the @boardname@ has, it must first be [paired with the @boardname@](/reference/bluetooth/bluetooth-pairing). Once paired, the other device may connect to the @boardname@ and exchange data relating to many of the @boardname@'s features.
### ~
Change the output power level of the transmitter to the given value.
```sig
bluetooth.setTransmitPower(7);
```
### Parameters
* `power`: a [number](/reference/types/number) in the range ``0..7``, where ``0`` is the lowest power and ``7`` is the highest.
### See also
[About Bluetooth](/reference/bluetooth/about-bluetooth), [@boardname@ Bluetooth profile overview ](http://lancaster-university.github.io/microbit-docs/ble/profile/), [@boardname@ Bluetooth profile reference](http://lancaster-university.github.io/microbit-docs/resources/bluetooth/microbit-profile-V1.9-Level-2.pdf), [Bluetooth on @boardname@ resources](http://bluetooth-mdw.blogspot.co.uk/p/bbc-microbit.html), [Bluetooth SIG](https://www.bluetooth.com)
```package
bluetooth
```

View File

@ -0,0 +1,28 @@
# Serial Read Until
Read a text from the serial port until a delimiter is found.
```sig
serial.readUntil(",");
```
### Returns
* a [string](/reference/types/string) containing input from the serial port, such as a response typed by a user
### Example
The following example reads strings separated by commands (``,``).
```blocks
basic.forever(() => {
let answer = serial.readUntil(",");
serial.writeLine(answer);
});
```
### See also
[serial](/device/serial),
[serial write line](/reference/serial/write-line),
[serial write value](/reference/serial/write-value)

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -38,7 +38,7 @@ That's it!
### Installation Instructions ### Installation Instructions
* Download the [Microsoft.Uploader.Microbit.zip](https://pxt.microbit.org/microbit-uploader.zip) file to your local computer. * Download the [Microsoft.Uploader.Microbit.zip](https://www.touchdevelop.com/microbituploader.zip) file to your local computer.
* Unzip the .zip file to your desktop. * Unzip the .zip file to your desktop.
* Launch the Microsoft.Uploader.exe file before working on your @boardname@. * Launch the Microsoft.Uploader.exe file before working on your @boardname@.

View File

@ -1,12 +1,15 @@
{ {
"bluetooth": "Support for additional Bluetooth services.", "bluetooth": "Support for additional Bluetooth services.",
"bluetooth.advertiseUrl": "Advertise an Eddystone URL", "bluetooth.advertiseUrl": "Advertise an Eddystone URL",
"bluetooth.advertiseUrl|param|power": "power level between 0 and 7, e.g.: 7", "bluetooth.advertiseUrl|param|connectable": "true to keep bluetooth connectable for other services, false otherwise.",
"bluetooth.advertiseUrl|param|url": "the url to transmit. Must be no longer than the supported eddystone url length", "bluetooth.advertiseUrl|param|power": "power level between 0 and 7, eg: 7",
"bluetooth.advertiseUrl|param|url": "the url to transmit. Must be no longer than the supported eddystone url length, eg: \"https://pxt.io/\"",
"bluetooth.onBluetoothConnected": "Register code to run when the micro:bit is connected to over Bluetooth", "bluetooth.onBluetoothConnected": "Register code to run when the micro:bit is connected to over Bluetooth",
"bluetooth.onBluetoothConnected|param|body": "Code to run when a Bluetooth connection is established", "bluetooth.onBluetoothConnected|param|body": "Code to run when a Bluetooth connection is established",
"bluetooth.onBluetoothDisconnected": "Register code to run when a bluetooth connection to the micro:bit is lost", "bluetooth.onBluetoothDisconnected": "Register code to run when a bluetooth connection to the micro:bit is lost",
"bluetooth.onBluetoothDisconnected|param|body": "Code to run when a Bluetooth connection is lost", "bluetooth.onBluetoothDisconnected|param|body": "Code to run when a Bluetooth connection is lost",
"bluetooth.setTransmitPower": "Sets the bluetooth transmit power between 0 (minimal) and 7 (maximum).",
"bluetooth.setTransmitPower|param|power": "power level between 0 (minimal) and 7 (maximum), eg: 7.",
"bluetooth.startAccelerometerService": "Starts the Bluetooth accelerometer service", "bluetooth.startAccelerometerService": "Starts the Bluetooth accelerometer service",
"bluetooth.startButtonService": "Starts the Bluetooth button service", "bluetooth.startButtonService": "Starts the Bluetooth button service",
"bluetooth.startIOPinService": "Starts the Bluetooth IO pin service.", "bluetooth.startIOPinService": "Starts the Bluetooth IO pin service.",

View File

@ -1,7 +1,8 @@
{ {
"bluetooth.advertiseUrl|block": "bluetooth advertise url %url|with power %power", "bluetooth.advertiseUrl|block": "bluetooth advertise url %url|with power %power|connectable %connectable",
"bluetooth.onBluetoothConnected|block": "on bluetooth connected", "bluetooth.onBluetoothConnected|block": "on bluetooth connected",
"bluetooth.onBluetoothDisconnected|block": "on bluetooth disconnected", "bluetooth.onBluetoothDisconnected|block": "on bluetooth disconnected",
"bluetooth.setTransmitPower|block": "bluetooth set transmit power %power",
"bluetooth.startAccelerometerService|block": "bluetooth accelerometer service", "bluetooth.startAccelerometerService|block": "bluetooth accelerometer service",
"bluetooth.startButtonService|block": "bluetooth button service", "bluetooth.startButtonService|block": "bluetooth button service",
"bluetooth.startIOPinService|block": "bluetooth io pin service", "bluetooth.startIOPinService|block": "bluetooth io pin service",

View File

@ -121,18 +121,30 @@ namespace bluetooth {
} }
const int8_t CALIBRATED_POWERS[] = {-49, -37, -33, -28, -25, -20, -15, -10}; const int8_t CALIBRATED_POWERS[] = {-49, -37, -33, -28, -25, -20, -15, -10};
/** /**
* Advertise an Eddystone URL * Advertise an Eddystone URL
* @param url the url to transmit. Must be no longer than the supported eddystone url length * @param url the url to transmit. Must be no longer than the supported eddystone url length, eg: "https://pxt.io/"
* @param power power level between 0 and 7, e.g.: 7 * @param power power level between 0 and 7, eg: 7
* @param connectable true to keep bluetooth connectable for other services, false otherwise.
*/ */
//% blockId=eddystone_advertise_url block="bluetooth advertise url %url|with power %power" //% blockId=eddystone_advertise_url block="bluetooth advertise url %url|with power %power|connectable %connectable"
//% parts=bluetooth weight=11 blockGap=8 //% parts=bluetooth weight=11 blockGap=8
//% help=bluetooth/advertise-url //% help=bluetooth/advertise-url blockExternalInputs=1
void advertiseUrl(StringData* url, int power) { void advertiseUrl(StringData* url, int power, bool connectable) {
int8_t level = CALIBRATED_POWERS[min(7, max(0, power))]; power = min(MICROBIT_BLE_POWER_LEVELS-1, max(0, power));
uBit.bleManager.advertiseEddystoneUrl(ManagedString(url), level); int8_t level = CALIBRATED_POWERS[power];
uBit.bleManager.advertiseEddystoneUrl(ManagedString(url), level, connectable);
uBit.bleManager.setTransmitPower(power);
}
/**
* Sets the bluetooth transmit power between 0 (minimal) and 7 (maximum).
* @param power power level between 0 (minimal) and 7 (maximum), eg: 7.
*/
//% parts=bluetooth weight=5 help=bluetooth/set-transmit-power advanced=true
//% blockId=bluetooth_settransmitpower block="bluetooth set transmit power %power"
void setTransmitPower(int power) {
uBit.bleManager.setTransmitPower(min(MICROBIT_BLE_POWER_LEVELS-1, max(0, power)));
} }
/** /**
@ -140,7 +152,7 @@ namespace bluetooth {
*/ */
//% blockId=eddystone_stop_advertising block="bluetooth stop advertising" //% blockId=eddystone_stop_advertising block="bluetooth stop advertising"
//% parts=bluetooth weight=10 //% parts=bluetooth weight=10
//% help=bluetooth/stop-advertising //% help=bluetooth/stop-advertising advanced=true
void stopAdvertising() { void stopAdvertising() {
uBit.bleManager.stopAdvertising(); uBit.bleManager.stopAdvertising();
} }

View File

@ -24,7 +24,6 @@
"microbit-dal": { "microbit-dal": {
"bluetooth": { "bluetooth": {
"private_addressing": 0, "private_addressing": 0,
"whitelist": 1,
"advertising_timeout": 0, "advertising_timeout": 0,
"tx_power": 6, "tx_power": 6,
"dfu_service": 1, "dfu_service": 1,
@ -32,33 +31,49 @@
"device_info_service": 1, "device_info_service": 1,
"eddystone_url": 1, "eddystone_url": 1,
"eddystone_uid": 0, "eddystone_uid": 0,
"pairing_mode": 1,
"open": 0, "open": 0,
"security_level": "SECURITY_MODE_ENCRYPTION_WITH_MITM" "pairing_mode": 1,
"whitelist": 1,
"security_level": "SECURITY_MODE_ENCRYPTION_NO_MITM"
} }
}, },
"gatt_table_size": "0x700" "gatt_table_size": "0x700"
}, },
"userConfigs": [ "userConfigs": [
{ {
"description": "No pairing: Anyone can connect via Bluetooth.", "description": "Unsecure: Anyone can connect via Bluetooth.",
"config": { "config": {
"microbit-dal": { "microbit-dal": {
"bluetooth": { "bluetooth": {
"open": 1, "open": 1,
"pairing_mode": null, "pairing_mode": 0,
"whitelist": 0,
"security_level": null "security_level": null
} }
} }
} }
}, },
{ {
"description": "Passkey pairing: Button press and 6 digit key to pair via Bluetooth.", "description": "JustWorks pairing (default): Button press to pair.",
"config": {
"microbit-dal": {
"bluetooth": {
"open": null,
"pairing_mode": null,
"whitelist": null,
"security_level": null
}
}
}
},
{
"description": "Passkey pairing: Button press and 6 digit key to pair.",
"config": { "config": {
"microbit-dal": { "microbit-dal": {
"bluetooth": { "bluetooth": {
"open": 0, "open": 0,
"pairing_mode": 1, "pairing_mode": 1,
"whitelist": 1,
"security_level": "SECURITY_MODE_ENCRYPTION_WITH_MITM" "security_level": "SECURITY_MODE_ENCRYPTION_WITH_MITM"
} }
} }

View File

@ -83,20 +83,29 @@ declare namespace bluetooth {
/** /**
* Advertise an Eddystone URL * Advertise an Eddystone URL
* @param url the url to transmit. Must be no longer than the supported eddystone url length * @param url the url to transmit. Must be no longer than the supported eddystone url length, eg: "https://pxt.io/"
* @param power power level between 0 and 7, e.g.: 7 * @param power power level between 0 and 7, eg: 7
* @param connectable true to keep bluetooth connectable for other services, false otherwise.
*/ */
//% blockId=eddystone_advertise_url block="bluetooth advertise url %url|with power %power" //% blockId=eddystone_advertise_url block="bluetooth advertise url %url|with power %power|connectable %connectable"
//% parts=bluetooth weight=11 blockGap=8 //% parts=bluetooth weight=11 blockGap=8
//% help=bluetooth/advertise-url shim=bluetooth::advertiseUrl //% help=bluetooth/advertise-url blockExternalInputs=1 shim=bluetooth::advertiseUrl
function advertiseUrl(url: string, power: number): void; function advertiseUrl(url: string, power: number, connectable: boolean): void;
/**
* Sets the bluetooth transmit power between 0 (minimal) and 7 (maximum).
* @param power power level between 0 (minimal) and 7 (maximum), eg: 7.
*/
//% parts=bluetooth weight=5 help=bluetooth/set-transmit-power advanced=true
//% blockId=bluetooth_settransmitpower block="bluetooth set transmit power %power" shim=bluetooth::setTransmitPower
function setTransmitPower(power: number): void;
/** /**
* Stops advertising Eddystone end points * Stops advertising Eddystone end points
*/ */
//% blockId=eddystone_stop_advertising block="bluetooth stop advertising" //% blockId=eddystone_stop_advertising block="bluetooth stop advertising"
//% parts=bluetooth weight=10 //% parts=bluetooth weight=10
//% help=bluetooth/stop-advertising shim=bluetooth::stopAdvertising //% help=bluetooth/stop-advertising advanced=true shim=bluetooth::stopAdvertising
function stopAdvertising(): void; function stopAdvertising(): void;
} }

View File

@ -85,7 +85,7 @@
"game.setLife": "Sets the current life value", "game.setLife": "Sets the current life value",
"game.setLife|param|value": "TODO", "game.setLife|param|value": "TODO",
"game.setScore": "Sets the current score value", "game.setScore": "Sets the current score value",
"game.setScore|param|value": "TODO", "game.setScore|param|value": "new score value.",
"game.showScore": "Displays the score on the screen.", "game.showScore": "Displays the score on the screen.",
"game.startCountdown": "Starts a game countdown timer", "game.startCountdown": "Starts a game countdown timer",
"game.startCountdown|param|ms": "countdown duration in milliseconds, eg: 10000", "game.startCountdown|param|ms": "countdown duration in milliseconds, eg: 10000",

View File

@ -9,6 +9,8 @@
"AcceleratorRange.TwoG|block": "2g", "AcceleratorRange.TwoG|block": "2g",
"BaudRate.BaudRate115200|block": "115200", "BaudRate.BaudRate115200|block": "115200",
"BaudRate.BaudRate9600|block": "9600", "BaudRate.BaudRate9600|block": "9600",
"BeatFraction.Breve|block": "4",
"BeatFraction.Double|block": "2",
"BeatFraction.Eighth|block": "1/8", "BeatFraction.Eighth|block": "1/8",
"BeatFraction.Half|block": "1/2", "BeatFraction.Half|block": "1/2",
"BeatFraction.Quarter|block": "1/4", "BeatFraction.Quarter|block": "1/4",
@ -108,6 +110,7 @@
"game.createSprite|block": "create sprite at|x: %x|y: %y", "game.createSprite|block": "create sprite at|x: %x|y: %y",
"game.gameOver|block": "game over", "game.gameOver|block": "game over",
"game.score|block": "score", "game.score|block": "score",
"game.setScore|block": "set score %points",
"game.startCountdown|block": "start countdown|(ms) %duration", "game.startCountdown|block": "start countdown|(ms) %duration",
"game|block": "game", "game|block": "game",
"images.createBigImage|block": "create big image", "images.createBigImage|block": "create big image",
@ -129,6 +132,7 @@
"input.temperature|block": "temperature (°C)", "input.temperature|block": "temperature (°C)",
"input|block": "input", "input|block": "input",
"led.brightness|block": "brightness", "led.brightness|block": "brightness",
"led.enable|block": "led enable %on",
"led.plotBarGraph|block": "plot bar graph of %value |up to %high", "led.plotBarGraph|block": "plot bar graph of %value |up to %high",
"led.plot|block": "plot|x %x|y %y", "led.plot|block": "plot|x %x|y %y",
"led.point|block": "point|x %x|y %y", "led.point|block": "point|x %x|y %y",

View File

@ -40,7 +40,7 @@ namespace game {
* @param x sprite horizontal coordinate, eg: 2 * @param x sprite horizontal coordinate, eg: 2
* @param y sprite vertical coordinate, eg: 2 * @param y sprite vertical coordinate, eg: 2
*/ */
//% weight=60 //% weight=60 blockGap=8
//% blockId=game_create_sprite block="create sprite at|x: %x|y: %y" //% blockId=game_create_sprite block="create sprite at|x: %x|y: %y"
//% parts="ledmatrix" //% parts="ledmatrix"
export function createSprite(x: number, y: number): LedSprite { export function createSprite(x: number, y: number): LedSprite {
@ -146,8 +146,9 @@ namespace game {
/** /**
* Sets the current score value * Sets the current score value
* @param value TODO * @param value new score value.
*/ */
//% blockId=game_set_score block="set score %points" blockGap=8
//% weight=10 help=game/set-score //% weight=10 help=game/set-score
export function setScore(value: number): void { export function setScore(value: number): void {
_score = Math.max(0, value); _score = Math.max(0, value);
@ -589,7 +590,7 @@ namespace game {
/** /**
* Turns on the sprite (on by default) * Turns on the sprite (on by default)
* @param this TODO * @param this the sprite
*/ */
public on(): void { public on(): void {
this.setBrightness(255); this.setBrightness(255);
@ -597,7 +598,7 @@ namespace game {
/** /**
* Turns off the sprite (on by default) * Turns off the sprite (on by default)
* @param this TODO * @param this the sprite
*/ */
public off(): void { public off(): void {
this.setBrightness(0); this.setBrightness(0);
@ -605,8 +606,8 @@ namespace game {
/** /**
* Set the ``brightness`` of a sprite * Set the ``brightness`` of a sprite
* @param this TODO * @param this the sprite
* @param brightness TODO * @param brightness the brightness from 0 (off) to 255 (on), eg: 255.
*/ */
//% parts="ledmatrix" //% parts="ledmatrix"
public setBrightness(brightness: number): void { public setBrightness(brightness: number): void {
@ -616,8 +617,9 @@ namespace game {
/** /**
* Reports the ``brightness` of a sprite on the LED screen * Reports the ``brightness` of a sprite on the LED screen
* @param this TODO * @param this the sprite
*/ */
//% parts="ledmatrix"
public brightness(): number { public brightness(): number {
let r: number; let r: number;
return this._brightness; return this._brightness;
@ -625,8 +627,8 @@ namespace game {
/** /**
* Changes the ``y`` position by the given amount * Changes the ``y`` position by the given amount
* @param this TODO * @param this the sprite
* @param value TODO * @param value the value to change brightness
*/ */
public changeBrightnessBy(value: number): void { public changeBrightnessBy(value: number): void {
this.setBrightness(this._brightness + value); this.setBrightness(this._brightness + value);
@ -643,10 +645,12 @@ namespace game {
/** /**
* Deletes the sprite from the game engine. All further operation of the sprite will not have any effect. * Deletes the sprite from the game engine. All further operation of the sprite will not have any effect.
* @param sprite TODO * @param this sprite to delete
*/ */
public delete(sprite: LedSprite): void { //% weight=59
sprites.removeElement(sprite); //% blockId="game_delete_sprite" block="delete %this"
public delete(): void {
sprites.removeElement(this);
} }
/** /**

View File

@ -95,7 +95,7 @@ namespace led {
/** /**
* Turns on or off the display * Turns on or off the display
*/ */
//% help=led/enable blockId=device_led_enable icon="\uf04d" //% help=led/enable blockId=device_led_enable block="led enable %on" icon="\uf04d"
//% advanced=true parts="ledmatrix" //% advanced=true parts="ledmatrix"
void enable(bool on) { void enable(bool on) {
if (on) uBit.display.enable(); if (on) uBit.display.enable();

View File

@ -119,7 +119,11 @@ enum BeatFraction {
//% block="1/8" //% block="1/8"
Eighth = 8, Eighth = 8,
//% block="1/16" //% block="1/16"
Sixteenth = 16 Sixteenth = 16,
//% block="2"
Double = 32,
//% block="4",
Breve = 64
} }
/** /**
@ -188,11 +192,15 @@ namespace music {
init(); init();
if (fraction == null) fraction = BeatFraction.Whole; if (fraction == null) fraction = BeatFraction.Whole;
let beat = 60000 / beatsPerMinute; let beat = 60000 / beatsPerMinute;
if (fraction == BeatFraction.Whole) return beat; switch (fraction) {
else if (fraction == BeatFraction.Half) return beat / 2; case BeatFraction.Half: return beat / 2;
else if (fraction == BeatFraction.Quarter) return beat / 4 case BeatFraction.Quarter: return beat / 4;
else if (fraction == BeatFraction.Eighth) return beat / 8; case BeatFraction.Eighth: return beat / 8;
else return beat / 16; case BeatFraction.Sixteenth: return beat / 16;
case BeatFraction.Double: return beat * 2;
case BeatFraction.Breve: return beat * 4;
default: return beat;
}
} }
/** /**

View File

@ -79,7 +79,7 @@ namespace pxt {
intcheck(vtable->methods[0] == &RefRecord_destroy, ERR_SIZE, 3); intcheck(vtable->methods[0] == &RefRecord_destroy, ERR_SIZE, 3);
intcheck(vtable->methods[1] == &RefRecord_print, ERR_SIZE, 4); intcheck(vtable->methods[1] == &RefRecord_print, ERR_SIZE, 4);
void *ptr = ::operator new(vtable->numbytes); void *ptr = ::operator new(vtable->numbytes);
RefRecord *r = new (ptr) RefRecord(PXT_VTABLE_TO_INT(vtable)); RefRecord *r = new (ptr) RefRecord(PXT_VTABLE_TO_INT(vtable));
memset(r->fields, 0, vtable->numbytes - sizeof(RefRecord)); memset(r->fields, 0, vtable->numbytes - sizeof(RefRecord));
@ -117,7 +117,6 @@ namespace pxt {
void RefObject::destroy() { void RefObject::destroy() {
((RefObjectMethod)getVTable()->methods[0])(this); ((RefObjectMethod)getVTable()->methods[0])(this);
delete this;
} }
void RefObject::print() { void RefObject::print() {
@ -132,6 +131,9 @@ namespace pxt {
if (refmask[i]) decr(r->fields[i]); if (refmask[i]) decr(r->fields[i]);
r->fields[i] = 0; r->fields[i] = 0;
} }
//RefRecord is allocated using placement new
r->~RefRecord();
::operator delete(r);
} }
void RefRecord_print(RefRecord *r) void RefRecord_print(RefRecord *r)
@ -242,6 +244,7 @@ namespace pxt {
this->data[i] = 0; this->data[i] = 0;
} }
this->data.resize(0); this->data.resize(0);
delete this;
} }
void RefCollection::print() void RefCollection::print()
@ -258,6 +261,9 @@ namespace pxt {
decr(fields[i]); decr(fields[i]);
fields[i] = 0; fields[i] = 0;
} }
//RefAction is allocated using placement new
this->~RefAction();
::operator delete(this);
} }
void RefAction::print() void RefAction::print()
@ -272,6 +278,7 @@ namespace pxt {
void RefLocal::destroy() void RefLocal::destroy()
{ {
delete this;
} }
PXT_VTABLE_CTOR(RefLocal) { PXT_VTABLE_CTOR(RefLocal) {
@ -290,6 +297,7 @@ namespace pxt {
void RefRefLocal::destroy() void RefRefLocal::destroy()
{ {
decr(v); decr(v);
delete this;
} }
PXT_VTABLE_BEGIN(RefMap, 0, RefMapMarker) PXT_VTABLE_BEGIN(RefMap, 0, RefMapMarker)
@ -304,6 +312,7 @@ namespace pxt {
data[i].val = 0; data[i].val = 0;
} }
data.resize(0); data.resize(0);
delete this;
} }
int RefMap::findIdx(uint32_t key) { int RefMap::findIdx(uint32_t key) {
@ -328,7 +337,7 @@ namespace pxt {
for(std::set<RefObject*>::iterator itr = allptrs.begin();itr!=allptrs.end();itr++) for(std::set<RefObject*>::iterator itr = allptrs.begin();itr!=allptrs.end();itr++)
{ {
(*itr)->print(); (*itr)->print();
} }
printf("\n"); printf("\n");
} }
#else #else
@ -341,16 +350,16 @@ namespace pxt {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
map<pair<int, int>, Action> handlersMap; map<pair<int, int>, Action> handlersMap;
MicroBitEvent lastEvent; MicroBitEvent lastEvent;
// We have the invariant that if [dispatchEvent] is registered against the DAL // We have the invariant that if [dispatchEvent] is registered against the DAL
// for a given event, then [handlersMap] contains a valid entry for that // for a given event, then [handlersMap] contains a valid entry for that
// event. // event.
void dispatchEvent(MicroBitEvent e) { void dispatchEvent(MicroBitEvent e) {
lastEvent = e; lastEvent = e;
Action curr = handlersMap[{ e.source, e.value }]; Action curr = handlersMap[{ e.source, e.value }];
if (curr) if (curr)
runAction1(curr, e.value); runAction1(curr, e.value);
@ -383,7 +392,7 @@ namespace pxt {
create_fiber((void(*)(void*))runAction0, (void*)a, fiberDone); create_fiber((void(*)(void*))runAction0, (void*)a, fiberDone);
} }
} }
void error(ERROR code, int subcode) void error(ERROR code, int subcode)
{ {
@ -435,10 +444,10 @@ namespace pxt {
// unique group for radio based on source hash // unique group for radio based on source hash
// ::touch_develop::micro_bit::radioDefaultGroup = programHash(); // ::touch_develop::micro_bit::radioDefaultGroup = programHash();
// repeat error 4 times and restart as needed // repeat error 4 times and restart as needed
microbit_panic_timeout(4); microbit_panic_timeout(4);
int32_t ver = *pc++; int32_t ver = *pc++;
checkStr(ver == 0x4209, ":( Bad runtime version"); checkStr(ver == 0x4209, ":( Bad runtime version");
@ -467,6 +476,6 @@ namespace pxt {
{ {
exec_binary((int32_t*)functionsAndBytecode); exec_binary((int32_t*)functionsAndBytecode);
} }
} }
// vim: ts=2 sw=2 expandtab // vim: ts=2 sw=2 expandtab

View File

@ -497,7 +497,7 @@ declare namespace led {
/** /**
* Turns on or off the display * Turns on or off the display
*/ */
//% help=led/enable blockId=device_led_enable icon="\uf04d" //% help=led/enable blockId=device_led_enable block="led enable %on" icon="\uf04d"
//% advanced=true parts="ledmatrix" shim=led::enable //% advanced=true parts="ledmatrix" shim=led::enable
function enable(on: boolean): void; function enable(on: boolean): void;

View File

@ -1,6 +1,6 @@
{ {
"name": "devices", "name": "devices",
"description": "The BLE specific services", "description": "Camera, remote control and other Bluetooth services",
"files": [ "files": [
"README.md", "README.md",
"enums.d.ts", "enums.d.ts",
@ -9,16 +9,8 @@
], ],
"public": true, "public": true,
"dependencies": { "dependencies": {
"core": "file:../core" "core": "file:../core",
}, "bluetooth": "file:../bluetooth"
"yotta": {
"config": {
"microbit-dal": {
"bluetooth": {
"enabled": 1
}
}
}
}, },
"installedVersion": "ljipgq" "installedVersion": "ljipgq"
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "pxt-microbit", "name": "pxt-microbit",
"version": "0.6.23", "version": "0.6.35",
"description": "micro:bit target for PXT", "description": "micro:bit target for PXT",
"keywords": [ "keywords": [
"JavaScript", "JavaScript",
@ -34,6 +34,6 @@
"semantic-ui-less": "^2.2.4" "semantic-ui-less": "^2.2.4"
}, },
"dependencies": { "dependencies": {
"pxt-core": "0.5.85" "pxt-core": "0.5.98"
} }
} }

View File

@ -173,15 +173,16 @@
"appTheme": { "appTheme": {
"accentColor": "#5C005C", "accentColor": "#5C005C",
"logoUrl": "http://microbit.org/", "logoUrl": "http://microbit.org/",
"logo": "./static/logo.portrait.black.svg", "logo": "./static/logo.portrait.white.svg",
"docsLogo": "./static/logo.square.white.svg", "docsLogo": "./static/logo.square.white.svg",
"portraitLogo": "./static/logo.square.black.svg", "portraitLogo": "./static/logo.square.white.svg",
"footerLogo": "./static/logo.portrait.black.svg", "footerLogo": "./static/logo.portrait.black.svg",
"cardLogo": "./static/icons/apple-touch-icon.png", "cardLogo": "./static/icons/apple-touch-icon.png",
"appLogo": "./static/icons/apple-touch-icon.png", "appLogo": "./static/icons/apple-touch-icon.png",
"organization": "Microsoft", "organization": "Microsoft",
"organizationUrl": "https://pxt.io/", "organizationUrl": "https://pxt.io/",
"organizationLogo": "./static/Microsoft-logo_rgb_c-gray.png", "organizationLogo": "./static/Microsoft-logo_rgb_c-gray.png",
"organizationWideLogo": "./static/Microsoft-logo_rgb_c-white.png",
"homeUrl": "https://pxt.microbit.org/", "homeUrl": "https://pxt.microbit.org/",
"embedUrl": "https://pxt.microbit.org/", "embedUrl": "https://pxt.microbit.org/",
"privacyUrl": "https://go.microsoft.com/fwlink/?LinkId=521839", "privacyUrl": "https://go.microsoft.com/fwlink/?LinkId=521839",
@ -311,6 +312,16 @@
"browser": "*", "browser": "*",
"path": "/static/mb/device/usb-windows-sendto.jpg" "path": "/static/mb/device/usb-windows-sendto.jpg"
} }
] ],
"invertedMenu": true,
"coloredToolbox": true,
"blocklyOptions": {
"grid": {
"spacing": 45,
"length": 7,
"colour": "rgba(189, 195, 199, 0.30)",
"snap": false
}
}
} }
} }

View File

@ -23,15 +23,15 @@ namespace pxsim.input {
} }
export function rotation(kind: number): number { export function rotation(kind: number): number {
let b = board().accelerometerState; const b = board().accelerometerState;
let acc = b.accelerometer; const acc = b.accelerometer;
acc.activate(); acc.activate();
let x = acc.getX(MicroBitCoordinateSystem.NORTH_EAST_DOWN); const x = acc.getX(MicroBitCoordinateSystem.NORTH_EAST_DOWN);
let y = acc.getX(MicroBitCoordinateSystem.NORTH_EAST_DOWN); const y = acc.getY(MicroBitCoordinateSystem.NORTH_EAST_DOWN);
let z = acc.getX(MicroBitCoordinateSystem.NORTH_EAST_DOWN); const z = acc.getZ(MicroBitCoordinateSystem.NORTH_EAST_DOWN);
let roll = Math.atan2(y, z); const roll = Math.atan2(y, z);
let pitch = Math.atan(-x / (y * Math.sin(roll) + z * Math.cos(roll))); const pitch = Math.atan(-x / (y * Math.sin(roll) + z * Math.cos(roll)));
let r = 0; let r = 0;
switch (kind) { switch (kind) {

View File

@ -177,7 +177,8 @@ namespace pxsim.bluetooth {
export function onBluetoothDisconnected(a: RefAction) { export function onBluetoothDisconnected(a: RefAction) {
// TODO // TODO
} }
export function advertiseUrl(url: string, power: number) { } export function advertiseUrl(url: string, power: number, connectable: boolean) { }
export function stopAdvertising() { } export function stopAdvertising() { }
export function setTransmitPower(power: number) {}
} }

View File

@ -556,12 +556,12 @@ namespace pxsim.visuals {
private updateTilt() { private updateTilt() {
if (this.props.disableTilt) return; if (this.props.disableTilt) return;
let state = this.board; const state = this.board;
if (!state || !state.accelerometerState.accelerometer.isActive) return; if (!state || !state.accelerometerState.accelerometer.isActive) return;
let x = state.accelerometerState.accelerometer.getX(); const x = state.accelerometerState.accelerometer.getX();
let y = state.accelerometerState.accelerometer.getY(); const y = -state.accelerometerState.accelerometer.getY();
let af = 8 / 1023; const af = 8 / 1023;
this.element.style.transform = "perspective(30em) rotateX(" + y * af + "deg) rotateY(" + x * af + "deg)" this.element.style.transform = "perspective(30em) rotateX(" + y * af + "deg) rotateY(" + x * af + "deg)"
this.element.style.perspectiveOrigin = "50% 50% 50%"; this.element.style.perspectiveOrigin = "50% 50% 50%";
@ -704,7 +704,7 @@ namespace pxsim.visuals {
} }
let tiltDecayer = 0; let tiltDecayer = 0;
this.element.addEventListener(pointerEvents.move, (ev: MouseEvent) => { this.element.addEventListener(pointerEvents.move, (ev: MouseEvent) => {
let state = this.board; const state = this.board;
if (!state.accelerometerState.accelerometer.isActive) return; if (!state.accelerometerState.accelerometer.isActive) return;
if (tiltDecayer) { if (tiltDecayer) {
@ -712,14 +712,14 @@ namespace pxsim.visuals {
tiltDecayer = 0; tiltDecayer = 0;
} }
let bbox = this.element.getBoundingClientRect(); const bbox = this.element.getBoundingClientRect();
let ax = (ev.clientX - bbox.width / 2) / (bbox.width / 3); const ax = (ev.clientX - bbox.width / 2) / (bbox.width / 3);
let ay = (ev.clientY - bbox.height / 2) / (bbox.height / 3); const ay = (ev.clientY - bbox.height / 2) / (bbox.height / 3);
let x = - Math.max(- 1023, Math.min(1023, Math.floor(ax * 1023))); const x = - Math.max(- 1023, Math.min(1023, Math.floor(ax * 1023)));
let y = Math.max(- 1023, Math.min(1023, Math.floor(ay * 1023))); const y = - Math.max(- 1023, Math.min(1023, Math.floor(ay * 1023)));
let z2 = 1023 * 1023 - x * x - y * y; const z2 = 1023 * 1023 - x * x - y * y;
let z = Math.floor((z2 > 0 ? -1 : 1) * Math.sqrt(Math.abs(z2))); const z = Math.floor((z2 > 0 ? -1 : 1) * Math.sqrt(Math.abs(z2)));
state.accelerometerState.accelerometer.update(x, y, z); state.accelerometerState.accelerometer.update(x, y, z);
this.updateTilt(); this.updateTilt();

View File

@ -1,3 +1,12 @@
/******************************* /*******************************
User Variable Overrides User Variable Overrides
*******************************/ *******************************/
@invertedBackground: #3454D1;
/*******************************
PXT Theme Overrides
*******************************/
@mainMenuHeight: 5rem;
@mainMenuMinHeight: (@itemVerticalPadding * 2) + 2em;

View File

@ -1,3 +1,35 @@
/******************************* /*******************************
User Global Variables User Global Variables
*******************************/ *******************************/
@importGoogleFonts: true;
@fontName : 'Roboto';
@emSize : 14px;
@fontSize : 13px;
@primaryColor: @purple;
@teal: #3891A6;
@blue: #456990;
@red: #EF767A;
@pink: #F46197;
@yellow: #FDE74C;
/* Microbit.org colors */
@orange: #ff8b27;
@purple: #6633cc;
@green: #00ED00;
@pageBackground: #fff;
/*******************************
PXT Overrides
*******************************/
@mainMenuHeight: 5rem;
@mobileMenuHeight: 5rem;
@simulatorBackground: #FDFDFF;
@blocklySvgColor: #ecf0f1;

View File

@ -13,7 +13,137 @@
*******************************/ *******************************/
.download-button { .download-button {
&:extend(.ui all); &:extend(.ui.button all);
&:extend(.button all); &:extend(.purple all);
}
.download-button.download-button-full {
&:extend(.ui.inverted.purple.button all);
}
.download-button:hover {
&:extend(.green all); &:extend(.green all);
} color: black !important;
}
.play-button.play-button-full {
&:extend(.ui.inverted.button all);
}
.getting-started-btn {
&:extend(.ui.button all);
&:extend(.orange all);
}
#filelist {
background: #fff url(https://az742082.vo.msecnd.net/pub/psopafpj) 0 0 repeat !important;
}
/*******************************
Blockly
*******************************/
.blocklyTreeRow {
border-bottom: 1px solid #ecf0f1 !important;
margin-bottom: 0px !important;
}
/* Blockly toolbox font size same as the page font */
.blocklyTreeLabel {
font-family: @pageFont !important;
font-weight: 200;
}
.blocklyToolboxDiv, .monacoToolboxDiv {
background-color: white !important;
border-left: 1px solid #ecf0f1 !important;
}
.blocklyFlyoutBackground {
fill: #525A67 !important;
fill-opacity: 0.5 !important;
}
/* Remove shadow around blockly blocks */
.blocklyPathDark, .blocklyPathLight {
display: none;
}
.organization {
top: 1.6em;
}
/* Blockly Toolbox Buttons */
#blocklyToolboxButtons .blocklyAddPackageButton {
&:extend(.ui.inverted.pink.button all);
&:extend(.circular all);
}
#blocklyToolboxButtons .blocklyUndoButton {
&:extend(.ui.inverted.blue.button all);
&:extend(.circular all);
}
/*******************************
Monaco
*******************************/
.monaco-editor, .monaco-editor .inputarea {
background: #ecf0f1;
}
.monaco-editor-background {
background: #ecf0f1;
}
.monacoFlyout {
background: rgba(82, 90, 103, 0.8);
}
/* Mobile */
@media only screen and (max-width: @largestMobileScreen) {
#filelist {
background: transparent !important;
}
.organization {
top: auto;
}
}
/* Tablet */
@media only screen and (min-width: @tabletBreakpoint) and (max-width: @largestTabletScreen) {
.organization {
top: auto;
}
/* Blockly Toolbox buttons */
#blocklyToolboxButtons {
margin-right: 0.5rem;
margin-left: 0.5rem;
}
}
/* Small Monitor */
@media only screen and (min-width: @computerBreakpoint) and (max-width: @largestSmallMonitor) {
.organization {
top: auto;
}
/* Blockly Toolbox buttons */
#blocklyToolboxButtons {
margin-right: 1rem;
margin-left: 1rem;
}
}
/* Large Monitor */
@media only screen and (min-width: @largeMonitorBreakpoint) {
.blocklyTreeRow {
width: 230px;
padding-left: 1rem;
}
/* Blockly Toolbox buttons */
#blocklyToolboxButtons {
margin-right: 2rem;
margin-left: 2rem;
}
}

View File

@ -32,7 +32,7 @@
@input : 'pxt'; @input : 'pxt';
@label : 'pxt'; @label : 'pxt';
@list : 'pxt'; @list : 'pxt';
@loader : 'pxt'; @loader : 'pulsar';
@rail : 'pxt'; @rail : 'pxt';
@reveal : 'pxt'; @reveal : 'pxt';
@segment : 'pxt'; @segment : 'pxt';
@ -41,7 +41,7 @@
/* Collections */ /* Collections */
@breadcrumb : 'default'; @breadcrumb : 'default';
@form : 'default'; @form : 'default';
@grid : 'default'; @grid : 'pxt';
@menu : 'pxt'; @menu : 'pxt';
@message : 'default'; @message : 'default';
@table : 'default'; @table : 'default';
@ -91,7 +91,9 @@
@fontPath : 'fonts'; @fontPath : 'fonts';
/*
@headerFont : 'Segoe UI', 'Helvetica Neue', Arial, Helvetica, sans-serif; @headerFont : 'Segoe UI', 'Helvetica Neue', Arial, Helvetica, sans-serif;
@pageFont : 'Segoe UI', 'Helvetica Neue', Arial, Helvetica, sans-serif; @pageFont : 'Segoe UI', 'Helvetica Neue', Arial, Helvetica, sans-serif;
*/
/* End Config */ /* End Config */