Start on the 'brick' api topics (#280)

* Start on the 'brick' api topics

* Add the delay to clear screen example

* Better output for clearsceen example
This commit is contained in:
Galen Nickel
2018-01-30 17:02:22 -08:00
committed by Peli de Halleux
parent e06659ab4c
commit 4f70d341e4
14 changed files with 222 additions and 9 deletions

View File

@ -29,11 +29,11 @@
"brick.buttonLeft": "Left button on the EV3 Brick.",
"brick.buttonRight": "Right button on the EV3 Brick.",
"brick.buttonUp": "Up button on the EV3 Brick.",
"brick.clearScreen": "Clears the screen",
"brick.printPorts": "Prints the port states on the screen",
"brick.clearScreen": "Clear the screen",
"brick.printPorts": "Print the port states on the screen",
"brick.setLight": "Set lights.",
"brick.setLight|param|pattern": "the lights pattern to use. eg: BrickLight.Orange",
"brick.showImage": "Shows an image on screen",
"brick.showImage": "Show an image on the screen",
"brick.showImage|param|image": "image to draw",
"brick.showNumber": "Shows a number on the screen",
"brick.showNumber|param|line": "the line number to print the text at, eg: 1",

View File

@ -72,6 +72,7 @@ namespace brick {
*/
//% blockId=screen_print block="show string %text|at line %line"
//% weight=98 group="Screen" inlineInputMode="inline" blockGap=8
//% help=brick/show-string
//% line.min=1 line.max=10
export function showString(text: string, line: number) {
const NUM_LINES = 9;
@ -87,6 +88,7 @@ namespace brick {
*/
//% blockId=screenShowNumber block="show number %name|at line %line"
//% weight=96 group="Screen" inlineInputMode="inline" blockGap=8
//% help=brick/show-number
//% line.min=1 line.max=10
export function showNumber(value: number, line: number) {
showString("" + value, line);
@ -99,6 +101,7 @@ namespace brick {
*/
//% blockId=screenShowValue block="show value %name|= %text|at line %line"
//% weight=96 group="Screen" inlineInputMode="inline" blockGap=8
//% help=brick/show-value
//% line.min=1 line.max=10
export function showValue(name: string, value: number, line: number) {
value = Math.round(value * 1000) / 1000;
@ -136,11 +139,12 @@ namespace brick {
}
/**
* Shows an image on screen
* Show an image on the screen
* @param image image to draw
*/
//% blockId=screen_show_image block="show image %image=screen_image_picker"
//% weight=100 group="Screen" blockGap=8
//% help=brick/show-image
export function showImage(image: Image) {
if (!image) return;
image.draw(0, 0, Draw.Normal);
@ -160,10 +164,11 @@ namespace brick {
}
/**
* Clears the screen
* Clear the screen
*/
//% blockId=screen_clear_screen block="clear screen"
//% weight=90 group="Screen"
//% help=brick/clear-screen
export function clearScreen() {
screen.clear();
}
@ -208,9 +213,10 @@ namespace brick {
}
/**
* Prints the port states on the screen
* Print the port states on the screen
*/
//% blockId=brickPrintPorts block="print ports"
//% help=brick/print-ports
//% weight=1 group="Screen"
export function printPorts() {
const col = 44;

View File

@ -1,7 +1,7 @@
{
"brick.Mood": "A mood",
"brick.Mood.show": "Shows the mood on the EV3",
"brick.showMood": "Shows a mood",
"brick.showMood": "Show a mood on the brick's screen",
"moods.angry": "An angry mood",
"moods.awake": "A awake mood",
"moods.dizzy": "A dizzy mood",

View File

@ -1,9 +1,10 @@
namespace brick {
/**
* Shows a mood
* Show a mood on the brick's screen
*/
//% weight=90
//% blockId=moodShow block="show mood %mood=mood_image_picker"
//% help=brick/show-mood
//% weight=101 group="Screen" blockGap=8
export function showMood(mood: Mood) {
if(mood)