Compare commits
17 Commits
Author | SHA1 | Date | |
---|---|---|---|
7e79635413 | |||
56e1cf91ac | |||
f9f96f33f0 | |||
0b33073be1 | |||
65594842fc | |||
c6ed665f84 | |||
79462deb24 | |||
5c05f3e241 | |||
4f7dd75fbe | |||
338e507b51 | |||
601231a5dc | |||
f0850336e5 | |||
a6b2187ec5 | |||
28ae4f4230 | |||
09933b6a8d | |||
45bb6e7cb3 | |||
33c234a87e |
@ -28,11 +28,12 @@ export function deployCoreAsync(res: ts.pxt.CompileResult) {
|
||||
|
||||
function getBitDrivesAsync(): Promise<string[]> {
|
||||
if (process.platform == "win32") {
|
||||
let rx = new RegExp("^([A-Z]:).* " + pxt.appTarget.compile.deployDrives)
|
||||
return execAsync("wmic PATH Win32_LogicalDisk get DeviceID, VolumeName, FileSystem")
|
||||
.then(buf => {
|
||||
let res: string[] = []
|
||||
buf.toString("utf8").split(/\n/).forEach(ln => {
|
||||
let m = /^([A-Z]:).* MICROBIT/.exec(ln)
|
||||
let m = rx.exec(ln)
|
||||
if (m) {
|
||||
res.push(m[1] + "/")
|
||||
}
|
||||
@ -41,8 +42,9 @@ function getBitDrivesAsync(): Promise<string[]> {
|
||||
})
|
||||
}
|
||||
else if (process.platform == "darwin") {
|
||||
let rx = new RegExp(pxt.appTarget.compile.deployDrives)
|
||||
return readDirAsync("/Volumes")
|
||||
.then(lst => lst.filter(s => /MICROBIT/.test(s)).map(s => "/Volumes/" + s + "/"))
|
||||
.then(lst => lst.filter(s => rx.test(s)).map(s => "/Volumes/" + s + "/"))
|
||||
} else {
|
||||
return Promise.resolve([])
|
||||
}
|
||||
|
@ -148,12 +148,6 @@ Trim any leftover fabric, threads or tape.
|
||||
|
||||
Your watch is ready!
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
Excellent, you're ready to continue with the [challenges](/projects/rock-paper-scissors)!
|
||||
|
||||
### ~
|
||||
|
||||
### Acknowledgements
|
||||
|
||||
Artistic design by Melinda Hoeneisen.
|
||||
|
@ -9,14 +9,24 @@ led.stopAnimation()
|
||||
|
||||
### Example
|
||||
|
||||
This program...
|
||||
This program sets up the ``stop animation`` part of the program,
|
||||
and then shows a string that you can stop with button ``B``.
|
||||
|
||||
```blocks
|
||||
basic.showString("STOP ME! STOP ME! PLEASE, WON'T SOMEBODY STOP ME?");
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
led.stopAnimation();
|
||||
});
|
||||
'```
|
||||
basic.showString("STOP ME! STOP ME! PLEASE, WON'T SOMEBODY STOP ME?");
|
||||
```
|
||||
|
||||
### ~hint
|
||||
|
||||
It's important to set up ``stop animation`` before showing the
|
||||
animation, so the ``stop animation`` part of the program will be ready
|
||||
to go.
|
||||
|
||||
### ~
|
||||
|
||||
### See Also
|
||||
|
||||
|
||||
[show animation](/reference/basic/show-animation)
|
||||
|
@ -1,18 +1,26 @@
|
||||
# Write Value To Serial
|
||||
|
||||
Writes the full data received data via ``radio`` to serial in JSON format.
|
||||
|
||||
**Note** - This method only works for [send number](/reference/radio/send-number) and [send value](/reference/radio/send-value). It does not work for [send string](/reference/radio/send-string) (although a string can be sent with [send value](/reference/radio/send-value)).
|
||||
Writes the data received by ``radio`` to serial in JSON format.
|
||||
|
||||
```sig
|
||||
radio.writeValueToSerial();
|
||||
```
|
||||
|
||||
## Data received format
|
||||
The format for received data printed to serial is as follows
|
||||
- [send number](/reference/radio/send-number) - ```{v:ValueSent,t:MicrobitTimeAlive,s:Unused}```
|
||||
- [send value](/reference/radio/send-number) - ```{v:Value,t:MicrobitTimeAlive,s:Unused,n:"Name"}```
|
||||
- [send string](/reference/radio/send-string) - ```{}``` (currently unavailable)
|
||||
### ~hint
|
||||
|
||||
This method only works for [send number](/reference/radio/send-number)
|
||||
and [send value](/reference/radio/send-value). It does not work for
|
||||
[send string](/reference/radio/send-string), although you can send a
|
||||
string as part of [send value](/reference/radio/send-value).
|
||||
|
||||
### ~
|
||||
|
||||
### Data received format
|
||||
|
||||
The format for received data printed to serial is as follows:
|
||||
|
||||
- [send number](/reference/radio/send-number): ```{v:ValueSent,t:MicrobitTimeAlive,s:Unused}```
|
||||
- [send value](/reference/radio/send-value): ```{v:ValueSent,t:MicrobitTimeAlive,s:Unused,n:"Name"}```
|
||||
|
||||
### Simulator
|
||||
|
||||
@ -20,7 +28,9 @@ This function only works on the micro:bit, not in browsers.
|
||||
|
||||
### Examples
|
||||
|
||||
When ```radio``` data is received (after pressing A button on 2nd micro:bit), output temperature data to serial.
|
||||
When ```radio``` data is received (after pressing the ``A`` button on
|
||||
the second micro:bit), this program sends temperature data to
|
||||
serial.
|
||||
|
||||
```blocks
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
@ -30,9 +40,11 @@ radio.onDataReceived(() => {
|
||||
radio.writeValueToSerial();
|
||||
});
|
||||
```
|
||||
Example output to serial when A button pressed:
|
||||
Sample output to serial when ``A`` button pressed:
|
||||
```{v:27,t:323,s:0}```
|
||||
|
||||
### See also
|
||||
|
||||
[send number](/reference/radio/send-number), [send value](/reference/radio/send-number), [on data received](/reference/radio/on-data-received)
|
||||
[send number](/reference/radio/send-number),
|
||||
[send value](/reference/radio/send-value),
|
||||
[on data received](/reference/radio/on-data-received)
|
||||
|
@ -23,7 +23,7 @@ namespace basic {
|
||||
if (value < 0 || value >= 10) {
|
||||
uBit.display.scroll(t, interval);
|
||||
} else {
|
||||
uBit.display.print(t.charAt(0), interval * 5);
|
||||
uBit.display.printChar(t.charAt(0), interval * 5);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "pxt-microbit",
|
||||
"version": "0.3.4",
|
||||
"version": "0.3.8",
|
||||
"description": "BBC micro:bit target for PXT",
|
||||
"keywords": [
|
||||
"JavaScript",
|
||||
@ -29,6 +29,6 @@
|
||||
"typescript": "^1.8.7"
|
||||
},
|
||||
"dependencies": {
|
||||
"pxt-core": "0.3.7"
|
||||
"pxt-core": "0.3.11"
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@
|
||||
"compile": {
|
||||
"isNative": false,
|
||||
"hasHex": true,
|
||||
"deployDrives": "^MICROBIT",
|
||||
"deployDrives": "(MICROBIT|MBED)",
|
||||
"driveName": "MICROBIT",
|
||||
"hexMimeType": "application/x-microbit-hex"
|
||||
},
|
||||
|
@ -725,7 +725,8 @@ namespace pxsim.ImageMethods {
|
||||
board().animationQ.enqueue({
|
||||
interval: interval,
|
||||
frame: () => {
|
||||
if (off >= leds.width || off < 0) return false;
|
||||
//TODO: support right to left.
|
||||
if (off >= leds.width + 5 || off < 0) return false;
|
||||
stride > 0 ? display.shiftLeft(stride) : display.shiftRight(-stride);
|
||||
let c = Math.min(stride, leds.width - off);
|
||||
leds.copyTo(off, c, display, 5 - stride)
|
||||
|
Reference in New Issue
Block a user