Compare commits

...

79 Commits

Author SHA1 Message Date
b36ffaf29c 0.5.30 2016-10-24 16:32:56 +01:00
bff088fced Bump pxt-core to 0.5.1 2016-10-24 16:32:56 +01:00
8c15af11db 0.5.29 2016-10-20 20:16:52 -07:00
35e414764f missing tools 2016-10-20 20:14:25 -07:00
333659c320 0.5.28 2016-10-20 20:12:03 -07:00
8c161583eb Bump pxt-core to 0.4.71 2016-10-20 20:12:02 -07:00
b20e185bf2 parameterize download button color 2016-10-20 19:36:00 -07:00
299b595581 added custom theme style 2016-10-20 19:29:10 -07:00
65433216e6 adding semantic ui files 2016-10-20 16:40:39 -07:00
9ea2081e89 0.5.27 2016-10-20 11:48:48 -07:00
808e5fa17b Bump pxt-core to 0.4.68 2016-10-20 11:48:46 -07:00
20d967a230 removing .ico file 2016-10-20 11:30:04 -07:00
c1e5419e45 updated icons 2016-10-20 11:26:44 -07:00
27f5411404 0.5.26 2016-10-20 08:29:16 -07:00
f53eab0539 Bump pxt-core to 0.4.67 2016-10-20 08:29:11 -07:00
445fe12629 0.5.25 2016-10-19 19:11:13 +02:00
ddd6e90c6d Merge remote-tracking branch 'origin/master' 2016-10-19 19:08:52 +02:00
fd14ba6ff1 fix touch pins, add test for buttons and pins, update dependency 2016-10-19 19:08:41 +02:00
28a8f21d40 merging ble changes 2016-10-18 21:55:02 -07:00
0f7323f2da 0.4.55 2016-10-18 21:52:38 -07:00
23d30484d4 updated docs page 2016-10-18 21:52:10 -07:00
6ad59e04a6 fixed uart issues 2016-10-18 21:47:54 -07:00
ae5d5c74a7 better support for BLE UART and alignment with serial blocks. (#276)
* aligning uart apis with serial

* reorganizing serial/bluetooth blocks

* Autoupdate configuration for UART. (#279)

* Autoupdate configuration for UART.

* removing serial autoupdates.
2016-10-18 21:36:42 -07:00
3f626105cd 0.5.24 2016-10-18 21:07:02 -07:00
d9ff9c4800 Bump pxt-core to 0.4.65 2016-10-18 21:07:00 -07:00
75baca4a97 0.4.54 2016-10-18 21:03:36 -07:00
58ae4945cb Bump pxt-core to 0.4.65 2016-10-18 21:03:34 -07:00
fba37d96b2 updated localization help 2016-10-18 13:19:46 -07:00
31998fec05 0.5.23 2016-10-18 13:18:45 -07:00
342aa3ca32 Bump pxt-core to 0.4.63 2016-10-18 13:18:43 -07:00
5eb8704382 0.4.53 2016-10-18 13:18:20 -07:00
81b66664ef Bump pxt-core to 0.4.63 2016-10-18 13:18:19 -07:00
135aaf4855 0.4.52 2016-10-18 09:08:25 -07:00
9b599b6242 0.5.22 2016-10-18 16:56:58 +02:00
e5e63c548f update dal defines 2016-10-18 16:56:42 +02:00
f3eb9a988f update dependencies 2016-10-18 16:56:15 +02:00
e7e2ff7752 gesture updates 2016-10-18 16:40:53 +02:00
f10ac93268 add handling of gestures (we only have 2g, 6g ... no 3g), add mac/idea ignored files 2016-10-18 15:44:49 +02:00
47f46553e0 fix name of board 2016-10-18 15:43:52 +02:00
3158e95cde 0.5.21 2016-10-17 21:39:08 -07:00
854029fe33 updated board name 2016-10-17 21:38:58 -07:00
1b379bddd0 0.5.20 2016-10-17 21:35:07 -07:00
9495da9a53 0.5.19 2016-10-17 21:25:11 -07:00
128b3f2f51 Bump pxt-core to 0.4.62 2016-10-17 21:25:08 -07:00
1fbf257619 0.4.51 2016-10-17 21:12:33 -07:00
932c01f394 Bump pxt-core to 0.4.62 2016-10-17 21:12:30 -07:00
c3b2b99d7c 0.4.50 2016-10-17 16:45:20 -07:00
ec910cb10f Bump pxt-core to 0.4.60 2016-10-17 16:45:17 -07:00
a19d1c848b renaming board name 2016-10-17 16:18:04 -07:00
a331a017b8 merged microbit changes 2016-10-17 13:36:54 -07:00
790b9f557a renaming translation files 2016-10-17 13:33:27 -07:00
0b469f69b6 Fix i18n not working after 277d5a7 (#277)
* Fix i18n not working after 277d5a7

The translation strings file in "core" package should have file names
"core-strings.json" or "core-jsdoc-strings.json".

* Enable ja translation

Rename "core-strings.json" to "core-jsdoc-strings.json".
Add new "core-strings.json" as a copy of the template.
Add two lines for the files in "pxt.json".
2016-10-17 11:13:38 -07:00
5cce86ec7e 0.5.18 2016-10-17 10:54:19 -07:00
65e01dc0df Bump pxt-core to 0.4.59 2016-10-17 10:54:17 -07:00
1a3c31c9f3 Deploy no longer throws when no drives found (#269)
pxt deploy no longer throws when no drives found
2016-10-17 07:39:29 -07:00
7aeb216462 0.5.17 2016-10-16 20:26:19 -07:00
543659b0e8 specifying pin positions 2016-10-16 20:25:55 -07:00
a2b5ff68af 0.5.16 2016-10-16 20:09:30 -07:00
b968d3b1de fixing simulator in IE11 2016-10-16 20:09:13 -07:00
4dbebe3e15 fixing logo in IE11 2016-10-16 09:28:30 -07:00
3b95fede48 optimizing logo 2016-10-16 09:19:40 -07:00
5d4bd77bf4 0.4.49 2016-10-14 22:57:42 -07:00
c83d7e9f07 Bump pxt-core to 0.4.58 2016-10-14 22:57:35 -07:00
971faed80a 0.5.15 2016-10-14 21:56:38 -07:00
02a58caf7a Bump pxt-core to 0.4.58 2016-10-14 21:56:37 -07:00
912e2e6159 enabling inverted menu 2016-10-14 11:32:00 -07:00
efee05c7f5 0.4.48 2016-10-14 11:30:47 -07:00
cc9ab86181 Bump pxt-core to 0.4.57 2016-10-14 11:30:41 -07:00
e834ae0656 0.5.14 2016-10-14 08:04:04 -07:00
175923fcb9 updated logos 2016-10-14 08:00:34 -07:00
ef8d7185ee adding lessons to create circuit using aluminium foil 2016-10-13 12:52:47 -07:00
b0392da8b1 Fix indentation of showLeds in a couple of projects. 2016-10-13 11:32:25 -07:00
c817f9e3ff re-enabling sharing after bug in share-editor has been fixed. 2016-10-13 10:55:52 -07:00
5f78f98f94 0.4.47 2016-10-12 23:52:11 -07:00
395b6184b9 Bump pxt-core to 0.4.55 2016-10-12 23:52:09 -07:00
3274964a11 0.4.46 2016-10-12 04:49:42 -07:00
f5e8b35df4 Bump pxt-core to 0.4.54 2016-10-12 04:49:40 -07:00
996073728c 0.4.45 2016-10-12 04:02:55 -07:00
1e964ba1ea Bump pxt-core to 0.4.53 2016-10-12 04:02:53 -07:00
202 changed files with 1443 additions and 355 deletions

4
.gitignore vendored
View File

@ -24,3 +24,7 @@ clients/electron/projects
*.db
*.suo
*.log
.DS_Store
.idea
*.iml

View File

@ -13,20 +13,20 @@ export function deployCoreAsync(res: ts.pxtc.CompileResult) {
return getBitDrivesAsync()
.then(drives => {
if (drives.length == 0) {
let msg = "cannot find any drives to deploy to";
console.log(msg);
return Promise.reject(new Error(msg));
console.log("cannot find any drives to deploy to");
return Promise.resolve(0);
}
console.log(`copy ${ts.pxtc.BINARY_HEX} to ` + drives.join(", "))
console.log(`copy ${ts.pxtc.BINARY_HEX} to ` + drives.join(", "));
return Promise.map(drives, d =>
writeFileAsync(d + ts.pxtc.BINARY_HEX, res.outfiles[ts.pxtc.BINARY_HEX])
.then(() => {
console.log("wrote hex file to " + d)
}))
})
.then(() => { })
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[]> {

View File

@ -1,11 +1,40 @@
# crocodile clips
The large holes at the bottom of the board are designed to attach alligator/crocodile clips.
Register an event that will execute whenever the user attaches one side of the crocodile clip to the `GND` pin, then connects and disconnects the unattached side of the crocodile clip to pin `0`, `1`, or `2`.
The large holes at the bottom of the board are designed to attach alligator/crocodile clips
to create electrical circuit with other components.
### Example: on pin pressed with random numbers
# ~hint
This example displays a random number every time the crocodile clip holds `GND` then connects and disconnects the `P0` pin. Each time the crocodile clip is firmly connected and disconnected from pin `P0`, the micro:bit will return a random Number between 0 and the parameter limit
**No crocodile clips!?!?!** Use wires or Aluminium foil! [Read more...](/device/foil-circuits)
# ~
## Connecting Crocodile Clips
The hole for ``P0`` and ``GND`` allow to grab the board on the side which makes for a great grip.
![](/static/mb/device/croc-clips/crocclipsclamped.jpg)
Pass one jaw in the hole and grab the side of the board with the other jaw.
![](/static/mb/device/croc-clips/sideclamp.jpg)
For the center holes, ``P1`` and ``P2``, you can also grab the bottom of the board but they are a bit harder to grip.
You can also grip the board between the jaws. In which case, you will want to make sure to avoid overlapping the jaws
with the other pins as it will create short-circuit in the board.
![](/static/mb/device/croc-clips/badclamp.jpg)
Adding a little tape helps keeping the crocodile clips in place.
![](/static/mb/device/croc-clips/frontclamp.jpg)
## Example: on pin pressed with random numbers
This example displays a random number every time the crocodile clip holds `GND` then connects and disconnects the `P0` pin.
Each time the crocodile clip is firmly connected and disconnected from pin `P0`, the micro:bit will return a random Number between 0 and the parameter limit.
```blocks
input.onPinPressed(TouchPin.P0, () => {
@ -13,11 +42,6 @@ input.onPinPressed(TouchPin.P0, () => {
})
```
### Connecting Crocodile Clips
![](/static/mb/crocodile-clips-2.jpg)
### See also
[micro:bit pins](/device/pins), [pin is pressed](/reference/input/pin-is-pressed), [analog read pin](/reference/pins/analog-read-pin), [analog write pin](/reference/pins/analog-write-pin), [digital read pin](/reference/pins/digital-read-pin), [digital write pin](/reference/pins/digital-write-pin)
## See also
[micro:bit pins](/device/pins)

View File

@ -1,7 +1,5 @@
# Error codes
The micro:bit error codes
Your micro:bit may encounter a situation that prevents it from running your code. When this happens, a frowny face will appear on your micro:bit screen (see picture) followed by an error number.
Below is a list of error numbers and what they mean:

View File

@ -0,0 +1,52 @@
# foil circuits
The large holes at the bottom of the board are designed to attach alligator/crocodile clips
to create electrical circuit with other components.
If you do not have crocodile clips at hand, dyou can use wires or even Aluminium foil to acheive the same result.
We will show you how to connect the micro:bit to headphones using Alumunium foil and tape.
https://youtu.be/mhXYyPuvpz0
### Materials
* micro:bit and battery pack (you can also power it via USB)
* a small piece of cardboard
* Aluminium foil
* tape
### Assembly instructions
Tape the micro:bit and battery pack to the card board. Make sure to remove the batteries while you are building your circuit.
![](/static/mb/device/croc-clips/microbitattached.jpg)
Cut the thinest strip of foil possible and roll it into a cable. You can also try to fold, whatever works for you.
Build two of those wires.
![](/static/mb/device/croc-clips/foilcut.jpg)
Place the foil wire on the ``GND`` pin and attach with a piece of tape. Press hard to get the best connection between
the foil and the pin board. Make sure the foil is not overlapping with the other pins!
![](/static/mb/device/croc-clips/groundconnected.jpg)
Place the second wire on the ``P0`` pin the same way. Make sure the wire does not overlap with the other pins!
![](/static/mb/device/croc-clips/microbitconnect.jpg)
Tape the headphone jack connector to the cardboard and roll the wire coming from ``GND`` around the metal base.
Make sure the wire does not touch the other metal rings on the jack.
![](/static/mb/device/croc-clips/jackground.jpg)
Tape the second wire on the head of the jack connector.
![](/static/mb/device/croc-clips/jackconnect.jpg)
![](/static/mb/device/croc-clips/foilcircuit.jpg)
## See also
[micro:bit pins](/device/pins)

View File

@ -5,7 +5,8 @@
### Things to do
* **[Getting Started](/getting-started)**
* [Ten projects](/projects)
* [Projects](/projects)
* [Lessons](/lessons)
### Micro:bit reference
@ -16,16 +17,15 @@
* [Blocks language](/blocks)
* [JavaScript language](/javascript)
* [Streaming data](/streaming)
### More questions?
* [Frequently Asked Question](/faq)
* [Embedding project](/share)
* [Help Translate](/translate)
* [Release notes](/release-notes)
* [Embedding project](/share)
### Developers
* [Command Line Interface](/cli)
* Learn about [packages](/packages)
* [Release notes](/release-notes)

View File

@ -7,11 +7,12 @@
```sim
basic.forever(() => {
basic.showLeds(`
. # . # .
# # # # #
# # # # #
. # # # .
. . # . .`);
. # . # .
# # # # #
# # # # #
. # # # .
. . # . .`
);
basic.pause(500);
basic.clearScreen();
basic.pause(500);
@ -29,11 +30,12 @@ Use [show leds](/reference/basic/show-leds) and make your code look like this:
```blocks
basic.showLeds(`
. # . # .
# # # # #
# # # # #
. # # # .
. . # . .`);
. # . # .
# # # # #
# # # # #
. # # # .
. . # . .`
);
```
## Step 2
@ -42,11 +44,11 @@ Add a [pause](/reference/basic/pause) to wait and [clear screen](/reference/basi
```blocks
basic.showLeds(`
. # . # .
# # # # #
# # # # #
. # # # .
. . # . .`);
. # . # .
# # # # #
# # # # #
. # # # .
. . # . .`);
basic.pause(500);
basic.clearScreen();
```
@ -58,11 +60,12 @@ Put a [forever loop](/reference/basic/forever) around it.
```blocks
basic.forever(() => {
basic.showLeds(`
. # . # .
# # # # #
# # # # #
. # # # .
. . # . .`);
. # . # .
# # # # #
# # # # #
. # # # .
. . # . .`
);
basic.pause(500);
basic.clearScreen();
})
@ -75,11 +78,12 @@ Add a [pause](/reference/basic/pause) to wait after clearing the screen.
```blocks
basic.forever(() => {
basic.showLeds(`
. # . # .
# # # # #
# # # # #
. # # # .
. . # . .`);
. # . # .
# # # # #
# # # # #
. # # # .
. . # . .`
);
basic.pause(500);
basic.clearScreen();
basic.pause(500);
@ -94,20 +98,22 @@ Add a second image of a broken heart.
```blocks
basic.forever(() => {
basic.showLeds(`
. # . # .
# # # # #
# # # # #
. # # # .
. . # . .`);
. # . # .
# # # # #
# # # # #
. # # # .
. . # . .`
);
basic.pause(500);
basic.clearScreen();
basic.pause(500);
basic.showLeds(`
. # . # .
# . # # #
# . . . #
. # # # .
. . # . .`);
. # . # .
# . # # #
# . . . #
. # # # .
. . # . .`
);
basic.pause(500);
basic.clearScreen();
basic.pause(500);

View File

@ -24,6 +24,12 @@ Build your own music player micro:bit from headphones.
* [Connect your headphone](/projects/hack-your-headphone/making)
* [Play sounds!]()
# ~hint
**No crocodile clips!?!?!** Use wires or Aluminium foil! [Read more...](/device/foil-circuits)
# ~
### ~button /projects/hack-your-headphones/making
Let's get started!

View File

@ -6,6 +6,12 @@ Did you know you could attach your headhpones to the micro:bit to generate sound
### ~
# ~hint
**No crocodile clips!?!?!** Use wires or Aluminium foil! [Read more...](/device/foil-circuits)
# ~
### Step 1
![](/static/mb/lessons/banana-keyboard-1.png)

View File

@ -10,11 +10,12 @@ Use [show leds](/reference/basic/show-leds) to make a smiley face:
```blocks
basic.showLeds(`
. # . # .
. # . # .
. . . . .
# . . . #
. # # # .`);
. # . # .
. # . # .
. . . . .
# . . . #
. # # # .`
);
```
## Step 2
@ -24,18 +25,20 @@ frowny face inside it:
```blocks
basic.showLeds(`
. # . # .
. # . # .
. . . . .
# . . . #
. # # # .`);
input.onButtonPressed(Button.A, () => {
basic.showLeds(`
. # . # .
. # . # .
. . . . .
. # # # .
# . . . #`);
# . . . #
. # # # .`
);
input.onButtonPressed(Button.A, () => {
basic.showLeds(`
. # . # .
. # . # .
. . . . .
. # # # .
# . . . #`
);
});
```
@ -45,25 +48,28 @@ Now add blocks so that when [button B is pressed](/reference/input/button-is-pre
```blocks
basic.showLeds(`
. # . # .
. # . # .
. . . . .
# . . . #
. # # # .`);
input.onButtonPressed(Button.A, () => {
basic.showLeds(`
. # . # .
. # . # .
. . . . .
. # # # .
# . . . #`);
});
input.onButtonPressed(Button.B, () => {
basic.showLeds(`
. # . # .
. # . # .
. . . . .
# . . . #
. # # # .`);
. # # # .`
);
input.onButtonPressed(Button.A, () => {
basic.showLeds(`
. # . # .
. # . # .
. . . . .
. # # # .
# . . . #`
);
});
input.onButtonPressed(Button.B, () => {
basic.showLeds(`
. # . # .
. # . # .
. . . . .
# . . . #
. # # # .`
);
});
```

View File

@ -2,6 +2,14 @@
Support for additional Bluetooth services.
### ~hint
![](/static/bluetooth/Bluetooth_SIG.png)
For another device like a smartphone to use any of the Bluetooth "services" which the micro:bit has, it must first be [paired with the micro:bit](/reference/bluetooth/bluetooth-pairing). Once paired, the other device may connect to the micro:bit and exchange data relating to many of the micro:bit's features.
### ~
```cards
bluetooth.startAccelerometerService();
bluetooth.startButtonService();
@ -9,20 +17,34 @@ bluetooth.startIOPinService();
bluetooth.startLEDService();
bluetooth.startMagnetometerService();
bluetooth.startTemperatureService();
bluetooth.uartRead("");
bluetooth.uartWrite("");
bluetooth.onBluetoothConnected(() => {
});
bluetooth.onBluetoothDisconnected(() => {
});
bluetooth.onBluetoothConnected(() => {});
bluetooth.onBluetoothDisconnected(() => {});
```
## UART
```cards
bluetooth.startUartService();
bluetooth.uartReadUntil("");
bluetooth.uartWriteString("");
bluetooth.uartWriteNumber(0);
bluetooth.uartWriteValue("", 0);
```
```package
microbit-bluetooth
```
### Advanced
For more advanced information on the micro:bit Bluetooth UART service including information on using a smartphone, see the [Lancaster University micro:bit runtime technical documentation](http://lancaster-university.github.io/microbit-docs/ble/uart-service/)
### See Also
[startAccelerometerService](/reference/bluetooth/start-accelerometer-service), [startButtonService](/reference/bluetooth/start-button-service), [startIOPinService](/reference/bluetooth/start-io-pin-service), [startLEDService](/reference/bluetooth/start-led-service), [startMagnetometerService](/reference/bluetooth/start-magnetometer-service), [startTemperatureService](/reference/bluetooth/start-temperature-service), [uartRead](/reference/bluetooth/uart-read), [uartWrite](/reference/bluetooth/uart-write), [onBluetoothConnected](/reference/bluetooth/on-bluetooth-connected), [onBluetoothDisconnected](/reference/bluetooth/on-bluetooth-disconnected)
[startAccelerometerService](/reference/bluetooth/start-accelerometer-service), [startButtonService](/reference/bluetooth/start-button-service), [startIOPinService](/reference/bluetooth/start-io-pin-service), [startLEDService](/reference/bluetooth/start-led-service), [startMagnetometerService](/reference/bluetooth/start-magnetometer-service), [startTemperatureService](/reference/bluetooth/start-temperature-service),
[startUartService](/reference/bluetooth/start-uart-service),
[uartReadUntil](/reference/bluetooth/uart-read-until),
[uartWriteString](/reference/bluetooth/uart-write-string),
[uartWriteNumber](/reference/bluetooth/uart-write-number),
[uartWriteValue](/reference/bluetooth/uart-write-value),
[onBluetoothConnected](/reference/bluetooth/on-bluetooth-connected), [onBluetoothDisconnected](/reference/bluetooth/on-bluetooth-disconnected)

View File

@ -12,7 +12,7 @@ The [Bluetooth UART service](start-uart-service.md) allows another device such a
With the Bluetooth UART service running, this block allows a micro:bit to read data which has been received from a Bluetooth connected device, terminating reading and returning the value obtained as soon as a specified delimiter character is encountered. This means that connected devices can send data to the micro:bit and indicate that the complete message has been sent by appending the message with the delimiter character.
```sig
bluetooth.uartRead("");
bluetooth.uartReadUntil("");
```
### Example: Starting the Bluetooth UART service and then reading data received from another device which is terminated by ":" character and then displaying it
@ -25,7 +25,7 @@ bluetooth.onBluetoothConnected(() => {
basic.showString("C");
connected = 1;
while (connected == 1) {
uartData = bluetooth.uartRead(":");
uartData = bluetooth.uartReadUntil(":");
basic.showString(uartData);
}
});

View File

@ -0,0 +1,28 @@
# UART Write Number
### ~hint
![](/static/bluetooth/Bluetooth_SIG.png)
For another device like a smartphone to use any of the Bluetooth "services" which the micro:bit has, it must first be [paired with the micro:bit](/reference/bluetooth/bluetooth-pairing). Once paired, the other device may connect to the micro:bit and exchange data relating to many of the micro:bit's features.
### ~
The [Bluetooth UART service](/reference/bluetooth/start-uart-service.md) allows another device such as a smartphone to exchange any data it wants to with the micro:bit, in small chunks.
With the Bluetooth UART service running, this block allows a micro:bit to send data to a Bluetooth connected device.
```sig
bluetooth.uartWriteNumber(42);
```
### Advanced
For more advanced information on the micro:bit Bluetooth UART service including information on using a smartphone, see the [Lancaster University micro:bit runtime technical documentation](http://lancaster-university.github.io/microbit-docs/ble/uart-service/)
### See also
[About Bluetooth](/reference/bluetooth/about-bluetooth), [micro:bit Bluetooth profile overview ](http://lancaster-university.github.io/microbit-docs/ble/profile/), [micro:bit Bluetooth profile reference](http://lancaster-university.github.io/microbit-docs/resources/bluetooth/microbit-profile-V1.9-Level-2.pdf), [Bluetooth on micro:bit resources](http://bluetooth-mdw.blogspot.co.uk/p/bbc-microbit.html), [Bluetooth SIG](https://www.bluetooth.com)
```package
microbit-bluetooth
```

View File

@ -1,4 +1,4 @@
# UART Write
# UART Write String
### ~hint
![](/static/bluetooth/Bluetooth_SIG.png)
@ -7,12 +7,12 @@ For another device like a smartphone to use any of the Bluetooth "services" whic
### ~
The [Bluetooth UART service](start-uart-service.md) allows another device such as a smartphone to exchange any data it wants to with the micro:bit, in small chunks.
The [Bluetooth UART service](/reference/bluetooth/start-uart-service.md) allows another device such as a smartphone to exchange any data it wants to with the micro:bit, in small chunks.
With the Bluetooth UART service running, this block allows a micro:bit to send data to a Bluetooth connected device.
```sig
bluetooth.uartWrite("");
bluetooth.uartWriteString("");
```
### Example: Starting the Bluetooth UART service and then sending "HELLO" whenever button A is pressed and another device has connected over Bluetooth
@ -29,7 +29,7 @@ bluetooth.onBluetoothDisconnected(() => {
});
input.onButtonPressed(Button.A, () => {
if (connected == 1) {
bluetooth.uartWrite("HELLO");
bluetooth.uartWriteString("HELLO");
}
});
```

View File

@ -0,0 +1,28 @@
# UART Write Value
### ~hint
![](/static/bluetooth/Bluetooth_SIG.png)
For another device like a smartphone to use any of the Bluetooth "services" which the micro:bit has, it must first be [paired with the micro:bit](/reference/bluetooth/bluetooth-pairing). Once paired, the other device may connect to the micro:bit and exchange data relating to many of the micro:bit's features.
### ~
The [Bluetooth UART service](/reference/bluetooth/start-uart-service.md) allows another device such as a smartphone to exchange any data it wants to with the micro:bit, in small chunks.
With the Bluetooth UART service running, this block allows a micro:bit to send data to a Bluetooth connected device.
```sig
bluetooth.uartWriteValue("x", 42);
```
### Advanced
For more advanced information on the micro:bit Bluetooth UART service including information on using a smartphone, see the [Lancaster University micro:bit runtime technical documentation](http://lancaster-university.github.io/microbit-docs/ble/uart-service/)
### See also
[About Bluetooth](/reference/bluetooth/about-bluetooth), [micro:bit Bluetooth profile overview ](http://lancaster-university.github.io/microbit-docs/ble/profile/), [micro:bit Bluetooth profile reference](http://lancaster-university.github.io/microbit-docs/resources/bluetooth/microbit-profile-V1.9-Level-2.pdf), [Bluetooth on micro:bit resources](http://bluetooth-mdw.blogspot.co.uk/p/bbc-microbit.html), [Bluetooth SIG](https://www.bluetooth.com)
```package
microbit-bluetooth
```

17
docs/static/Calliopeminieditor.svg vendored Normal file
View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" width="179.9" height="32.4" viewBox="0 0 179.9 32.4">
<path fill="#495260" d="M33.1 11.2h-8.5V5.8c0-2.3 1.9-4.2 4.2-4.2 2.3 0 4.2 1.9 4.2 4.2v5.4z"/>
<path fill="#7F96A1" d="M25.8 3.6H32v7.6h-6.2z"/>
<path fill="#845B32" d="M12.2 7.2V18h12.5V7.2c0-3.4-2.8-6.2-6.2-6.2s-6.3 2.8-6.3 6.2z"/>
<path fill="#26A7AA" d="M28.9 31.4H8.7c-6.3 0-9-8-4-11.8L16 11.2h17.1v16c0 2.3-1.9 4.2-4.2 4.2z"/>
<path fill="#43C9C9" d="M15.2 17.7l-8.8.7 10.7-8"/>
<path fill="#F6F4E7" d="M14.8 15.1l2.3-4.7 1.5 4.7m0 0l1.4-4.7 2.3 4.7"/>
<path fill="#BDD1CF" d="M21.9 17.7h-6.7l-.4-2.6h7.5"/>
<path fill="#F6F4E7" d="M26.8 31.4c-.6-4.6-1.9-10.2-4.8-13.7h-6.8c-3 3.5-4.2 9.1-4.8 13.7h16.4z"/>
<path fill="#FFCD9A" d="M18.6 10.5c-1.4 0-2.6-1.2-2.6-2.6V5h5.1v2.9c0 1.5-1.1 2.6-2.5 2.6z"/>
<path fill="#BDD1CF" d="M15.4 31.4V17.7c2.2 5.1 4.9 11.3 8.2 13.7h-8.2z"/>
<path fill="#FFCD9A" d="M17.1 10.4l1.5 4.7 1.4-4.7"/>
<path fill="#43C9C9" d="M25.8 11.2h7.3v9.4"/>
<path fill="#BCD1CF" d="M52.3 15.1h-1.6l-.2-1.4c-.2-.2-.5-.4-.8-.5s-.7-.2-1.2-.2c-.9 0-1.7.3-2.2 1s-.8 1.6-.8 2.7v.4c0 1.1.3 2 .8 2.7.5.7 1.2 1 2.1 1 .4 0 .8-.1 1.2-.2.4-.1.6-.3.8-.5l.2-1.4h1.6v2.1c-.4.5-1 .9-1.7 1.2-.7.3-1.4.5-2.3.5-1.5 0-2.6-.5-3.6-1.5s-1.4-2.3-1.4-3.9v-.4c0-1.6.5-2.9 1.4-3.9s2.1-1.5 3.6-1.5c.8 0 1.6.2 2.3.5.7.3 1.2.7 1.7 1.2v2.1zm1.5 5.9l.8-.1 3.3-9.4h2.2l3.3 9.4.8.1v1.3h-3.7V21l.8-.1-.5-1.5h-3.5l-.5 1.5.8.1v1.3h-3.7V21zm3.9-3.2h2.5L59 14l-1.3 3.8zm7.8 4.5V21l1.2-.2V13l-1.2-.2v-1.3H70v1.3l-1.2.2v7.6h3.1l.1-1.4h1.7v3h-8.2zm9.5 0V21l1.2-.2V13l-1.2-.2v-1.3h4.6v1.3l-1.3.2v7.6h3.1l.1-1.4h1.7v3H75zm9.5-9.5v-1.3H89v1.3l-1.1.2v7.8l1.1.2v1.3h-4.5V21l1.2-.2V13l-1.2-.2zm15.9 4.2c0 1.6-.5 2.9-1.4 3.9-.9 1-2.1 1.6-3.6 1.6s-2.6-.5-3.5-1.6-1.4-2.3-1.4-3.9v-.2c0-1.6.4-2.9 1.3-3.9s2.1-1.6 3.5-1.6c1.5 0 2.7.5 3.6 1.6s1.4 2.4 1.4 3.9v.2zm-2.2-.2c0-1.1-.2-2-.7-2.7s-1.2-1-2.1-1-1.6.3-2 1-.7 1.6-.7 2.7v.2c0 1.1.2 2.1.7 2.8.5.7 1.1 1 2 1 .9 0 1.6-.3 2.1-1s.7-1.6.7-2.8v-.2zm8.8-5.3c1.2 0 2.2.3 2.9 1S111 14 111 15s-.4 1.9-1.1 2.5c-.7.6-1.7.9-2.9.9h-1.8v2.4l1.2.2v1.3h-4.5V21l1.2-.2V13l-1.2-.2v-1.3h5.1zm-1.8 5.2h1.8c.6 0 1.1-.2 1.4-.5s.5-.8.5-1.3-.2-1-.5-1.3c-.3-.3-.8-.5-1.4-.5h-1.8v3.6zm14.1.9h-3.7v3.1h3.5l.1-1.3h1.7v3h-8.6V21l1.2-.2V13l-1.2-.2v-1.3h8.6v3h-1.7l-.1-1.3h-3.5v2.7h3.7v1.7z"/>
<path fill="#FFF" d="M134.3 11.6l.1 1.1c.2-.4.5-.7.9-1 .4-.2.8-.4 1.3-.4s.8.1 1.1.3c.3.2.5.5.7.8.2-.3.5-.6.8-.8.3-.2.7-.3 1.2-.3.4 0 .7.1 1 .2.3.1.5.3.8.6.2.3.4.6.5 1 .1.4.2.9.2 1.4v7.8h-2.2v-7.9c0-.4-.1-.7-.3-.9-.2-.2-.4-.2-.7-.2-.3 0-.5.1-.6.2s-.3.3-.3.5v8.3h-2.2v-7.9c0-.4-.1-.7-.3-.9-.2-.2-.4-.3-.7-.3-.3 0-.5.1-.7.2-.2.1-.3.3-.4.5v8.3h-2.2V11.6h2zm11.3 0h5.7v8.8h3.2v2h-8.9v-2h3.3v-6.8h-3.3v-2zm3.1-2.8c0-.4.1-.7.4-.9.2-.2.6-.4 1-.4s.8.1 1 .4c.2.2.4.5.4.9s-.1.7-.4.9c-.2.2-.6.4-1 .4s-.8-.1-1-.4c-.2-.2-.4-.5-.4-.9zm10.7 2.8l.1 1.5c.4-.5.9-1 1.4-1.2.6-.3 1.2-.4 1.8-.4.5 0 1 .1 1.5.2.5.2.8.4 1.2.7.3.3.6.8.8 1.3.2.5.3 1.2.3 1.9v6.7h-2.4v-6.7c0-.4-.1-.8-.2-1.1-.1-.3-.2-.5-.4-.7-.2-.2-.4-.3-.7-.4-.3-.1-.6-.1-.9-.1-.5 0-1 .1-1.4.3-.4.2-.7.5-.9.9v7.7h-2.4V11.6h2.2zm10.6 0h5.7v8.8h3.2v2H170v-2h3.3v-6.8H170v-2zm3.1-2.8c0-.4.1-.7.4-.9.2-.2.6-.4 1-.4s.8.1 1 .4c.2.2.4.5.4.9s-.1.7-.4.9c-.2.2-.6.4-1 .4s-.8-.1-1-.4c-.3-.2-.4-.5-.4-.9z"/>
</svg>

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@ -2,7 +2,7 @@
<!-- Generator: Adobe Illustrator 18.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 251.8 222.2" enable-background="new 0 0 251.8 222.2" xml:space="preserve">
viewBox="0 0 251.8 222.2" width="251.8" height="222.2" enable-background="new 0 0 251.8 222.2" xml:space="preserve">
<symbol id="Mini_front" viewBox="-121.4 -112.4 242.4 214.1">
<g>

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.3 KiB

1
docs/static/faviconData.json vendored Normal file

File diff suppressed because one or more lines are too long

56
docs/static/faviconDescription.json vendored Normal file
View File

@ -0,0 +1,56 @@
{
"masterPicture": "Logo_Calliope_Woman.svg",
"iconsPath": "/",
"design": {
"ios": {
"pictureAspect": "backgroundAndMargin",
"backgroundColor": "#ffffff",
"margin": "14%",
"assets": {
"ios6AndPriorIcons": true,
"ios7AndLaterIcons": true,
"precomposedIcons": true,
"declareOnlyDefaultIcon": true
}
},
"desktopBrowser": {},
"windows": {
"pictureAspect": "noChange",
"backgroundColor": "#da532c",
"onConflict": "override",
"assets": {
"windows80Ie10Tile": true,
"windows10Ie11EdgeTiles": {
"small": true,
"medium": true,
"big": true,
"rectangle": true
}
}
},
"androidChrome": {
"pictureAspect": "noChange",
"themeColor": "#ffffff",
"manifest": {
"name": "Calliope MINI",
"display": "standalone",
"orientation": "notSet",
"onConflict": "override",
"declared": true
},
"assets": {
"legacyIcon": true,
"lowResolutionIcons": true
}
},
"safariPinnedTab": {
"pictureAspect": "silhouette",
"themeColor": "#5bbad5"
}
},
"settings": {
"scalingAlgorithm": "Mitchell",
"errorOnImageTooSmall": false
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1011 B

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 352 B

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 450 B

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 565 B

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 724 B

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 757 B

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 752 B

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 917 B

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 958 B

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 429 B

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 480 B

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 543 B

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 557 B

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

12
docs/static/icons/browserconfig.xml vendored Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square70x70logo src="/mstile-70x70.png"/>
<square150x150logo src="/mstile-150x150.png"/>
<square310x310logo src="/mstile-310x310.png"/>
<wide310x150logo src="/mstile-310x150.png"/>
<TileColor>#da532c</TileColor>
</tile>
</msapplication>
</browserconfig>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 274 B

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 382 B

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 724 B

52
docs/static/icons/manifest.json vendored Normal file
View File

@ -0,0 +1,52 @@
{
"name": "Calliope MINI",
"icons": [
{
"src": "\/android-chrome-36x36.png",
"sizes": "36x36",
"type": "image\/png"
},
{
"src": "\/android-chrome-48x48.png",
"sizes": "48x48",
"type": "image\/png"
},
{
"src": "\/android-chrome-72x72.png",
"sizes": "72x72",
"type": "image\/png"
},
{
"src": "\/android-chrome-96x96.png",
"sizes": "96x96",
"type": "image\/png"
},
{
"src": "\/android-chrome-144x144.png",
"sizes": "144x144",
"type": "image\/png"
},
{
"src": "\/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image\/png"
},
{
"src": "\/android-chrome-256x256.png",
"sizes": "256x256",
"type": "image\/png"
},
{
"src": "\/android-chrome-384x384.png",
"sizes": "384x384",
"type": "image\/png"
},
{
"src": "\/android-chrome-512x512.png",
"sizes": "512x512",
"type": "image\/png"
}
],
"theme_color": "#ffffff",
"display": "standalone"
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1011 B

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 918 B

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 971 B

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 682 B

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

@ -2,58 +2,42 @@
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
width="319.000000pt" height="319.000000pt" viewBox="0 0 319.000000 319.000000"
width="704.000000pt" height="704.000000pt" viewBox="0 0 704.000000 704.000000"
preserveAspectRatio="xMidYMid meet">
<metadata>
Created by potrace 1.11, written by Peter Selinger 2001-2013
</metadata>
<g transform="translate(0.000000,319.000000) scale(0.100000,-0.100000)"
<g transform="translate(0.000000,704.000000) scale(0.100000,-0.100000)"
fill="#000000" stroke="none">
<path d="M145 2888 c-49 -17 -92 -55 -114 -101 -21 -43 -21 -46 -21 -1110 l0
-1067 40 0 40 0 0 -135 c0 -78 4 -135 9 -135 6 0 11 90 13 218 3 207 4 218 26
249 28 40 98 68 147 59 46 -9 102 -59 112 -99 5 -18 7 -127 5 -244 l-3 -212
-107 -4 -107 -3 120 0 120 1 3 158 3 158 142 -3 142 -3 3 -157 c1 -87 7 -158
12 -158 5 0 10 100 12 227 3 254 8 274 78 320 60 41 143 20 187 -46 22 -33 23
-41 23 -267 0 -149 4 -234 10 -234 6 0 10 60 10 160 l0 160 190 0 190 0 0
-161 c0 -104 3 -158 10 -154 6 4 10 93 10 233 0 207 2 230 20 259 40 67 112
88 182 54 78 -38 83 -53 86 -319 2 -135 7 -232 13 -232 5 0 9 68 9 160 l0 160
185 0 185 0 0 -154 c0 -93 4 -157 10 -161 7 -4 10 66 10 202 0 114 5 225 10
245 34 121 169 154 249 63 l31 -36 0 -234 c0 -145 4 -236 10 -240 7 -4 10 50
10 154 l0 161 150 0 150 0 0 -160 c0 -100 4 -160 10 -160 6 0 10 83 10 228 0
263 4 280 81 320 51 27 104 24 151 -9 54 -39 58 -58 58 -294 0 -137 4 -215 10
-215 6 0 10 53 10 140 l0 140 45 0 44 0 4 -77 c1 -43 4 435 5 1062 1 1092 1
1142 -17 1180 -24 53 -55 83 -105 106 -39 18 -96 19 -1466 18 -967 0 -1435 -4
-1455 -11z m1203 -635 l3 -73 -41 0 -40 0 0 76 0 75 38 -3 37 -3 3 -72z m587
2 l0 -70 -37 -3 -38 -3 0 76 0 76 38 -3 37 -3 0 -70z m-880 -280 l0 -70 -40 0
-40 0 -3 49 c-2 27 -1 60 3 73 5 21 11 24 43 21 l37 -3 0 -70z m589 59 c9 -23
7 -107 -3 -122 -5 -8 -22 -12 -42 -10 l-34 3 -3 59 c-2 32 -1 65 2 72 8 20 72
18 80 -2z m584 -61 l3 -73 -41 0 -40 0 0 68 c0 38 3 72 7 76 4 4 21 6 38 4
l30 -3 3 -72z m-880 -5 l-3 -73 -35 0 -35 0 -3 73 -3 72 41 0 41 0 -3 -72z
m570 -5 l3 -73 -41 0 -40 0 0 68 c0 38 3 72 7 76 4 4 21 6 38 4 l30 -3 3 -72z
m-1388 -363 l0 -180 -185 0 -185 0 0 180 0 180 185 0 185 0 0 -180z m2500 0
l0 -180 -180 0 -180 0 0 180 0 180 180 0 180 0 0 -180z m-1982 161 c9 -5 12
-27 10 -72 l-3 -64 -40 0 -40 0 -3 58 c-2 35 2 64 9 73 13 15 47 18 67 5z
m307 -66 l0 -70 -37 -3 -38 -3 0 76 0 76 38 -3 37 -3 0 -70z m873 -2 l3 -73
-41 0 -40 0 0 68 c0 38 3 72 7 76 4 4 21 6 38 4 l30 -3 3 -72z m-590 -10 l3
-73 -41 0 -40 0 0 68 c0 38 3 72 7 76 4 4 21 6 38 4 l30 -3 3 -72z m280 68 c9
-5 12 -27 10 -72 l-3 -64 -40 0 -40 0 -3 64 c-3 67 4 81 43 81 11 0 26 -4 33
-9z m-568 -341 l0 -70 -40 0 -40 0 0 70 0 70 40 0 40 0 0 -70z m590 0 l0 -70
-40 0 -40 0 0 70 0 70 40 0 40 0 0 -70z m-292 -27 l3 -73 -41 0 -40 0 0 68 c0
38 3 72 7 76 4 4 21 6 38 4 l30 -3 3 -72z m-3 -253 l0 -65 -42 -3 -43 -3 0 71
0 71 43 -3 42 -3 0 -65z"/>
<path d="M294 1689 c-25 -13 -54 -60 -54 -89 0 -55 47 -100 105 -100 42 0 75
20 94 57 15 29 14 49 -4 88 -24 49 -88 69 -141 44z"/>
<path d="M2779 1671 c-23 -23 -29 -38 -29 -71 0 -91 106 -135 171 -71 64 65
20 171 -71 171 -33 0 -48 -6 -71 -29z"/>
<path d="M845 836 c-88 -40 -106 -150 -34 -210 24 -20 41 -26 81 -26 44 0 54
4 84 34 32 32 40 56 34 111 -7 70 -99 121 -165 91z"/>
<path d="M1543 836 c-89 -40 -97 -178 -13 -221 66 -34 141 -10 175 55 19 37
19 64 -1 105 -28 60 -101 87 -161 61z"/>
<path d="M2255 836 c-86 -38 -105 -146 -35 -208 24 -23 40 -28 79 -28 143 0
173 188 38 239 -36 14 -45 13 -82 -3z"/>
<path d="M192 820 c-118 -72 -38 -255 98 -225 45 10 90 67 90 116 0 105 -99
163 -188 109z"/>
<path d="M2875 831 c-90 -40 -97 -169 -12 -221 122 -75 250 92 149 193 -32 31
-98 45 -137 28z"/>
<path d="M3559 6976 c-2 -3 -27 -7 -54 -10 -28 -3 -61 -8 -75 -11 -14 -3 -38
-8 -55 -11 -30 -5 -104 -27 -160 -46 -76 -27 -305 -145 -325 -167 -3 -4 -32
-26 -65 -51 -58 -42 -183 -163 -235 -225 -61 -75 -190 -291 -205 -345 -1 -3
-7 -18 -13 -33 -16 -38 -42 -119 -47 -143 -2 -10 -4 -19 -5 -19 -2 0 -6 -17
-24 -110 -16 -87 -20 -240 -21 -969 l-1 -828 -46 -37 c-25 -20 -56 -43 -68
-51 -12 -8 -30 -22 -41 -30 -123 -96 -251 -190 -259 -190 -4 0 -10 -4 -12 -8
-1 -5 -102 -82 -223 -172 -121 -91 -224 -168 -230 -172 -5 -5 -53 -40 -105
-78 -52 -39 -105 -78 -116 -88 -12 -9 -32 -25 -45 -34 -13 -9 -49 -36 -80 -60
-31 -24 -155 -117 -275 -208 -121 -90 -237 -180 -258 -200 -62 -55 -158 -153
-188 -191 -50 -63 -93 -124 -107 -152 -8 -15 -18 -27 -23 -27 -5 0 -7 -4 -3
-9 3 -5 1 -12 -4 -15 -21 -13 -124 -256 -138 -326 -8 -40 -9 -44 -16 -65 -37
-115 -44 -485 -11 -598 3 -10 7 -30 9 -45 3 -15 11 -52 20 -82 9 -30 17 -62
19 -70 27 -111 162 -371 233 -450 13 -14 23 -28 23 -31 0 -3 10 -17 22 -31 13
-14 35 -38 49 -54 58 -66 179 -170 259 -223 92 -62 230 -135 230 -123 0 4 4 3
8 -3 8 -11 92 -44 131 -51 14 -3 29 -8 35 -12 6 -4 13 -7 16 -7 3 -1 30 -7 60
-13 93 -21 104 -23 145 -29 22 -4 1125 -8 2450 -10 1808 -3 2429 0 2485 8 82
13 193 46 267 81 88 40 214 129 271 191 77 83 77 82 151 197 9 14 28 52 43 85
37 87 41 99 39 109 -1 4 4 14 10 22 6 8 9 14 6 14 -3 0 -1 15 4 33 6 17 13 46
15 62 10 54 11 5669 2 5705 -5 19 -11 41 -13 48 -3 7 -4 13 -3 15 5 6 -64 95
-94 122 -73 64 -134 84 -258 82 -49 -1 -90 2 -90 7 0 5 -6 5 -12 0 -11 -8 -40
-9 -110 -3 -7 0 -65 0 -128 0 -63 0 -124 -1 -135 -1 -11 1 -46 0 -77 0 -31 0
-60 0 -65 1 -4 1 -12 1 -18 0 -5 -1 -89 -2 -185 -1 -252 1 -285 0 -380 -4 -85
-3 -164 -26 -186 -52 -6 -8 -16 -14 -21 -14 -13 0 -73 -69 -87 -100 -6 -14
-13 -27 -16 -30 -11 -10 -27 -76 -26 -108 1 -18 -1 -32 -4 -32 -8 0 -4 -166 4
-178 4 -7 4 -12 -1 -12 -9 0 -9 -103 1 -118 3 -6 3 -13 -1 -15 -5 -3 -7 -43
-5 -89 3 -104 3 -95 -1 -148 -2 -25 1 -53 5 -62 4 -9 4 -19 0 -22 -8 -5 -6
-79 3 -103 2 -7 1 -15 -4 -17 -4 -3 -13 25 -20 62 -46 252 -163 493 -336 691
-91 104 -289 270 -322 271 -7 0 -13 5 -13 10 0 6 -6 10 -14 10 -8 0 -21 6 -28
14 -21 20 -233 116 -273 122 -5 1 -35 9 -65 17 -51 15 -92 23 -165 34 -45 6
-321 14 -326 9z"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View File

@ -16,13 +16,9 @@ You will find two files in that project:
## Translating the blocks and reference documentation
The project below contains the resources from the blocks and functions using in the https://codethemicrobit.com.
You will find package files under ``/microbit`` , one for the block definition and one for the descriptions:
* [https://crowdin.com/project/pxt-microbit](https://crowdin.com/project/pxt-microbit)
You will find two files for each package available in the micro:bit, one for the block definition and one for the descriptions:
* ``microbit-strings.json``: contains the block definitions
* ``microbit-jsdoc-strings.json``: contains the descriptions
* ``core-strings.json``: contains the block definitions
* ``core-jsdoc-strings.json``: contains the descriptions
The block definition should be carefully translated using the [block definition syntax](https://www.pxt.io/defining-blocks).

View File

@ -4,22 +4,6 @@
using namespace pxt;
enum Delimiters {
//% block="new line"
NewLine = 1,
//% block=","
Comma = 2,
//% block="$"
Dollar = 3,
//% block=":"
Colon = 4,
//% block="."
Fullstop = 5,
//% block="#"
Hash = 6,
};
/**
* Support for additional Bluetooth services.
*/
@ -27,12 +11,33 @@ enum Delimiters {
namespace bluetooth {
MicroBitUARTService *uart = NULL;
/**
* Starts the Bluetooth accelerometer service
*/
//% help=bluetooth/start-accelerometer-service
//% blockId=bluetooth_start_accelerometer_service block="bluetooth accelerometer service"
//% parts="bluetooth" weight=90 blockGap=8
void startAccelerometerService() {
new MicroBitAccelerometerService(*uBit.ble, uBit.accelerometer);
}
/**
* Starts the Bluetooth button service
*/
//% help=bluetooth/start-button-service
//% blockId=bluetooth_start_button_service block="bluetooth button service" blockGap=8
//% parts="bluetooth" weight=89
void startButtonService() {
new MicroBitButtonService(*uBit.ble);
}
/**
* Starts the Bluetooth IO pin service.
*/
//% help=bluetooth/start-io-pin-service
//% blockId=bluetooth_start_io_pin_service block="bluetooth io pin service" blockGap=8
//% parts="bluetooth"
//% parts="bluetooth" weight=88
void startIOPinService() {
new MicroBitIOPinService(*uBit.ble, uBit.io);
}
@ -42,7 +47,7 @@ namespace bluetooth {
*/
//% help=bluetooth/start-led-service
//% blockId=bluetooth_start_led_service block="bluetooth led service" blockGap=8
//% parts="bluetooth"
//% parts="bluetooth" weight=87
void startLEDService() {
new MicroBitLEDService(*uBit.ble, uBit.display);
}
@ -52,7 +57,7 @@ namespace bluetooth {
*/
//% help=bluetooth/start-temperature-service
//% blockId=bluetooth_start_temperature_service block="bluetooth temperature service" blockGap=8
//% parts="bluetooth"
//% parts="bluetooth" weight=86
void startTemperatureService() {
new MicroBitTemperatureService(*uBit.ble, uBit.thermometer);
}
@ -61,38 +66,19 @@ namespace bluetooth {
* Starts the Bluetooth magnetometer service
*/
//% help=bluetooth/start-magnetometer-service
//% blockId=bluetooth_start_magnetometer_service block="bluetooth magnetometer service" blockGap=8
//% parts="bluetooth"
//% blockId=bluetooth_start_magnetometer_service block="bluetooth magnetometer service"
//% parts="bluetooth" weight=85
void startMagnetometerService() {
new MicroBitMagnetometerService(*uBit.ble, uBit.compass);
}
/**
* Starts the Bluetooth accelerometer service
*/
//% help=bluetooth/start-accelerometer-service
//% blockId=bluetooth_start_accelerometer_service block="bluetooth accelerometer service" blockGap=8
//% parts="bluetooth"
void startAccelerometerService() {
new MicroBitAccelerometerService(*uBit.ble, uBit.accelerometer);
}
/**
* Starts the Bluetooth button service
*/
//% help=bluetooth/start-button-service
//% blockId=bluetooth_start_button_service block="bluetooth button service" blockGap=8
//% parts="bluetooth"
void startButtonService() {
new MicroBitButtonService(*uBit.ble);
}
/**
* Starts the Bluetooth UART service
*/
//% help=bluetooth/start-uart-service
//% blockId=bluetooth_start_uart_service block="bluetooth uart service" blockGap=8
//% parts="bluetooth"
//% blockId=bluetooth_start_uart_service block="bluetooth uart service"
//% parts="bluetooth" advanced=true
void startUartService() {
if (uart) return;
// 61 octet buffer size is 3 x (MTU - 3) + 1
@ -102,13 +88,13 @@ namespace bluetooth {
}
//%
void uartWrite(StringData *data) {
void uartWriteString(StringData *data) {
startUartService();
uart->send(ManagedString(data));
}
//%
StringData* uartRead(StringData *del) {
StringData* uartReadUntil(StringData *del) {
startUartService();
return uart->readUntil(ManagedString(del)).leakData();
}
@ -133,7 +119,5 @@ namespace bluetooth {
//% parts="bluetooth"
void onBluetoothDisconnected(Action body) {
registerWithDal(MICROBIT_ID_BLE, MICROBIT_BLE_EVT_DISCONNECTED, body);
}
}
}

View File

@ -1,42 +1,48 @@
/**
* Support for additional Bluetooth services.
*/
//% color=#0082FB weight=20
namespace bluetooth {
/**
* Returns the delimiter corresponding string
*/
//% blockId="bluetooth_uart_delimiter_conv" block="%del"
//% weight=1 parts="bluetooth"
export function delimiters(del: Delimiters): string {
// even though it might not look like, this is more
// (memory) efficient than the C++ implementation, because the
// strings are statically allocated and take no RAM
switch (del) {
case Delimiters.NewLine: return "\n"
case Delimiters.Comma: return ","
case Delimiters.Dollar: return "$"
case Delimiters.Colon: return ":"
case Delimiters.Fullstop: return "."
case Delimiters.Hash: return "#"
default: return "\n"
}
}
/**
* Writes to the Bluetooth UART service buffer. From there the data is transmitted over Bluetooth to a connected device.
*/
//% help=bluetooth/uart-write
//% blockId=bluetooth_uart_write block="bluetooth uart write %data" blockGap=8
//% parts="bluetooth" shim=bluetooth::uartWrite
export function uartWrite(data: string): void {
//% help=bluetooth/uart-write-string weight=80
//% blockId=bluetooth_uart_write block="bluetooth uart|write string %data" blockGap=8
//% parts="bluetooth" shim=bluetooth::uartWriteString advanced=true
export function uartWriteString(data: string): void {
// dummy implementation for simulator
console.log("UART Write: " + data)
}
/**
* Prints a numeric value to the serial
*/
//% help=bluetooth/uart-write-number weight=79
//% weight=89 blockGap=8 advanced=true
//% blockId=bluetooth_uart_writenumber block="bluetooth uart|write number %value"
export function uartWriteNumber(value: number): void {
uartWriteString(value.toString());
}
/**
* Writes a ``name: value`` pair line to the serial.
* @param name name of the value stream, eg: x
* @param value to write
*/
//% weight=88 weight=78
//% help=bluetooth/uart-write-value advanced=true
//% blockId=bluetooth_uart_writevalue block="bluetooth uart|write value %name|= %value"
export function uartWriteValue(name: string, value: number): void {
uartWriteString(name + ":" + value + "\r\n");
}
/**
* Reads from the Bluetooth UART service buffer, returning its contents when the specified delimiter character is encountered.
*/
//% help=bluetooth/uart-read
//% blockId=bluetooth_uart_read block="bluetooth uart read %del=bluetooth_uart_delimiter_conv" blockGap=8
//% parts="bluetooth" shim=bluetooth::uartRead
export function uartRead(del: string): string {
//% help=bluetooth/uart-read-until weight=75
//% blockId=bluetooth_uart_read block="bluetooth uart|read until %del=serial_delimiter_conv"
//% parts="bluetooth" shim=bluetooth::uartReadUntil advanced=true
export function uartReadUntil(del: string): string {
// dummy implementation for simulator
return "???"
}

View File

@ -1,20 +1,4 @@
// Auto-generated. Do not edit.
declare enum Delimiters {
//% block="new line"
NewLine = 1,
//% block=","
Comma = 2,
//% block="$"
Dollar = 3,
//% block=":"
Colon = 4,
//% block="."
Fullstop = 5,
//% block="#"
Hash = 6,
}
declare namespace bluetooth {
}

View File

@ -7,44 +7,12 @@
//% color=#0082FB weight=20
declare namespace bluetooth {
/**
* Starts the Bluetooth IO pin service.
*/
//% help=bluetooth/start-io-pin-service
//% blockId=bluetooth_start_io_pin_service block="bluetooth io pin service" blockGap=8
//% parts="bluetooth" shim=bluetooth::startIOPinService
function startIOPinService(): void;
/**
* Starts the Bluetooth LED service
*/
//% help=bluetooth/start-led-service
//% blockId=bluetooth_start_led_service block="bluetooth led service" blockGap=8
//% parts="bluetooth" shim=bluetooth::startLEDService
function startLEDService(): void;
/**
* Starts the Bluetooth temperature service
*/
//% help=bluetooth/start-temperature-service
//% blockId=bluetooth_start_temperature_service block="bluetooth temperature service" blockGap=8
//% parts="bluetooth" shim=bluetooth::startTemperatureService
function startTemperatureService(): void;
/**
* Starts the Bluetooth magnetometer service
*/
//% help=bluetooth/start-magnetometer-service
//% blockId=bluetooth_start_magnetometer_service block="bluetooth magnetometer service" blockGap=8
//% parts="bluetooth" shim=bluetooth::startMagnetometerService
function startMagnetometerService(): void;
/**
* Starts the Bluetooth accelerometer service
*/
//% help=bluetooth/start-accelerometer-service
//% blockId=bluetooth_start_accelerometer_service block="bluetooth accelerometer service" blockGap=8
//% parts="bluetooth" shim=bluetooth::startAccelerometerService
//% blockId=bluetooth_start_accelerometer_service block="bluetooth accelerometer service"
//% parts="bluetooth" weight=90 blockGap=8 shim=bluetooth::startAccelerometerService
function startAccelerometerService(): void;
/**
@ -52,15 +20,47 @@ declare namespace bluetooth {
*/
//% help=bluetooth/start-button-service
//% blockId=bluetooth_start_button_service block="bluetooth button service" blockGap=8
//% parts="bluetooth" shim=bluetooth::startButtonService
//% parts="bluetooth" weight=89 shim=bluetooth::startButtonService
function startButtonService(): void;
/**
* Starts the Bluetooth IO pin service.
*/
//% help=bluetooth/start-io-pin-service
//% blockId=bluetooth_start_io_pin_service block="bluetooth io pin service" blockGap=8
//% parts="bluetooth" weight=88 shim=bluetooth::startIOPinService
function startIOPinService(): void;
/**
* Starts the Bluetooth LED service
*/
//% help=bluetooth/start-led-service
//% blockId=bluetooth_start_led_service block="bluetooth led service" blockGap=8
//% parts="bluetooth" weight=87 shim=bluetooth::startLEDService
function startLEDService(): void;
/**
* Starts the Bluetooth temperature service
*/
//% help=bluetooth/start-temperature-service
//% blockId=bluetooth_start_temperature_service block="bluetooth temperature service" blockGap=8
//% parts="bluetooth" weight=86 shim=bluetooth::startTemperatureService
function startTemperatureService(): void;
/**
* Starts the Bluetooth magnetometer service
*/
//% help=bluetooth/start-magnetometer-service
//% blockId=bluetooth_start_magnetometer_service block="bluetooth magnetometer service"
//% parts="bluetooth" weight=85 shim=bluetooth::startMagnetometerService
function startMagnetometerService(): void;
/**
* Starts the Bluetooth UART service
*/
//% help=bluetooth/start-uart-service
//% blockId=bluetooth_start_uart_service block="bluetooth uart service" blockGap=8
//% parts="bluetooth" shim=bluetooth::startUartService
//% blockId=bluetooth_start_uart_service block="bluetooth uart service"
//% parts="bluetooth" advanced=true shim=bluetooth::startUartService
function startUartService(): void;
/**

View File

@ -0,0 +1,54 @@
/*basic.showString("RGB")
basic.setLedColor(Colors.Blue)
basic.pause(500)
basic.setLedColor(Colors.Red)
basic.pause(500)
basic.setLedColor(Colors.Green)
basic.pause(500)
basic.setLedColor(Colors.Violet)
basic.pause(500)
basic.setLedColor(0);
basic.showString("Gesten")
input.onGesture(Gesture.Shake, () => {
basic.showString("S")
})
input.onGesture(Gesture.LogoUp, () => {
basic.showString("U")
})
input.onGesture(Gesture.LogoDown, () => {
basic.showString("D")
})
input.onGesture(Gesture.ScreenUp, () => {
basic.showString("+")
})
input.onGesture(Gesture.TiltRight, () => {
basic.showString("R")
})
input.onGesture(Gesture.FreeFall, () => {
basic.showString("F")
})
input.onGesture(Gesture.ScreenDown, () => {
basic.showString("-")
})
input.onGesture(Gesture.TiltLeft, () => {
basic.showString("L")
})
input.onGesture(Gesture.ThreeG, () => {
basic.showString("3")
})
input.onGesture(Gesture.SixG, () => {
basic.showString("6")
})
*/
input.onPinPressed(TouchPin.P0, () => {
basic.showNumber(0)
})
input.onPinPressed(TouchPin.P1, () => {
basic.showNumber(1)
})
input.onPinPressed(TouchPin.P2, () => {
basic.showNumber(2)
})
input.onPinPressed(TouchPin.P3, () => {
basic.showNumber(3)
})

View File

@ -0,0 +1,11 @@
{
"name": "calliope",
"description": "Test of Calliope Parts",
"files": [
"calliope.ts"
],
"public": true,
"dependencies": {
"core": "file:../core"
}
}

View File

@ -0,0 +1,80 @@
{
"Math.randomBoolean|block": "pick random true or false",
"Math|block": "Math",
"String.fromCharCode|block": "text from char code %code",
"String|block": "String",
"basic.clearScreen|block": "clear screen",
"basic.forever|block": "forever",
"basic.pause|block": "pause (ms) %pause",
"basic.showLeds|block": "show leds",
"basic.showNumber|block": "show|number %number",
"basic.showString|block": "show|string %text",
"basic|block": "basic",
"control.inBackground|block": "run in background",
"control.reset|block": "reset",
"control.waitMicros|block": "wait (µs)%micros",
"control|block": "control",
"game.addScore|block": "change score by|%points",
"game.gameOver|block": "game over",
"game.score|block": "score",
"game.startCountdown|block": "start countdown|(ms) %duration",
"game|block": "game",
"images.createBigImage|block": "create big image",
"images.createImage|block": "create image",
"images|block": "images",
"input.acceleration|block": "acceleration (mg)|%NAME",
"input.buttonIsPressed|block": "button|%NAME|is pressed",
"input.compassHeading|block": "compass heading (°)",
"input.lightLevel|block": "light level",
"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.onPinReleased|block": "on pin %NAME|released",
"input.pinIsPressed|block": "pin %NAME|is pressed",
"input.rotation|block": "rotation (°)|%NAME",
"input.runningTime|block": "running time (ms)",
"input.setAccelerometerRange|block": "set accelerometer|range %range",
"input.temperature|block": "temperature (°C)",
"input|block": "input",
"led.brightness|block": "brightness",
"led.plotBarGraph|block": "plot bar graph of %value |up to %high",
"led.plot|block": "plot|x %x|y %y",
"led.point|block": "point|x %x|y %y",
"led.setBrightness|block": "set brightness %value",
"led.stopAnimation|block": "stop animation",
"led.toggle|block": "toggle|x %x|y %y",
"led.unplot|block": "unplot|x %x|y %y",
"led|block": "led",
"music.beat|block": "%fraction|beat",
"music.changeTempoBy|block": "change tempo by (bpm)|%value",
"music.noteFrequency|block": "%note",
"music.playTone|block": "play|tone %note=device_note|for %duration=device_beat",
"music.rest|block": "rest(ms)|%duration=device_beat",
"music.ringTone|block": "ring tone (Hz)|%note=device_note",
"music.setTempo|block": "set tempo to (bpm)|%value",
"music.tempo|block": "tempo (bpm)",
"music|block": "music",
"pins.analogReadPin|block": "analog read|pin %name",
"pins.analogSetPeriod|block": "analog set period|pin %pin|to (µs)%micros",
"pins.analogWritePin|block": "analog write|pin %name|to %value",
"pins.digitalReadPin|block": "digital read|pin %name",
"pins.digitalWritePin|block": "digital write|pin %name|to %value",
"pins.i2cReadNumber|block": "i2c read number|at address %address|of format %format=i2c_sizeof",
"pins.i2cWriteNumber|block": "i2c write number|at address %address|with value %value|of format %format=i2c_sizeof",
"pins.map|block": "map %value|from low %fromLow|from high %fromHigh|to low %toLow|to high %toHigh",
"pins.onPulsed|block": "on|pin %pin|pulsed %pulse",
"pins.pulseDuration|block": "pulse duration (µs)",
"pins.servoSetPulse|block": "servo set pulse|pin %value|to (µs) %micros",
"pins.servoWritePin|block": "servo write|pin %name|to %value",
"pins.setPull|block": "set pull|pin %pin|to %pull",
"pins.spiWrite|block": "spi write %value",
"pins|block": "pins",
"serial.readLine|block": "serial read line",
"serial.redirect|block": "serial redirect to|TX %tx|RX %rx|at baud rate %rate",
"serial.writeLine|block": "serial|write line %text",
"serial.writeNumber|block": "serial|write number %value",
"serial.writeString|block": "serial write string %text",
"serial.writeValue|block": "serial|write value %name|= %value",
"serial|block": "serial"
}

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

@ -145,13 +145,14 @@ declare const enum DAL {
MICROBIT_ID_RADIO_DATA_READY = 30,
MICROBIT_ID_MULTIBUTTON_ATTACH = 31,
MICROBIT_ID_SERIAL = 32,
CALLIOPE_ID_IO_P0 = 33,
CALLIOPE_ID_IO_P3 = 33,
CALLIOPE_ID_IO_P7 = 34,
CALLIOPE_ID_IO_P8 = 35,
CALLIOPE_ID_IO_P9 = 36,
CALLIOPE_ID_IO_P13 = 37,
CALLIOPE_ID_IO_P14 = 38,
CALLIOPE_ID_IO_P15 = 39,
CALLIOPE_ID_IO_P22 = 40,
MICROBIT_ID_MESSAGE_BUS_LISTENER = 1021,
MICROBIT_ID_NOTIFY_ONE = 1022,
MICROBIT_ID_NOTIFY = 1023,
@ -426,6 +427,7 @@ declare const enum DAL {
MICROBIT_ACCELEROMETER_TILT_TOLERANCE = 200,
MICROBIT_ACCELEROMETER_FREEFALL_TOLERANCE = 400,
MICROBIT_ACCELEROMETER_SHAKE_TOLERANCE = 400,
MICROBIT_ACCELEROMETER_2G_TOLERANCE = 2048,
MICROBIT_ACCELEROMETER_3G_TOLERANCE = 3072,
MICROBIT_ACCELEROMETER_6G_TOLERANCE = 6144,
MICROBIT_ACCELEROMETER_8G_TOLERANCE = 8192,

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

@ -37,6 +37,7 @@ declare namespace basic {
P0 = 7, // MICROBIT_ID_IO_P0
P1 = 8, // MICROBIT_ID_IO_P1
P2 = 9, // MICROBIT_ID_IO_P2
P3 = 33, // CALLIOPE_ID_IO_P3
}
@ -311,6 +312,22 @@ declare namespace motors {
//% block=9600
BaudRate9600 = 9600,
}
declare enum Delimiters {
//% block="new line"
NewLine = 1,
//% block=","
Comma = 2,
//% block="$"
Dollar = 3,
//% block=":"
Colon = 4,
//% block="."
Fullstop = 5,
//% block="#"
Hash = 6,
}
declare namespace serial {
}

View File

@ -29,6 +29,7 @@ enum class TouchPin {
P0 = MICROBIT_ID_IO_P0,
P1 = MICROBIT_ID_IO_P1,
P2 = MICROBIT_ID_IO_P2,
P3 = CALLIOPE_ID_IO_P3
};
enum class AcceleratorRange {
@ -130,7 +131,7 @@ namespace input {
//% parts="accelerometer"
void onGesture(Gesture gesture, Action body) {
if ((int)gesture == MICROBIT_ACCELEROMETER_EVT_3G && uBit.accelerometer.getRange() < 3)
uBit.accelerometer.setRange(4);
uBit.accelerometer.setRange(6);
else if ((int)gesture == MICROBIT_ACCELEROMETER_EVT_6G && uBit.accelerometer.getRange() < 6)
uBit.accelerometer.setRange(8);
registerWithDal(MICROBIT_ID_GESTURE, (int)gesture, body);

View File

@ -66,6 +66,14 @@ MicroBitPin *getPin(int id) {
//case MICROBIT_ID_IO_P16: return &uBit.io.P16;
case MICROBIT_ID_IO_P19: return &uBit.io.P19;
case MICROBIT_ID_IO_P20: return &uBit.io.P20;
case CALLIOPE_ID_IO_P3: return &uBit.io.CAL_P3;
case CALLIOPE_ID_IO_P7: return &uBit.io.CAL_P7;
case CALLIOPE_ID_IO_P8: return &uBit.io.CAL_P8;
case CALLIOPE_ID_IO_P9: return &uBit.io.CAL_P9;
case CALLIOPE_ID_IO_P13: return &uBit.io.CAL_P13;
case CALLIOPE_ID_IO_P14: return &uBit.io.CAL_P14;
case CALLIOPE_ID_IO_P15: return &uBit.io.CAL_P15;
case CALLIOPE_ID_IO_P22: return &uBit.io.CAL_P22;
default: return NULL;
}
}

View File

@ -33,7 +33,9 @@
"parts/speaker.svg",
"parts/headphone.svg",
"parts/dcmotor.svg",
"_locales/fr/microbit-jsdoc-strings.json"
"_locales/ja/core-jsdoc-strings.json",
"_locales/ja/core-strings.json",
"_locales/fr/core-jsdoc-strings.json"
],
"public": true,
"dependencies": {},

View File

@ -1,6 +1,6 @@
#include "ksbit.h"
enum class SerialPin {
enum SerialPin {
P0 = MICROBIT_ID_IO_P0,
P1 = MICROBIT_ID_IO_P1,
P2 = MICROBIT_ID_IO_P2,
@ -12,36 +12,52 @@ enum class SerialPin {
//P16 = MICROBIT_ID_IO_P16
};
enum class BaudRate {
enum BaudRate {
//% block=115200
BaudRate115200 = 115200,
//% block=9600
BaudRate9600 = 9600
};
enum Delimiters {
//% block="new line"
NewLine = 1,
//% block=","
Comma = 2,
//% block="$"
Dollar = 3,
//% block=":"
Colon = 4,
//% block="."
Fullstop = 5,
//% block="#"
Hash = 6,
};
//% weight=2 color=30
//% advanced=true
namespace serial {
// note that at least one // followed by % is needed per declaration!
/**
* Reads a line of text from the serial port.
* Reads a line of text from the serial port and returns the buffer when the delimiter is met.
* @param delimiter text delimiter that separates each text chunk
*/
//% help=serial/read-line
//% blockId=serial_read_line block="serial read line"
//% weight=20
StringData* readLine() {
return uBit.serial.readUntil(ManagedString("\n")).leakData();
//% help=serial/read-until
//% blockId=serial_read_until block="serial|read until %delimiter=serial_delimiter_conv"
//% weight=19
StringData* readUntil(StringData* delimiter) {
return uBit.serial.readUntil(ManagedString(delimiter)).leakData();
}
/**
* Sends a piece of text through Serial connection.
* Reads a line of text from the serial port.
*/
//% help=serial/write-string
//% weight=87
//% blockId=serial_writestring block="serial write string %text"
void writeString(StringData *text) {
uBit.serial.send(ManagedString(text));
//% help=serial/read-line
//% blockId=serial_read_line block="serial|read line"
//% weight=20 blockGap=8
StringData* readLine() {
return readUntil(ManagedString("\n").leakData());
}
/**
@ -49,12 +65,22 @@ namespace serial {
* @param delimiters the characters to match received characters against. eg:"\n"
*/
// help=serial/on-data-received
// weight=19
// weight=18
void onDataReceived(StringData* delimiters, Action body) {
uBit.serial.eventOn(ManagedString(delimiters));
registerWithDal(MICROBIT_ID_SERIAL, MICROBIT_SERIAL_EVT_DELIM_MATCH, body);
}
/**
* Sends a piece of text through Serial connection.
*/
//% help=serial/write-string
//% weight=87
//% blockId=serial_writestring block="serial|write string %text"
void writeString(StringData *text) {
uBit.serial.send(ManagedString(text));
}
/**
* Dynamically configuring the serial instance to use pins other than USBTX and USBRX.
* @param tx the new transmission pins
@ -63,7 +89,7 @@ namespace serial {
*/
//% weight=10
//% help=serial/redirect-to
//% blockId=serial_redirect block="serial redirect to|TX %tx|RX %rx|at baud rate %rate"
//% blockId=serial_redirect block="serial|redirect to|TX %tx|RX %rx|at baud rate %rate"
//% blockExternalInputs=1
void redirect(SerialPin tx, SerialPin rx, BaudRate rate) {
uBit.serial.redirect((PinName)tx, (PinName)rx);

View File

@ -46,4 +46,24 @@ namespace serial {
export function onLineReceived(body: Action): void {
// serial.onDataReceived("\n", body);
}
/**
* Returns the delimiter corresponding string
*/
//% blockId="serial_delimiter_conv" block="%del"
//% weight=1
export function delimiters(del: Delimiters): string {
// even though it might not look like, this is more
// (memory) efficient than the C++ implementation, because the
// strings are statically allocated and take no RAM
switch (del) {
case Delimiters.NewLine: return "\n"
case Delimiters.Comma: return ","
case Delimiters.Dollar: return "$"
case Delimiters.Colon: return ":"
case Delimiters.Fullstop: return "."
case Delimiters.Hash: return "#"
default: return "\n"
}
}
}

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

@ -671,12 +671,21 @@ declare namespace pins {
//% advanced=true
declare namespace serial {
/**
* Reads a line of text from the serial port and returns the buffer when the delimiter is met.
* @param delimiter text delimiter that separates each text chunk
*/
//% help=serial/read-until
//% blockId=serial_read_until block="serial|read until %delimiter=serial_delimiter_conv"
//% weight=19 shim=serial::readUntil
function readUntil(delimiter: string): string;
/**
* Reads a line of text from the serial port.
*/
//% help=serial/read-line
//% blockId=serial_read_line block="serial read line"
//% weight=20 shim=serial::readLine
//% blockId=serial_read_line block="serial|read line"
//% weight=20 blockGap=8 shim=serial::readLine
function readLine(): string;
/**
@ -684,7 +693,7 @@ declare namespace serial {
*/
//% help=serial/write-string
//% weight=87
//% blockId=serial_writestring block="serial write string %text" shim=serial::writeString
//% blockId=serial_writestring block="serial|write string %text" shim=serial::writeString
function writeString(text: string): void;
/**
@ -695,7 +704,7 @@ declare namespace serial {
*/
//% weight=10
//% help=serial/redirect-to
//% blockId=serial_redirect block="serial redirect to|TX %tx|RX %rx|at baud rate %rate"
//% blockId=serial_redirect block="serial|redirect to|TX %tx|RX %rx|at baud rate %rate"
//% blockExternalInputs=1 shim=serial::redirect
function redirect(tx: SerialPin, rx: SerialPin, rate: BaudRate): void;
}

Some files were not shown because too many files have changed in this diff Show More