@@ -506,44 +506,51 @@ export class ControlHubConnectedExpansionHub implements ParentExpansionHub {
506
506
numBytesToRead : number ,
507
507
register : number ,
508
508
) : Promise < number [ ] > {
509
- throw new Error ( "not implemented" ) ;
509
+ return await this . sendCommand ( "readI2cRegister" , {
510
+ hId : this . id ,
511
+ a : targetAddress ,
512
+ c : i2cChannel ,
513
+ cb : numBytesToRead ,
514
+ r : register ,
515
+ } ) ;
510
516
}
511
517
512
- readI2CMultipleBytes (
518
+ async readI2CMultipleBytes (
513
519
i2cChannel : number ,
514
520
targetAddress : number ,
515
521
numBytesToRead : number ,
516
522
) : Promise < number [ ] > {
517
- throw new Error ( "not implemented" ) ;
523
+ return await this . sendCommand ( "readI2cData" , {
524
+ hId : this . id ,
525
+ a : targetAddress ,
526
+ c : i2cChannel ,
527
+ cb : numBytesToRead ,
528
+ } ) ;
518
529
}
519
530
520
- readI2CSingleByte ( i2cChannel : number , targetAddress : number ) : Promise < number > {
521
- throw new Error ( "not implemented" ) ;
531
+ async readI2CSingleByte ( i2cChannel : number , targetAddress : number ) : Promise < number > {
532
+ return ( await this . readI2CMultipleBytes ( i2cChannel , targetAddress , 1 ) ) [ 0 ] ;
522
533
}
523
534
524
- writeI2CMultipleBytes (
535
+ async writeI2CMultipleBytes (
525
536
i2cChannel : number ,
526
537
targetAddress : number ,
527
538
bytes : number [ ] ,
528
539
) : Promise < void > {
529
- throw new Error ( "not implemented" ) ;
530
- }
531
-
532
- writeI2CReadMultipleBytes (
533
- i2cChannel : number ,
534
- targetAddress : number ,
535
- numBytesToRead : number ,
536
- startAddress : number ,
537
- ) : Promise < void > {
538
- throw new Error ( "not implemented" ) ;
540
+ await this . sendCommand ( "writeI2cData" , {
541
+ hId : this . id ,
542
+ a : targetAddress ,
543
+ c : i2cChannel ,
544
+ d : bytes ,
545
+ } ) ;
539
546
}
540
547
541
- writeI2CSingleByte (
548
+ async writeI2CSingleByte (
542
549
i2cChannel : number ,
543
550
targetAddress : number ,
544
551
byte : number ,
545
552
) : Promise < void > {
546
- throw new Error ( "not implemented" ) ;
553
+ await this . writeI2CMultipleBytes ( i2cChannel , targetAddress , [ byte ] ) ;
547
554
}
548
555
549
556
async readVersion ( ) : Promise < Version > {
0 commit comments