various docs updates

This commit is contained in:
Peli de Halleux 2016-04-05 23:11:48 -07:00
parent baf2c3247f
commit 2aa7c91ca7
5 changed files with 127 additions and 145 deletions

View File

@ -1,10 +1,12 @@
# Reference # Reference
## micro:bit
```namespaces ```namespaces
basic.showString("Hello!"); basic.showString("Hello!");
input.onButtonPressed(Button.A, () => {}); input.onButtonPressed(Button.A, () => {});
for (let i = 0;i<5;++i) {}
if (true){}
let x = 0;
Math.random(5);
led.plot(0,0); led.plot(0,0);
radio.sendNumber(0); radio.sendNumber(0);
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Whole)); music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Whole));
@ -13,146 +15,3 @@ pins.digitalReadPin(DigitalPin.P0);
serial.writeLine("Hello!"); serial.writeLine("Hello!");
control.inBackground(() => {}); control.inBackground(() => {});
``` ```
## Language
### @section full
### ~column
### Loops
[for](/microbit/reference/loops/for)
```block
for(let i = 0;i<5;i++) {}
```
[repeat](/microbit/reference/loops/repeat)
![](/static/mb/blocks/contents-0.png)
[while](/microbit/reference/loops/while)
```block
while(true) {}
```
[forever](/microbit/reference/basic/forever)
```block
basic.forever(() => {})
```
### ~
### ~column
### Logic
[if](/microbit/reference/logic/if)
```block
if(false) {
}
```
[Boolean](/microbit/reference/types/boolean) values: *true*; *false*
```block
true
false
```
Boolean binary operators: *and* (conjunction); *or* (disjunction)
```block
true && false;
true || false;
```
Boolean negation operator
```block
!true
```
Comparison operators (=, !=, <, >, <=, >=)
```block
0 == 0;
1 !- 0;
0 < 1;
1 > 0;
0 <= 1;
1 >= 0;
```
### Variables
[Assign](/microbit/reference/variables/assign) (set) a variable's value
```block
let x = 0;
```
Get a variable's value
```block
let x = 0;
x;
```
[Change](/microbit/reference/variables/change-var) a variable's value
```block
let x = 0;
x+=1;
```
### ~
### ~column
### Math
[Numeric](/microbit/reference/types/number) values: 0, 1, 2, ...
```block
0;
1;
2;
```
Arithmetic binary operation (+, -, *, /)
```block
0+1;
0-1;
1*2;
3/4;
```
Absolute value
```block
Math.abs(-5);
```
Minimum/maximum of two values
```block
Math.min(0, 1);
Math.max(0, 1);
```
Random value
```block
Math.random(5);
```
### Comments
[comment](/microbit/reference/comment)
### ~

39
docs/reference/logic.md Normal file
View File

@ -0,0 +1,39 @@
# Logic
[if](/microbit/reference/logic/if)
```blocks
if(true) {
}
```
[Boolean](/microbit/reference/types/boolean) values: *true*; *false*
```blocks
true
false
```
Boolean binary operators: *and* (conjunction); *or* (disjunction)
```blocks
true && false;
true || false;
```
Boolean negation operator
```blocks
!true
```
Comparison operators (=, !=, <, >, <=, >=)
```blocks
0 == 0;
1 !- 0;
0 < 1;
1 > 0;
0 <= 1;
1 >= 0;
```

26
docs/reference/loops.md Normal file
View File

@ -0,0 +1,26 @@
# Loops
Repeat code.
[for](/reference/loops/for)
```blocks
for(let i = 0;i<5;i++) {}
```
[repeat](/reference/loops/repeat)
![](/static/mb/blocks/contents-0.png)
[while](/reference/loops/while)
```blocks
while(true) {}
```
[forever](/reference/basic/forever)
```blocks
basic.forever(() => {})
```

37
docs/reference/math.md Normal file
View File

@ -0,0 +1,37 @@
# Math
[Numeric](/reference/types/number) values: 0, 1, 2, ...
```blocks
0;
1;
2;
```
Arithmetic binary operation (+, -, *, /)
```blocks
0+1;
0-1;
1*2;
3/4;
```
Absolute value
```blocks
Math.abs(-5);
```
Minimum/maximum of two values
```blocks
Math.min(0, 1);
Math.max(0, 1);
```
Random value
```blocks
Math.random(5);
```

View File

@ -0,0 +1,21 @@
## Variables
[Assign](/reference/variables/assign) (set) a variable's value
```blocks
let x = 0;
```
Get a variable's value
```blocks
let x = 0;
x;
```
[Change](/reference/variables/change-var) a variable's value
```blocks
let x = 0;
x+=1;
```