diff --git a/libs/base/enums.d.ts b/libs/base/enums.d.ts index 65d1dc38..bd7fcd0e 100644 --- a/libs/base/enums.d.ts +++ b/libs/base/enums.d.ts @@ -30,7 +30,5 @@ Object = 4, Function = 5, } -declare namespace serial { -} // Auto-generated. Do not edit. Really. diff --git a/libs/base/shims.d.ts b/libs/base/shims.d.ts new file mode 100644 index 00000000..4fed2348 --- /dev/null +++ b/libs/base/shims.d.ts @@ -0,0 +1,158 @@ +// Auto-generated. Do not edit. + + + + //% indexerGet=BufferMethods::getByte indexerSet=BufferMethods::setByte +declare interface Buffer { + /** + * Write a number in specified format in the buffer. + */ + //% shim=BufferMethods::setNumber + setNumber(format: NumberFormat, offset: int32, value: number): void; + + /** + * Read a number in specified format from the buffer. + */ + //% shim=BufferMethods::getNumber + getNumber(format: NumberFormat, offset: int32): number; + + /** Returns the length of a Buffer object. */ + //% property shim=BufferMethods::length + length: int32; + + /** + * Fill (a fragment) of the buffer with given value. + */ + //% offset.defl=0 length.defl=-1 shim=BufferMethods::fill + fill(value: int32, offset?: int32, length?: int32): void; + + /** + * Return a copy of a fragment of a buffer. + */ + //% offset.defl=0 length.defl=-1 shim=BufferMethods::slice + slice(offset?: int32, length?: int32): Buffer; + + /** + * Shift buffer left in place, with zero padding. + * @param offset number of bytes to shift; use negative value to shift right + * @param start start offset in buffer. Default is 0. + * @param length number of elements in buffer. If negative, length is set as the buffer length minus + * start. eg: -1 + */ + //% start.defl=0 length.defl=-1 shim=BufferMethods::shift + shift(offset: int32, start?: int32, length?: int32): void; + + /** + * Convert a buffer to its hexadecimal representation. + */ + //% shim=BufferMethods::toHex + toHex(): string; + + /** + * Rotate buffer left in place. + * @param offset number of bytes to shift; use negative value to shift right + * @param start start offset in buffer. Default is 0. + * @param length number of elements in buffer. If negative, length is set as the buffer length minus + * start. eg: -1 + */ + //% start.defl=0 length.defl=-1 shim=BufferMethods::rotate + rotate(offset: int32, start?: int32, length?: int32): void; + + /** + * Write contents of `src` at `dstOffset` in current buffer. + */ + //% shim=BufferMethods::write + write(dstOffset: int32, src: Buffer): void; +} +declare namespace loops { + + /** + * Repeats the code forever in the background. On each iteration, allows other codes to run. + * @param body code to execute + */ + //% help=loops/forever weight=100 blockGap=8 + //% blockId=forever block="forever" blockAllowMultiple=1 shim=loops::forever + function forever(a: () => void): void; + + /** + * Pause for the specified time in milliseconds + * @param ms how long to pause for, eg: 100, 200, 500, 1000, 2000 + */ + //% help=loops/pause weight=99 + //% async block="pause (ms) %pause" + //% blockId=device_pause shim=loops::pause + function pause(ms: int32): void; +} +declare namespace control { + + /** + * Gets the number of milliseconds elapsed since power on. + */ + //% help=control/millis weight=50 + //% blockId=control_running_time block="millis (ms)" shim=control::millis + function millis(): int32; + + /** + * Run code when a registered event happens. + * @param id the event compoent id + * @param value the event value to match + */ + //% weight=20 blockGap=8 blockId="control_on_event" block="on event|from %src|with value %value" + //% blockExternalInputs=1 + //% help="control/on-event" shim=control::onEvent + function onEvent(src: int32, value: int32, handler: () => void): void; + + /** + * Reset the device. + */ + //% weight=30 async help=control/reset blockGap=8 + //% blockId="control_reset" block="reset" shim=control::reset + function reset(): void; + + /** + * Block the current fiber for the given microseconds + * @param micros number of micro-seconds to wait. eg: 4 + */ + //% help=control/wait-micros weight=29 async + //% blockId="control_wait_us" block="wait (µs)%micros" shim=control::waitMicros + function waitMicros(micros: int32): void; + + /** + * Run other code in the background. + */ + //% help=control/run-in-background blockAllowMultiple=1 + //% blockId="control_run_in_background" block="run in background" blockGap=8 shim=control::runInBackground + function runInBackground(a: () => void): void; + + /** + * Blocks the calling thread until the specified event is raised. + */ + //% help=control/wait-for-event async + //% blockId=control_wait_for_event block="wait for event|from %src|with value %value" shim=control::waitForEvent + function waitForEvent(src: int32, value: int32): void; + + /** + * Derive a unique, consistent serial number of this device from internal data. + */ + //% blockId="control_device_serial_number" block="device serial number" weight=9 shim=control::deviceSerialNumber + function deviceSerialNumber(): int32; +} +declare namespace serial { + + /** + * Write some text to the serial port. + */ + //% help=serial/write-string + //% weight=87 + //% blockId=serial_writestring block="serial|write string %text" shim=serial::writeString + function writeString(text: string): void; + + /** + * Send a buffer across the serial connection. + */ + //% help=serial/write-buffer advanced=true weight=6 + //% blockId=serial_writebuffer block="serial|write buffer %buffer" shim=serial::writeBuffer + function writeBuffer(buffer: Buffer): void; +} + +// Auto-generated. Do not edit. Really. diff --git a/package.json b/package.json index aee9e0a1..6f76c4b6 100644 --- a/package.json +++ b/package.json @@ -39,8 +39,8 @@ "semantic-ui-less": "^2.2.4" }, "dependencies": { - "pxt-common-packages": "0.8.1", - "pxt-core": "1.7.4" + "pxt-common-packages": "0.9.1", + "pxt-core": "1.8.10" }, "scripts": { "test": "node node_modules/pxt-core/built/pxt.js travis"