bring back 'write number'

This commit is contained in:
Peli de Halleux 2016-04-15 16:40:51 -07:00
parent 24f2a45310
commit 26841de6cf
2 changed files with 11 additions and 4 deletions

View File

@ -32,5 +32,5 @@ basic.forever(() => {
### See also
[serial](/device/serial), [write value](/reference/serial/write-value)
[serial](/device/serial), [write line](/reference/serial/write-line)

View File

@ -14,17 +14,24 @@ namespace serial {
writeString("\r\n");
}
/**
* Prints a numeric value to the serial
*/
export function writeNumber(value: number): void {
writeString(value.toString());
}
/**
* Writes a ``name: value`` pair line to the serial.
* @param name name of the value stream, eg: x
* @param value to write
*/
//% help=/reference/serial/write-value
//% weight=80
//% blockId=serial_writevalue block="serial|write %name|= %value"
export function writeValue(name: string, value: number): void {
writeString(name);
writeString(":");
writeLine(value.toString());
writeString(": ");
writeNumber(value);
writeLine("");
}
}