This library is a set of cross platform drivers for common I2C devices.
npm install openi2cThis library is a set of cross platform drivers for common I2C devices using i2c-bus.
For detailed usage of each driver, click on the module name in the section above.
``ts`
import { PCA9685 } from 'openi2c';
const pwmDriver = new PCA9685();
await pwmDriver.setFrequency(50);
await pwmDriver.setDutyCycle(0, 0.5);
`ts``
import { sleep, mapValue } from 'openi2c';
await sleep(100); // Sleeps for 100ms
mapValue(50, 0, 100, 0, 1) // Maps 50 in range 0 - 100 to range 0 - 1, result: 0.5