From d61a63f70a999f42bc6b3e057a312af5c7114152 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Mon, 8 Jan 2018 09:08:59 -0800 Subject: [PATCH] avoid overlaps in port view --- libs/core/screen.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/libs/core/screen.ts b/libs/core/screen.ts index a3b3642d..61f6690e 100644 --- a/libs/core/screen.ts +++ b/libs/core/screen.ts @@ -215,25 +215,32 @@ namespace brick { //% blockId=brickPrintPorts block="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 * 52; - print(`${data.actualSpeed}%`, x, brick.LINE_HEIGHT) - print(`${data.count}>`, x, 2 * brick.LINE_HEIGHT) + 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) * 52; + const x = (si.port() - 1) * col; const v = si._query(); - print(`${v}`, x, 9 * brick.LINE_HEIGHT) + print(`${scale(v)}`, x, 9 * brick.LINE_HEIGHT) } } } \ No newline at end of file