Updates for V4 (#197)

* update yotta defaults for 16kb devices

* refactor deprecated blocks

* updates for button events

* update button events

* update refference

* update docs

* update docs

* update button event blocks

* update docs

* update block id
This commit is contained in:
Juri Wolf
2022-08-10 18:36:19 +02:00
committed by GitHub
parent 32783f38ba
commit 5f7a8e5301
107 changed files with 1218 additions and 706 deletions

View File

@ -1,4 +1,4 @@
# Forever
# forever
Keep running part of a program
[in the background](/reference/control/in-background).
@ -8,7 +8,20 @@ basic.forever(() => {
})
```
## Example: compass
You can have part of a program continuously by placing it in an **forever** loop. The **forever** loop will _yield_ to the other code in your program though, allowing that code to have time to run when needs to.
### ~ reminder
#### Event-based loops
Both the **forever** loop and the **every** loop are _event-based_ loops where the code inside is run as part of a function. These are different from the [for](/blocks/loops/for) and [while](/blocks/loops/while) loops. Those are loops are part of the programming language and can have [break](/blocks/loops/break) and [continue](/blocks/loops/continue) statements in them.
You can NOT use **break** or **continue** in either a **forever** loop or an **every** loop.
### ~
## Examples
### Example: compass
The following example constantly checks the
[compass heading](/reference/input/compass-heading)
@ -32,7 +45,7 @@ basic.forever(() => {
})
```
## Example: counter
### Example: counter
The following example keeps showing the [number](/types/number) stored in a global variable.
When you press button `A`, the number gets bigger.
@ -43,7 +56,7 @@ let num = 0
basic.forever(() => {
basic.showNumber(num)
})
input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
input.onButtonEvent(Button.A, input.buttonEventClick(), () => {
num = num + 1
})
```
@ -59,12 +72,12 @@ Try this on your @boardname@:
basic.forever(() => {
basic.showNumber(6789)
})
input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
input.onButtonEvent(Button.A, input.buttonEventClick(), () => {
basic.showNumber(2)
})
```
## See also
[while](/blocks/loops/while), [on button pressed](/reference/input/on-button-pressed), [in background](/reference/control/in-background)
[while](/blocks/loops/while), [in background](/reference/control/in-background), [every](/reference/loops/every-interval)

View File

@ -24,6 +24,10 @@ for (let i = 0; i < 5; i++) {
}
```
## Advanced
If `ms` is `NaN` (not a number), it will default to `20` ms.
## See also
[while](/blocks/loops/while), [running time](/reference/input/running-time), [for](/blocks/loops/for)

View File

@ -1,34 +0,0 @@
# Plot LEDs
Display an [Image](/reference/images/image) on the @boardname@'s [LED screen](/device/screen).
```sig
basic.showLeds(`
. . . . .
. # . # .
. . # . .
# . . . #
. # # # .
`)
```
## Parameters
* leds - a series of LED on/off states that form an image (see steps below)
## Example: smiley
```blocks
basic.showLeds(`
. . . . .
. # . # .
. . # . .
# . . . #
. # # # .
`)
```
## See also
[show animation](/reference/basic/show-animation), [image](/reference/images/image), [show image](/reference/images/show-image), [scroll image](/reference/images/scroll-image)

View File

@ -0,0 +1 @@
# RGB

View File

@ -0,0 +1 @@
# Set LED Color

View File

@ -1,64 +0,0 @@
# show Animation
Show a group of image frames (pictures) one after another on the [LED screen](/device/screen). It pauses the amount of time you tell it after each frame.
```sig
basic.showAnimation(`
. . # . . . # # # . . # # # .
. # # . . . . . # . . . . # .
. . # . . . . # . . . # # # .
. . # . . . # . . . . . . # .
. . # . . . # # # . . # # # .
`)
```
## Parameters
* `leds` is a [string](/types/string) that shows which LEDs are on and off, in groups one after another.
* `interval` is an optional [number](/types/number). It means the number of milliseconds to pause after each image frame.
## Example: Animating a group of image frames
In this animation, each row is 15 spaces wide because
there are three frames in the animation, and each frame is
five spaces wide, just like the screen on the @boardname@.
```blocks
basic.showAnimation(`
. . # . . . # # # . . # # # .
. # # . . . . . # . . . . # .
. . # . . . . # . . . # # # .
. . # . . . # . . . . . . # .
. . # . . . # # # . . # # # .
`)
```
## ~hint
If the animation is too fast, make `interval` bigger.
## ~
## Example: animating frames with a pause
This example shows six frames on the screen, pausing 500 milliseconds after each frame.
In this animation, each row is 30 spaces wide because
there are six frames in the animation, and each frame is
five spaces wide, just like the screen.
```blocks
basic.showAnimation(`
. . . . . # . . . . . . . . . . . . . # . . . . . # . . . .
. . # . . . . . . . . . # . . . . . . . . . # . . . . . . .
. # . # . . . # . . . # . # . . . # . . . # . # . . . # . .
. . # . . . . . . . . . # . . . . . . . . . # . . . . . . .
. . . . . . . . . # . . . . . # . . . . . . . . . . . . . #
`, 500)
```
## ~hint
Use [forever](/reference/basic/forever) to show an animation over and over.
## ~

View File

@ -0,0 +1 @@
# Show Compass

View File

@ -8,7 +8,7 @@ basic.showNumber(2)
## Parameters
* `value` is a [Number](/types/number).
* `value` is a [Number](/types/number). If the number is not single-digit number, it will scroll on the display.
* `interval` is an optional [Number](/types/number). It means the number of milliseconds before sliding the `value` left by one LED each time. Bigger intervals make the sliding slower.
## Examples:
@ -37,6 +37,10 @@ for (let i = 0; i < 6; i++) {
}
```
## Advanced
If `value` is `NaN` (not a number), `?` is displayed.
## Other show functions
* Use [show string](/reference/basic/show-string) to show a [String](/types/string) with letters on the screen.

View File

@ -0,0 +1 @@
# Turn RGB Led Off