From d548dfb578ff9eea42c3d8f04994bba93cef7422 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Wed, 31 Jan 2018 08:44:58 -0800 Subject: [PATCH] moving print ports to examples (#288) --- docs/examples/print-ports.md | 40 ++++++++++++++++++++++ docs/reference/brick.md | 1 - docs/reference/brick/print-ports.md | 19 ---------- libs/core/_locales/core-jsdoc-strings.json | 1 - libs/core/_locales/core-strings.json | 1 - libs/core/screen.ts | 36 ------------------- 6 files changed, 40 insertions(+), 58 deletions(-) create mode 100644 docs/examples/print-ports.md delete mode 100644 docs/reference/brick/print-ports.md diff --git a/docs/examples/print-ports.md b/docs/examples/print-ports.md new file mode 100644 index 00000000..1fe59641 --- /dev/null +++ b/docs/examples/print-ports.md @@ -0,0 +1,40 @@ + +# Print Ports + +```typescript +/** + * Print the port states on the screen + */ +//% blockId=brickPrintPorts block="print ports" +//% help=brick/print-ports +//% weight=1 group="Screen" +function printPorts() { + const col = 44; + clearScreen(); + + function scale(x: number) { + if (Math.abs(x) > 1000) return Math.round(x / 100) / 10 + "k"; + return ("" + (x >> 0)); + } + + // motors + const datas = motors.getAllMotorData(); + for(let i = 0; i < datas.length; ++i) { + const data = datas[i]; + if (!data.actualSpeed && !data.count) continue; + const x = i * col; + print(`${scale(data.actualSpeed)}%`, x, brick.LINE_HEIGHT) + print(`${scale(data.count)}>`, x, 2 * brick.LINE_HEIGHT) + print(`${scale(data.tachoCount)}|`, x, 3 * brick.LINE_HEIGHT) + } + + // sensors + const sis = sensors.internal.getActiveSensors(); + for(let i =0; i < sis.length; ++i) { + const si = sis[i]; + const x = (si.port() - 1) * col; + const v = si._query(); + print(`${scale(v)}`, x, 9 * brick.LINE_HEIGHT) + } +} +``` \ No newline at end of file diff --git a/docs/reference/brick.md b/docs/reference/brick.md index aab6ec1b..9a1ae91c 100644 --- a/docs/reference/brick.md +++ b/docs/reference/brick.md @@ -9,7 +9,6 @@ brick.showString("Hello world!", 1); brick.showNumber(0, 1); brick.showValue("item", 0, 1); brick.clearScreen(); -brick.printPorts(); ``` ## Buttons diff --git a/docs/reference/brick/print-ports.md b/docs/reference/brick/print-ports.md deleted file mode 100644 index 697900b6..00000000 --- a/docs/reference/brick/print-ports.md +++ /dev/null @@ -1,19 +0,0 @@ -# print Ports - -Print the status of the ports on the screen. - -```sig -brick.printPorts(); -``` - -## Example - -Show the port status. - -```blocks -brick.printPorts(); -``` - -## See also - -[show string](/reference/brick/show-string), [show value](/reference/brick/show-value) \ No newline at end of file diff --git a/libs/core/_locales/core-jsdoc-strings.json b/libs/core/_locales/core-jsdoc-strings.json index e96cc3df..5348a250 100644 --- a/libs/core/_locales/core-jsdoc-strings.json +++ b/libs/core/_locales/core-jsdoc-strings.json @@ -30,7 +30,6 @@ "brick.buttonRight": "Right button on the EV3 Brick.", "brick.buttonUp": "Up button on the EV3 Brick.", "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": "Show an image on the screen", diff --git a/libs/core/_locales/core-strings.json b/libs/core/_locales/core-strings.json index dd5759db..46445563 100644 --- a/libs/core/_locales/core-strings.json +++ b/libs/core/_locales/core-strings.json @@ -36,7 +36,6 @@ "brick.buttonRight|block": "button right", "brick.buttonUp|block": "button up", "brick.clearScreen|block": "clear screen", - "brick.printPorts|block": "print ports", "brick.setLight|block": "set light to %pattern", "brick.showImage|block": "show image %image=screen_image_picker", "brick.showNumber|block": "show number %name|at line %line", diff --git a/libs/core/screen.ts b/libs/core/screen.ts index 0ad64046..d257ff8a 100644 --- a/libs/core/screen.ts +++ b/libs/core/screen.ts @@ -211,40 +211,4 @@ namespace brick { if (y < y1) setLineCore(x, x1, y, mode); } - - /** - * 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; - clearScreen(); - - function scale(x: number) { - if (Math.abs(x) > 1000) return Math.round(x / 100) / 10 + "k"; - return ("" + (x >> 0)); - } - - // motors - const datas = motors.getAllMotorData(); - for(let i = 0; i < datas.length; ++i) { - const data = datas[i]; - if (!data.actualSpeed && !data.count) continue; - const x = i * col; - print(`${scale(data.actualSpeed)}%`, x, brick.LINE_HEIGHT) - print(`${scale(data.count)}>`, x, 2 * brick.LINE_HEIGHT) - print(`${scale(data.tachoCount)}|`, x, 3 * brick.LINE_HEIGHT) - } - - // sensors - const sis = sensors.internal.getActiveSensors(); - for(let i =0; i < sis.length; ++i) { - const si = sis[i]; - const x = (si.port() - 1) * col; - const v = si._query(); - print(`${scale(v)}`, x, 9 * brick.LINE_HEIGHT) - } - } } \ No newline at end of file