various docs updates
This commit is contained in:
		@@ -9,8 +9,9 @@ basic.showNumber(0);
 | 
			
		||||
input.onButtonPressed(Button.A, () => {
 | 
			
		||||
    
 | 
			
		||||
});
 | 
			
		||||
led.plot(0, 0);
 | 
			
		||||
music.playTone(0, 0);
 | 
			
		||||
led.plot(0, 0);
 | 
			
		||||
radio.sendNumber(0);
 | 
			
		||||
game.addScore(1);
 | 
			
		||||
images.createImage(`
 | 
			
		||||
. . . . .
 | 
			
		||||
 
 | 
			
		||||
@@ -1,39 +1,9 @@
 | 
			
		||||
# Logic
 | 
			
		||||
 | 
			
		||||
[if](/reference/logic/if)
 | 
			
		||||
 | 
			
		||||
```blocks
 | 
			
		||||
if(true) {
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
[Boolean](/reference/types/boolean) values: *true*; *false*
 | 
			
		||||
 | 
			
		||||
```blocks
 | 
			
		||||
true
 | 
			
		||||
false
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
Boolean binary operators: *and* (conjunction); *or* (disjunction)
 | 
			
		||||
 | 
			
		||||
```blocks
 | 
			
		||||
```cards
 | 
			
		||||
if(true) {}
 | 
			
		||||
true;
 | 
			
		||||
true && false;
 | 
			
		||||
true || false;
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
Boolean negation operator
 | 
			
		||||
 | 
			
		||||
```blocks
 | 
			
		||||
!true
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
Comparison operators (=, !=, <, >, <=, >=)
 | 
			
		||||
 | 
			
		||||
```blocks
 | 
			
		||||
0 == 0;
 | 
			
		||||
1 !- 0;
 | 
			
		||||
0 < 1;
 | 
			
		||||
1 > 0;
 | 
			
		||||
0 <= 1;
 | 
			
		||||
1 >= 0;
 | 
			
		||||
!true;
 | 
			
		||||
1 != 0;
 | 
			
		||||
```
 | 
			
		||||
 
 | 
			
		||||
@@ -1,23 +1,26 @@
 | 
			
		||||
# If
 | 
			
		||||
 | 
			
		||||
Run code based on a condition.
 | 
			
		||||
 | 
			
		||||
### @parent blocks/language
 | 
			
		||||
 
 | 
			
		||||
 | 
			
		||||
Conditionally run code depending on whether a [Boolean](/reference/types/boolean) condition is true or false.
 | 
			
		||||
 | 
			
		||||
### Block Editor
 | 
			
		||||
 | 
			
		||||

 | 
			
		||||
```blocks
 | 
			
		||||
if(true) {
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
In the Block Editor, click on the dark blue gear icon (see above) to add an *else* or *if* to the current block.
 | 
			
		||||
 | 
			
		||||
### Example: adjusting screen brightness
 | 
			
		||||
 | 
			
		||||

 | 
			
		||||
```blocks
 | 
			
		||||
if(input.lightLevel()<100){
 | 
			
		||||
    led.setBrightness(255);
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
If the screen [brightness](/reference/led/brightness) is `< 100`, this code sets the brightness to `255`:
 | 
			
		||||
If the [light level](/input/light-level) is `< 100`, this code sets the brightness to `255`:
 | 
			
		||||
 | 
			
		||||
### Lessons
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,26 +1,8 @@
 | 
			
		||||
# Loops
 | 
			
		||||
 | 
			
		||||
Repeat code.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
[for](/reference/loops/for)
 | 
			
		||||
 | 
			
		||||
```blocks
 | 
			
		||||
```cards
 | 
			
		||||
for(let i = 0;i<5;i++) {}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
[repeat](/reference/loops/repeat)
 | 
			
		||||
 | 
			
		||||

 | 
			
		||||
 | 
			
		||||
[while](/reference/loops/while)
 | 
			
		||||
 | 
			
		||||
```blocks
 | 
			
		||||
for(let i = 1;i<5;i++) {}
 | 
			
		||||
while(true) {}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
[forever](/reference/basic/forever)
 | 
			
		||||
 | 
			
		||||
```blocks
 | 
			
		||||
basic.forever(() => {})
 | 
			
		||||
```
 | 
			
		||||
 
 | 
			
		||||
@@ -1,15 +1,13 @@
 | 
			
		||||
# For
 | 
			
		||||
 | 
			
		||||
Repeat code a preset number of times.
 | 
			
		||||
 | 
			
		||||
### @parent blocks/language
 | 
			
		||||
 
 | 
			
		||||
 | 
			
		||||
Repeat code a fixed number of times.
 | 
			
		||||
 | 
			
		||||
### Block Editor
 | 
			
		||||
 | 
			
		||||

 | 
			
		||||
```blocks
 | 
			
		||||
for(let i = 0; i < 5; ++i) {
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
The Block Editor *for* loop is different than the Touch Develop *for* loop in an important way. The above for loop will iterate *five* times, with the loop variable *i* taking on values 0, 1, 2, 3, and 4. The Touch Develop for loop shown below will iterate four times:
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -2,8 +2,6 @@
 | 
			
		||||
 | 
			
		||||
Repeat code a preset number of times.
 | 
			
		||||
 | 
			
		||||
Repeat code a fixed number of times.
 | 
			
		||||
 | 
			
		||||
### Block Editor
 | 
			
		||||
 | 
			
		||||

 | 
			
		||||
 
 | 
			
		||||
@@ -1,23 +1,14 @@
 | 
			
		||||
# While
 | 
			
		||||
 | 
			
		||||
Repeat code in a loop while a condition is true.
 | 
			
		||||
 | 
			
		||||
### @parent blocks/language
 | 
			
		||||
 
 | 
			
		||||
 | 
			
		||||
Repeat code while a [Boolean](/reference/types/boolean) `condition` is true.
 | 
			
		||||
 | 
			
		||||
### ~hide
 | 
			
		||||
 | 
			
		||||
```blocks
 | 
			
		||||
while(true) {
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
let condition = false
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### ~
 | 
			
		||||
 | 
			
		||||
### Block Editor
 | 
			
		||||
 | 
			
		||||

 | 
			
		||||
 | 
			
		||||
The while loop has a *condition* that evaluates to a [Boolean](/reference/types/boolean) value. After the `do` keyword, add the code that you want to run while the `condition` is `true`. The while loop concludes with `end while`.
 | 
			
		||||
 | 
			
		||||
@@ -27,11 +18,13 @@ The condition is tested before any code runs. Which means that if the condition
 | 
			
		||||
 | 
			
		||||
The following example uses a while loop to make a diagonal line on the LED screen (points `0, 0`, `1, 1`, `2, 2`, `3, 3`, `4, 4`).
 | 
			
		||||
 | 
			
		||||
// index is set to 4
 | 
			
		||||
 | 
			
		||||

 | 
			
		||||
 | 
			
		||||
// subtract 1 from `index` each time through loop
 | 
			
		||||
```blocks
 | 
			
		||||
let index = 4;
 | 
			
		||||
while(index >= 0) {
 | 
			
		||||
    led.plot(index, index);
 | 
			
		||||
    index--;
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### Lessons
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -16,5 +16,5 @@ radio.receivedSignalStrength();
 | 
			
		||||
radio.setGroup(0);
 | 
			
		||||
radio.setTransmitPower(0);
 | 
			
		||||
radio.writeValueToSerial();
 | 
			
		||||
radio.setTransmitSerialNumber(◊);
 | 
			
		||||
radio.setTransmitSerialNumber(true);
 | 
			
		||||
```
 | 
			
		||||
 
 | 
			
		||||
@@ -3,6 +3,9 @@
 | 
			
		||||
Reading and writing data over a serial connection.
 | 
			
		||||
 | 
			
		||||
```cards
 | 
			
		||||
serial.writeValue(x, 0);
 | 
			
		||||
serial.writeLine("");
 | 
			
		||||
serial.writeNumber(0);
 | 
			
		||||
serial.writeValue(x, 0);
 | 
			
		||||
serial.writeString("");
 | 
			
		||||
serial.readLine();
 | 
			
		||||
```
 | 
			
		||||
 
 | 
			
		||||
@@ -93,6 +93,9 @@
 | 
			
		||||
  "radio.setTransmitSerialNumber": "Set the radio to transmit the serial number in each message.",
 | 
			
		||||
  "radio.writeValueToSerial": "Reads a value sent with `stream value` and writes it\nto the serial stream as JSON",
 | 
			
		||||
  "serial": "Reading and writing data over a serial connection.",
 | 
			
		||||
  "serial.readLine": "Reads a line of text from the serial port.",
 | 
			
		||||
  "serial.writeLine": "Prints a line of text to the serial",
 | 
			
		||||
  "serial.writeNumber": "Prints a numeric value to the serial",
 | 
			
		||||
  "serial.writeString": "Sends a piece of text through Serial connection.",
 | 
			
		||||
  "serial.writeValue": "Writes a ``name: value`` pair line to the serial."
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user