Compare commits

...

26 Commits

Author SHA1 Message Date
dc8afa6d45 0.3.10 2016-08-02 11:06:34 -07:00
22e2ab5ad9 Bump pxt-core to 0.3.13 2016-08-02 11:06:31 -07:00
f365726a8e fixed regfression in showleds
see 65594842fc
2016-08-02 11:04:49 -07:00
e329b3bd2e prepend all radio blocks with "radio" 2016-08-01 16:02:06 -07:00
d7b709e97b added screenshots 2016-08-01 16:01:45 -07:00
9714ec46e9 support page 2016-08-01 14:24:25 -07:00
20ef54f565 fixed win10 app 2016-08-01 14:23:40 -07:00
554df0bce9 0.3.9 2016-07-29 14:22:51 -07:00
6c89dddef6 Bump pxt-core to 0.3.12 2016-07-29 14:22:48 -07:00
23f91895f7 restore advanced section in reference 2016-07-29 14:19:21 -07:00
3f83cda087 mark serial messages as simulated 2016-07-29 13:42:21 -07:00
7e79635413 0.3.8 2016-07-29 10:49:38 -07:00
56e1cf91ac Bump pxt-core to 0.3.11 2016-07-29 10:49:36 -07:00
f9f96f33f0 0.3.7 2016-07-29 11:37:58 +01:00
0b33073be1 Bump pxt-core to 0.3.10 2016-07-29 11:37:57 +01:00
65594842fc Fix issue with multi digit numbers not scrolling all the way off screen as is the case on the physical pxt. 2016-07-28 15:54:10 -07:00
c6ed665f84 Fix for issue 176: basic.showNumber timing in the simulator
- updated basic.cpp::showNumber to use printChar instead of print.
2016-07-28 15:04:56 -07:00
79462deb24 Merge pull request #190 from Microsoft/microsoftsam/issue179
Fix for issue 179: Watch Challenges goes to Rock Paper Scissors instead of the challenges code
2016-07-28 14:21:18 -07:00
5c05f3e241 Fix for issue 179: Watch Challenges goes to Rock Paper Scissors instead of the challenges code 2016-07-28 13:13:33 -07:00
4f7dd75fbe Finished animation API 2016-07-28 12:16:18 -07:00
338e507b51 temporary fix for reference 2016-07-28 12:03:03 -07:00
601231a5dc 0.3.6 2016-07-28 11:54:23 -07:00
f0850336e5 Bump pxt-core to 0.3.9 2016-07-28 11:54:18 -07:00
a6b2187ec5 Edited advanced page 2016-07-28 10:56:37 -07:00
28ae4f4230 better board name detection 2016-07-28 10:22:05 -07:00
09933b6a8d advanced section 2016-07-28 09:15:31 -07:00
19 changed files with 101 additions and 68 deletions

3
.gitignore vendored
View File

@ -7,6 +7,9 @@ typings
tmp
temp
projects/**
clients/win10/app/AppPackages
clients/win10/app/BundlePackages
clients/win10/app/BundleArtifacts
clients/win10/app/bin
clients/win10/app/bld
clients/win10/*.opendb

View File

@ -20,22 +20,18 @@
<ProjectConfiguration Include="Release|AnyCPU">
<Configuration>Release</Configuration>
<Platform>AnyCPU</Platform>
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM">
<Configuration>Release</Configuration>
<Platform>ARM</Platform>
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x86">
<Configuration>Release</Configuration>
<Platform>x86</Platform>
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

View File

@ -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([])
}

View File

@ -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.

View File

@ -22,3 +22,14 @@ control.inBackground(() => {
});
```
## Advanced
```namespaces
devices.tellCameraTo(MesCameraEvent.TakePhoto);
bluetooth.onBluetoothConnected(() => {});
```
```package
microbit-devices
microbit-bluetooth
```

View File

@ -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)

View File

@ -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)

3
docs/support.md Normal file
View File

@ -0,0 +1,3 @@
# Support
Please use the [GitHub issue tracker](https://github.com/microsoft/pxt-microbit) to report bugs.

View File

@ -43,7 +43,7 @@ namespace radio {
*/
//% help=radio/send-number
//% weight=60
//% blockId=radio_datagram_send block="send number %value" blockGap=8
//% blockId=radio_datagram_send block="radio send number %value" blockGap=8
void sendNumber(int value) {
if (radioEnable() != MICROBIT_OK) return;
uint32_t t = system_timer_current_time();
@ -54,13 +54,13 @@ namespace radio {
/**
* Broadcasts a name / value pair along with the device serial number
* and running time to any connected BBC micro:bit in the group.
* and running time to any connected micro:bit in the group.
* @param name the field name (max 12 characters), eg: "data"
* @param value the numberic value
*/
//% help=radio/send-value
//% weight=59
//% blockId=radio_datagram_send_value block="send|value %name|= %value" blockGap=8
//% blockId=radio_datagram_send_value block="radio send|value %name|= %value" blockGap=8
void sendValue(StringData* name, int value) {
if (radioEnable() != MICROBIT_OK) return;
@ -86,7 +86,7 @@ namespace radio {
*/
//% help=radio/send-string
//% weight=58
//% blockId=radio_datagram_send_string block="send string %msg"
//% blockId=radio_datagram_send_string block="radio send string %msg"
void sendString(StringData* msg) {
if (radioEnable() != MICROBIT_OK) return;
@ -103,7 +103,7 @@ namespace radio {
*/
//% help=radio/write-value-to-serial
//% weight=3
//% blockId=radio_write_value_serial block="write value to serial"
//% blockId=radio_write_value_serial block="radio write value to serial"
void writeValueToSerial() {
if (radioEnable() != MICROBIT_OK) return;
PacketBuffer p = uBit.radio.datagram.recv();
@ -139,7 +139,7 @@ namespace radio {
*/
//% help=radio/on-data-received
//% weight=50
//% blockId=radio_datagram_received_event block="on data received" blockGap=8
//% blockId=radio_datagram_received_event block="radio on data received" blockGap=8
void onDataReceived(Action body) {
if (radioEnable() != MICROBIT_OK) return;
registerWithDal(MICROBIT_ID_RADIO, MICROBIT_RADIO_EVT_DATAGRAM, body);
@ -151,7 +151,7 @@ namespace radio {
*/
//% help=radio/received-number-at
//% weight=45 debug=true
//% blockId=radio_datagram_received_number_at block="receive number|at %VALUE" blockGap=8
//% blockId=radio_datagram_received_number_at block="radio receive number|at %VALUE" blockGap=8
int receivedNumberAt(int index) {
if (radioEnable() != MICROBIT_OK) return 0;
if (0 <= index && index < packet.length() / 4) {
@ -168,7 +168,7 @@ namespace radio {
*/
//% help=radio/receive-number
//% weight=46
//% blockId=radio_datagram_receive block="receive number" blockGap=8
//% blockId=radio_datagram_receive block="radio receive number" blockGap=8
int receiveNumber()
{
if (radioEnable() != MICROBIT_OK) return 0;
@ -179,7 +179,7 @@ namespace radio {
/**
* Reads the next packet as a string and returns it.
*/
//% blockId=radio_datagram_receive_string block="receive string" blockGap=8
//% blockId=radio_datagram_receive_string block="radio receive string" blockGap=8
//% weight=44
//% help=radio/receive-string
StringData* receiveString() {
@ -194,7 +194,7 @@ namespace radio {
*/
//% help=radio/received-signal-strength
//% weight=40
//% blockId=radio_datagram_rssi block="received signal strength"
//% blockId=radio_datagram_rssi block="radio received signal strength"
int receivedSignalStrength() {
if (radioEnable() != MICROBIT_OK) return 0;
return packet.getRSSI();
@ -205,8 +205,8 @@ namespace radio {
* @ param id the group id between ``0`` and ``255``, 1 eg
*/
//% help=radio/set-group
//% weight=10
//% blockId=radio_set_group block="set group %ID"
//% weight=10 blockGap=8
//% blockId=radio_set_group block="radio set group %ID"
void setGroup(int id) {
if (radioEnable() != MICROBIT_OK) return;
uBit.radio.setGroup(id);
@ -217,8 +217,8 @@ namespace radio {
* @param power a value in the range 0..7, where 0 is the lowest power and 7 is the highest. eg: 7
*/
//% help=radio/set-transmit-power
//% weight=9
//% blockId=radio_set_transmit_power block="set transmit power %power"
//% weight=9 blockGap=8
//% blockId=radio_set_transmit_power block="radio set transmit power %power"
void setTransmitPower(int power) {
if (radioEnable() != MICROBIT_OK) return;
uBit.radio.setTransmitPower(power);
@ -228,8 +228,8 @@ namespace radio {
* Set the radio to transmit the serial number in each message.
*/
//% help=radio/set-transmit-serial-number
//% weight=8
//% block=radio_set_transmit_serial_number block="set tranmist serial number %transmit"
//% weight=8 blockGap=8
//% blockId=radio_set_transmit_serial_number block="radio set transmit serial number %transmit"
void setTransmitSerialNumber(bool transmit) {
transmitSerialNumber = transmit;
}

View File

@ -10,18 +10,18 @@ declare namespace radio {
*/
//% help=radio/send-number
//% weight=60
//% blockId=radio_datagram_send block="send number %value" blockGap=8 shim=radio::sendNumber
//% blockId=radio_datagram_send block="radio send number %value" blockGap=8 shim=radio::sendNumber
function sendNumber(value: number): void;
/**
* Broadcasts a name / value pair along with the device serial number
* and running time to any connected BBC micro:bit in the group.
* and running time to any connected micro:bit in the group.
* @param name the field name (max 12 characters), eg: "data"
* @param value the numberic value
*/
//% help=radio/send-value
//% weight=59
//% blockId=radio_datagram_send_value block="send|value %name|= %value" blockGap=8 shim=radio::sendValue
//% blockId=radio_datagram_send_value block="radio send|value %name|= %value" blockGap=8 shim=radio::sendValue
function sendValue(name: string, value: number): void;
/**
@ -29,7 +29,7 @@ declare namespace radio {
*/
//% help=radio/send-string
//% weight=58
//% blockId=radio_datagram_send_string block="send string %msg" shim=radio::sendString
//% blockId=radio_datagram_send_string block="radio send string %msg" shim=radio::sendString
function sendString(msg: string): void;
/**
@ -38,7 +38,7 @@ declare namespace radio {
*/
//% help=radio/write-value-to-serial
//% weight=3
//% blockId=radio_write_value_serial block="write value to serial" shim=radio::writeValueToSerial
//% blockId=radio_write_value_serial block="radio write value to serial" shim=radio::writeValueToSerial
function writeValueToSerial(): void;
/**
@ -46,7 +46,7 @@ declare namespace radio {
*/
//% help=radio/on-data-received
//% weight=50
//% blockId=radio_datagram_received_event block="on data received" blockGap=8 shim=radio::onDataReceived
//% blockId=radio_datagram_received_event block="radio on data received" blockGap=8 shim=radio::onDataReceived
function onDataReceived(body: () => void): void;
/**
@ -55,7 +55,7 @@ declare namespace radio {
*/
//% help=radio/received-number-at
//% weight=45 debug=true
//% blockId=radio_datagram_received_number_at block="receive number|at %VALUE" blockGap=8 shim=radio::receivedNumberAt
//% blockId=radio_datagram_received_number_at block="radio receive number|at %VALUE" blockGap=8 shim=radio::receivedNumberAt
function receivedNumberAt(index: number): number;
/**
@ -63,13 +63,13 @@ declare namespace radio {
*/
//% help=radio/receive-number
//% weight=46
//% blockId=radio_datagram_receive block="receive number" blockGap=8 shim=radio::receiveNumber
//% blockId=radio_datagram_receive block="radio receive number" blockGap=8 shim=radio::receiveNumber
function receiveNumber(): number;
/**
* Reads the next packet as a string and returns it.
*/
//% blockId=radio_datagram_receive_string block="receive string" blockGap=8
//% blockId=radio_datagram_receive_string block="radio receive string" blockGap=8
//% weight=44
//% help=radio/receive-string shim=radio::receiveString
function receiveString(): string;
@ -80,7 +80,7 @@ declare namespace radio {
*/
//% help=radio/received-signal-strength
//% weight=40
//% blockId=radio_datagram_rssi block="received signal strength" shim=radio::receivedSignalStrength
//% blockId=radio_datagram_rssi block="radio received signal strength" shim=radio::receivedSignalStrength
function receivedSignalStrength(): number;
/**
@ -88,8 +88,8 @@ declare namespace radio {
* @ param id the group id between ``0`` and ``255``, 1 eg
*/
//% help=radio/set-group
//% weight=10
//% blockId=radio_set_group block="set group %ID" shim=radio::setGroup
//% weight=10 blockGap=8
//% blockId=radio_set_group block="radio set group %ID" shim=radio::setGroup
function setGroup(id: number): void;
/**
@ -97,16 +97,16 @@ declare namespace radio {
* @param power a value in the range 0..7, where 0 is the lowest power and 7 is the highest. eg: 7
*/
//% help=radio/set-transmit-power
//% weight=9
//% blockId=radio_set_transmit_power block="set transmit power %power" shim=radio::setTransmitPower
//% weight=9 blockGap=8
//% blockId=radio_set_transmit_power block="radio set transmit power %power" shim=radio::setTransmitPower
function setTransmitPower(power: number): void;
/**
* Set the radio to transmit the serial number in each message.
*/
//% help=radio/set-transmit-serial-number
//% weight=8
//% block=radio_set_transmit_serial_number block="set tranmist serial number %transmit" shim=radio::setTransmitSerialNumber
//% weight=8 blockGap=8
//% blockId=radio_set_transmit_serial_number block="radio set transmit serial number %transmit" shim=radio::setTransmitSerialNumber
function setTransmitSerialNumber(transmit: boolean): void;
}

View File

@ -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);
}
}

View File

@ -1,6 +1,6 @@
{
"name": "pxt-microbit",
"version": "0.3.5",
"version": "0.3.10",
"description": "BBC micro:bit target for PXT",
"keywords": [
"JavaScript",
@ -29,6 +29,6 @@
"typescript": "^1.8.7"
},
"dependencies": {
"pxt-core": "0.3.8"
"pxt-core": "0.3.13"
}
}

View File

@ -52,7 +52,7 @@
"compile": {
"isNative": false,
"hasHex": true,
"deployDrives": "^MICROBIT",
"deployDrives": "(MICROBIT|MBED)",
"driveName": "MICROBIT",
"hexMimeType": "application/x-microbit-hex"
},

View File

@ -197,7 +197,7 @@ namespace pxsim.basic {
clearScreen();
pause(interval * 5);
} else {
if (s.length == 1) showLeds(createImageFromString(s), interval * 5)
if (s.length == 1) showLeds(createImageFromString(s + " "), interval * 5)
else ImageMethods.scrollImage(createImageFromString(s + " "), 1, interval);
}
}
@ -725,6 +725,7 @@ namespace pxsim.ImageMethods {
board().animationQ.enqueue({
interval: interval,
frame: () => {
//TODO: support right to left.
if (off >= leds.width || off < 0) return false;
stride > 0 ? display.shiftLeft(stride) : display.shiftRight(-stride);
let c = Math.min(stride, leds.width - off);

View File

@ -612,9 +612,9 @@ svg.sim.grayscale {
private attachEvents() {
Runtime.messagePosted = (msg) => {
switch (msg.type || '') {
case 'serial': this.flashSystemLed(); break;
case 'radiopacket': this.flashAntenna(); break;
switch (msg.type || "") {
case "serial": this.flashSystemLed(); break;
case "radiopacket": this.flashAntenna(); break;
}
}
let tiltDecayer = 0;

View File

@ -600,7 +600,8 @@ namespace pxsim {
Runtime.postMessage(<SimulatorSerialMessage>{
type: "serial",
data: this.serialOutBuffer,
id: runtime.id
id: runtime.id,
sim: true
})
this.serialOutBuffer = ""
break;