From fa37f1fac042849fcee43c6921af4a776a96f446 Mon Sep 17 00:00:00 2001 From: Galen Nickel Date: Mon, 24 Jul 2017 13:40:36 -0700 Subject: [PATCH] Batch of fixes from the Lancaster doc review (#451) * Local commit. * local commit * Doc fixes from Lancaster review. * I don't want to change these yet. * Trailing newlines, arrr. * Get the 'Game' cards setup. * Take block support off of 'show animation'. * Add 'see also' for showArrow(). --- docs/SUMMARY.md | 1 - docs/blocks/loops.md | 4 --- docs/reference/basic.md | 13 ++----- docs/reference/basic/show-animation.md | 6 ++-- docs/reference/game.md | 36 ++++++++++++++++--- docs/reference/game/change-sprite-property.md | 4 +-- docs/reference/input.md | 17 +-------- docs/reference/led/enable.md | 2 +- docs/reference/led/set-display-mode.md | 22 ++++++++++-- docs/reference/serial.md | 7 ++-- libs/core/serial.cpp | 4 ++- 11 files changed, 69 insertions(+), 47 deletions(-) diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md index 3f77295e..73e295fa 100644 --- a/docs/SUMMARY.md +++ b/docs/SUMMARY.md @@ -137,7 +137,6 @@ * [clear screen](/reference/basic/clear-screen) * [forever](/reference/basic/forever) * [pause](/reference/basic/pause) - * [plot leds](/reference/basic/plot-leds) * [show arrow](/reference/basic/show-arrow) * [show animation](/reference/basic/show-animation) * [Input](/reference/input) diff --git a/docs/blocks/loops.md b/docs/blocks/loops.md index 9db85e53..e7d35ee3 100644 --- a/docs/blocks/loops.md +++ b/docs/blocks/loops.md @@ -1,7 +1,3 @@ # @extends ### #specific - -``` -basic.forever(() => {}); -``` diff --git a/docs/reference/basic.md b/docs/reference/basic.md index 9a07cf29..30c5faa3 100644 --- a/docs/reference/basic.md +++ b/docs/reference/basic.md @@ -1,6 +1,6 @@ # Basic -Provides access to basic @boardname@ functionality. +Use basic @boardname@ functions and actions. ```cards basic.showNumber(0); @@ -18,13 +18,6 @@ basic.forever(() => { }); basic.pause(100); -basic.plotLeds(` -. . . . . -. . . . . -. . # . . -. . . . . -. . . . . -`); basic.showArrow(ArrowNames.North); basic.showAnimation(` . . . . . @@ -35,10 +28,10 @@ basic.showAnimation(` `); ``` -### See Also +### See also [showNumber](/reference/basic/show-number), [showIcon](/reference/basic/show-icon), [showLeds](/reference/basic/show-leds), [showString](/reference/basic/show-string), [clearScreen](/reference/basic/clear-screen), [forever](/reference/basic/forever), [pause](/reference/basic/pause), -[showAnimation](/reference/basic/show-animation) +[showArrow](/reference/basic/show-arrow), [showAnimation](/reference/basic/show-animation) diff --git a/docs/reference/basic/show-animation.md b/docs/reference/basic/show-animation.md index 0d0e74a4..1ea9aade 100644 --- a/docs/reference/basic/show-animation.md +++ b/docs/reference/basic/show-animation.md @@ -1,4 +1,4 @@ -# Show Animation +# 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. @@ -14,8 +14,8 @@ 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. +* `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 diff --git a/docs/reference/game.md b/docs/reference/game.md index 89f1f7ae..2d44bf4a 100644 --- a/docs/reference/game.md +++ b/docs/reference/game.md @@ -1,15 +1,41 @@ # Game -A single-LED sprite game engine +Make games with sprites. Keep score and control gameplay. + +## Sprites + +```cards +game.createSprite(0,0); +game.createSprite(0,0).delete(); +game.createSprite(0,0).move(0); +game.createSprite(0,0).turn(Direction.Left,0); +game.createSprite(0,0).ifOnEdgeBounce(); +game.createSprite(0,0).get(LedSpriteProperty.X); +game.createSprite(0,0).set(LedSpriteProperty.X, 0); +game.createSprite(0,0).change(LedSpriteProperty.X, 0); +game.createSprite(0,0).isTouching(null); +game.createSprite(0,0).isTouchingEdge(); +``` + +## Scoring ```cards game.addScore(1); game.score(); -game.startCountdown(10000); -game.gameOver(); game.setScore(0); ``` -### See Also +## Game control -[addScore](/reference/game/change-score-by), [score](/reference/game/score), [startCountdown](/reference/game/start-countdown), [gameOver](/reference/game/game-over), [setScore](/reference/game/set-score) +```cards +game.startCountdown(10000); +game.gameOver(); +``` + +### See also + +[createSprite](/reference/game/create-sprite), [move](/reference/game/move), [turn](/reference/game/turn), +[ifOnEdgeBounce](/reference/game/if-on-edge-bounce), [get](/reference/game/get), [set](/reference/game/set), +[change](/reference/game/change), [isTouching](/reference/game/touching) [isTouchingEdge](/reference/game/touching-edge), +[addScore](/reference/game/change-score-by), [score](/reference/game/score), [setScore](/reference/game/set-score), +[startCountdown](/reference/game/start-countdown), [gameOver](/reference/game/game-over) diff --git a/docs/reference/game/change-sprite-property.md b/docs/reference/game/change-sprite-property.md index 31a39506..9a1c9ab3 100644 --- a/docs/reference/game/change-sprite-property.md +++ b/docs/reference/game/change-sprite-property.md @@ -1,10 +1,10 @@ -# Get Sprite Property +# change Sprite Property Change the kind of [number](/types/number) you say for a [sprite](/reference/game/create-sprite). ```sig let item: game.LedSprite = null; -item.set(LedSpriteProperty.X, 0); +item.change(LedSpriteProperty.X, 0); ``` ### Parameters diff --git a/docs/reference/input.md b/docs/reference/input.md index 1481cb10..d4246522 100644 --- a/docs/reference/input.md +++ b/docs/reference/input.md @@ -22,23 +22,8 @@ input.rotation(Rotation.Pitch); input.magneticForce(Dimension.X); input.runningTime(); input.setAccelerometerRange(AcceleratorRange.OneG); -input.onLogoDown(() => { - -}); -input.onLogoUp(() => { - -}); -input.onScreenDown(() => { - -}); -input.onScreenUp(() => { - -}); -input.onShake(() => { - -}); ``` -### See Also +### See also [onButtonPressed](/reference/input/on-button-pressed), [onGesture](/reference/input/on-gesture), [onPinPressed](/reference/input/on-pin-pressed), [buttonIsPressed](/reference/input/button-is-pressed), [compassHeading](/reference/input/compass-heading), [pinIsPressed](/reference/input/pin-is-pressed), [temperature](/reference/input/temperature), [acceleration](/reference/input/acceleration), [lightLevel](/reference/input/light-level), [rotation](/reference/input/rotation), [magneticForce](/reference/input/magnetic-force), [runningTime](/reference/input/running-time), [setAccelerometerRange](/reference/input/set-accelerometer-range), [calibrate-compass](/reference/input/calibrate-compass) diff --git a/docs/reference/led/enable.md b/docs/reference/led/enable.md index 4da69fc8..2845fdac 100644 --- a/docs/reference/led/enable.md +++ b/docs/reference/led/enable.md @@ -14,7 +14,7 @@ led.enable(false); This program turns off the screen when pressing button ``B`` -```typescript +```blocks input.onButtonPressed(Button.B, () => { led.enable(false) }); diff --git a/docs/reference/led/set-display-mode.md b/docs/reference/led/set-display-mode.md index 36ec168f..b934e29f 100644 --- a/docs/reference/led/set-display-mode.md +++ b/docs/reference/led/set-display-mode.md @@ -1,8 +1,26 @@ -# Set Display Mode +# set Display Mode -Sets the display mode between black and white and greyscale for rendering [LEDs](/device/screen). +Set the display mode to either black and white or greyscale for rendering [LEDs](/device/screen). ```sig led.setDisplayMode(DisplayMode.Greyscale) ``` +The LED screen can create a sense of color depth with the display mode setting. Color depth is the difference in darkness between the pixels in the display. The `greyscale` mode makes the pixels appear +to have some amount of brightness to represent the grey value of real color. The `black and white` mode just shows an image on the pixels with the LEDs either on or off. + +## Parameters + +* ``mode`` the display mode type. This is either `BlackAndWhite` or `GreyScale`. + +## Example + +Set the display mode to `black and white`. + +```blocks +led.setDisplayMode(DisplayMode.BackAndWhite) +``` + +## See also + +[set brightness](/reference/led/set-brightness) \ No newline at end of file diff --git a/docs/reference/serial.md b/docs/reference/serial.md index f261cdd3..4f6fc6b4 100644 --- a/docs/reference/serial.md +++ b/docs/reference/serial.md @@ -1,6 +1,6 @@ # Serial -Reading and writing data over a serial connection. +Read and write data over a serial connection. ```cards serial.writeLine(""); @@ -23,4 +23,7 @@ serial.readBuffer(64); ### See Also -[writeLine](/reference/serial/write-line), [writeNumber](/reference/serial/write-number), [writeValue](/reference/serial/write-value), [writeString](/reference/serial/write-string), [readLine](/reference/serial/read-line), [redirect](/reference/serial/redirect-to) +[writeLine](/reference/serial/write-line), [writeNumber](/reference/serial/write-number), [writeValue](/reference/serial/write-value), +[writeString](/reference/serial/write-string), [readUntil](/reference/serial/read-until), [readLine](/reference/serial/read-line), +[readString](/reference/serial/read-string), [onDataReceived](/reference/serial/on-data-received), +[redirect](/reference/serial/redirect-to), [writeBuffer](/reference/serial/write-buffer), [readBuffer](/reference/serial/read-buffer) diff --git a/libs/core/serial.cpp b/libs/core/serial.cpp index 76f0a3b3..1b25242f 100644 --- a/libs/core/serial.cpp +++ b/libs/core/serial.cpp @@ -111,6 +111,7 @@ namespace serial { /** * Sends a buffer through Serial connection */ + //% blockId=serial_writebuffer block="serial|write buffer %buffer" //% help=serial/write-buffer advanced=true weight=6 void writeBuffer(Buffer buffer) { if (!buffer) return; @@ -120,9 +121,10 @@ namespace serial { } /** - * Reads multiple characters from the rxBuff and fills a user buffer. + * Reads multiple characters from the receive buffer and fills a user buffer. * @param length default buffer length, eg: 64 */ + //% blockId=serial_readbuffer block="serial|read buffer %length" //% help=serial/read-buffer advanced=true weight=5 Buffer readBuffer(int length) { if (length <= 0)