Compare commits

...

18 Commits

Author SHA1 Message Date
Peli de Halleux
8e581eaa41 0.9.36 2017-03-01 14:58:46 -08:00
Peli de Halleux
4252829a9e moving setgroup to main category (#362) 2017-03-01 14:57:47 -08:00
Peli de Halleux
d4475645f4 updated to lancaster rc8 (#363) 2017-03-01 14:57:40 -08:00
Richard Knoll
44beec4661 Adding docs for always decompile blocks (#360)
* Adding docs for always decompile blocks

* Renaming file and adding example

* Adding link to javascript blocks
2017-03-01 14:51:39 -08:00
Peli de Halleux
bd1f5a2b75 support for recorder (#361) 2017-03-01 14:24:59 -08:00
Sam El-Husseini
2cd3bca8db Release Candidate release 2017-03-01 14:02:09 -08:00
Sam El-Husseini
7d751fa322 0.9.35 2017-03-01 13:43:02 -08:00
Sam El-Husseini
3ee7c7f0b2 0.9.34 2017-03-01 13:36:08 -08:00
Sam El-Husseini
4ebeee7cf2 Bump pxt-core to 0.11.59 2017-03-01 13:36:07 -08:00
Sam El-Husseini
ea3cf55670 0.9.33 2017-03-01 13:35:50 -08:00
Sam El-Husseini
7c1b761964 Swapping play builtin melody with begin melody in reference docs 2017-03-01 00:38:12 -08:00
Sam El-Husseini
b0fddd7e72 Fix melody reference docs. 2017-03-01 00:34:31 -08:00
Sam El-Husseini
5a1321c711 0.9.32 2017-03-01 00:24:54 -08:00
Sam El-Husseini
e448512a3a Bump pxt-core to 0.11.58 2017-03-01 00:24:53 -08:00
Sam El-Husseini
f67e79ff3e 0.9.31 2017-03-01 00:20:08 -08:00
Sam El-Husseini
ae6108e4fe 0.9.30 2017-03-01 00:19:41 -08:00
Sam El-Husseini
0fac3cac8f 0.9.29 2017-03-01 00:19:12 -08:00
Sam El-Husseini
a67d9ef1ab 0.9.28 2017-03-01 00:13:50 -08:00
11 changed files with 93 additions and 21 deletions

View File

@@ -15,4 +15,4 @@ Math.random(5);
## See Also
[logic](/blocks/logic), [loops](/blocks/loops), [math](/blocks/math), [variables](/blocks/variables), [on-start](/blocks/on-start)
[logic](/blocks/logic), [loops](/blocks/loops), [math](/blocks/math), [variables](/blocks/variables), [on-start](/blocks/on-start), [javascript blocks](/blocks/javascript-blocks)

View File

@@ -0,0 +1,65 @@
# JavaScript Block
JavaScript is a very powerful language; so powerful that some concepts in
JavaScript can't be shown using blocks. When PXT encounters a piece of code
that can't be converted into blocks, it instead creates a grey JavaScript block
to preserve it. These blocks get converted right back into the original
JavaScript when you switch back to the text editor.
```blocks
for (let index = 0; index <= 5; index++) {
basic.showNumber(fibonacci(index))
}
function fibonacci(n: number): number {
if (n === 0 || n === 1) {
return 1;
}
return fibonacci(n - 1) + fibonacci(n - 2);
}
```
The code in JavaScript blocks cannot be edited, but the blocks
themselves can be moved, copied, pasted, and deleted just like any
other block.
## How do I get my JavaScript code to convert without any grey blocks?
The easiest way to write code that will convert cleanly back to blocks
is to write the code using blocks and convert it to JavaScript. Many blocks
have a very specifc structure to their JavaScript that must be
followed in order to have them convert properly. If you have a
piece of your code that does not convert, try looking at the block
you were expecting and the JavaScript it produces.
For example, a for-loop must have this structure to convert to a block:
```typescript
for (let x = 0; x <= 5; x++) {
}
```
The following examples can't be represented by the blocks:
```typescript
// Condition must be either < or <= with a variable on the left side
for (let x = 0; x > -1; x++) {
}
// The variable in the condition and incrementor must be the declared variable
for (let x = 0; x <= 5; y++) {
}
// The declared variable must be initialized to 0
for (let x = 2; x <= 5; x++) {
}
// All three parts of the for-loop must be present
for (;;) {
}
```
Try to match the JavaScript of the desired block as closely as
possible.

View File

@@ -1,3 +1,3 @@
{
"appref": "v0.9.23"
"appref": "v0.9.35"
}

View File

@@ -1,25 +1,25 @@
# Play Built-in Melody
# Begin Melody
Play a built in musical melody through pin ``P0`` of the @boardname@.
Begin playing a musical melody through pin ``P0`` of the @boardname@.
## Simulator
This function only works on the @boardname@ and in some browsers.
```sig
music.playBuiltinMelody(Melodies.Entertainer)
music.beginMelody(music.builtInMelody(Melodies.Entertainer), MelodyOptions.Once)
```
### Parameters
* ``melody`` is the kind of built-in melody you want to play
* ``melody`` is the array representation of a melody you wish to play
## Example
This example plays the ``Entertainer`` melody.
This example plays the ``Entertainer`` built-in melody.
```blocks
music.playBuiltinMelody(Melodies.Entertainer)
music.beginMelody(music.builtInMelody(Melodies.Entertainer), MelodyOptions.Once)
```
### See also

10
libs/core/dal.d.ts vendored
View File

@@ -81,6 +81,9 @@ declare const enum DAL {
MICROBIT_BLE_MAXIMUM_BONDS = 4,
MICROBIT_BLE_EDDYSTONE_ADV_INTERVAL = 400,
MICROBIT_BLE_EDDYSTONE_DEFAULT_POWER = 0xF0,
MICROBIT_BLE_STATUS_STORE_SYSATTR = 0x02,
MICROBIT_BLE_STATUS_DISCONNECT = 0x04,
MICROBIT_BLE_DISCONNECT_AFTER_PAIRING_DELAY = 500,
// built/yt/yotta_modules/microbit-dal/inc/bluetooth/MicroBitButtonService.h
// built/yt/yotta_modules/microbit-dal/inc/bluetooth/MicroBitDFUService.h
MICROBIT_DFU_OPCODE_START_DFU = 1,
@@ -191,10 +194,7 @@ declare const enum DAL {
MICROBIT_SERIAL_EVT_TX_EMPTY = 2,
MICROBIT_UART_S_EVT_TX_EMPTY = 3,
// built/yt/yotta_modules/microbit-dal/inc/drivers/DynamicPwm.h
NO_PWMS = 3,
MICROBIT_DEFAULT_PWM_PERIOD = 20000,
PWM_PERSISTENCE_TRANSIENT = 1,
PWM_PERSISTENCE_PERSISTENT = 2,
// built/yt/yotta_modules/microbit-dal/inc/drivers/MicroBitAccelerometer.h
MICROBIT_ACCEL_PITCH_ROLL_VALID = 0x02,
MICROBIT_ACCEL_ADDED_TO_IDLE = 0x04,
@@ -375,8 +375,8 @@ declare const enum DAL {
MICROBIT_PIN_EVT_FALL = 3,
MICROBIT_PIN_EVT_PULSE_HI = 4,
MICROBIT_PIN_EVT_PULSE_LO = 5,
PIN_CAPABILITY_DIGITAL = 0x01,
PIN_CAPABILITY_ANALOG = 0x02,
PIN_CAPABILITY_DIGITAL_IN = 0x01,
PIN_CAPABILITY_DIGITAL_OUT = 0x02,
// built/yt/yotta_modules/microbit-dal/inc/drivers/MicroBitRadio.h
MICROBIT_RADIO_STATUS_INITIALISED = 0x0001,
MICROBIT_RADIO_BASE_ADDRESS = 0x75626974,

View File

@@ -274,7 +274,7 @@ namespace music {
* @param melody the melody array to play, eg: ['g5:1']
* @param options melody options, once / forever, in the foreground / background
*/
//% help=music/start-melody weight=60
//% help=music/begin-melody weight=60
//% blockId=device_start_melody block="start|melody %melody=device_builtin_melody| repeating %options"
//% parts="headphone"
export function beginMelody(melodyArray: string[], options: MelodyOptions = MelodyOptions.Once) {

View File

@@ -317,7 +317,7 @@ namespace radio {
* @ param id the group id between ``0`` and ``255``, 1 eg
*/
//% help=radio/set-group
//% weight=10 blockGap=8 advanced=true
//% weight=10 blockGap=8
//% blockId=radio_set_group block="radio set group %ID"
void setGroup(int id) {
if (radioEnable() != MICROBIT_OK) return;

View File

@@ -98,7 +98,7 @@ declare namespace radio {
* @ param id the group id between ``0`` and ``255``, 1 eg
*/
//% help=radio/set-group
//% weight=10 blockGap=8 advanced=true
//% weight=10 blockGap=8
//% blockId=radio_set_group block="radio set group %ID" shim=radio::setGroup
function setGroup(id: number): void;

View File

@@ -1,6 +1,6 @@
{
"name": "pxt-microbit",
"version": "0.9.27",
"version": "0.9.36",
"description": "micro:bit target for PXT",
"keywords": [
"JavaScript",
@@ -36,6 +36,6 @@
"semantic-ui-less": "^2.2.4"
},
"dependencies": {
"pxt-core": "0.11.51"
"pxt-core": "0.11.59"
}
}

View File

@@ -181,7 +181,7 @@
"yottaTarget": "bbc-microbit-classic-gcc",
"yottaCorePackage": "microbit",
"githubCorePackage": "lancaster-university/microbit",
"gittag": "v2.0.0-rc7",
"gittag": "v2.0.0-rc8",
"serviceId": "microbit"
},
"serial": {

View File

@@ -16,6 +16,9 @@ namespace pxsim {
neopixelState: NeoPixelState;
fileSystem: FileSystemState;
// visual
view: SVGElement;
constructor() {
super()
@@ -123,10 +126,14 @@ namespace pxsim {
}), opts);
document.body.innerHTML = ""; // clear children
document.body.appendChild(viewHost.getView());
document.body.appendChild(this.view = viewHost.getView());
return Promise.resolve();
}
screenshot(): string {
return svg.toDataUri(new XMLSerializer().serializeToString(this.view));
}
}
export function initRuntimeWithDalBoard() {