-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(typescript): Improve type definitions
- Loading branch information
1 parent
f09413a
commit 33ec1f5
Showing
11 changed files
with
87 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { I2cBusFuncs } from 'i2c-bus'; | ||
|
||
import { I2cBusPromised } from '../types'; | ||
|
||
export default interface BusInterface { | ||
readonly busNumber: number; | ||
readonly i2cBus: I2cBusPromised | null; | ||
readonly isOpen: boolean; | ||
|
||
open(): Promise<BusInterface>; | ||
close(): Promise<BusInterface>; | ||
|
||
i2cFuncs(): Promise<I2cBusFuncs>; | ||
scan(): Promise<number[]>; | ||
|
||
i2cRead(address: number, length: number, buffer: Buffer): Promise<number>; | ||
i2cWrite(address: number, length: number, buffer: Buffer): Promise<number>; | ||
|
||
receiveByte(address: number): Promise<number>; | ||
sendByte(address: number, byte: number): Promise<void>; | ||
|
||
readByte(address: number, command: number): Promise<number>; | ||
readI2cBlock(address: number, command: number, length: number, buffer: Buffer): Promise<number>; | ||
readWord(address: number, command: number): Promise<number>; | ||
|
||
writeByte(address: number, command: number, byte: number): Promise<void>; | ||
writeWord(address: number, command: number, word: number): Promise<void>; | ||
writeI2cBlock(address: number, command: number, length: number, buffer: Buffer): Promise<number>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import Bus from './Bus'; | ||
import BusError from './BusError'; | ||
import BusInterface from './BusInterface'; | ||
|
||
export { Bus, BusError }; | ||
export { Bus, BusError, BusInterface }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import BusInterface from '../Bus/BusInterface'; | ||
|
||
export default interface DeviceInterface { | ||
readonly address: number; | ||
readonly bus: BusInterface; | ||
|
||
i2cRead(length: number, buffer: Buffer): Promise<number>; | ||
i2cWrite(length: number, buffer: Buffer): Promise<number>; | ||
|
||
receiveByte(): Promise<number>; | ||
sendByte(byte: number): Promise<void>; | ||
|
||
readByte(command: number): Promise<number>; | ||
readI2cBlock(command: number, length: number, buffer: Buffer): Promise<number>; | ||
readWord(command: number): Promise<number>; | ||
|
||
writeByte(command: number, byte: number): Promise<void>; | ||
writeWord(command: number, word: number): Promise<void>; | ||
writeI2cBlock(command: number, length: number, buffer: Buffer): Promise<number>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import Device from './Device'; | ||
import DeviceError from './DeviceError'; | ||
import DeviceInterface from './DeviceInterface'; | ||
|
||
export { Device, DeviceError }; | ||
export { Device, DeviceError, DeviceInterface }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { Bus, BusError } from './Bus'; | ||
import { Device, DeviceError } from './Device'; | ||
import { Bus, BusError, BusInterface } from './Bus'; | ||
import { Device, DeviceError, DeviceInterface } from './Device'; | ||
|
||
import createI2cBusMock from './createI2cBusMock'; | ||
|
||
export { Bus, BusError, Device, DeviceError, createI2cBusMock }; | ||
export { Bus, BusError, BusInterface, Device, DeviceError, DeviceInterface, createI2cBusMock }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters