Redirecttousb (#604)

* add block to redirect back to USB

* added docs

* bump minor version
This commit is contained in:
Peli de Halleux
2017-12-14 06:44:48 -08:00
committed by GitHub
parent caa563ee30
commit b45f456736
9 changed files with 44 additions and 4 deletions

View File

@ -152,6 +152,7 @@ namespace serial {
//% tx.fieldOptions.tooltips="false"
//% rx.fieldEditor="gridpicker" rx.fieldOptions.columns=3
//% rx.fieldOptions.tooltips="false"
//% blockGap=8
void redirect(SerialPin tx, SerialPin rx, BaudRate rate) {
MicroBitPin* txp = getPin(tx); if (!tx) return;
MicroBitPin* rxp = getPin(rx); if (!rx) return;
@ -159,4 +160,14 @@ namespace serial {
uBit.serial.redirect(txp->name, rxp->name);
uBit.serial.baud((int)rate);
}
/**
* Redirects the serial instance to USBTX and USBRX.
*/
//% weight=9 help=serial/redirect-to-usb
//% blockId=serial_redirect_to_usb block="serial|redirect to USB"
void redirectToUSB() {
uBit.serial.redirect(USBTX, USBRX);
uBit.serial.baud(115200);
}
}