Add auto toString for various APIs (#1033)
This commit is contained in:
parent
27024baa51
commit
2700a77cae
@ -33,6 +33,7 @@ namespace basic {
|
|||||||
//% async
|
//% async
|
||||||
//% blockId=device_print_message
|
//% blockId=device_print_message
|
||||||
//% parts="ledmatrix"
|
//% parts="ledmatrix"
|
||||||
|
//% text.shadowOptions.toString=true
|
||||||
void showString(String text, int interval = 150) {
|
void showString(String text, int interval = 150) {
|
||||||
if (interval <= 0)
|
if (interval <= 0)
|
||||||
interval = 1;
|
interval = 1;
|
||||||
|
@ -103,6 +103,7 @@ namespace serial {
|
|||||||
//% help=serial/write-string
|
//% help=serial/write-string
|
||||||
//% weight=87 blockGap=8
|
//% weight=87 blockGap=8
|
||||||
//% blockId=serial_writestring block="serial|write string %text"
|
//% blockId=serial_writestring block="serial|write string %text"
|
||||||
|
//% text.shadowOptions.toString=true
|
||||||
void writeString(String text) {
|
void writeString(String text) {
|
||||||
if (!text) return;
|
if (!text) return;
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ namespace serial {
|
|||||||
//% weight=90
|
//% weight=90
|
||||||
//% help=serial/write-line blockGap=8
|
//% help=serial/write-line blockGap=8
|
||||||
//% blockId=serial_writeline block="serial|write line %text"
|
//% blockId=serial_writeline block="serial|write line %text"
|
||||||
|
//% text.shadowOptions.toString=true
|
||||||
export function writeLine(text: string): void {
|
export function writeLine(text: string): void {
|
||||||
if (!text) text = "";
|
if (!text) text = "";
|
||||||
// pad data to the 32 byte boundary
|
// pad data to the 32 byte boundary
|
||||||
|
6
libs/core/shims.d.ts
vendored
6
libs/core/shims.d.ts
vendored
@ -153,7 +153,8 @@ declare namespace basic {
|
|||||||
//% block="show|string %text"
|
//% block="show|string %text"
|
||||||
//% async
|
//% async
|
||||||
//% blockId=device_print_message
|
//% blockId=device_print_message
|
||||||
//% parts="ledmatrix" interval.defl=150 shim=basic::showString
|
//% parts="ledmatrix"
|
||||||
|
//% text.shadowOptions.toString=true interval.defl=150 shim=basic::showString
|
||||||
function showString(text: string, interval?: int32): void;
|
function showString(text: string, interval?: int32): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -791,7 +792,8 @@ declare namespace serial {
|
|||||||
*/
|
*/
|
||||||
//% help=serial/write-string
|
//% help=serial/write-string
|
||||||
//% weight=87 blockGap=8
|
//% weight=87 blockGap=8
|
||||||
//% blockId=serial_writestring block="serial|write string %text" shim=serial::writeString
|
//% blockId=serial_writestring block="serial|write string %text"
|
||||||
|
//% text.shadowOptions.toString=true shim=serial::writeString
|
||||||
function writeString(text: string): void;
|
function writeString(text: string): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -244,6 +244,7 @@ namespace radio {
|
|||||||
//% help=radio/send-string
|
//% help=radio/send-string
|
||||||
//% weight=58
|
//% weight=58
|
||||||
//% blockId=radio_datagram_send_string block="radio send string %msg"
|
//% blockId=radio_datagram_send_string block="radio send string %msg"
|
||||||
|
//% msg.shadowOptions.toString=true
|
||||||
void sendString(String msg) {
|
void sendString(String msg) {
|
||||||
if (radioEnable() != MICROBIT_OK || NULL == msg) return;
|
if (radioEnable() != MICROBIT_OK || NULL == msg) return;
|
||||||
|
|
||||||
|
3
libs/radio/shims.d.ts
vendored
3
libs/radio/shims.d.ts
vendored
@ -30,7 +30,8 @@ declare namespace radio {
|
|||||||
*/
|
*/
|
||||||
//% help=radio/send-string
|
//% help=radio/send-string
|
||||||
//% weight=58
|
//% weight=58
|
||||||
//% blockId=radio_datagram_send_string block="radio send string %msg" shim=radio::sendString
|
//% blockId=radio_datagram_send_string block="radio send string %msg"
|
||||||
|
//% msg.shadowOptions.toString=true shim=radio::sendString
|
||||||
function sendString(msg: string): void;
|
function sendString(msg: string): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user