Merge pull request #185 from Microsoft/printlineinverted

invert arguments in print line
This commit is contained in:
Sam El-Husseini 2018-01-07 12:14:16 -08:00 committed by GitHub
commit 44386be3c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 8 deletions

View File

@ -37,7 +37,7 @@
"brick.buttonUp|block": "up", "brick.buttonUp|block": "up",
"brick.clearScreen|block": "clear screen", "brick.clearScreen|block": "clear screen",
"brick.lightPattern|block": "%pattern", "brick.lightPattern|block": "%pattern",
"brick.printLine|block": "print %text| at line %line", "brick.printLine|block": "print at line %line|%text",
"brick.printPorts|block": "print ports", "brick.printPorts|block": "print ports",
"brick.setLight|block": "set light to %pattern=led_pattern", "brick.setLight|block": "set light to %pattern=led_pattern",
"brick.showImage|block": "show image %image=screen_image_picker", "brick.showImage|block": "show image %image=screen_image_picker",

View File

@ -92,10 +92,10 @@ namespace brick {
* @param text the text to print on the screen, eg: "Hello world" * @param text the text to print on the screen, eg: "Hello world"
* @param line the line number to print the text at, eg: 0 * @param line the line number to print the text at, eg: 0
*/ */
//% blockId=screen_print block="print %text| at line %line" //% blockId=screen_print block="print at line %line|%text"
//% weight=98 group="Screen" inlineInputMode="inline" blockGap=8 //% weight=98 group="Screen" inlineInputMode="inline" blockGap=8
//% line.min=0 line.max=9 //% line.min=0 line.max=9
export function printLine(text: string, line: number) { export function printLine(line: number, text: string) {
const NUM_LINES = 9; const NUM_LINES = 9;
const offset = 5; const offset = 5;
const y = offset + (Math.clamp(0, NUM_LINES, line) / (NUM_LINES + 2)) * DAL.LCD_HEIGHT; const y = offset + (Math.clamp(0, NUM_LINES, line) / (NUM_LINES + 2)) * DAL.LCD_HEIGHT;
@ -223,9 +223,6 @@ namespace brick {
const x = i * 52; const x = i * 52;
print(`${data.actualSpeed}%`, x, brick.LINE_HEIGHT) print(`${data.actualSpeed}%`, x, brick.LINE_HEIGHT)
print(`${data.count}>`, x, 2 * brick.LINE_HEIGHT) print(`${data.count}>`, x, 2 * brick.LINE_HEIGHT)
console.logValue(`speed.` + "ABCD"[i], data.actualSpeed);
console.logValue(`angle.` + "ABCD"[i], data.count);
} }
// sensors // sensors
@ -235,8 +232,6 @@ namespace brick {
const x = (si.port() - 1) * 52; const x = (si.port() - 1) * 52;
const v = si._query(); const v = si._query();
print(`${v}`, x, 9 * brick.LINE_HEIGHT) print(`${v}`, x, 9 * brick.LINE_HEIGHT)
console.logValue(`sensor.` + si.port(), v);
} }
} }
} }