2016-04-06 00:59:25 +02:00
|
|
|
/**
|
|
|
|
* Reading and writing data over a serial connection.
|
|
|
|
*/
|
2016-03-30 19:46:40 +02:00
|
|
|
//% weight=2 color=30
|
2016-03-10 23:01:04 +01:00
|
|
|
namespace serial {
|
|
|
|
/**
|
|
|
|
* Prints a line of text to the serial
|
|
|
|
* @param value to send over serial
|
|
|
|
*/
|
2016-04-16 01:36:31 +02:00
|
|
|
//% help=/reference/serial/write-line
|
2016-03-22 06:13:39 +01:00
|
|
|
//% blockId=serial_writeline block="serial|write %text"
|
2016-03-10 23:01:04 +01:00
|
|
|
export function writeLine(text: string): void {
|
|
|
|
writeString(text);
|
|
|
|
writeString("\r\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Writes a ``name: value`` pair line to the serial.
|
|
|
|
* @param name name of the value stream, eg: x
|
|
|
|
* @param value to write
|
|
|
|
*/
|
2016-04-16 01:36:31 +02:00
|
|
|
//% help=/reference/serial/write-value
|
2016-03-10 23:01:04 +01:00
|
|
|
//% weight=80
|
|
|
|
//% blockId=serial_writevalue block="serial|write %name|= %value"
|
|
|
|
export function writeValue(name: string, value: number): void {
|
|
|
|
writeString(name);
|
2016-04-16 01:36:31 +02:00
|
|
|
writeString(":");
|
|
|
|
writeLine(value.toString());
|
2016-03-10 23:01:04 +01:00
|
|
|
}
|
|
|
|
}
|