This commit is contained in:
Abhijith Chatra 2018-10-15 16:42:30 -07:00
Родитель 11e70cf5dc
Коммит d38b878c96
2 изменённых файлов: 25 добавлений и 11 удалений

Просмотреть файл

@ -7,29 +7,43 @@ namespace dataStreamer {
* Print a numeric value to the serial port
* @param value to send over serial
*/
//% blockId=datastreamer_writeNumber block="dataStreamer| write number %value"
//% weight=5
//% blockId=datastreamer_writeNumber block="write number %value"
//% weight=30
export function writeNumber(value: number) {
serial.writeNumber(value)
}
/**
* Print a line of text to the serial port
* Print a text to the serial port
* @param text to send over serial
*/
//% blockId=datastreamer_writeline block="dataStreamer|write line %text"
//% weight=5
//% blockId=datastreamer_writeline block="write string %text"
//% weight=20
//% text.default=","
export function writeString(text: string) {
serial.writeString(text)
}
/**
* Print a new line to the serial port, optionally add the text before the new line
* @param optional text to send over serial before new line
*/
//% blockId=datastreamer_writeline block="write line %text"
//% weight=20
export function writeLine(text: string) {
serial.writeLine(text)
}
}
/**
* Print an array of numeric values as CSV to the serial port
*/
//% weight=86
//% blockId=datastreamer_writenumbers block="dataStreamer|write numbers %values"
//% blockId=datastreamer_writenumbers block="write comma seperated numbers %values"
//% weight=10
export function writeNumbers(values: number[]): void {
serial.writeNumbers(values)
for (let i = 0; i < values.length; i++) {
serial.writeNumber(values[i])
serial.writeLine(",")
}
}
//% shim=dataStreamer::init
@ -39,5 +53,5 @@ namespace dataStreamer {
}
init();
}

Просмотреть файл

@ -15,4 +15,4 @@ dataStreamer.writeLine("");
dataStreamer.writeNumber(-1);
dataStreamer.writeLine("");
dataStreamer.writeNumber(-1000 / 3);
dataStreamer.writeNumbers([5, 2/5, 44/444, 5/5]);
dataStreamer.writeNumbers([5, 2 / 5, 44 / 444, 5 / 5]);