Use the improved default parameters
This commit is contained in:
parent
e2b2aa7ff1
commit
d62c10d278
@ -199,8 +199,8 @@ namespace pins {
|
||||
/**
|
||||
* Read `size` bytes from a 7-bit I2C `address`.
|
||||
*/
|
||||
//% repeat.defl=0
|
||||
Buffer i2cReadBuffer(int address, int size, bool repeat)
|
||||
//%
|
||||
Buffer i2cReadBuffer(int address, int size, bool repeat = false)
|
||||
{
|
||||
Buffer buf = createBuffer(size);
|
||||
uBit.i2c.read(address << 1, (char*)buf->payload, size, repeat);
|
||||
@ -210,8 +210,8 @@ namespace pins {
|
||||
/**
|
||||
* Write bytes to a 7-bit I2C `address`.
|
||||
*/
|
||||
//% repeat.defl=0
|
||||
void i2cWriteBuffer(int address, Buffer buf, bool repeat)
|
||||
//%
|
||||
void i2cWriteBuffer(int address, Buffer buf, bool repeat = false)
|
||||
{
|
||||
uBit.i2c.write(address << 1, (char*)buf->payload, buf->length, repeat);
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ namespace pins {
|
||||
* Read one number from 7-bit I2C address.
|
||||
*/
|
||||
export function i2cReadNumber(address: number, format: NumberFormat): number {
|
||||
let buf = pins.i2cReadBuffer(address, pins.sizeOf(format), false)
|
||||
let buf = pins.i2cReadBuffer(address, pins.sizeOf(format))
|
||||
return buf.getNumber(format, 0)
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ namespace pins {
|
||||
export function i2cWriteNumber(address: number, value: number, format: NumberFormat): void {
|
||||
let buf = createBuffer(pins.sizeOf(format))
|
||||
buf.setNumber(format, 0, value)
|
||||
pins.i2cWriteBuffer(address, buf, false)
|
||||
pins.i2cWriteBuffer(address, buf)
|
||||
}
|
||||
|
||||
/**
|
||||
|
6
libs/microbit/shims.d.ts
vendored
6
libs/microbit/shims.d.ts
vendored
@ -375,7 +375,7 @@ declare namespace control {
|
||||
*/
|
||||
//% weight=21 blockGap=12 blockId="control_raise_event" block="raise event|from source %src=control_event_source|with value %value=control_event_value" blockExternalInputs=1
|
||||
//% mode.defl=1 shim=control::raiseEvent
|
||||
function raiseEvent(src: number, value: number, mode: EventCreationMode): void;
|
||||
function raiseEvent(src: number, value: number, mode?: EventCreationMode): void;
|
||||
|
||||
/**
|
||||
* Raises an event in the event bus.
|
||||
@ -546,13 +546,13 @@ declare namespace pins {
|
||||
* Read `size` bytes from a 7-bit I2C `address`.
|
||||
*/
|
||||
//% repeat.defl=0 shim=pins::i2cReadBuffer
|
||||
function i2cReadBuffer(address: number, size: number, repeat: boolean): Buffer;
|
||||
function i2cReadBuffer(address: number, size: number, repeat?: boolean): Buffer;
|
||||
|
||||
/**
|
||||
* Write bytes to a 7-bit I2C `address`.
|
||||
*/
|
||||
//% repeat.defl=0 shim=pins::i2cWriteBuffer
|
||||
function i2cWriteBuffer(address: number, buf: Buffer, repeat: boolean): void;
|
||||
function i2cWriteBuffer(address: number, buf: Buffer, repeat?: boolean): void;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user