namspace docs
This commit is contained in:
parent
0f56142317
commit
cdd4798945
@ -1,113 +1,25 @@
|
||||
# Reference
|
||||
|
||||
## micro:bit
|
||||
|
||||
```namespaces
|
||||
basic.showString("Hello!");
|
||||
input.onButtonPressed(Button.A, () => {});
|
||||
led.plot(0,0);
|
||||
radio.sendNumber(0);
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Whole));
|
||||
game.createSprite();
|
||||
pins.digitalReadPin(DigitalPin.P0);
|
||||
serial.WriteLine("Hello!")
|
||||
control.inBackground(() => {});
|
||||
```
|
||||
|
||||
## Language
|
||||
|
||||
### @section full
|
||||
|
||||
### ~column
|
||||
|
||||
### Basic
|
||||
|
||||
[show number](/microbit/reference/basic/show-number)
|
||||
|
||||
~~~~block
|
||||
basic.showNumber(2)
|
||||
~~~~
|
||||
|
||||
[show string](/microbit/reference/basic/show-string)
|
||||
|
||||
~~~~block
|
||||
basic.showString('Hello!')
|
||||
~~~~
|
||||
|
||||
[show LEDs](/microbit/reference/basic/show-leds)
|
||||
|
||||
~~~~block
|
||||
basic.showLeds(`. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
# . . . #
|
||||
. # # # .`)
|
||||
~~~~
|
||||
|
||||
[clear screen](/microbit/reference/basic/clear-screen)
|
||||
|
||||
~~~~block
|
||||
basic.clearScreen()
|
||||
~~~~
|
||||
|
||||
[forever](/microbit/reference/basic/forever)
|
||||
|
||||
~~~~block
|
||||
basic.forever(() => { })
|
||||
~~~~
|
||||
|
||||
[pause](/microbit/reference/basic/pause)
|
||||
|
||||
```block
|
||||
basic.pause(200)
|
||||
```
|
||||
|
||||
### Input
|
||||
|
||||
[on button pressed](/microbit/reference/input/on-button-pressed)
|
||||
|
||||
```block
|
||||
input.onButtonPressed(Button.A, () => {})
|
||||
```
|
||||
|
||||
[on pin pressed](/microbit/reference/input/on-pin-pressed)
|
||||
|
||||
```block
|
||||
input.onPinPressed(TouchPin.P0, () => {})
|
||||
```
|
||||
|
||||
[on shake](/microbit/reference/input/on-shake)
|
||||
|
||||

|
||||
|
||||
[on logo up](/microbit/reference/on-logo-up)
|
||||
|
||||

|
||||
|
||||
[on logo down](/microbit/reference/on-logo-down)
|
||||
|
||||

|
||||
|
||||
[on screen up](/microbit/reference/on-screen-up)
|
||||
|
||||

|
||||
|
||||
[on screen down](/microbit/reference/on-screen-down)
|
||||
|
||||

|
||||
|
||||
[button is pressed](/microbit/reference/button-is-pressed)
|
||||
|
||||

|
||||
|
||||
[compass heading](/microbit/reference/compass-heading)
|
||||
|
||||

|
||||
|
||||
[temperature](/microbit/reference/temperature)
|
||||
|
||||

|
||||
|
||||
[acceleration](/microbit/reference/input/acceleration)
|
||||
|
||||

|
||||
|
||||
[rotation](/microbit/reference/rotation)
|
||||
|
||||

|
||||
|
||||
[magnetic force](/microbit/reference/magnetic-force)
|
||||
|
||||

|
||||
|
||||
[running time](/microbit/reference/running-time)
|
||||
|
||||

|
||||
|
||||
### Loops
|
||||
|
||||
[for](/microbit/reference/loops/for)
|
||||
@ -132,8 +44,6 @@ while(true) {}
|
||||
basic.forever(() => {})
|
||||
```
|
||||
|
||||
|
||||
|
||||
### ~
|
||||
|
||||
### ~column
|
||||
@ -199,6 +109,10 @@ x;
|
||||
let x = 0;
|
||||
x+=1;
|
||||
```
|
||||
### ~
|
||||
|
||||
### ~column
|
||||
|
||||
|
||||
### Math
|
||||
|
||||
@ -237,224 +151,8 @@ Random value
|
||||
```block
|
||||
Math.random(5);
|
||||
```
|
||||
|
||||
### LED
|
||||
|
||||
[plot](/microbit/reference/led/plot)
|
||||
|
||||
```block
|
||||
led.plot(2,2)
|
||||
```
|
||||
|
||||
[unplot](/microbit/reference/led/unplot)
|
||||
|
||||
```block
|
||||
led.unplot(2,2)
|
||||
```
|
||||
|
||||
[point](/microbit/reference/point)
|
||||
|
||||
```block
|
||||
led.point(2,2)
|
||||
```
|
||||
|
||||
[brightness](/microbit/reference/brightness)
|
||||
|
||||
```block
|
||||
led.brightness()
|
||||
```
|
||||
|
||||
[set brightness](/microbit/reference/set-brightness)
|
||||
|
||||
```block
|
||||
led.setBrightness(255)
|
||||
```
|
||||
|
||||
[stop animation](/microbit/reference/stop-animation)
|
||||
|
||||
```block
|
||||
led.stopAnimation()
|
||||
```
|
||||
|
||||
[plot bar graph](/microbit/reference/led/plot-bar-graph)
|
||||
|
||||
```block
|
||||
led.plotBarGraph(0, 1023)
|
||||
```
|
||||
|
||||
### Game
|
||||
|
||||
[create sprite](/microbit/reference/game/create-sprite)
|
||||
|
||||

|
||||
|
||||
[move](/microbit/reference/game/move)
|
||||
|
||||

|
||||
|
||||
[turn](/microbit/reference/game/turn)
|
||||
|
||||

|
||||
|
||||
[change](/microbit/reference/game/change)
|
||||
|
||||

|
||||
|
||||
[set](/microbit/reference/game/set)
|
||||
|
||||

|
||||
|
||||
[reports](/microbit/reference/reports)
|
||||
|
||||

|
||||
|
||||
[touching](/microbit/reference/touching)
|
||||
|
||||

|
||||
|
||||
[touching edge](/microbit/reference/touching-edge)
|
||||
|
||||

|
||||
|
||||
[if on edge, bounce](/microbit/reference/logic/if-on-edge-bounce)
|
||||
|
||||

|
||||
|
||||
[change score by](/microbit/reference/change-score-by)
|
||||
|
||||

|
||||
|
||||
[score](/microbit/reference/score)
|
||||
|
||||

|
||||
|
||||
[start countdown](/microbit/reference/start-countdown)
|
||||
|
||||

|
||||
|
||||
[game over](/microbit/reference/game-over)
|
||||
|
||||

|
||||
|
||||
### Music
|
||||
|
||||
[play tone](/microbit/reference/play-tone)
|
||||
|
||||

|
||||
|
||||
[ring tone](/microbit/reference/ring-tone)
|
||||
|
||||

|
||||
|
||||
[rest](/microbit/reference/rest)
|
||||
|
||||

|
||||
|
||||
[tempo](/microbit/reference/tempo)
|
||||
|
||||

|
||||
|
||||
[set tempo](/microbit/reference/set-tempo)
|
||||
|
||||

|
||||
|
||||
[change tempo](/microbit/reference/music/set-tempo)
|
||||
|
||||

|
||||
|
||||
### Comments
|
||||
|
||||
[comment](/microbit/reference/comment)
|
||||
|
||||
### Images
|
||||
|
||||
[show image](/microbit/reference/show-image)
|
||||
|
||||

|
||||
|
||||
[scroll image](/microbit/reference/scroll-image)
|
||||
|
||||

|
||||
|
||||
[create image](/microbit/reference/create-image)
|
||||
|
||||

|
||||
|
||||
|
||||
### ~
|
||||
|
||||
### ~column
|
||||
|
||||
### Pins
|
||||
|
||||
[digital read pin](/microbit/reference/pins/digital-read-pin)
|
||||
|
||||

|
||||
|
||||
[digital write pin](/microbit/reference/pins/digital-write-pin)
|
||||
|
||||

|
||||
|
||||
[analog read pin](/microbit/reference/pins/analog-read-pin)
|
||||
|
||||

|
||||
|
||||
[analog write pin](/microbit/reference/pins/analog-write-pin)
|
||||
|
||||

|
||||
|
||||
[analog set period](/microbit/reference/pins/analog-set-period)
|
||||
|
||||

|
||||
|
||||
[servo write pin](/microbit/reference/pins/servo-write-pin)
|
||||
|
||||

|
||||
|
||||
[servo set pulse](/microbit/reference/pins/servo-set-pulse)
|
||||
|
||||

|
||||
|
||||
[map](/microbit/reference/map)
|
||||
|
||||

|
||||
|
||||
|
||||
## Devices
|
||||
|
||||
Functions in this category require to be connected to a remote device.
|
||||
|
||||
[tell camera to](/microbit/reference/devices/tell-camera-to)
|
||||
|
||||

|
||||
|
||||
[tell remote control to](/microbit/reference/devices/tell-remote-control-to)
|
||||
|
||||

|
||||
|
||||
[raise alert to](/microbit/reference/devices/raise-alert-to)
|
||||
|
||||

|
||||
|
||||
[on notified](/microbit/reference/on-notified)
|
||||
|
||||

|
||||
|
||||
[on gamepad button](/microbit/reference/on-gamepad-button)
|
||||
|
||||

|
||||
|
||||
[on notified](/microbit/reference/on-notified)
|
||||
|
||||

|
||||
|
||||
[signal strength](/microbit/reference/signal-strength)
|
||||
|
||||

|
||||
|
||||
[on signal strength changed](/microbit/reference/on-signal-strength-changed)
|
||||
|
||||

|
||||
|
||||
### ~
|
||||
|
||||
|
35
docs/reference/basic.md
Normal file
35
docs/reference/basic.md
Normal file
@ -0,0 +1,35 @@
|
||||
# Basic
|
||||
|
||||
Provides access to basic micro:bit functionality.
|
||||
|
||||
|
||||
```cards
|
||||
basic.showNumber(0);
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . # . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
`);
|
||||
basic.showString("Hello!");
|
||||
basic.clearScreen();
|
||||
basic.forever(() => {
|
||||
|
||||
});
|
||||
basic.pause(100);
|
||||
basic.plotLeds(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . # . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
`);
|
||||
basic.showAnimation(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . # . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
`);
|
||||
```
|
11
docs/reference/control.md
Normal file
11
docs/reference/control.md
Normal file
@ -0,0 +1,11 @@
|
||||
# Control
|
||||
|
||||
|
||||
|
||||
|
||||
```cards
|
||||
control.inBackground(() => {
|
||||
|
||||
});
|
||||
control.reset();
|
||||
```
|
12
docs/reference/game.md
Normal file
12
docs/reference/game.md
Normal file
@ -0,0 +1,12 @@
|
||||
# Game
|
||||
|
||||
|
||||
|
||||
|
||||
```cards
|
||||
game.addScore(1);
|
||||
game.score();
|
||||
game.startCountdown(10000);
|
||||
game.gameOver();
|
||||
game.setScore(0);
|
||||
```
|
21
docs/reference/images.md
Normal file
21
docs/reference/images.md
Normal file
@ -0,0 +1,21 @@
|
||||
# Images
|
||||
|
||||
|
||||
|
||||
|
||||
```cards
|
||||
images.createImage(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . # . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
`);
|
||||
images.createBigImage(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . # . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
`);
|
||||
```
|
42
docs/reference/input.md
Normal file
42
docs/reference/input.md
Normal file
@ -0,0 +1,42 @@
|
||||
# Input
|
||||
|
||||
|
||||
|
||||
|
||||
```cards
|
||||
input.onButtonPressed(.Button, () => {
|
||||
|
||||
});
|
||||
input.onGesture(.Gesture, () => {
|
||||
|
||||
});
|
||||
input.onPinPressed(.TouchPin, () => {
|
||||
|
||||
});
|
||||
input.buttonIsPressed(.Button);
|
||||
input.compassHeading();
|
||||
input.temperature();
|
||||
input.acceleration(.Dimension);
|
||||
input.lightLevel();
|
||||
input.rotation(.Rotation);
|
||||
input.magneticForce(.Dimension);
|
||||
input.runningTime();
|
||||
input.setAccelerometerRange(.AcceleratorRange);
|
||||
input.pinIsPressed(.TouchPin);
|
||||
input.calibrate();
|
||||
input.onLogoDown(() => {
|
||||
|
||||
});
|
||||
input.onLogoUp(() => {
|
||||
|
||||
});
|
||||
input.onScreenDown(() => {
|
||||
|
||||
});
|
||||
input.onScreenUp(() => {
|
||||
|
||||
});
|
||||
input.onShake(() => {
|
||||
|
||||
});
|
||||
```
|
21
docs/reference/led.md
Normal file
21
docs/reference/led.md
Normal file
@ -0,0 +1,21 @@
|
||||
# Led
|
||||
|
||||
|
||||
|
||||
|
||||
```cards
|
||||
led.plot(0, 0);
|
||||
led.unplot(0, 0);
|
||||
led.point(0, 0);
|
||||
led.brightness();
|
||||
led.setBrightness(255);
|
||||
led.stopAnimation();
|
||||
led.plotBarGraph(0, 1023);
|
||||
led.fadeIn();
|
||||
led.fadeOut();
|
||||
led.plotAll();
|
||||
led.screenshot();
|
||||
led.toggle(0, 0);
|
||||
led.toggleAll();
|
||||
led.setDisplayMode(.DisplayMode);
|
||||
```
|
15
docs/reference/music.md
Normal file
15
docs/reference/music.md
Normal file
@ -0,0 +1,15 @@
|
||||
# Music
|
||||
|
||||
|
||||
|
||||
|
||||
```cards
|
||||
music.playTone(0, 0);
|
||||
music.ringTone(0);
|
||||
music.rest(0);
|
||||
music.noteFrequency(.Note);
|
||||
music.beat();
|
||||
music.tempo();
|
||||
music.changeTempoBy(20);
|
||||
music.setTempo(120);
|
||||
```
|
17
docs/reference/pins.md
Normal file
17
docs/reference/pins.md
Normal file
@ -0,0 +1,17 @@
|
||||
# Pins
|
||||
|
||||
|
||||
|
||||
|
||||
```cards
|
||||
pins.digitalReadPin(.DigitalPin);
|
||||
pins.digitalWritePin(.DigitalPin, 0);
|
||||
pins.analogReadPin(.AnalogPin);
|
||||
pins.analogWritePin(.AnalogPin, 1023);
|
||||
pins.analogSetPeriod(.AnalogPin, 20000);
|
||||
pins.servoWritePin(.AnalogPin, 180);
|
||||
pins.servoSetPulse(.AnalogPin, 1500);
|
||||
pins.map(0, 0, 1023, 0, 4);
|
||||
pins.analogPitch(0, 0);
|
||||
pins.analogSetPitchPin(.AnalogPin);
|
||||
```
|
Loading…
x
Reference in New Issue
Block a user