diff --git a/libs/core/_locales/core-jsdoc-strings.json b/libs/core/_locales/core-jsdoc-strings.json index 8168f5ff..9a42e63d 100644 --- a/libs/core/_locales/core-jsdoc-strings.json +++ b/libs/core/_locales/core-jsdoc-strings.json @@ -41,6 +41,10 @@ "screen.clear": "Clear screen and reset font to normal.", "screen.doubleIcon": "Double size of an icon.", "screen.drawIcon": "Draw an icon on the screen.", + "screen.drawText": "Show text on the screen.", + "screen.drawText|param|text": "the text to print on the screen, eg: \"Hello world\"", + "screen.drawText|param|x": "the starting position's x coordinate, eg: 0", + "screen.drawText|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 ef85312e..83193a67 100644 --- a/libs/core/_locales/core-strings.json +++ b/libs/core/_locales/core-strings.json @@ -24,6 +24,7 @@ "output.stop|block": "turn motor %out| off", "output.turn|block": "turn motor %out| on for %ms| milliseconds", "output|block": "output", + "screen.drawText|block": "say %text| at x: %x| y: %y", "screen|block": "screen", "serial|block": "serial", "{id:category}Control": "Control", @@ -32,5 +33,6 @@ "{id:category}Screen": "Screen", "{id:category}Serial": "Serial", "{id:group}Lights": "Lights", - "{id:group}Motors": "Motors" + "{id:group}Motors": "Motors", + "{id:group}Screen": "Screen" } \ No newline at end of file diff --git a/libs/core/screen.ts b/libs/core/screen.ts index 4974c811..24fe10ca 100644 --- a/libs/core/screen.ts +++ b/libs/core/screen.ts @@ -84,8 +84,17 @@ namespace screen { if (0 <= x && x < DAL.LCD_WIDTH && 0 <= y && y < DAL.LCD_HEIGHT) _setPixel(x, y, mode) } + - export function drawText(x: number, y: number, text: string, mode = Draw.Normal) { + /** + * Show text on the screen. + * @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 + */ + //% blockId=screen_drawText block="say %text| at x: %x| y: %y" + //% weight=99 group="Screen" blockNamespace=output inlineInputMode="inline" + export function drawText(text: string, x: number, y: number, mode = Draw.Normal) { x |= 0 y |= 0 if (!currFont) currFont = defaultFont() diff --git a/libs/ev3/ns.ts b/libs/ev3/ns.ts index 7f3ce52c..a2adb82d 100644 --- a/libs/ev3/ns.ts +++ b/libs/ev3/ns.ts @@ -1,10 +1,11 @@ //% color="#D42878" +//% groups="['Brick buttons']" namespace input { } //% color="#8AC044" weight=90 icon="\uf185" -//% groups="['Lights', 'Motors']" +//% groups="['Lights', 'Screen', Motors']" namespace output { }