Block layout fixes. Fixes to screen blocks. Adding print line API.
This commit is contained in:
@ -29,17 +29,12 @@
|
||||
"brick.clearScreen": "Clears the screen",
|
||||
"brick.lightPattern": "Pattern block.",
|
||||
"brick.lightPattern|param|pattern": "the lights pattern to use. eg: LightsPattern.Green",
|
||||
"brick.print": "Show text on the screen.",
|
||||
"brick.printLine": "Show text on the screen at a specific line.",
|
||||
"brick.printLine|param|line": "the line number to print the text at, eg: 0",
|
||||
"brick.printLine|param|text": "the text to print on the screen, eg: \"Hello world\"",
|
||||
"brick.printPorts": "Prints the port states on the screen",
|
||||
"brick.print|param|text": "the text to print on the screen, eg: \"Hello world\"",
|
||||
"brick.print|param|x": "the starting position's x coordinate, eg: 0",
|
||||
"brick.print|param|y": "the starting position's x coordinate, eg: 0",
|
||||
"brick.setLight": "Set lights.",
|
||||
"brick.setLight|param|pattern": "the lights pattern to use.",
|
||||
"brick.setPixel": "Sets a pixel on or off",
|
||||
"brick.setPixel|param|on": "a value indicating if the pixel should be on or off",
|
||||
"brick.setPixel|param|x": "the starting position's x coordinate, eg: 0",
|
||||
"brick.setPixel|param|y": "the starting position's x coordinate, eg: 0",
|
||||
"brick.showImage": "Shows an image on screen",
|
||||
"brick.showImage|param|image": "image to draw",
|
||||
"console": "Reading and writing data to the console output.\n\nReading and writing data to the console output.",
|
||||
|
@ -35,10 +35,9 @@
|
||||
"brick.buttonUp|block": "up",
|
||||
"brick.clearScreen|block": "clear screen",
|
||||
"brick.lightPattern|block": "%pattern",
|
||||
"brick.printLine|block": "print %text| at line: %line",
|
||||
"brick.printPorts|block": "print ports",
|
||||
"brick.print|block": "print %text| at x: %x| y: %y",
|
||||
"brick.setLight|block": "set light to %pattern=led_pattern",
|
||||
"brick.setPixel|block": "set pixel %on| at x: %x| y: %y",
|
||||
"brick.showImage|block": "show image %image=screen_image_picker",
|
||||
"brick|block": "brick",
|
||||
"console.logValue|block": "console|log value %name|= %value",
|
||||
|
@ -105,7 +105,7 @@ namespace brick {
|
||||
//% blockId=buttonWasPressed
|
||||
//% parts="brick"
|
||||
//% blockNamespace=brick
|
||||
//% weight=80 blockGap=8
|
||||
//% weight=80
|
||||
//% group="Buttons"
|
||||
wasPressed() {
|
||||
const r = this._wasPressed
|
||||
|
@ -80,15 +80,6 @@ namespace brick {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a pixel on or off
|
||||
* @param on a value indicating if the pixel should be on or off
|
||||
* @param x the starting position's x coordinate, eg: 0
|
||||
* @param y the starting position's x coordinate, eg: 0
|
||||
*/
|
||||
//% blockId=screen_setpixel block="set pixel %on| at x: %x| y: %y"
|
||||
//% weight=98 group="Screen"
|
||||
//% x.min=0 x.max=178 y.min=0 y.max=128 on.fieldEditor=toggleonoff
|
||||
export function setPixel(on: boolean, x: number, y: number) {
|
||||
x |= 0
|
||||
y |= 0
|
||||
@ -97,14 +88,20 @@ namespace brick {
|
||||
}
|
||||
|
||||
/**
|
||||
* Show text on the screen.
|
||||
* Show text on the screen at a specific line.
|
||||
* @param text the text to print on the screen, eg: "Hello world"
|
||||
* @param x the starting position's x coordinate, eg: 0
|
||||
* @param y the starting position's x coordinate, eg: 0
|
||||
* @param line the line number to print the text at, eg: 0
|
||||
*/
|
||||
//% blockId=screen_print block="print %text| at x: %x| y: %y"
|
||||
//% weight=99 group="Screen" inlineInputMode="inline" blockGap=8
|
||||
//% x.min=0 x.max=178 y.min=0 y.max=128
|
||||
//% blockId=screen_print block="print %text| at line: %line"
|
||||
//% weight=98 group="Screen" inlineInputMode="inline" blockGap=8
|
||||
//% line.min=0 line.max=9
|
||||
export function printLine(text: string, line: number) {
|
||||
const NUM_LINES = 9;
|
||||
const offset = 5;
|
||||
const y = offset + (Math.clamp(0, NUM_LINES, line) / (NUM_LINES + 2)) * DAL.LCD_HEIGHT;
|
||||
brick.print(text, offset, y);
|
||||
}
|
||||
|
||||
export function print(text: string, x: number, y: number, mode = Draw.Normal) {
|
||||
x |= 0
|
||||
y |= 0
|
||||
@ -140,7 +137,7 @@ namespace brick {
|
||||
* @param image image to draw
|
||||
*/
|
||||
//% blockId=screen_show_image block="show image %image=screen_image_picker"
|
||||
//% weight=95 group="Screen" blockGap=8
|
||||
//% weight=100 group="Screen" blockGap=8
|
||||
export function showImage(image: Image, delay: number = 400) {
|
||||
if (!image) return;
|
||||
image.draw(0, 0, Draw.Normal);
|
||||
@ -166,7 +163,7 @@ namespace brick {
|
||||
* Clears the screen
|
||||
*/
|
||||
//% blockId=screen_clear_screen block="clear screen"
|
||||
//% weight=94 group="Screen" blockGap=8
|
||||
//% weight=90 group="Screen"
|
||||
export function clearScreen() {
|
||||
screen.clear();
|
||||
}
|
||||
|
Reference in New Issue
Block a user