From aa0476c1da35a95a54ed52b9adb918c9813187a0 Mon Sep 17 00:00:00 2001 From: Nicole Parrot Date: Sun, 1 Dec 2019 23:15:02 -0500 Subject: [PATCH] Docs: Change default value in Javascript. (#2540) * Change default value in Javascript. Per @microbit-mark 's suggestion, add an example of how to change the default interval value by switching to Javascript. * edits to new example --- docs/reference/basic/show-icon.md | 36 +++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/docs/reference/basic/show-icon.md b/docs/reference/basic/show-icon.md index d76264b2..d3b7451d 100644 --- a/docs/reference/basic/show-icon.md +++ b/docs/reference/basic/show-icon.md @@ -9,7 +9,7 @@ basic.showIcon(IconNames.Heart) ## Parameters * ``icon``, the identifier of the icon to display -* ``interval`` (optional), the time to display in milliseconds. default is 400. +* ``interval`` (optional), the time to display in milliseconds. default is 600. ## Example @@ -21,6 +21,38 @@ basic.pause(1000) basic.showIcon(IconNames.Sad) ``` +## Beating Heart + +You can create a beating heart by using the forever block as follows: + +```blocks +basic.forever(function () { + basic.showIcon(IconNames.Heart) + basic.showIcon(IconNames.SmallHeart) +}) +``` + +## Fast Beating Heart + +You could slow down the previous animation by inserting a pause block: + +```block +basic.pause(1000) +``` + +...but how would you speed it up? + +You can change the default pause value, which is set in the ``interval`` parameter, to be smaller than `600` by changing it in the JavaScript editor. + +This JavaScript code creates a crazy fast heart beat! Did you know that a hamster's heart beats at a rate this fast? + +```typescript +basic.forever(function () { + basic.showIcon(IconNames.Heart, 60) + basic.showIcon(IconNames.SmallHeart, 60) +}) +``` + ## See also -[showLeds](/reference/basic/show-leds) \ No newline at end of file +[showLeds](/reference/basic/show-leds)