Compare commits

...

12 Commits

Author SHA1 Message Date
8c474c899c 0.7.49 2017-01-31 08:29:58 -08:00
48bb0e238a Bump pxt-core to 0.11.6 2017-01-31 08:29:56 -08:00
1d47b4de0d Lightmonster (#346)
* fixed boardname issues

* refactored servo info

* coffee cup monster lesson skeleton

* display event source id / value in advanced section

* normalized project structure

* updated project name

* Update projects.md
2017-01-31 08:29:25 -08:00
595e4a23e6 package approval docs (#344)
* updated docs

* @jaustin comments

* Update packages.md
2017-01-31 08:28:33 -08:00
72d5e83e5b Exposing pin eventOn method (#349) 2017-01-30 19:19:54 +00:00
436b56a2fa 0.7.48 2017-01-29 22:25:42 -08:00
7a41730f82 Bump pxt-core to 0.11.4 2017-01-29 22:25:41 -08:00
372ddfa641 0.7.47 2017-01-28 22:46:03 -08:00
30078923a3 Bump pxt-core to 0.11.3 2017-01-28 22:46:02 -08:00
5ab9222200 0.7.46 2017-01-28 21:59:48 -08:00
8ae5a48f1e Bump pxt-core to 0.11.2 2017-01-28 21:59:48 -08:00
f9ed37d07b Using pxtsemantic optimization 2017-01-28 21:55:48 -08:00
38 changed files with 364 additions and 118 deletions

View File

@ -1,5 +1,5 @@
# microbit-chrome # microbit-chrome
Prototype chrome addon that exposes the micro:bit's serial output to webpages. Prototype chrome addon that exposes the @boardname@'s serial output to webpages.
* watch the [demo video](https://vimeo.com/146207766) * watch the [demo video](https://vimeo.com/146207766)
# Installation # Installation

View File

@ -1,13 +1,4 @@
# Preparing the servo # Equipping a microservo with Crocodile clips
### @description Connecting the servo to crocodile clips
### ~avatar avatar
Equip the microservo with crocodile clips.
### ~
## Duration: ~30 minutes
## Materials ## Materials
* Cutting pliers or wire cutter * Cutting pliers or wire cutter
@ -70,7 +61,7 @@ Place the cables next to each other
It is very **important** to ensure that there is a good connection between the 2 cables. It is very **important** to ensure that there is a good connection between the 2 cables.
If the connection is weak, the microservo will not receive enough current and it will not work. If the connection is weak, the microservo will not receive enough current and it will not work.
If you have access to a soldering iron, we strongly recommend to solver this connection. **If you have access to a soldering iron, we strongly recommend to solder this connection.**
### ~ ### ~
@ -105,11 +96,9 @@ When attaching the crocodile clips to the pins, don't hesitate to grab the side
* Download the following code to your @boardname@ * Download the following code to your @boardname@
```blocks ```blocks
let a = 0
basic.forever(() => { basic.forever(() => {
a = input.acceleration(Dimension.X)
pins.servoWritePin(AnalogPin.P0, pins.map( pins.servoWritePin(AnalogPin.P0, pins.map(
a, input.acceleration(Dimension.X),
-512, -512,
512, 512,
0, 0,
@ -121,10 +110,7 @@ basic.forever(() => {
* When powered by USB, make sure that the servo moves when you tilt the board. * When powered by USB, make sure that the servo moves when you tilt the board.
* When powered by batteries **only**, make sure that the servo moves when you tilt the board. * When powered by batteries **only**, make sure that the servo moves when you tilt the board.
## Troubleshooting
If your servo seems to sutter and stay stuck at a particular position, it means that it is not receiving enough power. If your servo seems to sutter and stay stuck at a particular position, it means that it is not receiving enough power.
This is probably due to a weak connection or low battery level. Check each connection and check your batteries. This is probably due to a weak connection or low battery level. Check each connection and check your batteries.
### ~button /projects/inchworm/chassis
NEXT: Chassis
### ~

View File

@ -5,25 +5,46 @@ that users can then add to their scripts. These typically
provide a driver for a particular hardware device you can connect provide a driver for a particular hardware device you can connect
to a microbit. to a microbit.
* [pxt-max6675](https://github.com/Microsoft/pxt-max6675) -- TypeScript ### ~ hint
All packages need to be approved by the Micro:bit Foundation before being available in the web editor.
See **Approval** section below.
### ~
* [pxt-neopixel](https://github.com/Microsoft/pxt-neopixel) -- TypeScript + ARM Thumb assembly package * [pxt-neopixel](https://github.com/Microsoft/pxt-neopixel) -- TypeScript + ARM Thumb assembly package
* [pxt-max6675](https://github.com/Microsoft/pxt-max6675) -- TypeScript
* [pxt-sonar](https://github.com/microsoft/pxt-sonar) -- TypeScript * [pxt-sonar](https://github.com/microsoft/pxt-sonar) -- TypeScript
* [pxt-i2c-fram](https://github.com/microsoft/pxt-i2c-fram) -- TypeScript * [pxt-i2c-fram](https://github.com/microsoft/pxt-i2c-fram) -- TypeScript
* [Sample C++ extension](https://github.com/Microsoft/pxt-microbit-cppsample) * [Sample C++ extension](https://github.com/Microsoft/pxt-microbit-cppsample)
* [Sample TypeScript extension](https://github.com/Microsoft/pxt-microbit/tree/master/libs/i2c-fram)
## Finding packages ## Finding packages
From the editor, the user clicks on **More** then **Add Package** and searches for the package. From the block editor, the user clicks on **Add Package** and searches for the package.
Otherwise, the **Add Package** is also available from the gearwheel menu.
To see the list of packages, click on **More** then **Show Files** to see the project file list. To see the list of packages, switch to JavaScript and use the **Explorer** view to find them.
To remove a package, click on the garbage button in the file list next to the package. To remove a package, click on the garbage button in the **Explorer** view next to the package.
## Publishing packages ## Publishing and Approving packages
Packages can be published from the pxt command line. Check out [the docs](https://www.pxt.io/packages). Once your package is ready, follow these steps to get it approved and listed in the pxt.microbit.org web site:
1. setup a public GitHub repository with your package sources
2. ensure that the license is **Apache2** or **MIT**
3. fill ``test.ts`` with a test scenario
4. ensure that the package builds by running ``pxt`` from the package folder. [Read more...](https://www.pxt.io/packages).
5. fill up the ``README.md`` file with documentation. See [markdown docs](https://pxt.io/writing-docs) for syntax.
6. publish a release by running ``pxt bump`` from the package folder.
7. open a support ticket at https://support.microbit.org, add **package approval** in the subject line.
```
Package approval request
github repo: .....
```
## Localizing packages ## Localizing packages

View File

@ -62,17 +62,13 @@ Fun games to build with your @boardname@.
}] }]
``` ```
## Science and Engineering ## Toys
```codecard ```codecard
[{ [{
"name": "Inchworm", "name": "Inchworm",
"url":"/projects/inchworm", "url":"/projects/inchworm",
"imageUrl":"/static/mb/projects/inchworm.jpg" "imageUrl":"/static/mb/projects/inchworm.jpg"
}, {
"name": "Timing gates",
"url":"/projects/timing-gates",
"imageUrl":"/static/mb/projects/timing-gates.jpg"
}] }]
``` ```
@ -80,6 +76,10 @@ Fun games to build with your @boardname@.
```codecard ```codecard
[{ [{
"name": "Timing gates",
"url":"/projects/timing-gates",
"imageUrl":"/static/mb/projects/timing-gates.jpg"
}, {
"name": "Compass", "name": "Compass",
"url":"/projects/compass", "url":"/projects/compass",
"imageUrl":"/static/mb/projects/a5-compass.png" "imageUrl":"/static/mb/projects/a5-compass.png"

View File

@ -21,8 +21,8 @@ Build your own @boardname@ piano using bananas!
## Activities ## Activities
* [Making the keyboard](/projects/banana-keyboard/make) * [Make](/projects/banana-keyboard/make)
* [Beat box](/projects/banana-keyboard/beat-box) * [Code](/projects/banana-keyboard/code)
### ~button /projects/banana-keyboard/make ### ~button /projects/banana-keyboard/make
Let's get started! Let's get started!

View File

@ -1,4 +1,4 @@
# banana keyboard - beat box # Code
Have you ever tried to making beat box sounds? Let's try making a beatbox with code! Have you ever tried to making beat box sounds? Let's try making a beatbox with code!

View File

@ -1,4 +1,4 @@
# banana keyboard - making # Make
## Materials ## Materials
@ -80,6 +80,6 @@ input.onPinPressed(TouchPin.P1, () => {
Tap your banana instrument to play sound against... the fruit! Tap your banana instrument to play sound against... the fruit!
### ~button /projects/banana-keyboard/beat-box ### ~button /projects/banana-keyboard/code
NEXT: beat box NEXT: beat box
### ~ ### ~

View File

@ -0,0 +1,43 @@
# Coffee Cup Monster
### @description A monster made of cardboard that responds to light
### ~avatar avatar
Make a coffee cup monster that responds to light!
### ~
https://youtu.be/BiZLjugXMbM
## Duration
3 Activities, approx 30-45 min each based on familiarity with the coding concepts
## Materials
* 3 Coffee cup holders
* 2 Coffee cup strirer wood sticks
* Glue gun
* Scissors that can cut cardboard
* 1 @boardname@, battery holder and 2 AAA batteries
* 3 Crocodile clips
* 1 micro servo 9g SG90
* 1 paper clip
## Preparation
* [Equip the microservo with crocodile clips](/device/servo)
## Activities
* [Make](/projects/coffee-cup-monster/make)
* [Code](/projects/coffee-cup-monster/code)
* [Connect](/projects/coffee-cup-monster/connect)
### ~button /projects/coffee-cup-monster/make
Let's get started!
### ~

View File

@ -0,0 +1,29 @@
# Code
### @description code to make the coffee cup monster alive
### ~avatar avatar
Add code to open the mouth when light is detected.
### ~
## Duration: ~30 minutes
We are going to add code to open the mouth proportionally to the amount of light on the @boardname@.
In a loop, we will read the light and map it to an angle using the ``pins.map`` function.
```blocks
basic.forever(() => {
pins.servoWritePin(AnalogPin.P0, pins.map(
input.lightLevel(),
0,
255,
30,
150
))
})
```
### ~button /projects/coffee-cup-monster/connect
NEXT: Connect
### ~

View File

@ -0,0 +1,29 @@
# Connect
### ~avatar avatar
Remote control your monster with another @boardname@
### ~
## Duration: ~30 minutes
You will need 2 @boardname@ for this part. By using the radio, we can make the inchworm controlled by another @boardname@.
Download the code below to the @boardname@ on the inchworm and another "controller" @boardname@.
Whenere A is pressed, the monster will open and close it's mouth will move once.
```blocks
radio.onDataPacketReceived(({receivedNumber}) => {
pins.servoWritePin(AnalogPin.P0, 30)
basic.pause(500)
pins.servoWritePin(AnalogPin.P0, 150)
basic.pause(500)
})
input.onButtonPressed(Button.A, () => {
radio.sendNumber(0)
})
```
```package
radio
```

View File

@ -0,0 +1,25 @@
# Make
### @description Building the coffee cup monster
### ~avatar avatar
Turn a piece of coffee holders into a monster!
### ~
## Duration: ~60 minutes
## Materials
* 3 Coffee cup holders
* 2 Coffee cup strirer wood sticks
* Scissors
* glue gun or tape
* 1 paper clip
## Step 1: cardboard
TODO
### ~button /projects/coffee-cup-monster/code
NEXT: Code
### ~

View File

@ -27,8 +27,8 @@ Build your own music player @boardname@ from headphones.
## Activities ## Activities
* [Connect your headphone](/projects/hack-your-headphones/make) * [Make](/projects/hack-your-headphones/make)
* [Play sounds!]() * [Code](/projects/hack-your-headphones/code)
### ~button /projects/hack-your-headphones/make ### ~button /projects/hack-your-headphones/make

View File

@ -1,4 +1,4 @@
# hack your headphones - music of light # Code
### ~avatar avatar ### ~avatar avatar

View File

@ -1,4 +1,4 @@
# hack your headphones - making # Make
### ~avatar avatar ### ~avatar avatar
@ -46,7 +46,7 @@ Using the 2nd crocodile clip, connect the second end of the crocodile clip onto
You hacked your headphones! You hacked your headphones!
### ~button /projects/hack-your-headphones/music-of-light ### ~button /projects/hack-your-headphones/code
NEXT: music of light NEXT: music of light

View File

@ -1,7 +1,7 @@
# Inchworm # Inchworm
### @description A inchworm like robot built with the micro:bit ### @description A inchworm like robot built with the @boardname@
### ~avatar avatar ### ~avatar avatar
@ -27,13 +27,17 @@ https://youtu.be/BiZLjugXMbM
![Materials](/static/mb/projects/inchworm/materials.jpg) ![Materials](/static/mb/projects/inchworm/materials.jpg)
## Preparation
* [Equip the microservo with crocodile clips](/device/servo)
## Activities ## Activities
* [Servo](/projects/inchworm/servo) * [Make](/projects/inchworm/make)
* [Chassis](/projects/inchworm/chassis)
* [Code](/projects/inchworm/code) * [Code](/projects/inchworm/code)
* [Connect](/projects/inchworm/connect)
### ~button /projects/inchworm/servo ### ~button /projects/inchworm/make
Let's get started! Let's get started!

View File

@ -30,23 +30,6 @@ so that the inchworm goes as fast as possible. Trying it on carpet also great he
### ~ ### ~
## Step 2: radio controlled inchworm ### ~button /projects/inchworm/connect
NEXT: Connect
You will need 2 @boardname@ for this part. By using the radio, we can make the inchworm controlled by another @boardname@. ### ~
Download the code below to the @boardname@ on the inchworm and another "controller" @boardname@. Whenere A is pressed, the inchworm will move once.
```blocks
radio.onDataPacketReceived(({receivedNumber}) => {
pins.servoWritePin(AnalogPin.P0, 0)
basic.pause(500)
pins.servoWritePin(AnalogPin.P0, 180)
basic.pause(500)
})
input.onButtonPressed(Button.A, () => {
radio.sendNumber(0)
})
```
```package
radio
```

View File

@ -0,0 +1,28 @@
# Connect
### ~avatar avatar
Remote control your inchworm with another @boardname@
### ~
## Duration: ~30 minutes
You will need 2 @boardname@ for this part. By using the radio, we can make the inchworm controlled by another @boardname@.
Download the code below to the @boardname@ on the inchworm and another "controller" @boardname@. Whenere A is pressed, the inchworm will move once.
```blocks
radio.onDataPacketReceived(({receivedNumber}) => {
pins.servoWritePin(AnalogPin.P0, 0)
basic.pause(500)
pins.servoWritePin(AnalogPin.P0, 180)
basic.pause(500)
})
input.onButtonPressed(Button.A, () => {
radio.sendNumber(0)
})
```
```package
radio
```

View File

@ -1,4 +1,4 @@
# Chassis # Make
### @description Building the cardboard inchworm ### @description Building the cardboard inchworm
### ~avatar avatar ### ~avatar avatar

View File

@ -17,8 +17,8 @@ Build a telegraph between two @boardname@s to communicate with your friends!
## Activities ## Activities
* [Making the circuit](/projects/telegraph/make) * [Make](/projects/telegraph/make)
* [Manual telegraph](/projects/telegraph/manual-telegraph) * [Code](/projects/telegraph/code)
### ~button /projects/telegraph/make ### ~button /projects/telegraph/make
Let's get started! Let's get started!

View File

@ -1,4 +1,4 @@
# telegraph - manual telegraph # Code
Let's build the code that will send a impulse while the user presses ``A``. Let's build the code that will send a impulse while the user presses ``A``.

View File

@ -1,4 +1,4 @@
# telegraph - making # Make
### ~avatar ### ~avatar
@ -68,8 +68,8 @@ Using the 4th crocodile clip, connect the unattached end of the crocodile clip o
![](/static/mb/lessons/telegraph-0.png) ![](/static/mb/lessons/telegraph-0.png)
### ~button /projects/telegraph/manual-telegraph ### ~button /projects/telegraph/code
NEXT: manual telegraph NEXT: Code
### ~ ### ~

View File

@ -1,4 +1,4 @@
# Wallet - Code # Code
## Simple animation ## Simple animation

View File

@ -1,4 +1,4 @@
# Wallet - Make # Make
### @description Maker Project for Wallet ### @description Maker Project for Wallet

View File

@ -25,7 +25,7 @@ bluetooth.advertiseUidBuffer(pins.createBuffer(16), 7, true);
* ``buffer`` - a 16 bytes buffer containing the namespace (first 10 bytes) and instance (last 6 bytes). * ``buffer`` - a 16 bytes buffer containing the namespace (first 10 bytes) and instance (last 6 bytes).
* ``power`` - a [number](/reference/types/number) representing the power level between 0 (short) and 7 (maximum range). * ``power`` - a [number](/reference/types/number) representing the power level between 0 (short) and 7 (maximum range).
* ``connectable`` - a [boolean](/blocks/logic/boolean) indicating whether or not the micro:bit should accept connections. * ``connectable`` - a [boolean](/blocks/logic/boolean) indicating whether or not the @boardname@ should accept connections.
## See Also ## See Also

View File

@ -26,7 +26,7 @@ bluetooth.advertiseUid(42, 1, 7, true);
* ``namespace`` last 4 bytes of the namespace uid (6 to 9) * ``namespace`` last 4 bytes of the namespace uid (6 to 9)
* ``instance`` last 4 bytes of the instance (2 to 5) * ``instance`` last 4 bytes of the instance (2 to 5)
* ``power`` - a [number](/reference/types/number) representing the power level between 0 (short) and 7 (maximum range). * ``power`` - a [number](/reference/types/number) representing the power level between 0 (short) and 7 (maximum range).
* ``connectable`` - a [boolean](/blocks/logic/boolean) indicating whether or not the micro:bit should accept connections. * ``connectable`` - a [boolean](/blocks/logic/boolean) indicating whether or not the @boardname@ should accept connections.
## Encoding ## Encoding

View File

@ -25,7 +25,7 @@ bluetooth.advertiseUrl("https://pxt.microbit.org/", 7, true);
* ``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. * ``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). * ``power`` - a [number](/reference/types/number) representing the power level between 0 (short) and 7 (maximum range).
* ``connectable`` - a [boolean](/blocks/logic/boolean) indicating whether or not the micro:bit should accept connections. * ``connectable`` - a [boolean](/blocks/logic/boolean) indicating whether or not the @boardname@ should accept connections.
### Example: Broadcast a secret code ### Example: Broadcast a secret code

View File

@ -0,0 +1,30 @@
# Set Events
Configure the type of events emitted by a given pin.
```sig
pins.setEvents(DigitalPin.P0, PinEventType.Edge);
```
### Parameters
* ``name``: The @boardname@ hardware pin to configure (``P0`` through ``P20``)
* ``type``: The type of events this pin should emit
### Example
The following example configures pin ``P0`` and then
subscribes to the rise and fall events.
```blocks
control.onEvent(control.eventSourceId(EventBusSource.MICROBIT_ID_IO_P0), control.eventValueId(EventBusValue.MICROBIT_PIN_EVT_RISE), () => {
basic.showString("Rise")
})
control.onEvent(control.eventSourceId(EventBusSource.MICROBIT_ID_IO_P0), control.eventValueId(EventBusValue.MICROBIT_PIN_EVT_FALL), () => {
basic.showString("Fall")
})
pins.setEvents(DigitalPin.P0, PinEventType.Edge)
```
**This is an advanced API.** For more information, see the
[@boardname@ runtime messageBus documentation](https://lancaster-university.github.io/microbit-docs/ubit/messageBus/)

View File

@ -223,6 +223,9 @@
"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": "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, eg: AnalogPin.P0", "pins.servoWritePin|param|name": "pin to write to, eg: AnalogPin.P0",
"pins.servoWritePin|param|value": "angle or rotation speed, eg:180,90,0", "pins.servoWritePin|param|value": "angle or rotation speed, eg:180,90,0",
"pins.setEvents": "Configures the events emitted by this pin. Events can be subscribed to\nusing ``control.onEvent()``.",
"pins.setEvents|param|name": "pin to set the event mode on, eg: DigitalPin.P0",
"pins.setEvents|param|type": "the type of events for this pin to emit, eg: PinEventType.Edge",
"pins.setPull": "Configures the pull of this pin.", "pins.setPull": "Configures the pull of this pin.",
"pins.setPull|param|name": "pin to set the pull mode on, eg: DigitalPin.P0", "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.setPull|param|pull": "one of the mbed pull configurations, eg: PinPullMode.PullUp",

View File

@ -74,6 +74,10 @@
"Note.GSharp4|block": "G#4", "Note.GSharp4|block": "G#4",
"Note.GSharp5|block": "G#5", "Note.GSharp5|block": "G#5",
"Note.GSharp|block": "G#", "Note.GSharp|block": "G#",
"PinEventType.Edge|block": "edge",
"PinEventType.None|block": "none",
"PinEventType.Pulse|block": "pulse",
"PinEventType.Touch|block": "touch",
"PinPullMode.PullDown|block": "down", "PinPullMode.PullDown|block": "down",
"PinPullMode.PullNone|block": "none", "PinPullMode.PullNone|block": "none",
"PinPullMode.PullUp|block": "up", "PinPullMode.PullUp|block": "up",
@ -167,6 +171,7 @@
"pins.pulseIn|block": "pulse in (µs)|pin %name|pulsed %value", "pins.pulseIn|block": "pulse in (µs)|pin %name|pulsed %value",
"pins.servoSetPulse|block": "servo set pulse|pin %value|to (µs) %micros", "pins.servoSetPulse|block": "servo set pulse|pin %value|to (µs) %micros",
"pins.servoWritePin|block": "servo write|pin %name|to %value", "pins.servoWritePin|block": "servo write|pin %name|to %value",
"pins.setEvents|block": "set pin %pin|to emit %type|events",
"pins.setPull|block": "set pull|pin %pin|to %pull", "pins.setPull|block": "set pull|pin %pin|to %pull",
"pins.spiWrite|block": "spi write %value", "pins.spiWrite|block": "spi write %value",
"pins|block": "pins", "pins|block": "pins",

View File

@ -56,6 +56,10 @@ enum EventBusValue {
MICROBIT_BUTTON_EVT_CLICK_ = MICROBIT_BUTTON_EVT_CLICK, MICROBIT_BUTTON_EVT_CLICK_ = MICROBIT_BUTTON_EVT_CLICK,
MICROBIT_RADIO_EVT_DATAGRAM_ = MICROBIT_RADIO_EVT_DATAGRAM, MICROBIT_RADIO_EVT_DATAGRAM_ = MICROBIT_RADIO_EVT_DATAGRAM,
MICROBIT_ACCELEROMETER_EVT_DATA_UPDATE_ = MICROBIT_ACCELEROMETER_EVT_DATA_UPDATE, MICROBIT_ACCELEROMETER_EVT_DATA_UPDATE_ = MICROBIT_ACCELEROMETER_EVT_DATA_UPDATE,
MICROBIT_PIN_EVT_RISE_ = MICROBIT_PIN_EVT_RISE,
MICROBIT_PIN_EVT_FALL_ = MICROBIT_PIN_EVT_FALL,
MICROBIT_PIN_EVT_PULSE_HI_ = MICROBIT_PIN_EVT_PULSE_HI,
MICROBIT_PIN_EVT_PULSE_LO_ = MICROBIT_PIN_EVT_PULSE_LO,
MES_ALERT_EVT_ALARM1_ = MES_ALERT_EVT_ALARM1, MES_ALERT_EVT_ALARM1_ = MES_ALERT_EVT_ALARM1,
MES_ALERT_EVT_ALARM2_ = MES_ALERT_EVT_ALARM2, MES_ALERT_EVT_ALARM2_ = MES_ALERT_EVT_ALARM2,
MES_ALERT_EVT_ALARM3_ = MES_ALERT_EVT_ALARM3, MES_ALERT_EVT_ALARM3_ = MES_ALERT_EVT_ALARM3,
@ -189,6 +193,7 @@ namespace control {
* Gets a friendly name for the device derived from the its serial number * Gets a friendly name for the device derived from the its serial number
*/ */
//% blockId="control_device_name" block="device name" weight=10 blockGap=8 //% blockId="control_device_name" block="device name" weight=10 blockGap=8
//% advanced=true
StringData* deviceName() { StringData* deviceName() {
return ManagedString(microbit_friendly_name()).leakData(); return ManagedString(microbit_friendly_name()).leakData();
} }
@ -197,6 +202,7 @@ namespace control {
* Derive a unique, consistent serial number of this device from internal data. * Derive a unique, consistent serial number of this device from internal data.
*/ */
//% blockId="control_device_serial_number" block="device serial number" weight=9 //% blockId="control_device_serial_number" block="device serial number" weight=9
//% advanced=true
int deviceSerialNumber() { int deviceSerialNumber() {
return microbit_serial_number(); return microbit_serial_number();
} }

View File

@ -9,7 +9,7 @@ namespace control {
* Returns the value of a C++ runtime constant * Returns the value of a C++ runtime constant
*/ */
//% weight=2 weight=19 blockId="control_event_source_id" block="%id" blockGap=8 //% weight=2 weight=19 blockId="control_event_source_id" block="%id" blockGap=8
//% shim=TD_ID //% shim=TD_ID advanced=true
export function eventSourceId(id: EventBusSource): number { export function eventSourceId(id: EventBusSource): number {
return id; return id;
} }
@ -17,7 +17,7 @@ namespace control {
* Returns the value of a C++ runtime constant * Returns the value of a C++ runtime constant
*/ */
//% weight=1 weight=19 blockId="control_event_value_id" block="%id" //% weight=1 weight=19 blockId="control_event_value_id" block="%id"
//% shim=TD_ID //% shim=TD_ID advanced=true
export function eventValueId(id: EventBusValue): number { export function eventValueId(id: EventBusValue): number {
return id; return id;
} }

16
libs/core/enums.d.ts vendored
View File

@ -179,6 +179,10 @@ declare namespace input {
MICROBIT_BUTTON_EVT_CLICK = 3, // MICROBIT_BUTTON_EVT_CLICK MICROBIT_BUTTON_EVT_CLICK = 3, // MICROBIT_BUTTON_EVT_CLICK
MICROBIT_RADIO_EVT_DATAGRAM = 1, // MICROBIT_RADIO_EVT_DATAGRAM MICROBIT_RADIO_EVT_DATAGRAM = 1, // MICROBIT_RADIO_EVT_DATAGRAM
MICROBIT_ACCELEROMETER_EVT_DATA_UPDATE = 1, // MICROBIT_ACCELEROMETER_EVT_DATA_UPDATE MICROBIT_ACCELEROMETER_EVT_DATA_UPDATE = 1, // MICROBIT_ACCELEROMETER_EVT_DATA_UPDATE
MICROBIT_PIN_EVT_RISE = 2, // MICROBIT_PIN_EVT_RISE
MICROBIT_PIN_EVT_FALL = 3, // MICROBIT_PIN_EVT_FALL
MICROBIT_PIN_EVT_PULSE_HI = 4, // MICROBIT_PIN_EVT_PULSE_HI
MICROBIT_PIN_EVT_PULSE_LO = 5, // MICROBIT_PIN_EVT_PULSE_LO
MES_ALERT_EVT_ALARM1 = 6, // MES_ALERT_EVT_ALARM1 MES_ALERT_EVT_ALARM1 = 6, // MES_ALERT_EVT_ALARM1
MES_ALERT_EVT_ALARM2 = 7, // MES_ALERT_EVT_ALARM2 MES_ALERT_EVT_ALARM2 = 7, // MES_ALERT_EVT_ALARM2
MES_ALERT_EVT_ALARM3 = 8, // MES_ALERT_EVT_ALARM3 MES_ALERT_EVT_ALARM3 = 8, // MES_ALERT_EVT_ALARM3
@ -297,6 +301,18 @@ declare namespace led {
} }
declare enum PinEventType {
//% block="edge"
Edge = 1, // MICROBIT_PIN_EVENT_ON_EDGE
//% block="pulse"
Pulse = 2, // MICROBIT_PIN_EVENT_ON_PULSE
//% block="touch"
Touch = 3, // MICROBIT_PIN_EVENT_ON_TOUCH
//% block="none"
None = 0, // MICROBIT_PIN_EVENT_NONE
}
declare enum SerialPin { declare enum SerialPin {
P0 = 7, // MICROBIT_ID_IO_P0 P0 = 7, // MICROBIT_ID_IO_P0
P1 = 8, // MICROBIT_ID_IO_P1 P1 = 8, // MICROBIT_ID_IO_P1

View File

@ -174,7 +174,7 @@ namespace music {
*/ */
//% weight=50 help=music/note-frequency //% weight=50 help=music/note-frequency
//% blockId=device_note block="%note" //% blockId=device_note block="%note"
//% shim=TD_ID //% shim=TD_ID blockHidden=true
export function noteFrequency(name: Note): number { export function noteFrequency(name: Note): number {
return name; return name;
} }

View File

@ -47,6 +47,17 @@ enum class PinPullMode {
PullNone = 2 PullNone = 2
}; };
enum class PinEventType {
//% block="edge"
Edge = MICROBIT_PIN_EVENT_ON_EDGE,
//% block="pulse"
Pulse = MICROBIT_PIN_EVENT_ON_PULSE,
//% block="touch"
Touch = MICROBIT_PIN_EVENT_ON_TOUCH,
//% block="none"
None = MICROBIT_PIN_EVENT_NONE
};
MicroBitPin *getPin(int id) { MicroBitPin *getPin(int id) {
switch (id) { switch (id) {
case MICROBIT_ID_IO_P0: return &uBit.io.P0; case MICROBIT_ID_IO_P0: return &uBit.io.P0;
@ -275,6 +286,18 @@ namespace pins {
PINOP(setPull(m)); PINOP(setPull(m));
} }
/**
* Configures the events emitted by this pin. Events can be subscribed to
* using ``control.onEvent()``.
* @param name pin to set the event mode on, eg: DigitalPin.P0
* @param type the type of events for this pin to emit, eg: PinEventType.Edge
*/
//% help=pins/set-events weight=4 advanced=true
//% blockId=device_set_pin_events block="set pin %pin|to emit %type|events"
void setEvents(DigitalPin name, PinEventType type) {
getPin((int)name)->eventOn((int)type);
}
/** /**
* Create a new zero-initialized buffer. * Create a new zero-initialized buffer.
* @param size number of bytes in the buffer * @param size number of bytes in the buffer

16
libs/core/shims.d.ts vendored
View File

@ -415,13 +415,15 @@ declare namespace control {
/** /**
* Gets a friendly name for the device derived from the its serial number * Gets a friendly name for the device derived from the its serial number
*/ */
//% blockId="control_device_name" block="device name" weight=10 blockGap=8 shim=control::deviceName //% blockId="control_device_name" block="device name" weight=10 blockGap=8
//% advanced=true shim=control::deviceName
function deviceName(): string; function deviceName(): string;
/** /**
* Derive a unique, consistent serial number of this device from internal data. * Derive a unique, consistent serial number of this device from internal data.
*/ */
//% blockId="control_device_serial_number" block="device serial number" weight=9 shim=control::deviceSerialNumber //% blockId="control_device_serial_number" block="device serial number" weight=9
//% advanced=true shim=control::deviceSerialNumber
function deviceSerialNumber(): number; function deviceSerialNumber(): number;
} }
@ -628,6 +630,16 @@ declare namespace pins {
//% blockId=device_set_pull block="set pull|pin %pin|to %pull" shim=pins::setPull //% blockId=device_set_pull block="set pull|pin %pin|to %pull" shim=pins::setPull
function setPull(name: DigitalPin, pull: PinPullMode): void; function setPull(name: DigitalPin, pull: PinPullMode): void;
/**
* Configures the events emitted by this pin. Events can be subscribed to
* using ``control.onEvent()``.
* @param name pin to set the event mode on, eg: DigitalPin.P0
* @param type the type of events for this pin to emit, eg: PinEventType.Edge
*/
//% help=pins/set-events weight=4 advanced=true
//% blockId=device_set_pin_events block="set pin %pin|to emit %type|events" shim=pins::setEvents
function setEvents(name: DigitalPin, type: PinEventType): void;
/** /**
* Create a new zero-initialized buffer. * Create a new zero-initialized buffer.
* @param size number of bytes in the buffer * @param size number of bytes in the buffer

View File

@ -1,6 +1,6 @@
{ {
"name": "pxt-microbit", "name": "pxt-microbit",
"version": "0.7.45", "version": "0.7.49",
"description": "micro:bit target for PXT", "description": "micro:bit target for PXT",
"keywords": [ "keywords": [
"JavaScript", "JavaScript",
@ -36,6 +36,6 @@
"semantic-ui-less": "^2.2.4" "semantic-ui-less": "^2.2.4"
}, },
"dependencies": { "dependencies": {
"pxt-core": "0.11.1" "pxt-core": "0.11.6"
} }
} }

View File

@ -119,6 +119,9 @@ namespace pxsim.pins {
export function getPinAddress(name: number) { export function getPinAddress(name: number) {
return getPin(name) return getPin(name)
} }
export function setEvents(name: number, event: number) {
}
} }
namespace pxsim.devices { namespace pxsim.devices {

View File

@ -1,5 +1,5 @@
/* Import all components */ /* Import all components */
@import 'semantic'; @import 'pxtsemantic';
@import 'pxt'; @import 'pxt';
@import 'themes/default/globals/site.variables'; @import 'themes/default/globals/site.variables';
@import 'themes/pxt/globals/site.variables'; @import 'themes/pxt/globals/site.variables';