diff --git a/packages/control-hub/src/internal/ControlHub.ts b/packages/control-hub/src/internal/ControlHub.ts index 0578cc3a..9f94d446 100644 --- a/packages/control-hub/src/internal/ControlHub.ts +++ b/packages/control-hub/src/internal/ControlHub.ts @@ -502,20 +502,6 @@ export class ControlHubInternal implements ControlHub { return await this.embedded.writeI2CMultipleBytes(i2cChannel, targetAddress, bytes); } - async writeI2CReadMultipleBytes( - i2cChannel: number, - targetAddress: number, - numBytesToRead: number, - startAddress: number, - ): Promise { - return await this.embedded.writeI2CReadMultipleBytes( - i2cChannel, - targetAddress, - numBytesToRead, - startAddress, - ); - } - async writeI2CSingleByte( i2cChannel: number, targetAddress: number, diff --git a/packages/control-hub/src/internal/ControlHubConnectedExpansionHub.ts b/packages/control-hub/src/internal/ControlHubConnectedExpansionHub.ts index 769c4ae0..e815210e 100644 --- a/packages/control-hub/src/internal/ControlHubConnectedExpansionHub.ts +++ b/packages/control-hub/src/internal/ControlHubConnectedExpansionHub.ts @@ -506,44 +506,51 @@ export class ControlHubConnectedExpansionHub implements ParentExpansionHub { numBytesToRead: number, register: number, ): Promise { - throw new Error("not implemented"); + return await this.sendCommand("readI2cRegister", { + hId: this.id, + a: targetAddress, + c: i2cChannel, + cb: numBytesToRead, + r: register, + }); } - readI2CMultipleBytes( + async readI2CMultipleBytes( i2cChannel: number, targetAddress: number, numBytesToRead: number, ): Promise { - throw new Error("not implemented"); + return await this.sendCommand("readI2cData", { + hId: this.id, + a: targetAddress, + c: i2cChannel, + cb: numBytesToRead, + }); } - readI2CSingleByte(i2cChannel: number, targetAddress: number): Promise { - throw new Error("not implemented"); + async readI2CSingleByte(i2cChannel: number, targetAddress: number): Promise { + return (await this.readI2CMultipleBytes(i2cChannel, targetAddress, 1))[0]; } - writeI2CMultipleBytes( + async writeI2CMultipleBytes( i2cChannel: number, targetAddress: number, bytes: number[], ): Promise { - throw new Error("not implemented"); - } - - writeI2CReadMultipleBytes( - i2cChannel: number, - targetAddress: number, - numBytesToRead: number, - startAddress: number, - ): Promise { - throw new Error("not implemented"); + await this.sendCommand("writeI2cData", { + hId: this.id, + a: targetAddress, + c: i2cChannel, + d: bytes, + }); } - writeI2CSingleByte( + async writeI2CSingleByte( i2cChannel: number, targetAddress: number, byte: number, ): Promise { - throw new Error("not implemented"); + await this.writeI2CMultipleBytes(i2cChannel, targetAddress, [byte]); } async readVersion(): Promise {