forked from microsoft/pxt-calliope
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bdad617
commit fd70199
Showing
22 changed files
with
358 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# built In Melody | ||
|
||
Get a melody string for a built-in melody. | ||
|
||
```sig | ||
music.builtInMelody(Melodies.Dadadadum) | ||
``` | ||
|
||
A collection of built-in melodies are available. You choose one by selecting the name of the melody. | ||
|
||
## Parameters | ||
|
||
* **melody**: A melody name. The available melodies are: | ||
|
||
>* `dadadum` | ||
>* `entertainer` | ||
>* `prelude` | ||
>* `ode` | ||
>* `nyan` | ||
>* `ringtone` | ||
>* `funk` | ||
>* `blues` | ||
>* `birthday` | ||
>* `wedding` | ||
>* `funeral` | ||
>* `punchline` | ||
>* `baddy` | ||
>* `chase` | ||
>* `ba ding` | ||
>* `wawawawaa` | ||
>* `jump up` | ||
>* `jump down` | ||
>* `power up` | ||
>* `power down` | ||
## Returns | ||
|
||
* a [string](/types/string) that contains the melody. | ||
|
||
## Example | ||
|
||
Play the built-in melody for **blues**. | ||
|
||
```blocks | ||
music.startMelody(music.builtInMelody(Melodies.Blues), MelodyOptions.Once) | ||
``` | ||
|
||
## See also | ||
|
||
[start melody](/reference/music/start-melody), | ||
[built-in sound effect](/reference/music/builtin-sound-effect) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# built In Playable Melody | ||
|
||
Get a playable sound object for a built-in melody. | ||
|
||
```sig | ||
music.builtInPlayableMelody(Melodies.Dadadadum) | ||
``` | ||
|
||
A collection of built-in melodies are available as [playable](/types/playable) sound objects. You choose one by selecting the name of the melody. | ||
|
||
## Parameters | ||
|
||
* **melody**: A melody name. The available melodies are: | ||
|
||
>* `dadadum` | ||
>* `entertainer` | ||
>* `prelude` | ||
>* `ode` | ||
>* `nyan` | ||
>* `ringtone` | ||
>* `funk` | ||
>* `blues` | ||
>* `birthday` | ||
>* `wedding` | ||
>* `funeral` | ||
>* `punchline` | ||
>* `baddy` | ||
>* `chase` | ||
>* `ba ding` | ||
>* `wawawawaa` | ||
>* `jump up` | ||
>* `jump down` | ||
>* `power up` | ||
>* `power down` | ||
## Returns | ||
|
||
* a [playable](/types/playable) object that contains the melody. | ||
|
||
## Example | ||
|
||
Play the built-in melody for **blues**. | ||
|
||
```blocks | ||
music.play(music.builtInPlayableMelody(Melodies.Blues), music.PlaybackMode.InBackground) | ||
``` | ||
|
||
## See also | ||
|
||
[built-in sound effect](/reference/music/builtin-sound-effect) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# is Sound Playing | ||
|
||
Check if sound is playing at any sound output. | ||
|
||
```sig | ||
music.isSoundPlaying() | ||
``` | ||
|
||
### ~ reminder | ||
|
||
This function requires the Calliope mini 3 hardware. If you use this function with a Calliope mini 1 or 2 board, you will see the **927** error code on the screen. | ||
|
||
### ~ | ||
|
||
Sound is played at the built-in speaker or at the selected audio output pin. You can check if any sound is currently being played at any of these outputs. | ||
|
||
## Returns | ||
|
||
* a [boolean](/types/boolean) value that is `true` if sound is being played at the built-in speaker or at the audio pin. The value is `false` otherwise. | ||
|
||
## Example #example | ||
|
||
Stop all sounds if any are currently playing. | ||
|
||
```blocks | ||
if (music.isSoundPlaying()) { | ||
music.stopAllSounds() | ||
} | ||
``` | ||
|
||
## See also | ||
|
||
[set built-in speaker enabled](/reference/music/set-built-in-speaker-enabled), | ||
[set audio pin](/reference/pins/set-audio-pin) | ||
|
||
```package | ||
music | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# analog Pin | ||
|
||
Get an analog pin number for a pin identifier. | ||
|
||
```sig | ||
pins._analogPin(AnalogPin.P0) | ||
``` | ||
|
||
## Parameters | ||
|
||
* **pin**: a pin identifier for an analog pin (`P0` through `P20`). | ||
|
||
## Returns | ||
|
||
* a pin [number](/types/number) for the pin identifier. | ||
|
||
## Example | ||
|
||
Set an analog pin variable for `P1`, read pin `P1`, and show the input value on the LED screen. | ||
|
||
```blocks | ||
let myPin = AnalogPin.P1 | ||
basic.forever(function() { | ||
let value = pins.analogReadPin(myPin) | ||
basic.showNumber(value) | ||
}) | ||
``` | ||
|
||
## See also | ||
|
||
[analog read pin](/reference/pins/analog-read-pin), | ||
[analog write pin](/reference/pins/analog-write-pin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# digital Pin | ||
|
||
Get an digital pin number for a pin identifier. | ||
|
||
```sig | ||
pins._digitalPin(DigitalPin.P3) | ||
``` | ||
|
||
## Parameters | ||
|
||
* **pin**: a pin identifier for an digital pin (`P0` through `P20`). | ||
|
||
## Returns | ||
|
||
* a pin [number](/types/number) for the pin identifier. | ||
|
||
## Example: football score keeper | ||
|
||
This program reads pin `P0` to find when a goal is scored. When `P0` | ||
is `1`, the program makes the score bigger and plays a buzzer sound | ||
through `P2` with ``||pins:digital write pin||``. Use pin variables | ||
to set the read and write pin numbers. | ||
|
||
```blocks | ||
let score = 0 | ||
let readPin = DigitalPin.P0 | ||
let writePin = DigitalPin.P2 | ||
basic.showNumber(score) | ||
basic.forever(() => { | ||
if (pins.digitalReadPin(readPin) == 1) { | ||
score++; | ||
pins.digitalWritePin(writePin, 1) | ||
basic.showNumber(score) | ||
basic.pause(1000) | ||
pins.digitalWritePin(writePin, 0) | ||
} | ||
}) | ||
``` | ||
|
||
## See also | ||
|
||
[digital read pin](/reference/pins/digital-read-pin), | ||
[digital write pin](/reference/pins/digital-write-pin) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.