diff --git a/libs/core/_locales/core-jsdoc-strings.json b/libs/core/_locales/core-jsdoc-strings.json index 043f085c..1f6d96c3 100644 --- a/libs/core/_locales/core-jsdoc-strings.json +++ b/libs/core/_locales/core-jsdoc-strings.json @@ -68,6 +68,10 @@ "screen.print|param|text": "the text to print on the screen, eg: \"Hello world\"", "screen.print|param|x": "the starting position's x coordinate, eg: 0", "screen.print|param|y": "the starting position's x coordinate, eg: 0", + "screen.setPixel": "Sets a pixel on or off", + "screen.setPixel|param|on": "a value indicating if the pixel should be on or off", + "screen.setPixel|param|x": "the starting position's x coordinate, eg: 0", + "screen.setPixel|param|y": "the starting position's x coordinate, eg: 0", "serial": "Reading and writing data over a serial connection.", "serial.writeDmesg": "Send DMESG debug buffer over serial." } \ No newline at end of file diff --git a/libs/core/_locales/core-strings.json b/libs/core/_locales/core-strings.json index 1db2554e..7bb52492 100644 --- a/libs/core/_locales/core-strings.json +++ b/libs/core/_locales/core-strings.json @@ -75,6 +75,7 @@ "output.setStatusLight|block": "set status light %pattern=led_pattern", "output|block": "output", "screen.print|block": "print %text| at x: %x| y: %y", + "screen.setPixel|block": "set pixel %on| at x: %x| y: %y", "screen|block": "screen", "serial|block": "serial", "{id:category}Control": "Control", diff --git a/libs/core/screen.ts b/libs/core/screen.ts index 30b6b411..bf85567f 100644 --- a/libs/core/screen.ts +++ b/libs/core/screen.ts @@ -78,13 +78,21 @@ namespace screen { } } - export function setPixel(x: number, y: number, mode = Draw.Normal) { + /** + * 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="Brick" blockNamespace=output + //% 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 if (0 <= x && x < DAL.LCD_WIDTH && 0 <= y && y < DAL.LCD_HEIGHT) - _setPixel(x, y, mode) + _setPixel(x, y, on ? Draw.Normal : Draw.Clear) } - /** * Show text on the screen.