1import * as i2c from 'i2c'
2
3var memaddr = 0x18
4
5var msgbuf = [0x10, 0xee]
6
7var sensor = i2c.open({
8    id: 'I2C0',
9    success: function () {
10        console.log('open i2c success')
11    },
12    fail: function () {
13        console.log('open i2c failed')
14    }
15});
16
17sensor.write(msgbuf)
18var value = sensor.read(2)
19
20console.log('sensor read ' + '0x' + value[0].toString(16) + ' 0x' + value[1].toString(16))
21
22sensor.writeMem(memaddr, msgbuf)
23
24var vol = sensor.readMem(memaddr, 2)
25console.log('sensor read mem vol is ' + '0x' + value[0].toString(16) + ' 0x' + value[1].toString(16))
26
27sensor.close();