pad serial.writeLine to the 32byte boundary (#676)
* pad writeline with zeros * added padded for serial writline
This commit is contained in:
parent
bc886db97a
commit
cc2d8b0b6a
@ -12,7 +12,14 @@ namespace serial {
|
||||
//% help=serial/write-line blockGap=8
|
||||
//% blockId=serial_writeline block="serial|write line %text"
|
||||
export function writeLine(text: string): void {
|
||||
writeString(text + "\r\n");
|
||||
if (!text) text = "";
|
||||
// pad data to the 32 byte boundary
|
||||
// to ensure apps receive the packet
|
||||
let r = (32 - (text.length + 2) % 32) % 32;
|
||||
serial.writeString(text);
|
||||
for (let i = 0; i < r; ++i)
|
||||
serial.writeString(" ");
|
||||
serial.writeString("\r\n");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -34,7 +41,7 @@ namespace serial {
|
||||
//% help=serial/write-value
|
||||
//% blockId=serial_writevalue block="serial|write value %name|= %value"
|
||||
export function writeValue(name: string, value: number): void {
|
||||
writeString(name + ":" + value + "\r\n");
|
||||
writeLine(name + ":" + value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user