updated for cCODAL (#6)
This commit is contained in:
Коммит
126503c48f
|
@ -2,21 +2,12 @@
|
|||
using namespace pxt;
|
||||
|
||||
namespace dataStreamer {
|
||||
//%
|
||||
void init() {
|
||||
uBit.serial.redirect(USBTX, USBRX);
|
||||
uBit.serial.baud(9600);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the USB baud rate connection.
|
||||
* @param rate the new baud rate.
|
||||
*/
|
||||
//% weight=10
|
||||
//% blockId=datastreamer_setBaud block="set baud rate %rate"
|
||||
//% rate.defl=9600
|
||||
|
||||
//%
|
||||
void setBaudRate(int rate) {
|
||||
uBit.serial.baud(rate);
|
||||
#if MICROBIT_CODAL
|
||||
uBit.serial.setBaud(9600);
|
||||
#else
|
||||
uBit.serial.baud(9600);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
16
extension.ts
16
extension.ts
|
@ -12,7 +12,6 @@ namespace dataStreamer {
|
|||
//% weight=30
|
||||
//% decimalDigits.defl=2
|
||||
//% expandableArgumentMode=toggle
|
||||
|
||||
export function writeNumber(value: number, decimalDigits: number = 2) {
|
||||
//Format to right number of decimalDigits
|
||||
let text: string = value.toString();
|
||||
|
@ -71,12 +70,17 @@ namespace dataStreamer {
|
|||
}
|
||||
}
|
||||
|
||||
//% shim=dataStreamer::init
|
||||
function init() {
|
||||
// keep this statement
|
||||
/**
|
||||
* Set the USB baud rate connection.
|
||||
* @param rate the new baud rate.
|
||||
*/
|
||||
//% weight=10
|
||||
//% blockId=datastreamer_setBaud block="set baud rate %rate"
|
||||
//% rate.defl=9600 shim=dataStreamer::setBaudRate
|
||||
export function setBaudRate(rate?: BaudRate): void {
|
||||
return;
|
||||
}
|
||||
|
||||
init();
|
||||
|
||||
serial.redirectToUSB()
|
||||
dataStreamer.setBaudRate(BaudRate.BaudRate9600)
|
||||
}
|
12
pxt.json
12
pxt.json
|
@ -9,12 +9,14 @@
|
|||
"files": [
|
||||
"README.md",
|
||||
"extension.cpp",
|
||||
"extension.ts",
|
||||
"shims.d.ts",
|
||||
"enums.d.ts"
|
||||
"extension.ts"
|
||||
],
|
||||
"testFiles": [
|
||||
"test.ts"
|
||||
],
|
||||
"public": true
|
||||
}
|
||||
"public": true,
|
||||
"supportedTargets": [
|
||||
"microbit"
|
||||
],
|
||||
"preferredEditor": "tsprj"
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче