Document additional panic codes.

This commit is contained in:
ganicke
2017-08-30 16:53:58 -07:00
parent 01f665b268
commit c8c923eb20
3 changed files with 78 additions and 5 deletions

View File

@ -0,0 +1,29 @@
# assert
Stop the program if the assertion condition is false.
```sig
control.assert(false)
```
You can insist that your program will stop at an assert block if a certain condition you check is false. The error number in the assert is written to the serial port with a failure message.
## Parameters
* **cond**: a [boolean](/types/boolean) where true means everything is ok or false which means, stop the program!
* **msg**: an optional [string](/types/string) with a message describing the failed assertion.
## Example
Stop the program if a sensor connected to pin `P0` sends a low (`0`) signal.
```blocks
basic.forever(() => {
control.assert(pins.digitalReadPin(DigitalPin.P0) == 1)
basic.pause(1000)
})
```
## See also
[panic](/reference/control/panic)