uart write sim support (#1933)

* pass data to uart without prefix

* added NEW_LINE support
This commit is contained in:
Peli de Halleux
2019-03-21 10:22:24 -07:00
committed by GitHub
parent 3840aee859
commit 3477d40ce0
2 changed files with 13 additions and 7 deletions

View File

@ -4,6 +4,11 @@
//% weight=2 color=#002050 icon="\uf287"
//% advanced=true
namespace serial {
/**
* The string used to mark a new line, default is \r\n
*/
export let NEW_LINE = "\r\n";
/**
* Print a line of text to the serial port
* @param value to send over serial
@ -20,7 +25,7 @@ namespace serial {
serial.writeString(text);
for (let i = 0; i < r; ++i)
serial.writeString(" ");
serial.writeString("\r\n");
serial.writeString(NEW_LINE);
}
/**
@ -57,7 +62,7 @@ namespace serial {
//% help=serial/write-value
//% blockId=serial_writevalue block="serial|write value %name|= %value"
export function writeValue(name: string, value: number): void {
writeLine(name + ":" + value);
writeLine((name ? name + ":" : "") + value);
}
/**