avoid overlaps in port view
This commit is contained in:
parent
4207bd06c0
commit
d61a63f70a
@ -215,25 +215,32 @@ namespace brick {
|
|||||||
//% blockId=brickPrintPorts block="print ports"
|
//% blockId=brickPrintPorts block="print ports"
|
||||||
//% weight=1 group="Screen"
|
//% weight=1 group="Screen"
|
||||||
export function printPorts() {
|
export function printPorts() {
|
||||||
|
const col = 44;
|
||||||
clearScreen();
|
clearScreen();
|
||||||
|
|
||||||
|
function scale(x: number) {
|
||||||
|
if (Math.abs(x) > 1000) return Math.round(x / 100) / 10 + "k";
|
||||||
|
return ("" + (x >> 0));
|
||||||
|
}
|
||||||
|
|
||||||
// motors
|
// motors
|
||||||
const datas = motors.getAllMotorData();
|
const datas = motors.getAllMotorData();
|
||||||
for(let i = 0; i < datas.length; ++i) {
|
for(let i = 0; i < datas.length; ++i) {
|
||||||
const data = datas[i];
|
const data = datas[i];
|
||||||
if (!data.actualSpeed && !data.count) continue;
|
if (!data.actualSpeed && !data.count) continue;
|
||||||
const x = i * 52;
|
const x = i * col;
|
||||||
print(`${data.actualSpeed}%`, x, brick.LINE_HEIGHT)
|
print(`${scale(data.actualSpeed)}%`, x, brick.LINE_HEIGHT)
|
||||||
print(`${data.count}>`, x, 2 * brick.LINE_HEIGHT)
|
print(`${scale(data.count)}>`, x, 2 * brick.LINE_HEIGHT)
|
||||||
|
print(`${scale(data.tachoCount)}|`, x, 3 * brick.LINE_HEIGHT)
|
||||||
}
|
}
|
||||||
|
|
||||||
// sensors
|
// sensors
|
||||||
const sis = sensors.internal.getActiveSensors();
|
const sis = sensors.internal.getActiveSensors();
|
||||||
for(let i =0; i < sis.length; ++i) {
|
for(let i =0; i < sis.length; ++i) {
|
||||||
const si = sis[i];
|
const si = sis[i];
|
||||||
const x = (si.port() - 1) * 52;
|
const x = (si.port() - 1) * col;
|
||||||
const v = si._query();
|
const v = si._query();
|
||||||
print(`${v}`, x, 9 * brick.LINE_HEIGHT)
|
print(`${scale(v)}`, x, 9 * brick.LINE_HEIGHT)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user