Updates for V4 (#197)

* update yotta defaults for 16kb devices

* refactor deprecated blocks

* updates for button events

* update button events

* update refference

* update docs

* update docs

* update button event blocks

* update docs

* update block id
This commit is contained in:
Juri Wolf
2022-08-10 18:36:19 +02:00
committed by GitHub
parent 32783f38ba
commit 5f7a8e5301
107 changed files with 1218 additions and 706 deletions

View File

@ -48,7 +48,7 @@ keeper @boardname@, you can press button `B` on the remote to buzz and
make the score bigger on the other @boardname@.
```blocks
input.onButtonEvent(Button.B, ButtonEvent.Click, () => {
input.onButtonEvent(Button.B, input.buttonEventClick(), () => {
pins.digitalWritePin(DigitalPin.P1, 1);
basic.pause(500);
pins.digitalWritePin(DigitalPin.P1, 0);

View File

@ -46,7 +46,7 @@ will use ``digital write pin`` to make the other @boardname@ buzz and
make the score bigger.
```blocks
input.onButtonEvent(Button.B, ButtonEvent.Click, () => {
input.onButtonEvent(Button.B, input.buttonEventClick(), () => {
pins.digitalWritePin(DigitalPin.P1, 1);
basic.pause(500);
pins.digitalWritePin(DigitalPin.P1, 0);

View File

@ -0,0 +1,35 @@
# Neopixel matrix width
For Neopixel matrix (strip) on the specified [pin](/device/pins),
set the width of that matrix. This informs the simulator to display
the Neopixel strip as a matrix.
```sig
pins.setMatrixWidth(Digital.P1, 16)
```
## Parameters
* ``name``: The @boardname@ hardware pin to configure (``P0``-``P20``)
* ``width``: a [number](/types/number) (for example, from `2` through `16`)
## Example
To use the example below, you should add the Neopixel extension to your
project and then copy the JavaScript code below over to your project.
The example creates a strip of 25 neopixels corresponding to a 5x5 matrix and then draws
an `X` on the matrix. Try changing the value of the variable `width`
to get matrices of different sizes.
```blocks
let width = 5
let strip = neopixel.create(DigitalPin.P1, width * width, NeoPixelMode.RGB)
strip.setMatrixWidth(width)
pins.setMatrixWidth(DigitalPin.P1, width)
for (let i = 0; i <= width - 1; i++) {
strip.setMatrixColor(i, i, neopixel.colors(NeoPixelColors.Red))
strip.setMatrixColor(width - (i + 1), i, neopixel.colors(NeoPixelColors.Blue))
}
strip.show()
```

View File

@ -0,0 +1,34 @@
# set Audio Pin
Set the [pin](/device/pins) (P0, P1, P2) that is used to play music and generate tones.
```sig
pins.setAudioPin(AnalogPin.P0)
```
### ~ hint
#### micro:bit V2 speaker
With the [micro:bit V2](/device/v2) hardware, the built-in speaker will play (mirror) the same tones and music sent to the audio pin.
### ~
## Parameters
* **name**: the pin to set for audio output: `P0`, `P1`, or `P2`.
## Example
Play a tone for the "A4" note at pin **P0** for 1 second.
```blocks
pins.setAudioPin(AnalogPin.P0)
let frequency = 440
let duration = 1000
pins.analogPitch(frequency, duration)
```
## See also
[@boardname@ pins](/device/pins), [analog set pitch pin](/reference/pins/analog-set-pitch-pin)