Use the improved default parameters

This commit is contained in:
Michal Moskal 2016-04-04 19:11:33 -07:00
parent e2b2aa7ff1
commit d62c10d278
3 changed files with 9 additions and 9 deletions

View File

@ -199,8 +199,8 @@ namespace pins {
/** /**
* Read `size` bytes from a 7-bit I2C `address`. * 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); Buffer buf = createBuffer(size);
uBit.i2c.read(address << 1, (char*)buf->payload, size, repeat); uBit.i2c.read(address << 1, (char*)buf->payload, size, repeat);
@ -210,8 +210,8 @@ namespace pins {
/** /**
* Write bytes to a 7-bit I2C `address`. * 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); uBit.i2c.write(address << 1, (char*)buf->payload, buf->length, repeat);
} }

View File

@ -18,7 +18,7 @@ namespace pins {
* Read one number from 7-bit I2C address. * Read one number from 7-bit I2C address.
*/ */
export function i2cReadNumber(address: number, format: NumberFormat): number { 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) return buf.getNumber(format, 0)
} }
@ -28,7 +28,7 @@ namespace pins {
export function i2cWriteNumber(address: number, value: number, format: NumberFormat): void { export function i2cWriteNumber(address: number, value: number, format: NumberFormat): void {
let buf = createBuffer(pins.sizeOf(format)) let buf = createBuffer(pins.sizeOf(format))
buf.setNumber(format, 0, value) buf.setNumber(format, 0, value)
pins.i2cWriteBuffer(address, buf, false) pins.i2cWriteBuffer(address, buf)
} }
/** /**

View File

@ -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 //% 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 //% 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. * Raises an event in the event bus.
@ -546,13 +546,13 @@ declare namespace pins {
* Read `size` bytes from a 7-bit I2C `address`. * Read `size` bytes from a 7-bit I2C `address`.
*/ */
//% repeat.defl=0 shim=pins::i2cReadBuffer //% 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`. * Write bytes to a 7-bit I2C `address`.
*/ */
//% repeat.defl=0 shim=pins::i2cWriteBuffer //% repeat.defl=0 shim=pins::i2cWriteBuffer
function i2cWriteBuffer(address: number, buf: Buffer, repeat: boolean): void; function i2cWriteBuffer(address: number, buf: Buffer, repeat?: boolean): void;
} }