2.0.0 • Published 5 years ago

i2c-bus-promise v2.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

ATTENTION!

i2c-bus > 5.0.0 now has a promise API included. If you're unable to upgrade, you can use this module - this module serves as a polyfill.

i2c-bus-promise

Nothing complicated here. Just a promise wrapper for i2c-bus.

i2c-bus dependency defined as ^4 to allow wide compatibility with existing version you may have installed already.

Install

npm install i2c-bus-promise

Use

const i2c = require('i2c-bus-promise');

i2c.openPromisified(1).then(async bus => {
  console.log(await bus.scan())
})

BYOi2c-bus

If you already have an i2c-bus bus instance, you can just wrap it...

const i2c = require('i2c-bus');
const wrap = require('i2c-bus-promise').wrap;

const bus = wrap(i2c.open(1, async (err) => {
  if (err) throw err

  console.log(await bus.scan())
}))

License

MIT

2.0.0

5 years ago

1.0.0

5 years ago