merging microbit changes

This commit is contained in:
Peli de Halleux 2016-11-01 08:35:45 -07:00
commit 94e72784b9
66 changed files with 26504 additions and 697 deletions

View File

@ -91,3 +91,10 @@ basic.showString("d", 150)
You will not see the LED at position `0,0` lit up because the `show string` function overwrites the whole display buffer. You will not see the LED at position `0,0` lit up because the `show string` function overwrites the whole display buffer.
### Pins: P3, P4, P6, P7, P9, P10
These pins are coupled to the LED matrix display, and also its associated ambient light sensing mode.
To disable the display driver feature (which will automatically disable the light sensing feature) use the function [led.enable](/reference/led/enable).
More information at http://tech.microbit.org/hardware/edgeconnector_ds/ .

View File

@ -22,9 +22,8 @@ Learn the functions of **on data received**, **send number** and **receive numbe
input.acceleration(Dimension.X) input.acceleration(Dimension.X)
led.plotBarGraph(0, 1023) led.plotBarGraph(0, 1023)
basic.showNumber(0) basic.showNumber(0)
radio.onDataReceived(() => {}) radio.onDataPacketReceived(() => {})
radio.sendNumber(0) radio.sendNumber(0)
radio.receiveNumber()
``` ```
## Objectives ## Objectives

View File

@ -28,7 +28,7 @@ We want to register code to run when a packet is received over radio. We can imp
basic.forever(() => { basic.forever(() => {
radio.sendNumber(input.acceleration(Dimension.X)) radio.sendNumber(input.acceleration(Dimension.X))
}) })
radio.onDataReceived(() => { radio.onDataPacketReceived(() => {
}) })
``` ```
@ -39,8 +39,8 @@ Finally, we want to chart the acceleration. So we must first implement `plot bar
basic.forever(() => { basic.forever(() => {
radio.sendNumber(input.acceleration(Dimension.X)) radio.sendNumber(input.acceleration(Dimension.X))
}) })
radio.onDataReceived(() => { radio.onDataPacketReceived(({ receivedNumber }) => {
led.plotBarGraph(radio.receiveNumber(), 1023) led.plotBarGraph(receivedNumber, 1023)
}) })
``` ```

View File

@ -19,7 +19,6 @@ Learn how to use running time. We will be learning how to create a pogo game usi
let jumps = 0 let jumps = 0
let acc = input.acceleration(Dimension.Y) let acc = input.acceleration(Dimension.Y)
basic.showNumber(0) basic.showNumber(0)
radio.receiveNumber()
led.stopAnimation() led.stopAnimation()
radio.sendNumber(0) radio.sendNumber(0)
basic.forever(() => { }) basic.forever(() => { })
@ -32,7 +31,7 @@ basic.showLeds(`
`) `)
basic.clearScreen() basic.clearScreen()
if (true) {} if (true) {}
radio.onDataReceived(() => { }) radio.onDataPacketReceived(() => { })
``` ```
## Objectives ## Objectives

View File

@ -120,8 +120,8 @@ input.onButtonPressed(Button.AB, () => {
let jumps = 0 let jumps = 0
basic.showNumber(jumps) basic.showNumber(jumps)
}) })
radio.onDataReceived(() => { radio.onDataPacketReceived(({ receivedNumber }) => {
basic.showNumber(radio.receiveNumber()) basic.showNumber(receivedNumber)
}) })
``` ```
@ -151,8 +151,8 @@ input.onButtonPressed(Button.AB, () => {
let jumps = 0 let jumps = 0
basic.showNumber(jumps) basic.showNumber(jumps)
}) })
radio.onDataReceived(() => { radio.onDataPacketReceived(({ receivedNumber }) => {
basic.showNumber(radio.receiveNumber()) basic.showNumber(receivedNumber)
led.stopAnimation() led.stopAnimation()
}) })

View File

@ -21,9 +21,8 @@ Learn how to **show LEDs** to turn on a LED light pattern on the LED screen. We
basic.forever(() => {}); basic.forever(() => {});
radio.sendNumber(0); radio.sendNumber(0);
input.acceleration(Dimension.Strength) input.acceleration(Dimension.Strength)
radio.onDataReceived(() => {}); radio.onDataPacketReceived(() => {});
led.plotBarGraph(0, 0); led.plotBarGraph(0, 0);
radio.receiveNumber();
``` ```
## Objectives ## Objectives

View File

@ -78,7 +78,7 @@ Your finished code will look like this:
basic.forever(() => { basic.forever(() => {
radio.sendNumber(input.acceleration(Dimension.Strength) - 1023); radio.sendNumber(input.acceleration(Dimension.Strength) - 1023);
}); });
radio.onDataReceived(() => { radio.onDataPacketReceived(() => {
}); });
``` ```
@ -92,8 +92,8 @@ Your finished code will look like this:
basic.forever(() => { basic.forever(() => {
radio.sendNumber(input.acceleration(Dimension.Strength) - 1023); radio.sendNumber(input.acceleration(Dimension.Strength) - 1023);
}); });
radio.onDataReceived(() => { radio.onDataPacketReceived(({ receivedNumber }) => {
led.plotBarGraph(radio.receiveNumber(), 0); led.plotBarGraph(receivedNumber, 0);
}); });
``` ```

View File

@ -16,13 +16,13 @@ input.onButtonPressed(Button.A, () => {
## Step 2 ## Step 2
Use [radio on data received](/reference/radio/on-data-received) display "YO" when the number ``0`` is received Use [radio on data packet received](/reference/radio/on-data-packet-received) display "YO" when the number ``0`` is received
by radio. by radio.
```blocks ```blocks
let message = 0; let message = 0;
radio.onDataReceived(() => { radio.onDataPacketReceived(({ receivedNumber }) => {
message = radio.receiveNumber(); message = receivedNumber;
if (message == 0) { if (message == 0) {
basic.showString("YO") basic.showString("YO")
} }
@ -43,13 +43,13 @@ input.onButtonPressed(Button.B, () => {
## Step 4 ## Step 4
Add blocks in [radio on data received](/reference/radio/on-data-received) to display "BYE" when the number ``1`` is received Add blocks in [radio on data packet received](/reference/radio/on-data-packet-received) to display "BYE" when the number ``1`` is received
by radio. by radio.
```blocks ```blocks
let message = 0; let message = 0;
radio.onDataReceived(() => { radio.onDataPacketReceived(({ receivedNumber }) => {
message = radio.receiveNumber(); message = receivedNumber;
if (message == 0) { if (message == 0) {
basic.showString("YO") basic.showString("YO")
} }

View File

@ -28,7 +28,7 @@ We want to register code to run when a packet is received over radio. We can imp
basic.forever(() => { basic.forever(() => {
radio.sendNumber(input.acceleration(Dimension.X)) radio.sendNumber(input.acceleration(Dimension.X))
}) })
radio.onDataReceived(() => { radio.onDataPacketReceived(() => {
}) })
``` ```
@ -39,8 +39,8 @@ Finally, we want to chart the acceleration. So we must first implement `plot bar
basic.forever(() => { basic.forever(() => {
radio.sendNumber(input.acceleration(Dimension.X)) radio.sendNumber(input.acceleration(Dimension.X))
}) })
radio.onDataReceived(() => { radio.onDataPacketReceived(({ receivedNumber }) => {
led.plotBarGraph(radio.receiveNumber(), 1023) led.plotBarGraph(receivedNumber, 1023)
}) })
``` ```

View File

@ -17,8 +17,9 @@ led.plotAll();
led.screenshot(); led.screenshot();
led.toggleAll(); led.toggleAll();
led.setDisplayMode(DisplayMode.BackAndWhite); led.setDisplayMode(DisplayMode.BackAndWhite);
led.enable(false)
``` ```
### See Also ### See Also
[plot](/reference/led/plot), [unplot](/reference/led/unplot), [point](/reference/led/point), [brightness](/reference/led/brightness), [setBrightness](/reference/led/set-brightness), [stopAnimation](/reference/led/stop-animation), [plotBarGraph](/reference/led/plot-bar-graph), [fadeIn](/reference/led/fade-in), [fadeOut](/reference/led/fade-out), [plotAll](/reference/led/plot-all), [screenshot](/reference/led/screenshot), [toggle](/reference/led/toggle), [toggleAll](/reference/led/toggle-all), [setDisplayMode](/reference/led/set-display-mode) [plot](/reference/led/plot), [unplot](/reference/led/unplot), [point](/reference/led/point), [brightness](/reference/led/brightness), [setBrightness](/reference/led/set-brightness), [stopAnimation](/reference/led/stop-animation), [plotBarGraph](/reference/led/plot-bar-graph), [fadeIn](/reference/led/fade-in), [fadeOut](/reference/led/fade-out), [plotAll](/reference/led/plot-all), [screenshot](/reference/led/screenshot), [toggle](/reference/led/toggle), [toggleAll](/reference/led/toggle-all), [setDisplayMode](/reference/led/set-display-mode), [enabled](/reference/led/enable)

View File

@ -0,0 +1,33 @@
# Enable
Turns the LED screen on and off
```sig
led.enable(false);
```
### Parameters
* ``on`` is a [boolean](/reference/types/boolean) that defines the on/off state of the screen
### Example: Turning off the screen
This program turns off the screen when pressing button ``B``
```typescript
input.onButtonPressed(Button.B, () => {
led.enable(false)
});
```
### Pins: P3, P4, P6, P7, P9, P10
These pins are coupled to the LED matrix display, and also its associated ambient light sensing mode.
To disable the display driver feature (which will automatically disable the light sensing feature) call the DAL function ``led.enable(false)``.
To turn the display driver back on again later, call ``led.enable(true)``.
More information at http://tech.microbit.org/hardware/edgeconnector_ds/ .
### See also
[unplot](/reference/led/unplot), [point](/reference/led/point), [LED screen](/device/screen)

View File

@ -4,19 +4,15 @@ Communicate data using radio packets
```cards ```cards
radio.sendNumber(0); radio.sendNumber(0);
radio.sendValue("data", 0); radio.sendValue("name", 0);
radio.sendString(""); radio.sendString("");
radio.onDataReceived(() => { radio.onDataPacketReceived(() => {
}); });
radio.receiveNumber();
radio.receivedNumberAt(0);
radio.receiveString();
radio.receivedSignalStrength();
radio.setGroup(0); radio.setGroup(0);
radio.setTransmitPower(7); radio.setTransmitPower(7);
radio.setTransmitSerialNumber(false); radio.setTransmitSerialNumber(false);
radio.writeValueToSerial(); radio.writeReceivedPacketToSerial();
``` ```
```package ```package
@ -25,4 +21,11 @@ radio
### See Also ### See Also
[sendNumber](/reference/radio/send-number), [sendValue](/reference/radio/send-value), [sendString](/reference/radio/send-string), [onDataReceived](/reference/radio/on-data-received), [receiveNumber](/reference/radio/receive-number), [receiveString](/reference/radio/receive-string), [receivedSignalStrength](/reference/radio/received-signal-strength), [setGroup](/reference/radio/set-group), [setTransmitPower](/reference/radio/set-transmit-power), [setTransmitSerialNumber](/reference/radio/set-transmit-serial-number), [writeValueToSerial](/reference/radio/write-value-to-serial) [sendNumber](/reference/radio/send-number),
[sendValue](/reference/radio/send-value),
[sendString](/reference/radio/send-string),
[onDataPacketReceived](/reference/radio/on-data-packet-received),
[setGroup](/reference/radio/set-group),
[setTransmitPower](/reference/radio/set-transmit-power),
[setTransmitSerialNumber](/reference/radio/set-transmit-serial-number),
[writeReceivedPacketToSerial](/reference/radio/write-received-packet-to-serial)

View File

@ -0,0 +1,51 @@
# On Data Packet Received
Run part of a program when the micro:bit receives a
[number](/reference/types/number) or [string](/reference/types/string) over ``radio``.
```sig
radio.onDataPacketReceived(({receivedNumber, receivedString, time, serial, signal}) => { });
```
### ~hint
To add or remove the parts of the packet from the block, try clicking the blue gear in the corner!
### ~
### Callback Parameters
* ``packet`` - the [packet](/reference/radio/packet) that was received by the radio. The packet has the following properties:
* `receivedNumber` - The [number](/reference/types/number) that was sent in this packet or `0` if this packet did not contain a number. See [send number](/reference/radio/send-number) and [send value](/reference/radio/send-value)
* `receivedString` - The [string](/reference/types/string) that was sent in this packet or the empty string if this packet did not contain a string. See [send string](/reference/radio/send-string) and [send value](/reference/radio/send-value)
* `time` - The system time of the micro:bit that sent this packet at the time the packet was sent.
* `serial` - The serial number of the micro:bit that sent this packet or `0` if the micro:bit did not include its serial number.
* `signal` - How strong the radio signal is from `255` (weak) to `0` (strong).
### Example
This program keeps sending numbers that says how fast the micro:bit is
slowing down or speeding up. It also receives numbers for the same
thing from nearby micro:bits. It shows these numbers as a
[bar graph](/reference/led/plot-bar-graph).
```blocks
basic.forever(() => {
radio.sendNumber(input.acceleration(Dimension.X));
})
radio.onDataPacketReceived(({ receivedNumber }) => {
led.plotBarGraph(receivedNumber, 1023);
})
```
### See also
[send number](/reference/radio/send-number),
[send string](/reference/radio/send-string),
[send value](/reference/radio/send-value),
[set group](/reference/radio/set-group)
```package
radio
```

View File

@ -1,5 +1,7 @@
# On Data Received # On Data Received
> Note: This API has been deprecated! Use [on data packet received](/reference/radio/on-data-packet-received) instead.
Run part of a program when the micro:bit receives a Run part of a program when the micro:bit receives a
[number](/reference/types/number) or [string](/reference/types/string) over ``radio``. [number](/reference/types/number) or [string](/reference/types/string) over ``radio``.
@ -8,10 +10,6 @@ Run part of a program when the micro:bit receives a
radio.onDataReceived(() => { }); radio.onDataReceived(() => { });
``` ```
### Simulator
This function only works on the micro:bit, not in browsers.
### Example ### Example
This program keeps sending numbers that says how fast the micro:bit is This program keeps sending numbers that says how fast the micro:bit is
@ -30,7 +28,7 @@ radio.onDataReceived(() => {
### See also ### See also
[receive number](/reference/radio/receive-number), [on data packet received](/reference/radio/on-data-packet-received),
[send number](/reference/radio/send-number), [set group](/reference/radio/set-group) [send number](/reference/radio/send-number), [set group](/reference/radio/set-group)
```package ```package

View File

@ -0,0 +1,19 @@
# Packet
A packet that was received by the radio.
## Properties
* `receivedNumber` - The [number](/reference/types/number) that was sent in this packet or `0` if this packet did not contain a number. See [send number](/reference/radio/send-number) and [send value](/reference/radio/send-value)
* `receivedString` - The [string](/reference/types/string) that was sent in this packet or the empty string if this packet did not contain a string. See [send string](/reference/radio/send-string) and [send value](/reference/radio/send-value)
* `time` - The system time of the micro:bit that sent this packet at the time the packet was sent.
* `serial` - The serial number of the micro:bit that sent this packet or `0` if the micro:bit did not include its serial number.
* `signal` - How strong the radio signal is from `255` (weak) to `0` (strong).
### See also
[on data packet received](/reference/radio/on-data-packet-received),
```package
radio
```

View File

@ -1,5 +1,7 @@
# Receive Number # Receive Number
> Note: This API has been deprecated! Use [on data packet received](/reference/radio/on-data-packet-received) instead.
Receives the next number sent by a micro:bit in the same ``radio`` group. Receives the next number sent by a micro:bit in the same ``radio`` group.
```sig ```sig
@ -10,10 +12,6 @@ radio.receiveNumber();
* the first [number](/reference/types/number) that the micro:bit received. If it did not receive any numbers, this function will return `0`. * the first [number](/reference/types/number) that the micro:bit received. If it did not receive any numbers, this function will return `0`.
### Simulator
This function only works on the micro:bit, not in browsers.
### Example: Simple number receiver ### Example: Simple number receiver
This example receives the number broadcasted another micro:bit and shows it This example receives the number broadcasted another micro:bit and shows it

View File

@ -1,5 +1,7 @@
# Receive String # Receive String
> Note: This API has been deprecated! Use [on data packet received](/reference/radio/on-data-packet-received) instead.
Find the next string sent by `radio` from another micro:bit. Find the next string sent by `radio` from another micro:bit.
```sig ```sig
@ -11,10 +13,6 @@ radio.receiveString()
* the first [string](/reference/types/string) that was sent. If no * the first [string](/reference/types/string) that was sent. If no
string was sent, then this function returns an empty (blank) string. string was sent, then this function returns an empty (blank) string.
### Simulator
This function only works on the micro:bit, not in browsers.
### Example: Simple receiver ### Example: Simple receiver
Show the string sent by another micro:bit. Show the string sent by another micro:bit.

View File

@ -1,11 +1,13 @@
# Received Signal Strength # Received Signal Strength
> Note: This API has been deprecated! Use [on data packet received](/reference/radio/on-data-packet-received) instead.
Find how strong the ``radio`` signal is, from `255` to `0`. Find how strong the ``radio`` signal is, from `255` to `0`.
(`255` means a weak signal and `0` means a strong one.) (`255` means a weak signal and `0` means a strong one.)
The micro:bit finds the signal strength by checking how strong it was The micro:bit finds the signal strength by checking how strong it was
the last time it ran the the last time it ran the
[receive number](/reference/radio/receive-number) function. That means [on data packet received](/reference/radio/on-data-packet-received) function. That means
it needs to run **receive number** first. it needs to run **receive number** first.
```sig ```sig
@ -37,7 +39,7 @@ basic.forever(() => {
### See also ### See also
[receive number](/reference/radio/receive-number), [send number](/reference/radio/send-number), [on data received](/reference/radio/on-data-received) [on data packet received](/reference/radio/on-data-packet-received), [send number](/reference/radio/send-number), [on data received](/reference/radio/on-data-received)
```package ```package
radio radio

View File

@ -10,9 +10,6 @@ radio.sendNumber(0);
* ``value`` - a [number](/reference/types/number) to send. * ``value`` - a [number](/reference/types/number) to send.
### Simulator
This function only works on the micro:bit, not in browsers.
### Example: Broadcasting acceleration ### Example: Broadcasting acceleration
@ -30,7 +27,7 @@ input.onButtonPressed(Button.A, () => {
This example broadcasts the level of the light around it. This example broadcasts the level of the light around it.
You can do some interesting things with it if you use it along with the You can do some interesting things with it if you use it along with the
[Mailbot](/reference/radio/receive-number) example. [on data packet received](/reference/radio/on-data-packet-received) example.
```blocks ```blocks
radio.setGroup(99) radio.setGroup(99)
@ -42,7 +39,7 @@ basic.forever(() => {
### See also ### See also
[receive number](/reference/radio/receive-number), [on data received](/reference/radio/on-data-received) [on data packet received](/reference/radio/on-data-packet-received)
```package ```package
radio radio

View File

@ -1,6 +1,7 @@
# Send String # Send String
Sends a string to other micro:bits in the area connected by radio. Sends a string to other micro:bits in the area connected by radio. The
maximum string length is 19 characters.
```sig ```sig
radio.sendString("Hello!") radio.sendString("Hello!")
@ -10,9 +11,6 @@ radio.sendString("Hello!")
* `msg` is a [string](/reference/types/string) to send by radio. * `msg` is a [string](/reference/types/string) to send by radio.
### Simulator
This function only works on the micro:bit, not in browsers.
### Example: Two-way radio ### Example: Two-way radio
@ -26,8 +24,8 @@ input.onButtonPressed(Button.A, () => {
basic.showString("SENT"); basic.showString("SENT");
}) })
radio.onDataReceived(() => { radio.onDataPacketReceived(({ receivedString }) => {
basic.showString(radio.receiveString()); basic.showString(receivedString);
}); });
``` ```
@ -39,7 +37,7 @@ A radio that can both transmit and receive is called a _transceiver_.
### See also ### See also
[receive string](/reference/radio/receive-string), [on data received](/reference/radio/on-data-received) [on data packet received](/reference/radio/on-data-packet-received)
```package ```package
radio radio

View File

@ -1,9 +1,10 @@
# Send Value # Send Value
Send a [string]() and [number]() together by ``radio`` to other micro:bits. Send a [string]() and [number]() together by ``radio`` to other micro:bits.
The maximum [string]() length is 12 characters.
```sig ```sig
radio.sendValue("data", 0); radio.sendValue("name", 0);
``` ```
### Parameters ### Parameters
@ -11,10 +12,6 @@ radio.sendValue("data", 0);
* ``name`` is a [string](/reference/types/string) to send by radio * ``name`` is a [string](/reference/types/string) to send by radio
* ``value`` a [number](/reference/types/number) to send by radio * ``value`` a [number](/reference/types/number) to send by radio
### Simulator
This function only works on the micro:bit, not in browsers.
### Example: Broadcasting acceleration ### Example: Broadcasting acceleration
This program sends your micro:bit's **acceleration** (amount it is This program sends your micro:bit's **acceleration** (amount it is
@ -25,7 +22,7 @@ or model rocket.
```blocks ```blocks
radio.setGroup(99) radio.setGroup(99)
input.onButtonPressed(Button.A, () => { input.onButtonPressed(Button.A, () => {
radio.sendValue("acc",input.acceleration(Dimension.X)) radio.sendValue("acc", input.acceleration(Dimension.X))
}) })
``` ```
@ -34,15 +31,15 @@ Then it shows them on the LED screen.
```blocks ```blocks
radio.setGroup(99) radio.setGroup(99)
radio.onDataReceived(() => { radio.onDataPacketReceived(({ receivedString, receivedNumber }) => {
basic.showString(radio.receiveString()); basic.showString(receivedString);
basic.showNumber(radio.receiveNumber()); basic.showNumber(receivedNumber);
}); });
``` ```
### See also ### See also
[receive number](/reference/radio/receive-number), [on data received](/reference/radio/on-data-received) [on data packet received](/reference/radio/on-data-packet-received)
```package ```package
radio radio

View File

@ -32,7 +32,10 @@ radio.setGroup(128)
### See also ### See also
[receive number](/reference/radio/receive-number), [send number](/reference/radio/send-number), [on data received](/reference/radio/on-data-received) [on data packet received](/reference/radio/on-data-packet-received),
[send number](/reference/radio/send-number),
[send value](/reference/radio/send-value),
[send string](/reference/radio/send-string)
```package ```package
radio radio

View File

@ -37,7 +37,10 @@ radio.setTransmitPower(7)
### See also ### See also
[receive number](/reference/radio/receive-number), [send number](/reference/radio/send-number), [on data received](/reference/radio/on-data-received) [on data packet received](/reference/radio/on-data-packet-received),
[send number](/reference/radio/send-number),
[send value](/reference/radio/send-value),
[send string](/reference/radio/send-string)
```package ```package
radio radio

View File

@ -10,10 +10,6 @@ radio.setTransmitSerialNumber(true);
* ``transmit`` is a [boolean](/reference/types/boolean) that represents whether the serial number needs to be transmitted. * ``transmit`` is a [boolean](/reference/types/boolean) that represents whether the serial number needs to be transmitted.
### Simulator
This function only works on the micro:bit, not in browsers.
### Example ### Example
This program makes the ``radio`` send the serial number in each packet. This program makes the ``radio`` send the serial number in each packet.
@ -24,7 +20,10 @@ radio.setTransmitSerialNumber(true);
### See also ### See also
[receive number](/reference/radio/receive-number), [send number](/reference/radio/send-number), [on data received](/reference/radio/on-data-received) [on data packet received](/reference/radio/on-data-packet-received),
[send number](/reference/radio/send-number),
[send value](/reference/radio/send-value),
[send string](/reference/radio/send-string)
```package ```package
radio radio

View File

@ -0,0 +1,48 @@
# Write Received Packet To Serial
Writes the last packet received by the ``radio`` to serial in JSON format.
Should be called within a callback to
[on data packet received](/reference/radio/on-data-packet-received).
```sig
radio.writeReceivedPacketToSerial();
```
### 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:SerialNumber}```
- [send value](/reference/radio/send-value): ```{v:ValueSent,t:MicrobitTimeAlive,s:SerialNumber,n:"Name"}```
- [send string](/reference/radio/send-string): ```{t:MicrobitTimeAlive,s:SerialNumber,n:"Text"}```
### Examples
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, () => {
radio.sendNumber(input.temperature());
});
radio.onDataPacketReceived(() => {
radio.writeReceivedPacketToSerial();
});
```
Sample output to serial when ``A`` button pressed:
```Text
{v:27,t:323,s:0}
```
### See also
[send number](/reference/radio/send-number),
[send value](/reference/radio/send-value),
[send string](/reference/radio/send-string),
[on data packet received](/reference/radio/on-data-packet-received)
```package
radio
```

View File

@ -1,30 +1,20 @@
# Write Value To Serial # Write Value To Serial
> Note: This API has been deprecated! Use [write received packet to serial](/reference/radio/write-received-packet-to-serial) instead.
Writes the data received by ``radio`` to serial in JSON format. Writes the data received by ``radio`` to serial in JSON format.
```sig ```sig
radio.writeValueToSerial(); radio.writeValueToSerial();
``` ```
### ~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 ### Data received format
The format for received data printed to serial is as follows: The format for received data printed to serial is as follows:
- [send number](/reference/radio/send-number): ```{v:ValueSent,t:MicrobitTimeAlive,s:Unused}``` - [send number](/reference/radio/send-number): ```{v:ValueSent,t:MicrobitTimeAlive,s:SerialNumber}```
- [send value](/reference/radio/send-value): ```{v:ValueSent,t:MicrobitTimeAlive,s:Unused,n:"Name"}``` - [send value](/reference/radio/send-value): ```{v:ValueSent,t:MicrobitTimeAlive,s:SerialNumber,n:"Name"}```
- [send string](/reference/radio/send-string): ```{t:MicrobitTimeAlive,s:SerialNumber,n:"Text"}```
### Simulator
This function only works on the micro:bit, not in browsers.
### Examples ### Examples
@ -50,7 +40,8 @@ Sample output to serial when ``A`` button pressed:
[send number](/reference/radio/send-number), [send number](/reference/radio/send-number),
[send value](/reference/radio/send-value), [send value](/reference/radio/send-value),
[on data received](/reference/radio/on-data-received) [send string](/reference/radio/send-string),
[on data packet received](/reference/radio/on-data-packet-received)
```package ```package
radio radio

View File

@ -3,16 +3,23 @@
Our translations are managed via Crowdin, a translation management platform. It is free to join Our translations are managed via Crowdin, a translation management platform. It is free to join
and you can volunteer to translate parts of the web site. and you can volunteer to translate parts of the web site.
## Translating the editor interface ## Crowdin project
The project below contains the resources from https://www.pxt.io and the menu items of https://pxt.microbit.org. The project below contains the resources from https://www.pxt.io and the menu items of https://pxt.microbit.org.
* [https://crowdin.com/project/kindscript](https://crowdin.com/project/kindscript) * [https://crowdin.com/project/kindscript](https://crowdin.com/project/kindscript)
You will find two files in that project: If you want to help translating the editor, please sign in to Crowdin and send us a translator request.
* ``string.json``: text contained in the menu items of https://pxt.microbit.org ## Translating the editor interface
* ``website.json``: text contained in the pages served by https://www.pxt.io
The editor interface strings, like the "Download" button are in the ``strings.json`` file. Start by updating this file to translate the UI.
To test your changes "live", use **beta** build and the ``?livelang=CODE`` query argument where ``CODE`` is your language ISO code. For example, to see the french translations:
* https://pxt.microbit.org/beta?livelang=fr
Note that there may be a delay of up to 5 minutes before your changes in Crowdin make it into the "live" view.
## Translating the blocks and reference documentation ## Translating the blocks and reference documentation

View File

@ -1,240 +0,0 @@
{
"Math.randomBoolean":"يقوم بإنشاء قيمة 'صحيح' أو 'false' عشوائياً، تماما مثل التقليب عمله.",
"Math.randomBoolean|block":"اختيار عشوائي true أو false",
"Math|block":"الرياضيات",
"String.fromCharCode":"جعل سلسلة من رمز الحرف ASCII معطى.",
"String.fromCharCode|block":"النص من حرف رمز %code",
"String|block":"السلسلة",
"basic":"يوفر الوصول إلى الوظيفة الأساسية الصغرى: بت.",
"basic.clearScreen":"إيقاف تشغيل كافة المصابيح",
"basic.clearScreen|block":"مسح الشاشة",
"basic.forever":"تكرار التعليمات البرمجية إلى الأبد في الخلفية. في كل تكرار، يسمح رموز أخرى لتشغيل.",
"basic.forever|block":"إلى الأبد",
"basic.pause":"إيقاف مؤقت للوقت المحدد بالمللي ثانية",
"basic.pause|block":"إيقاف %pause (مللي ثانية)",
"basic.pause|param|ms":"كم من الوقت للتوقف، على سبيل المثال: 100، 200، 500، 1000، 2000",
"basic.plotLeds":"يرسم صورة على شاشة LED.",
"basic.plotLeds|param|leds":"نمط من المصابيح لتشغيل\/إيقاف تشغيل",
"basic.showAnimation":"ويبين تسلسل الشاشات LED كالرسوم متحركة.",
"basic.showAnimation|param|interval":"الوقت بالمللي ثانية بين كل رسم",
"basic.showAnimation|param|leds":"نمط من المصابيح لتشغيل\/إيقاف تشغيل",
"basic.showLeds":"يرسم صورة على شاشة LED.",
"basic.showLeds|block":"إظهار المصابيح",
"basic.showLeds|param|interval":"الوقت بالمللي ثانية وقفه بعد الرسم",
"basic.showLeds|param|leds":"نمط الصمام لتشغيل\/إيقاف تشغيل",
"basic.showNumber":"قم بالتمرير رقم على الشاشة. إذا كان العدد يناسب على الشاشة (أي هو رقم واحد)، لا يتم تمرير.",
"basic.showNumber|block":"show|number %number",
"basic.showNumber|param|interval":"سرعة التمرير؛ على سبيل المثال: 150، 200-100، 100",
"basic.showString":"عرض النص على الشاشة، حرف واحد في كل مرة. إذا كانت السلسلة يناسب على الشاشة (أي حرف واحد)، لا يتم تمرير.",
"basic.showString|block":"show|string %text",
"basic.showString|param|interval":"طريقة سريعة لتحويل الأحرف؛ على سبيل المثال: 150، 200-100، 100",
"basic.showString|param|text":"النص للتمرير على الشاشة، على سبيل المثال: \"مرحبا!\"",
"basic|block":"الأساسية",
"control":"المرافق وقت التشغيل والحدث.",
"control.inBackground":"الجداول الزمنية للتعليمات البرمجية التي يتم تشغيلها في الخلفية.",
"control.inBackground|block":"تشغيل في الخلفية",
"control.reset":"يعيد تعيين الصغير: بت ال بي بي سي.",
"control.reset|block":"إعادة تعيين",
"control|block":"التحكم",
"game":"محرك لعبة واحدة تقودها العفريت",
"game.addScore":"إضافة نقاط إلى النتيجة الحالية",
"game.addScore|block":"تغيير درجة by|%points",
"game.addScore|param|points":"كمية من النقاط لتغيير، على سبيل المثال: 1",
"game.gameOver":"يعرض لعبة الرسوم المتحركة.",
"game.gameOver|block":"انتهت اللعبة",
"game.score":"يحصل على النتيجة الحالية",
"game.score|block":"نقاط",
"game.setScore":"تعيين القيمة إلى النتيجة الحالية",
"game.setScore|param|value":"تودو",
"game.startCountdown":"بدء تشغيل جهاز ضبط وقت العد التنازلي لعبة",
"game.startCountdown|block":"بدء تشغيل countdown| (مللي ثانية) %duration",
"game.startCountdown|param|ms":"مدة العد التنازلي في ميلي ثانية، على سبيل المثال: 10000",
"game|block":"لعبة",
"images":"إنشاء والتلاعب وعرض الصور الصمام.",
"images.createBigImage":"يقوم بإنشاء صورة مع إطارات 2.",
"images.createBigImage|block":"إنشاء صورة كبيرة",
"images.createImage":"يقوم بإنشاء صورة التي تناسبها على شاشة LED.",
"images.createImage|block":"إنشاء الصورة",
"images|block":"الصور",
"input":"الأحداث والبيانات من أجهزة الاستشعار",
"input.acceleration":"الحصول على قيمة التسارع في المجلس الملي-جرافيتيس (عندما يتم إرساء المجلس شقة مع الشاشة حتى, x = 0, y = 0 و z = 1024)",
"input.acceleration|block":"|%NAME التسارع (mg)",
"input.acceleration|param|dimension":"تودو",
"input.buttonIsPressed":"الحصول على حالة زر (ضغط أو لا) '' '' و '' ب ''.",
"input.buttonIsPressed|block":"button|%NAME|is الضغط",
"input.calibrate":"معايرة بوصلة عفا عليها الزمن، والتلقائي.",
"input.compassHeading":"الحصول على عنوان البوصلة البوصلة الحالية في درجات.",
"input.compassHeading|block":"بوصلة العنوان (°)",
"input.lightLevel":"يقرأ مستوى الضوء المطبقة على شاشة LED في طائفة من '' 0 '' (الظلام) إلى 255 '' '' مشرق.",
"input.lightLevel|block":"مستوى الضوء",
"input.magneticForce":"الحصول على قيمة القوة المغناطيسية في '' الصغرى-Teslas '' ('' µT ''). هذه الوظيفة غير معتمدة في المحاكاة.",
"input.magneticForce|block":"القوة المغناطيسية (µT) |%NAME",
"input.magneticForce|param|dimension":"تودو",
"input.onButtonPressed":"القيام بشيء عند الضغط على زر ('' '' أو '' ب '' أو كلا '' أ + ب '')",
"input.onButtonPressed|block":"على button|%NAME|pressed",
"input.onButtonPressed|param|body":"تودو",
"input.onButtonPressed|param|button":"تودو",
"input.onGesture":"وتولى تشغيل التعليمات البرمجية عند هو مواجهة الشاشة.",
"input.onGesture|block":"على |%NAME",
"input.onGesture|param|body":"تودو",
"input.onLogoDown":"وتولى تشغيل التعليمات البرمجية عند الشعار وتتجه نزولا والمجلس بشكل عمودي.",
"input.onLogoDown|param|body":"تودو",
"input.onLogoUp":"وتولى تشغيل التعليمات البرمجية عند الشعار وتتجه صعودا والمجلس بشكل عمودي.",
"input.onLogoUp|param|body":"تودو",
"input.onPinPressed":"تفعل شيئا عند الضغط على رقم التعريف الشخصي ('' P0 '' أو '' P1 '' أو كلا '' P2 '').",
"input.onPinPressed|block":"على pin|%NAME|pressed",
"input.onPinPressed|param|body":"تودو",
"input.onPinPressed|param|name":"تودو",
"input.onScreenDown":"وتولى تشغيل التعليمات البرمجية عند هو أسفل الشاشة.",
"input.onScreenDown|param|body":"تودو",
"input.onScreenUp":"وتولى تشغيل التعليمات البرمجية عند هو مواجهة الشاشة.",
"input.onScreenUp|param|body":"تودو",
"input.onShake":"وتولى تشغيل التعليمات البرمجية عند هو هز الجهاز.",
"input.onShake|param|body":"تودو",
"input.pinIsPressed":"الحصول على دولة طرف (ضغط أو لا). ويتطلب عقد الأرض من أجل إغلاق الدائرة.",
"input.pinIsPressed|block":"pin|%NAME|is الضغط",
"input.pinIsPressed|param|name":"دبوس المستخدمة للكشف عن لمسة",
"input.rotation":"الملعب للجهاز، وتناوب على طول '' المحور ''، بدرجات.",
"input.rotation|block":"|%NAME دوران (°)",
"input.rotation|param|kind":"تودو",
"input.runningTime":"يحصل على عدد المللي ثانية المنقضية منذ السلطة في.",
"input.runningTime|block":"إدارة الوقت (مللي ثانية)",
"input.setAccelerometerRange":"يعين نطاق العينة التسارع في جاذبيات.",
"input.setAccelerometerRange|block":"تعيين نطاق % accelerometer|range",
"input.setAccelerometerRange|param|range":"قيمة وصف قوتها القصوى لقياس التسارع",
"input.temperature":"يحصل على درجة حرارة مئوية درجات (درجة مئوية).",
"input.temperature|block":"درجة الحرارة (درجة مئوية)",
"input|block":"الإدخال",
"led":"التحكم في شاشة LED.",
"led.brightness":"الحصول على سطوع الشاشة من 0 (إيقاف) إلى 255 (مشرق كامل).",
"led.brightness|block":"سطوع",
"led.fadeIn":"يتلاشى في العرض على الشاشة.",
"led.fadeIn|param|ms":"تودو",
"led.fadeOut":"إخفاء مستوى سطوع الشاشة.",
"led.fadeOut|param|ms":"تودو",
"led.plot":"قم بتشغيل باستخدام الصمام المحدد x, y إحداثيات (س الأفقي، ص العمودي). (0, 0) هو أعلى اليسار.",
"led.plotAll":"تشغيل كافة المصابيح",
"led.plotBarGraph":"يعرض رسم بياني شريطي عمودي استناداً إلى 'قيمة' والقيمة 'عالية'.\nإذا كان 'عالية' هو 0، ويحصل ضبط التخطيط تلقائياً.",
"led.plotBarGraph|block":"رسم بياني شريطي من الإقلاع القيمة % إلى %high",
"led.plotBarGraph|param|high":"الحد الأقصى للقيمة. إذا كان 0, الحد الأقصى للقيمة المعدلة تلقائياً، على سبيل المثال: 0",
"led.plotBarGraph|param|value":"القيمة الحالية الأرض",
"led.plot|block":"plot|x %x|y %y",
"led.plot|param|x":"تودو",
"led.plot|param|y":"تودو",
"led.point":"الحصول على حالة تشغيل\/إيقاف استخدام الصمام المحدد x, y إحداثيات. (0, 0) هو أعلى اليسار.",
"led.point|block":"point|x %x|y %y",
"led.point|param|x":"تودو",
"led.point|param|y":"تودو",
"led.screenshot":"تأخذ لقطة للشاشة LED وترجع صورة.",
"led.setBrightness":"تعيين سطوع الشاشة من 0 (إيقاف) إلى 255 (مشرق كامل).",
"led.setBrightness|block":"قم بتعيين القيمة % السطوع",
"led.setBrightness|param|value":"قيمة السطوع، على سبيل المثال: 255، 127، 0",
"led.setDisplayMode":"تعيين وضع العرض بين الأسود والأبيض واللون الرمادي لجعلها المصابيح.",
"led.setDisplayMode|param|mode":"تودو",
"led.stopAnimation":"إلغاء الحركة الحالية ومسح أخرى انتظارا للرسوم المتحركة.",
"led.stopAnimation|block":"وقف الرسوم المتحركة",
"led.toggle":"يبدل بكسل خاص",
"led.toggleAll":"عكس العرض LED الحالية",
"led.toggle|param|x":"تودو",
"led.toggle|param|y":"تودو",
"led.unplot":"إيقاف استخدام الصمام المحدد x, y إحداثيات (س الأفقي، ص العمودي). (0, 0) هو أعلى اليسار.",
"led.unplot|block":"unplot|x %x|y %y",
"led.unplot|param|x":"تودو",
"led.unplot|param|y":"تودو",
"led|block":"شاشة",
"music":"جيل نغمات الموسيقى عن طريق الرقم السري '''' P0 ''.",
"music.beat":"إرجاع المدة للفوز في ميلي ثانية",
"music.beat|block":"%fraction|beat",
"music.changeTempoBy":"تغيير الإيقاع بالمبلغ المحدد",
"music.changeTempoBy|block":"تغيير الإيقاع بواسطة (bpm) | قيمة %",
"music.changeTempoBy|param|bpm":"التغيير في دقات في الدقيقة الواحدة للايقاع، على سبيل المثال: 20",
"music.noteFrequency":"يحصل على تكرار الملاحظة.",
"music.noteFrequency|block":"%note",
"music.noteFrequency|param|name":"ملاحظة اسم",
"music.playTone":"يلعب نغمة عن طريق الرقم السري '''' P0 '' لمدة معينة.",
"music.playTone|block":"play|tone %note = device_note|for %duration = device_beat",
"music.playTone|param|frequency":"الملعب لهجة للعب في هرتز (هرتز)",
"music.playTone|param|ms":"مدة نغمة في ميلي ثانية (مللي ثانية)",
"music.rest":"تقع (يلعب شيئا) لفترة زمنية محددة عن طريق الرقم السري '''' P0 ''.",
"music.rest|block":"|%duration بقية (مللي ثانية) = device_beat",
"music.rest|param|ms":"مدة الراحة في ميلي ثانية (مللي ثانية)",
"music.ringTone":"يلعب نغمة عن طريق الرقم السري '''' P0 ''.",
"music.ringTone|block":"عصابة لهجة (هرتز) |%note = device_note",
"music.ringTone|param|frequency":"الملعب لهجة للعب في هرتز (هرتز)",
"music.setTempo":"يحدد وتيرة إلى المبلغ المحدد",
"music.setTempo|block":"ضبط الإيقاع (نبضة في الدقيقة) | قيمة %",
"music.setTempo|param|bpm":"يدق على وتيرة جديدة في كل دقيقة، على سبيل المثال: 120",
"music.tempo":"تقوم بإرجاع الإيقاع في نبضة في الدقيقة. الإيقاع هو السرعة (bpm = نبضة في الدقيقة) في اللعب وتلاحظ فيه. أكبر قيمة الإيقاع، سيتم تشغيل أسرع وتلاحظ.",
"music.tempo|block":"الإيقاع (نبضة في الدقيقة)",
"music|block":"الموسيقى",
"pins":"التحكم في التيارات في دبابيس للإشارات التناظرية\/الرقمية، الماكينات، i2c،...",
"pins.analogPitch":"يبث إشارات تحوير (بوم) عرض نبض بدبوس الملعب الحالي. استخدام 'النظير تعيين pin الملعب' لتعريف pin في الملعب.",
"pins.analogPitch|param|frequency":"تودو",
"pins.analogPitch|param|ms":"تودو",
"pins.analogReadPin":"قراءة القيمة موصل النظير، وهذا هو، كقيمة بين 0 و 1023 وتتألف.",
"pins.analogReadPin|block":"%name read|pin التناظرية",
"pins.analogReadPin|param|name":"دبوس الكتابة إلى",
"pins.analogSetPeriod":"تكوين تحوير عرض النبضة (PWM) التناظرية المخرجات إلى قيمة معينة في * * ميكرو * * أو '' 1\/1000 ميلي ثانية.\nإذا لم يتم تكوين هذا الدبوس تمثيلي الإخراج (باستخدام 'الكتابة التناظرية دبوس')، قد العملية أي تأثير.",
"pins.analogSetPeriod|block":"تعيين النظير period|pin %pin|to مايكروون % (المايكروثانيه)",
"pins.analogSetPeriod|param|micros":"الفترة في الدقيقة ثانية. على سبيل المثال: 20000",
"pins.analogSetPeriod|param|name":"دبوس التناظرية لتعيين الفترة إلى",
"pins.analogSetPitchPin":"تعيين رقم pin المستخدم عند استخدام 'دبابيس-> التناظرية في الملعب'.",
"pins.analogSetPitchPin|param|name":"تودو",
"pins.analogWritePin":"تعيين القيمة رابط تمثيلي. يجب أن تتألف القيمة بين 0 و 1023.",
"pins.analogWritePin|block":"القيمة % %name|to write|pin التناظرية",
"pins.analogWritePin|param|name":"اسم دبوس الكتابة إلى",
"pins.analogWritePin|param|value":"قيمة لكتابة رقم التعريف الشخصي بين '' 0 '' و '' 1023 ''. على سبيل المثال: 1023, 0",
"pins.digitalReadPin":"قراءة المحدد رقم pin أو موصل أما 0 أو 1",
"pins.digitalReadPin|block":"read|pin رقمي %name",
"pins.digitalReadPin|param|name":"رقم التعريف الشخصي لقراءة من",
"pins.digitalWritePin":"تعيين قيمة رقم pin أو الرابط إلى 0 أو 1.",
"pins.digitalWritePin|block":"القيمة % %name|to write|pin الرقمي",
"pins.digitalWritePin|param|name":"دبوس الكتابة إلى",
"pins.digitalWritePin|param|value":"قيمة لتعيين رقم pin، 1 على سبيل المثال، 0",
"pins.i2cReadNumber":"قراءة رقم واحد من عنوان I2C 7 بت.",
"pins.i2cReadNumber|block":"i2c قراءة عنوان number|at %address|of الشكل %format = i2c_sizeof",
"pins.i2cWriteNumber":"كتابة رقم واحد لعنوان I2C 7 بت.",
"pins.i2cWriteNumber|block":"i2c يكتب عنوان number|at %address|with % قيمة value|of %format الشكل = i2c_sizeof",
"pins.map":"إعادة تعيين عدد من مجموعة واحدة إلى أخرى. فالحصول على تعيين قيمة '' من منخفضة '' إلى '' إلى انخفاض ''، قيمة '' من السامي '' إلى '' إلى ارتفاع ''، قيم الفترات الفاصلة بين القيم بينهما، إلخ.",
"pins.map|block":"خريطة % value|from %fromLow|from منخفضة %fromHigh|to ارتفاع منخفض %toLow|to عالية %toHigh",
"pins.map|param|fromHigh":"العليا ملزمة للنطاق الحالي للقيمة، على سبيل المثال: 1023",
"pins.map|param|fromLow":"الحد الأدنى للنطاق الحالي للقيمة",
"pins.map|param|toHigh":"الحد الأعلى المستهدفة القيمة تتراوح، على سبيل المثال: 4",
"pins.map|param|toLow":"الحد الأدنى للنطاق المستهدف للقيمة",
"pins.map|param|value":"قيمة للتعيين في نطاقات",
"pins.onPulsed":"تكوين هذا الرقم السري لأحد مدخلات رقمية، وينشئ الأحداث حيث الطابع الزمني هو المدة التي كان هذا الرقم '' عالية '' أو '' منخفضة ''.",
"pins.onPulsed|block":"on|pin %pin|pulsed %pulse",
"pins.pulseDuration":"يحصل على مدة نبض الماضي في مايكرو-ثانية. يجب أن يتم استدعاء هذه الدالة من معالج '' أونبولسيد ''.",
"pins.pulseDuration|block":"مدة النبضة (المايكروثانيه)",
"pins.servoSetPulse":"تكوين هذا دبوس آيو كناتج التناظرية\/بوم وتكوين الفترة بأن يكون 20 مللي ثانية، وتعيين عرض النبض، استناداً إلى القيمة التي تعطي * * ميكرو * * أو '' 1\/1000 ميلي ثانية.",
"pins.servoSetPulse|block":"تعيين مضاعفات pulse|pin value|to (المايكروثانيه) % % مايكروون",
"pins.servoSetPulse|param|micros":"مدة النبضة في الدقيقة ثانية، على سبيل المثال: 1500",
"pins.servoSetPulse|param|name":"اسم دبوس",
"pins.servoWritePin":"تكتب قيمة إلى مضاعفات، السيطرة الرمح تبعاً لذلك. في مضاعفات قياسية، سيؤدي هذا إلى تعيين زاوية الرمح (بالدرجات)، تتحرك الرمح لهذا التوجه. في مضاعفات تناوب مستمر، وهذا سيتم تعيين سرعة الماكينة (مع '' 0 '''' بسرعة كاملة في اتجاه واحد، '' 180 '' يجري كامل السرعة في أخرى، وقيمة قرب '' 90 '' يجري أي حركة).",
"pins.servoWritePin|block":"مضاعفات write|pin %name|to القيمة %",
"pins.servoWritePin|param|name":"دبوس الكتابة إلى",
"pins.servoWritePin|param|value":"زاوية أو التناوب سرعة، على سبيل المثال: 180، 90، 0",
"pins.setPull":"تكوين السحب من هذا الرقم.",
"pins.setPull|block":"تعيين pull|pin %pin|to %pull",
"pins.setPull|param|name":"رقم التعريف الشخصي لتعيين وضع الانسحاب في",
"pins.setPull|param|pull":"أحد تكوينات السحب مبيد: بولوب، المنسدلة، بولنوني ",
"pins|block":"دبابيس",
"serial":"قراءة وكتابة البيانات عبر اتصال تسلسلي.",
"serial.readLine":"يقرأ سطر من النص من المنفذ التسلسلي.",
"serial.readLine|block":"قراءة سطر للمسلسل",
"serial.redirect":"بشكل حيوي تكوين مثيل تسلسلي استخدام دبابيس خلاف أوسبتكس واسبر.",
"serial.redirect|block":"إعادة توجيه المسلسل to| TX %tx| RX % rx|at % معدل معدل الباود",
"serial.redirect|param|rx":"دبوس الاستقبال الجديدة",
"serial.redirect|param|tx":"دبابيس الإرسال الجديدة",
"serial.writeLine":"طباعة سطر من النص للمسلسل",
"serial.writeLine|block":"serial|write خط %text",
"serial.writeNumber":"طباعة قيمة رقمية للمسلسل",
"serial.writeNumber|block":"قيمة % رقم serial|write",
"serial.writeString":"يرسل جزء من النص من خلال اتصال تسلسلي.",
"serial.writeString|block":"كتابة المسلسل سلسلة %text",
"serial.writeValue":"يكتب '' الاسم: قيمة '' زوج الخط للمسلسل.",
"serial.writeValue|block":"serial|write قيمة %name| = القيمة %",
"serial.writeValue|param|name":"اسم القيمة الدفق، على سبيل المثال: x",
"serial.writeValue|param|value":"يكتب",
"serial|block":"مصدر الاتصال"
}

View File

@ -1,92 +0,0 @@
{
"Math.randomBoolean":"Genera un valor 'verdadero' o 'false' al azar, al igual que una moneda de los bancos.",
"String.fromCharCode":"Hacer una cadena desde el código de carácter ASCII dado.",
"basic":"Proporciona acceso a funcionalidad básica micro: bit.",
"basic.clearScreen":"Apagar todos los LEDs",
"basic.forever":"Repite el código para siempre en el fondo. En cada iteración, permite otros códigos ejecutar.",
"basic.pause":"Pausa para el tiempo especificado en milisegundos",
"basic.plotLeds":"Dibuja una imagen en la pantalla de LED.",
"basic.showAnimation":"Muestra una secuencia de pantallas de LED como una animación.",
"basic.showLeds":"Dibuja una imagen en la pantalla de LED.",
"basic.showNumber":"Desplácese a un número en la pantalla. Si el número cabe en la pantalla (es decir, es un solo dígito), no se desplazan.",
"basic.showString":"Mostrar texto en la pantalla, un carácter a la vez. Si la cadena encaja en la pantalla (es decir, es una letra), no se desplacen.",
"control":"Utilidades de tiempo de ejecución y evento.",
"control.inBackground":"Horarios de código que se ejecutan en segundo plano.",
"control.reset":"Restablece el BBC micro: bit.",
"game":"Un motor de juego de sprite solo LED",
"game.addScore":"Añade puntos a la cuenta corriente",
"game.gameOver":"Muestra un juego más de animación.",
"game.score":"Obtiene la puntuación actual",
"game.setScore":"Establece el valor de cuenta actual",
"game.startCountdown":"Comienza un temporizador de cuenta atrás juego",
"images":"Creación, manipulación y visualización de imágenes LED.",
"images.createBigImage":"Crea una imagen con 2 marcos.",
"images.createImage":"Crea una imagen que encaja en la pantalla de LED.",
"input":"Eventos y datos de los sensores",
"input.acceleration":"Obtener el valor de la aceleración en milli-gravitys (cuando es poner la junta plana con la pantalla hacia arriba, x = 0, y = 0 y z =-1024)",
"input.buttonIsPressed":"Obtener el estado de botón (presionado o no) para '' A'' y '' B''.",
"input.calibrate":"Obsoleto, brújula calibración es automática.",
"input.compassHeading":"Consigue el actual rumbo de la brújula brújula en grados.",
"input.lightLevel":"Lee el nivel de luz aplicado a la pantalla de LED en un rango de '' 0'' (oscuro) a '' 255'' brillante.",
"input.magneticForce":"Obtener el valor de la fuerza magnética en '' micro Teslas'' ('' μT ''). Esta función no se admite en el simulador.",
"input.onButtonPressed":"Hacer algo cuando se pulsa un botón ('' A'', '' B'' o ambos '' A + B'')",
"input.onGesture":"Concede el código a ejecutar cuando la pantalla quede mirando hacia arriba.",
"input.onLogoDown":"Concede el código a ejecutar cuando el logo está orientado hacia abajo y el tablero es vertical.",
"input.onLogoUp":"Concede el código a ejecutar cuando el logo está orientado hacia arriba y el tablero es vertical.",
"input.onPinPressed":"Hacer algo cuando se pulsa un pin ('' P0'', '' P1'' o '' ambos P2'').",
"input.onScreenDown":"Concede el código a ejecutar cuando la pantalla esté hacia abajo.",
"input.onScreenUp":"Concede el código a ejecutar cuando la pantalla quede mirando hacia arriba.",
"input.onShake":"Concede el código a ejecutar cuando se agita el dispositivo.",
"input.pinIsPressed":"Obtener el estado de pin (presionado o no). Requiere para mantener el suelo para cerrar el circuito.",
"input.rotation":"El tono del dispositivo de rotación a lo largo del '' x '', en grados.",
"input.runningTime":"Obtiene. que el número de milisegundos transcurrido desde el poder.",
"input.setAccelerometerRange":"Establece el intervalo de muestra de acelerómetro en gravedades.",
"input.temperature":"Obtiene la temperatura en grados Celsius grados (° C).",
"led":"Control de la pantalla LED.",
"led.brightness":"Bajar el brillo de la pantalla de 0 () a 255 (completo brillante).",
"led.fadeIn":"Difumina en la pantalla.",
"led.fadeOut":"Se descolora hacia fuera el brillo de la pantalla.",
"led.plot":"Encienda el LED especificado usando, coordenadas x y (x es horizontal, es vertical). (0,0) es la parte superior izquierda.",
"led.plotAll":"Enciende todos los LEDS",
"led.plotBarGraph":"Muestra un gráfico de barras vertical basado en el 'valor' y ' valor '.\nSi 'alto' es 0, la carta es ajustada automáticamente.",
"led.point":"Obtener el estado de encendido de la especificada usando LED, coordenadas x y. (0,0) es la parte superior izquierda.",
"led.screenshot":"Toma una captura de pantalla de la pantalla LED y devuelve una imagen.",
"led.setBrightness":"Configurar el brillo de la pantalla de 0 (off) a 255 (completo brillante).",
"led.setDisplayMode":"Establece el modo de pantalla entre el blanco y negro y escala de grises para la representación de LEDs.",
"led.stopAnimation":"Cancela la animación actual y borra otros pendiente de animaciones.",
"led.toggle":"Alterna un píxel particular",
"led.toggleAll":"Invierte la actual pantalla de LED",
"led.unplot":"Apagar el LED especificado usando, coordenadas x y (x es horizontal, es vertical). (0,0) es la parte superior izquierda.",
"music":"Generación de tonos de la música a través de pin '' P0''.",
"music.beat":"Devuelve la duración de un beat en milisegundos",
"music.changeTempoBy":"Cambiar el tempo en la cantidad especificada",
"music.noteFrequency":"Obtiene la frecuencia de una nota.",
"music.playTone":"Se reproduce un tono a través de pin '' P0'' la duración determinada.",
"music.rest":"Descansa (juega nada) durante un tiempo especificado a través de pin '' P0''.",
"music.ringTone":"Toca un tono a través de pin '' P0''.",
"music.setTempo":"El ritmo se establece en la cantidad especificada",
"music.tempo":"Vuelve el ritmo en pulsaciones por minuto. Tempo es la velocidad (bpm = beats por minuto) en qué juego de notas. Cuanto mayor sea el valor del tempo, se juegan más rápido las notas.",
"pins":"Control de corrientes de Pins para señales de analógico\/digital, servos, i2c...",
"pins.analogPitch":"Emite una señal de ancho de pulso modulación (PWM) para el pin de la echada actual. Utilice 'analog set pin pitch' para definir el pin pitch.",
"pins.analogReadPin":"Lea el valor de conector como analógica, es decir, como un valor comprendido entre 0 y 1023.",
"pins.analogSetPeriod":"Configura la modulación por ancho de pulso (PWM) de la analógica de salida para el valor dado en ** microsegundos ** o ' 1\/1000 «milisegundos.\nSi este pin no está configurado como un análogo de salida (usando 'escritura analógica pin'), la operación no tiene efecto.",
"pins.analogSetPitchPin":"Establece el pin cuando se usa 'pins-> tono analógico'.",
"pins.analogWritePin":"Establezca el valor de conector como analógica. Debe estar conformados por valor de entre 0 y 1023.",
"pins.digitalReadPin":"Leer el pin especificado o conector como 0 o 1",
"pins.digitalWritePin":"Establecer un valor de pin o conector de 0 o 1.",
"pins.i2cReadNumber":"Leer un número de 7 bits I2C dirección.",
"pins.i2cWriteNumber":"Escribir un número en una dirección de 7 bits I2C.",
"pins.map":"Volver a le asigna un número del uno al otro. Es decir, un valor de '' de baja '' conseguir asignado a '' a la baja '', un valor de '' de alta '' a '' a '', valores intermedios a intermedios, etc. de valores.",
"pins.onPulsed":"Configura este pin a una entrada digital y genera eventos donde la marca de tiempo es la duración que este pin fue '' alto '' o '' baja ''.",
"pins.pulseDuration":"Obtiene la duración del último pulso en micro segundos. Esta función debe ser llamada desde un controlador de '' onPulsed''.",
"pins.servoSetPulse":"Configura este pin IO como salida analógica\/pwm, configura el período para ser ms 20 y establece el ancho de pulso, basado en el valor se da ** microsegundos ** o ' 1\/1000 «milisegundos.",
"pins.servoWritePin":"Escribe un valor en el servo, control del eje por consiguiente. En un servo estándar, esto ajustará el ángulo del eje (en grados), moviendo el eje para que la orientación. En un servo de rotación continua, esto ajustará la velocidad del servo (siendo '' 0'' máxima velocidad en una dirección, '' 180'' lleno de velocidad en el otro y un valor de cerca de '' 90'' no que ningún movimiento).",
"pins.setPull":"Configura el tirón de este pin.",
"serial":"Leer y escribir datos en una conexión en serie.",
"serial.readLine":"Lee una línea de texto del puerto serial.",
"serial.redirect":"Configurar dinámicamente la instancia serial para usar pernos excepto USBTX y USBRX.",
"serial.writeLine":"Imprime una línea de texto para la serie",
"serial.writeNumber":"Imprime un valor numérico a la serie",
"serial.writeString":"Envía un fragmento de texto a través de la conexión en serie.",
"serial.writeValue":"Escribe un \"nombre: valor '' par línea de la serie."
}

View File

@ -1,80 +0,0 @@
{
"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"
}

View File

@ -84,14 +84,24 @@ namespace led {
/** /**
* Sets the display mode between black and white and greyscale for rendering LEDs. * Sets the display mode between black and white and greyscale for rendering LEDs.
* @param mode TODO * @param mode mode the display mode in which the screen operates
*/ */
//% weight=1 help=led/set-display-mode //% weight=1 help=led/set-display-mode
//% parts="ledmatrix" //% parts="ledmatrix" advanced=true
void setDisplayMode(DisplayMode_ mode) { void setDisplayMode(DisplayMode_ mode) {
uBit.display.setDisplayMode((DisplayMode)mode); uBit.display.setDisplayMode((DisplayMode)mode);
} }
/**
* Turns on or off the display
*/
//% help=led/enable blockId=device_led_enable icon="\uf04d"
//% advanced=true parts="ledmatrix"
void enable(bool on) {
if (on) uBit.display.enable();
else uBit.display.disable();
}
/** /**
* Takes a screenshot of the LED screen and returns an image. * Takes a screenshot of the LED screen and returns an image.
*/ */

View File

@ -209,6 +209,7 @@ namespace pins {
*/ */
//% help=pins/servo-write-pin weight=20 //% help=pins/servo-write-pin weight=20
//% blockId=device_set_servo_pin block="servo write|pin %name|to %value" blockGap=8 //% blockId=device_set_servo_pin block="servo write|pin %name|to %value" blockGap=8
//% parts=microservo trackArgs=0
void servoWritePin(AnalogPin name, int value) { void servoWritePin(AnalogPin name, int value) {
PINOP(setServoValue(value)); PINOP(setServoValue(value));
} }

View File

@ -29,6 +29,37 @@
{"pinIndices": [2, 3]} {"pinIndices": [2, 3]}
] ]
}, },
"microservo": {
"simulationBehavior": "microservo",
"visual": {
"builtIn": "microservo",
"width": 74.85,
"height": 200,
"pinDistance": 10,
"pinLocations": [
{"x": 30, "y": 5},
{"x": 37, "y": 5},
{"x": 45, "y": 5}
]
},
"numberOfPins": 3,
"pinDefinitions": [
{"target": {"pinInstantiationIdx": 0}, "style": "croc", "orientation": "+Z"},
{"target": "threeVolt", "style": "croc", "orientation": "+Z"},
{"target": "ground", "style": "croc", "orientation": "+Z"}
],
"instantiation": {
"kind": "function",
"fullyQualifiedName": "pins.servoWritePin",
"argumentRoles": [
{"pinInstantiationIdx": 0, "partParameter": "name"}
]
},
"assembly": [
{"part": true, "pinIndices": [2]},
{"pinIndices": [0, 1]}
]
},
"neopixel": { "neopixel": {
"simulationBehavior": "neopixel", "simulationBehavior": "neopixel",
"visual": { "visual": {

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

@ -495,12 +495,19 @@ declare namespace led {
/** /**
* Sets the display mode between black and white and greyscale for rendering LEDs. * Sets the display mode between black and white and greyscale for rendering LEDs.
* @param mode TODO * @param mode mode the display mode in which the screen operates
*/ */
//% weight=1 help=led/set-display-mode //% weight=1 help=led/set-display-mode
//% parts="ledmatrix" shim=led::setDisplayMode //% parts="ledmatrix" advanced=true shim=led::setDisplayMode
function setDisplayMode(mode: DisplayMode): void; function setDisplayMode(mode: DisplayMode): void;
/**
* Turns on or off the display
*/
//% help=led/enable blockId=device_led_enable icon="\uf04d"
//% advanced=true parts="ledmatrix" shim=led::enable
function enable(on: boolean): void;
/** /**
* Takes a screenshot of the LED screen and returns an image. * Takes a screenshot of the LED screen and returns an image.
*/ */
@ -622,7 +629,8 @@ declare namespace pins {
* @param value angle or rotation speed, eg:180,90,0 * @param value angle or rotation speed, eg:180,90,0
*/ */
//% help=pins/servo-write-pin weight=20 //% help=pins/servo-write-pin weight=20
//% blockId=device_set_servo_pin block="servo write|pin %name|to %value" blockGap=8 shim=pins::servoWritePin //% blockId=device_set_servo_pin block="servo write|pin %name|to %value" blockGap=8
//% parts=microservo trackArgs=0 shim=pins::servoWritePin
function servoWritePin(name: AnalogPin, value: number): void; function servoWritePin(name: AnalogPin, value: number): void;
/** /**

View File

@ -100,6 +100,25 @@ namespace radio {
return ManagedString().leakData(); return ManagedString().leakData();
} }
void writePacketAsJSON(uint8_t tp, int v, int s, int t, StringData* m) {
// Convert the packet to JSON and send over serial
uBit.serial.send("{");
uBit.serial.send("\"t\":");
uBit.serial.send(t);
uBit.serial.send(",\"s\":");
uBit.serial.send(s);
if (tp == PACKET_TYPE_STRING || tp == PACKET_TYPE_VALUE) {
uBit.serial.send(",\"n\":\"");
uBit.serial.send(m);
uBit.serial.send("\"");
}
if (tp == PACKET_TYPE_NUMBER || tp == PACKET_TYPE_VALUE) {
uBit.serial.send(",\"v\":");
uBit.serial.send(v);
}
uBit.serial.send("}\r\n");
}
/** /**
* Takes a packet from the micro:bit radio queue. * Takes a packet from the micro:bit radio queue.
* @param writeToSerial if true, write the received packet to serial without updating the global packet; * @param writeToSerial if true, write the received packet to serial without updating the global packet;
@ -144,22 +163,7 @@ namespace radio {
msg = m; msg = m;
} }
else { else {
// Convert the packet to JSON and send over serial writePacketAsJSON(tp, v, s, t, m);
uBit.serial.send("{");
uBit.serial.send("\"t\":");
uBit.serial.send(t);
uBit.serial.send(",\"s\":");
uBit.serial.send(s);
if (tp == PACKET_TYPE_STRING || tp == PACKET_TYPE_VALUE) {
uBit.serial.send(",\"n\":\"");
uBit.serial.send(m);
uBit.serial.send("\"");
}
if (tp == PACKET_TYPE_NUMBER || tp == PACKET_TYPE_VALUE) {
uBit.serial.send(",\"v\":");
uBit.serial.send(v);
}
uBit.serial.send("}\r\n");
} }
} }
@ -184,7 +188,7 @@ namespace radio {
/** /**
* Broadcasts a name / value pair along with the device serial number * Broadcasts a name / value pair along with the device serial number
* and running time to any connected 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 name the field name (max 12 characters), eg: "name"
* @param value the numberic value * @param value the numberic value
*/ */
//% help=radio/send-value //% help=radio/send-value
@ -231,12 +235,25 @@ namespace radio {
//% help=radio/write-value-to-serial //% help=radio/write-value-to-serial
//% weight=3 //% weight=3
//% blockId=radio_write_value_serial block="radio write value to serial" //% blockId=radio_write_value_serial block="radio write value to serial"
//% advanced=true //% deprecated=true
void writeValueToSerial() { void writeValueToSerial() {
if (radioEnable() != MICROBIT_OK) return; if (radioEnable() != MICROBIT_OK) return;
receivePacket(true); receivePacket(true);
} }
/**
* Writes the last received packet to serial as JSON. This should be called
* within an ``onDataPacketReceived`` callback.
*/
//% help=radio/write-received-packet-to-serial
//% weight=3
//% blockId=radio_write_packet_serial block="radio write received packet to serial"
//% advanced=true
void writeReceivedPacketToSerial() {
if (radioEnable() != MICROBIT_OK) return;
writePacketAsJSON(type, value, (int) serial, (int) time, msg);
}
/** /**
* Reads the next packet from the radio queue and returns the packet's number * Reads the next packet from the radio queue and returns the packet's number
* payload or 0 if the packet did not contain a number. * payload or 0 if the packet did not contain a number.
@ -244,7 +261,7 @@ namespace radio {
//% help=radio/receive-number //% help=radio/receive-number
//% weight=46 //% weight=46
//% blockId=radio_datagram_receive block="radio receive number" blockGap=8 //% blockId=radio_datagram_receive block="radio receive number" blockGap=8
//% advanced=true //% deprecated=true
int receiveNumber() int receiveNumber()
{ {
if (radioEnable() != MICROBIT_OK) return 0; if (radioEnable() != MICROBIT_OK) return 0;
@ -258,7 +275,7 @@ namespace radio {
//% help=radio/on-data-received //% help=radio/on-data-received
//% weight=50 //% weight=50
//% blockId=radio_datagram_received_event block="radio on data received" blockGap=8 //% blockId=radio_datagram_received_event block="radio on data received" blockGap=8
//% advanced=true //% deprecated=true
void onDataReceived(Action body) { void onDataReceived(Action body) {
if (radioEnable() != MICROBIT_OK) return; if (radioEnable() != MICROBIT_OK) return;
registerWithDal(MICROBIT_ID_RADIO, MICROBIT_RADIO_EVT_DATAGRAM, body); registerWithDal(MICROBIT_ID_RADIO, MICROBIT_RADIO_EVT_DATAGRAM, body);
@ -274,7 +291,7 @@ namespace radio {
//% blockId=radio_datagram_receive_string block="radio receive string" blockGap=8 //% blockId=radio_datagram_receive_string block="radio receive string" blockGap=8
//% weight=44 //% weight=44
//% help=radio/receive-string //% help=radio/receive-string
//% advanced=true //% deprecated=true
StringData* receiveString() { StringData* receiveString() {
if (radioEnable() != MICROBIT_OK) return ManagedString().leakData(); if (radioEnable() != MICROBIT_OK) return ManagedString().leakData();
receivePacket(false); receivePacket(false);
@ -289,7 +306,7 @@ namespace radio {
//% help=radio/received-signal-strength //% help=radio/received-signal-strength
//% weight=40 //% weight=40
//% blockId=radio_datagram_rssi block="radio received signal strength" //% blockId=radio_datagram_rssi block="radio received signal strength"
//% advanced=true //% deprecated=true
int receivedSignalStrength() { int receivedSignalStrength() {
if (radioEnable() != MICROBIT_OK) return 0; if (radioEnable() != MICROBIT_OK) return 0;
return packet.getRSSI(); return packet.getRSSI();

View File

@ -13,7 +13,7 @@ namespace radio {
* The string payload if a string was sent in this packet (via ``sendString()`` or ``sendValue()``) * The string payload if a string was sent in this packet (via ``sendString()`` or ``sendValue()``)
* or the empty string if this packet did not contain a string. * or the empty string if this packet did not contain a string.
*/ */
public text: string; public receivedString: string;
/** /**
* The system time of the sender of the packet at the time the packet was sent. * The system time of the sender of the packet at the time the packet was sent.
*/ */
@ -32,9 +32,10 @@ namespace radio {
* Registers code to run when the radio receives a packet. Also takes the * Registers code to run when the radio receives a packet. Also takes the
* received packet from the radio queue. * received packet from the radio queue.
*/ */
//% help=radio/on-data-packet-received
//% mutate=true //% mutate=true
//% mutateText=Packet //% mutateText=Packet
//% mutateDefaults="receivedNumber;text,receivedNumber;text" //% mutateDefaults="receivedNumber;receivedString:name,receivedNumber:value;receivedString"
//% blockId=radio_on_packet block="on radio received" blockGap=8 //% blockId=radio_on_packet block="on radio received" blockGap=8
export function onDataPacketReceived(cb: (packet: Packet) => void) { export function onDataPacketReceived(cb: (packet: Packet) => void) {
onDataReceived(() => { onDataReceived(() => {
@ -43,7 +44,7 @@ namespace radio {
packet.receivedNumber = receivedNumber(); packet.receivedNumber = receivedNumber();
packet.time = receivedTime(); packet.time = receivedTime();
packet.serial = receivedSerial(); packet.serial = receivedSerial();
packet.text = receivedString(); packet.receivedString = receivedString();
packet.signal = receivedSignalStrength(); packet.signal = receivedSignalStrength();
cb(packet) cb(packet)
}); });

22
libs/radio/shims.d.ts vendored
View File

@ -16,7 +16,7 @@ declare namespace radio {
/** /**
* Broadcasts a name / value pair along with the device serial number * Broadcasts a name / value pair along with the device serial number
* and running time to any connected 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 name the field name (max 12 characters), eg: "name"
* @param value the numberic value * @param value the numberic value
*/ */
//% help=radio/send-value //% help=radio/send-value
@ -40,9 +40,19 @@ declare namespace radio {
//% help=radio/write-value-to-serial //% help=radio/write-value-to-serial
//% weight=3 //% weight=3
//% blockId=radio_write_value_serial block="radio write value to serial" //% blockId=radio_write_value_serial block="radio write value to serial"
//% advanced=true shim=radio::writeValueToSerial //% deprecated=true shim=radio::writeValueToSerial
function writeValueToSerial(): void; function writeValueToSerial(): void;
/**
* Writes the last received packet to serial as JSON. This should be called
* within an ``onDataPacketReceived`` callback.
*/
//% help=radio/write-received-packet-to-serial
//% weight=3
//% blockId=radio_write_packet_serial block="radio write received packet to serial"
//% advanced=true shim=radio::writeReceivedPacketToSerial
function writeReceivedPacketToSerial(): void;
/** /**
* Reads the next packet from the radio queue and returns the packet's number * Reads the next packet from the radio queue and returns the packet's number
* payload or 0 if the packet did not contain a number. * payload or 0 if the packet did not contain a number.
@ -50,7 +60,7 @@ declare namespace radio {
//% help=radio/receive-number //% help=radio/receive-number
//% weight=46 //% weight=46
//% blockId=radio_datagram_receive block="radio receive number" blockGap=8 //% blockId=radio_datagram_receive block="radio receive number" blockGap=8
//% advanced=true shim=radio::receiveNumber //% deprecated=true shim=radio::receiveNumber
function receiveNumber(): number; function receiveNumber(): number;
/** /**
@ -59,7 +69,7 @@ declare namespace radio {
//% help=radio/on-data-received //% help=radio/on-data-received
//% weight=50 //% weight=50
//% blockId=radio_datagram_received_event block="radio on data received" blockGap=8 //% blockId=radio_datagram_received_event block="radio on data received" blockGap=8
//% advanced=true shim=radio::onDataReceived //% deprecated=true shim=radio::onDataReceived
function onDataReceived(body: () => void): void; function onDataReceived(body: () => void): void;
/** /**
@ -69,7 +79,7 @@ declare namespace radio {
//% blockId=radio_datagram_receive_string block="radio receive string" blockGap=8 //% blockId=radio_datagram_receive_string block="radio receive string" blockGap=8
//% weight=44 //% weight=44
//% help=radio/receive-string //% help=radio/receive-string
//% advanced=true shim=radio::receiveString //% deprecated=true shim=radio::receiveString
function receiveString(): string; function receiveString(): string;
/** /**
@ -80,7 +90,7 @@ declare namespace radio {
//% help=radio/received-signal-strength //% help=radio/received-signal-strength
//% weight=40 //% weight=40
//% blockId=radio_datagram_rssi block="radio received signal strength" //% blockId=radio_datagram_rssi block="radio received signal strength"
//% advanced=true shim=radio::receivedSignalStrength //% deprecated=true shim=radio::receivedSignalStrength
function receivedSignalStrength(): number; function receivedSignalStrength(): number;
/** /**

View File

View File

@ -0,0 +1,62 @@
<xml xmlns="http://www.w3.org/1999/xhtml">
<block type="device_forever">
<statement name="HANDLER">
<block type="device_show_leds">
<field name="LED00">FALSE</field>
<field name="LED10">FALSE</field>
<field name="LED20">FALSE</field>
<field name="LED30">FALSE</field>
<field name="LED40">FALSE</field>
<field name="LED01">FALSE</field>
<field name="LED11">TRUE</field>
<field name="LED21">FALSE</field>
<field name="LED31">TRUE</field>
<field name="LED41">FALSE</field>
<field name="LED02">FALSE</field>
<field name="LED12">FALSE</field>
<field name="LED22">FALSE</field>
<field name="LED32">FALSE</field>
<field name="LED42">FALSE</field>
<field name="LED03">TRUE</field>
<field name="LED13">FALSE</field>
<field name="LED23">FALSE</field>
<field name="LED33">FALSE</field>
<field name="LED43">TRUE</field>
<field name="LED04">FALSE</field>
<field name="LED14">TRUE</field>
<field name="LED24">TRUE</field>
<field name="LED34">TRUE</field>
<field name="LED44">FALSE</field>
<next>
<block type="device_show_leds">
<field name="LED00">FALSE</field>
<field name="LED10">FALSE</field>
<field name="LED20">FALSE</field>
<field name="LED30">FALSE</field>
<field name="LED40">FALSE</field>
<field name="LED01">FALSE</field>
<field name="LED11">FALSE</field>
<field name="LED21">FALSE</field>
<field name="LED31">FALSE</field>
<field name="LED41">FALSE</field>
<field name="LED02">FALSE</field>
<field name="LED12">FALSE</field>
<field name="LED22">FALSE</field>
<field name="LED32">FALSE</field>
<field name="LED42">FALSE</field>
<field name="LED03">FALSE</field>
<field name="LED13">FALSE</field>
<field name="LED23">FALSE</field>
<field name="LED33">FALSE</field>
<field name="LED43">FALSE</field>
<field name="LED04">FALSE</field>
<field name="LED14">FALSE</field>
<field name="LED24">FALSE</field>
<field name="LED34">FALSE</field>
<field name="LED44">FALSE</field>
</block>
</next>
</block>
</statement>
</block>
</xml>

View File

@ -0,0 +1,16 @@
basic.forever(() => {
basic.showLeds(`
. # . # .
# . # . #
# . . . #
. # . # .
. . # . .
`)
basic.showLeds(`
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
`)
})

View File

@ -0,0 +1,13 @@
{
"name": "{0} block",
"dependencies": {
"core": "*",
"radio": "*"
},
"description": "",
"files": [
"main.blocks",
"main.ts",
"README.md"
]
}

View File

@ -0,0 +1,8 @@
{
"compilerOptions": {
"target": "es5",
"noImplicitAny": true,
"outDir": "built",
"rootDir": "."
}
}

View File

View File

@ -0,0 +1,7 @@
basic.showLeds(`
. . . . .
. # . # .
. . . . .
# . . . #
. # # # .
`);

View File

@ -0,0 +1,12 @@
{
"name": "{0} bit",
"dependencies": {
"core": "*",
"radio": "*"
},
"description": "",
"files": [
"main.ts",
"README.md"
]
}

View File

@ -0,0 +1,8 @@
{
"compilerOptions": {
"target": "es5",
"noImplicitAny": true,
"outDir": "built",
"rootDir": "."
}
}

View File

@ -130,11 +130,7 @@ Welcome to the Touch Develop home page for the BBC micro:bit. Below you will fin
* [running time](/reference/input/running-time) * [running time](/reference/input/running-time)
* [on shake](/reference/input/on-gesture) * [on shake](/reference/input/on-gesture)
* [on button pressed](/reference/input/on-button-pressed) * [on button pressed](/reference/input/on-button-pressed)
* [on logo down](/functions/on-logo-down)
* [on logo up](/functions/on-logo-up)
* [on pin pressed](/reference/input/on-pin-pressed) * [on pin pressed](/reference/input/on-pin-pressed)
* [on screen down](/functions/on-screen-down)
* [on screen up](/functions/on-screen-up)
* [pin is pressed](/reference/input/pin-is-pressed) * [pin is pressed](/reference/input/pin-is-pressed)
### Image ### Image

View File

@ -55,5 +55,4 @@ To learn more about how the BBC micro:bit queues up and schedules event handlers
### see also ### see also
[on button pressed](/reference/input/on-button-pressed), [on logo up](/functions/on-logo-up), [on logo down](/functions/on-logo-down), [on screen up](/functions/on-screen-up), [on screen down](/functions/on-screen-down), [on shake](/reference/input/on-gesture), [on pin pressed](/reference/input/on-pin-pressed) [on button pressed](/reference/input/on-button-pressed)

View File

@ -77,11 +77,6 @@ Overview of TouchDevelop lessons for the micro:bit.
* [compass heading](/reference/input/compass-heading) * [compass heading](/reference/input/compass-heading)
* [calibrate](/functions/calibrate) * [calibrate](/functions/calibrate)
* [running time](/reference/input/running-time) * [running time](/reference/input/running-time)
* [on shake](/reference/input/on-gesture)
* [on screen up](/functions/on-screen-up)
* [on screen down](/functions/on-screen-down)
* [on logo up](/functions/on-logo-up)
* [on logo down](/functions/on-logo-down)
### ~ ### ~

View File

@ -43,9 +43,6 @@ Learn how to create a guessing game with **global variables** `var str: "this is
* **show string** : [read more...](/reference/basic/show-string) * **show string** : [read more...](/reference/basic/show-string)
* **local variables** : [read more...](/reference/variables/var) * **local variables** : [read more...](/reference/variables/var)
* **assignment operator** : [read more...](/reference/variables/assign) * **assignment operator** : [read more...](/reference/variables/assign)
* **on logo up** [read more...](/functions/on-logo-up)
* **on screen down** [read more...](/functions/on-screen-down)
* **on screen up** [read more...](/functions/on-screen-up)
* **math random** : [read more...](/js/math) * **math random** : [read more...](/js/math)
## Resources ## Resources

View File

@ -30,7 +30,7 @@
"typescript": "^1.8.7" "typescript": "^1.8.7"
}, },
"dependencies": { "dependencies": {
"pxt-core": "0.5.33", "pxt-core": "0.5.34",
"less": "^2.6.0", "less": "^2.6.0",
"semantic-ui-less": "^2.2.4" "semantic-ui-less": "^2.2.4"
} }

View File

@ -20,46 +20,6 @@
], ],
"githubPackages": true "githubPackages": true
}, },
"blocksprj": {
"id": "blocksprj",
"config": {
"name": "{0} block",
"dependencies": {
"core": "*",
"radio": "*"
},
"description": "",
"files": [
"main.blocks",
"main.ts",
"README.md"
]
},
"files": {
"main.blocks": "<xml xmlns=\"http://www.w3.org/1999/xhtml\">\n<block type=\"device_forever\">\n<statement name=\"HANDLER\">\n<block type=\"device_show_leds\">\n<field name=\"LED00\">FALSE</field>\n<field name=\"LED10\">FALSE</field>\n<field name=\"LED20\">FALSE</field>\n<field name=\"LED30\">FALSE</field>\n<field name=\"LED40\">FALSE</field>\n<field name=\"LED01\">FALSE</field>\n<field name=\"LED11\">TRUE</field>\n<field name=\"LED21\">FALSE</field>\n<field name=\"LED31\">TRUE</field>\n<field name=\"LED41\">FALSE</field>\n<field name=\"LED02\">FALSE</field>\n<field name=\"LED12\">FALSE</field>\n<field name=\"LED22\">FALSE</field>\n<field name=\"LED32\">FALSE</field>\n<field name=\"LED42\">FALSE</field>\n<field name=\"LED03\">TRUE</field>\n<field name=\"LED13\">FALSE</field>\n<field name=\"LED23\">FALSE</field>\n<field name=\"LED33\">FALSE</field>\n<field name=\"LED43\">TRUE</field>\n<field name=\"LED04\">FALSE</field>\n<field name=\"LED14\">TRUE</field>\n<field name=\"LED24\">TRUE</field>\n<field name=\"LED34\">TRUE</field>\n<field name=\"LED44\">FALSE</field>\n<next>\n<block type=\"device_show_leds\">\n<field name=\"LED00\">FALSE</field>\n<field name=\"LED10\">FALSE</field>\n<field name=\"LED20\">FALSE</field>\n<field name=\"LED30\">FALSE</field>\n<field name=\"LED40\">FALSE</field>\n<field name=\"LED01\">FALSE</field>\n<field name=\"LED11\">FALSE</field>\n<field name=\"LED21\">FALSE</field>\n<field name=\"LED31\">FALSE</field>\n<field name=\"LED41\">FALSE</field>\n<field name=\"LED02\">FALSE</field>\n<field name=\"LED12\">FALSE</field>\n<field name=\"LED22\">FALSE</field>\n<field name=\"LED32\">FALSE</field>\n<field name=\"LED42\">FALSE</field>\n<field name=\"LED03\">FALSE</field>\n<field name=\"LED13\">FALSE</field>\n<field name=\"LED23\">FALSE</field>\n<field name=\"LED33\">FALSE</field>\n<field name=\"LED43\">FALSE</field>\n<field name=\"LED04\">FALSE</field>\n<field name=\"LED14\">FALSE</field>\n<field name=\"LED24\">FALSE</field>\n<field name=\"LED34\">FALSE</field>\n<field name=\"LED44\">FALSE</field>\n</block>\n</next>\n</block>\n</statement>\n</block>\n</xml>",
"main.ts": "basic.forever(() => {\r\n basic.showLeds(`\r\n . # . # .\r\n # . # . #\r\n # . . . #\r\n . # . # .\r\n . . # . .\r\n `)\r\n basic.showLeds(`\r\n . . . . .\r\n . . . . .\r\n . . . . .\r\n . . . . .\r\n . . . . .\r\n `)\r\n})\r\n",
"README.md": ""
}
},
"tsprj": {
"id": "tsprj",
"config": {
"name": "{0} bit",
"dependencies": {
"core": "*",
"radio": "*"
},
"description": "",
"files": [
"main.ts",
"README.md"
]
},
"files": {
"main.ts": "basic.showLeds(`\r\n . . . . .\r\n . # . # .\r\n . . . . .\r\n # . . . #\r\n . # # # .\r\n `);",
"README.md": ""
}
},
"compile": { "compile": {
"isNative": false, "isNative": false,
"hasHex": true, "hasHex": true,

View File

@ -12,9 +12,11 @@ namespace pxsim {
lightSensorState: LightSensorState; lightSensorState: LightSensorState;
buttonPairState: ButtonPairState; buttonPairState: ButtonPairState;
radioState: RadioState; radioState: RadioState;
// TODO: not singletons
neopixelState: NeoPixelState; neopixelState: NeoPixelState;
rgbLedState: number; rgbLedState: number;
speakerState: SpeakerState; speakerState: SpeakerState;
microServoState: MicroServoState;
constructor() { constructor() {
super() super()
@ -61,14 +63,17 @@ namespace pxsim {
this.builtinParts["compass"] = this.compassState = new CompassState(); this.builtinParts["compass"] = this.compassState = new CompassState();
this.builtinParts["neopixel"] = this.neopixelState = new NeoPixelState(); this.builtinParts["neopixel"] = this.neopixelState = new NeoPixelState();
this.builtinParts["speaker"] = this.speakerState = new SpeakerState(); this.builtinParts["speaker"] = this.speakerState = new SpeakerState();
this.builtinParts["microservo"] = this.microServoState = new MicroServoState();
this.builtinVisuals["buttonpair"] = () => new visuals.ButtonPairView(); this.builtinVisuals["buttonpair"] = () => new visuals.ButtonPairView();
this.builtinVisuals["ledmatrix"] = () => new visuals.LedMatrixView(); this.builtinVisuals["ledmatrix"] = () => new visuals.LedMatrixView();
this.builtinVisuals["neopixel"] = () => new visuals.NeoPixelView(); this.builtinVisuals["neopixel"] = () => new visuals.NeoPixelView();
this.builtinVisuals["microservo"] = () => new visuals.MicroServoView();
this.builtinPartVisuals["buttonpair"] = (xy: visuals.Coord) => visuals.mkBtnSvg(xy); this.builtinPartVisuals["buttonpair"] = (xy: visuals.Coord) => visuals.mkBtnSvg(xy);
this.builtinPartVisuals["ledmatrix"] = (xy: visuals.Coord) => visuals.mkLedMatrixSvg(xy, 8, 8); this.builtinPartVisuals["ledmatrix"] = (xy: visuals.Coord) => visuals.mkLedMatrixSvg(xy, 8, 8);
this.builtinPartVisuals["neopixel"] = (xy: visuals.Coord) => visuals.mkNeoPixelPart(xy); this.builtinPartVisuals["neopixel"] = (xy: visuals.Coord) => visuals.mkNeoPixelPart(xy);
this.builtinPartVisuals["microservo"] = (xy: visuals.Coord) => visuals.mkMicroServoPart(xy);
} }
receiveMessage(msg: SimulatorMessage) { receiveMessage(msg: SimulatorMessage) {

View File

@ -11,7 +11,7 @@ namespace pxsim.input {
if (!pin) return; if (!pin) return;
pin.isTouched(); pin.isTouched();
pxtcore.registerWithDal(pin.id, DAL.MICROBIT_BUTTON_EVT_UP, handler); pxtcore.registerWithDal(pin.id, DAL.MICROBIT_BUTTON_EVT_UP, handler);
} }
export function pinIsPressed(pinId: number): boolean { export function pinIsPressed(pinId: number): boolean {
let pin = getPin(pinId); let pin = getPin(pinId);
@ -73,7 +73,11 @@ namespace pxsim.pins {
export function servoWritePin(pinId: number, value: number) { export function servoWritePin(pinId: number, value: number) {
analogSetPeriod(pinId, 20000); analogSetPeriod(pinId, 20000);
// TODO // TODO: per pin state
if (board().microServoState.angle != value) {
board().microServoState.angle = value;
runtime.queueDisplayUpdate();
}
} }
export function servoSetPulse(pinId: number, micros: number) { export function servoSetPulse(pinId: number, micros: number) {

View File

@ -9,6 +9,7 @@ namespace pxsim {
brigthness = 255; brigthness = 255;
displayMode = DisplayMode.bw; displayMode = DisplayMode.bw;
font: Image = createFont(); font: Image = createFont();
disabled: boolean;
animationQ: AnimationQueue; animationQ: AnimationQueue;
@ -284,4 +285,8 @@ namespace pxsim.led {
board().ledMatrixState.image.copyTo(0, 5, img, 0); board().ledMatrixState.image.copyTo(0, 5, img, 0);
return img; return img;
} }
export function enable(on: boolean) {
board().ledMatrixState.disabled = !on;
runtime.queueDisplayUpdate();
}
} }

View File

@ -138,21 +138,13 @@ namespace pxsim.radio {
} }
export function writeValueToSerial(): void { export function writeValueToSerial(): void {
let b = board(); const b = board();
let p = b.radioState.bus.datagram.recv(); writePacketToSerial(b, b.radioState.bus.datagram.recv())
}
switch(p.payload.type) { export function writeReceivedPacketToSerial(): void {
case PacketPayloadType.NUMBER: const b = board();
b.writeSerial(`{"t":${p.time},"s":${p.serial},"v":${p.payload.numberData}}`) writePacketToSerial(b, b.radioState.bus.datagram.lastReceived);
break;
case PacketPayloadType.VALUE:
b.writeSerial(`{"t":${p.time},"s":${p.serial},"n":"${p.payload.stringData}","v":${p.payload.numberData}}`)
break;
case PacketPayloadType.STRING:
b.writeSerial(`{"t":${p.time},"s":${p.serial},"n":"${p.payload.stringData}"}`)
break;
default:
}
} }
export function sendValue(name: string, value: number) { export function sendValue(name: string, value: number) {
@ -200,4 +192,19 @@ namespace pxsim.radio {
export function receivedTime(): number { export function receivedTime(): number {
return board().radioState.bus.datagram.lastReceived.time; return board().radioState.bus.datagram.lastReceived.time;
} }
function writePacketToSerial(b: DalBoard, p: PacketBuffer) {
switch(p.payload.type) {
case PacketPayloadType.NUMBER:
b.writeSerial(`{"t":${p.time},"s":${p.serial},"v":${p.payload.numberData}}\r\n`)
break;
case PacketPayloadType.VALUE:
b.writeSerial(`{"t":${p.time},"s":${p.serial},"n":"${p.payload.stringData}","v":${p.payload.numberData}}\r\n`)
break;
case PacketPayloadType.STRING:
b.writeSerial(`{"t":${p.time},"s":${p.serial},"n":"${p.payload.stringData}"}\r\n`)
break;
default:
}
}
} }

View File

@ -3,9 +3,9 @@
namespace pxsim.visuals { namespace pxsim.visuals {
export function mkLedMatrixSvg(xy: Coord, rows: number, cols: number): export function mkLedMatrixSvg(xy: Coord, rows: number, cols: number):
{el: SVGGElement, y: number, x: number, w: number, h: number, leds: SVGElement[], ledsOuter: SVGElement[], background: SVGElement} { { el: SVGGElement, y: number, x: number, w: number, h: number, leds: SVGElement[], ledsOuter: SVGElement[], background: SVGElement } {
let result: {el: SVGGElement, y: number, x: number, w: number, h: number, leds: SVGElement[], ledsOuter: SVGElement[], background: SVGElement} let result: { el: SVGGElement, y: number, x: number, w: number, h: number, leds: SVGElement[], ledsOuter: SVGElement[], background: SVGElement }
= {el: null, y: 0, x: 0, w: 0, h: 0, leds: [], ledsOuter: [], background: null}; = { el: null, y: 0, x: 0, w: 0, h: 0, leds: [], ledsOuter: [], background: null };
result.el = <SVGGElement>svg.elt("g"); result.el = <SVGGElement>svg.elt("g");
let width = cols * PIN_DIST; let width = cols * PIN_DIST;
let height = rows * PIN_DIST; let height = rows * PIN_DIST;
@ -19,7 +19,7 @@ namespace pxsim.visuals {
result.y = top; result.y = top;
result.w = width; result.w = width;
result.h = height; result.h = height;
result.background = svg.child(result.el, "rect", {class: "sim-display", x: left, y: top, width: width, height: height}) result.background = svg.child(result.el, "rect", { class: "sim-display", x: left, y: top, width: width, height: height })
// ledsOuter // ledsOuter
result.leds = []; result.leds = [];
@ -101,8 +101,16 @@ namespace pxsim.visuals {
} }
public updateState() { public updateState() {
let bw = this.state.displayMode == pxsim.DisplayMode.bw if (this.state.disabled) {
let img = this.state.image; this.leds.forEach((led, i) => {
let sel = (<SVGStylable><any>led)
sel.style.opacity = 0 + "";
});
return;
}
const bw = this.state.displayMode == pxsim.DisplayMode.bw
const img = this.state.image;
this.leds.forEach((led, i) => { this.leds.forEach((led, i) => {
let sel = (<SVGStylable><any>led) let sel = (<SVGStylable><any>led)
let dx = i % this.DRAW_SIZE; let dx = i % this.DRAW_SIZE;

View File

@ -1335,12 +1335,19 @@ namespace pxsim.visuals {
svg.fill(this.buttons[index], btn.pressed ? (btn.virtual ? theme.virtualButtonDown : theme.buttonDown) : (btn.virtual ? theme.virtualButtonUp : theme.buttonUps[index])); svg.fill(this.buttons[index], btn.pressed ? (btn.virtual ? theme.virtualButtonDown : theme.buttonDown) : (btn.virtual ? theme.virtualButtonUp : theme.buttonUps[index]));
}); });
let bw = state.ledMatrixState.displayMode == pxsim.DisplayMode.bw if (state.ledMatrixState.disabled) {
let img = state.ledMatrixState.image; this.leds.forEach((led, i) => {
this.leds.forEach((led, i) => { const sel = (<SVGStylable><any>led)
let sel = (<SVGStylable><any>led) sel.style.opacity = "0";
sel.style.opacity = ((bw ? img.data[i] > 0 ? 255 : 0 : img.data[i]) / 255.0) + ""; })
}) } else {
const bw = state.ledMatrixState.displayMode == pxsim.DisplayMode.bw
const img = state.ledMatrixState.image;
this.leds.forEach((led, i) => {
const sel = (<SVGStylable><any>led)
sel.style.opacity = ((bw ? img.data[i] > 0 ? 255 : 0 : img.data[i]) / 255.0) + "";
})
}
this.updatePins(); this.updatePins();
this.updateTilt(); this.updateTilt();
this.updateHeading(); this.updateHeading();

9
tests/deprecated-apis.ts Normal file
View File

@ -0,0 +1,9 @@
// deprecated APIs
radio.receivedNumber();
radio.receivedSerial();
radio.receivedSignalStrength();
radio.receivedString();
radio.receivedTime();
radio.onDataReceived(() => {
});

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -36,3 +36,4 @@
*******************************/ *******************************/
@blocklyToolboxColor: #F6F4E6; @blocklyToolboxColor: #F6F4E6;

View File

@ -7,6 +7,9 @@
/* Reference import */ /* Reference import */
@import (reference) "semantic.less"; @import (reference) "semantic.less";
/*******************************
Add your custom CSS here
*******************************/
.openproject { .openproject {
background: #4ECC60 !important; background: #4ECC60 !important;
} }

View File

@ -91,4 +91,5 @@
@fontPath : 'fonts'; @fontPath : 'fonts';
/* End Config */ /* End Config */