From 32976ad448237dd3a5345749feafd33e27419dde Mon Sep 17 00:00:00 2001 From: Philippe Coval Date: Wed, 15 Jan 2020 20:40:37 +0100 Subject: [PATCH] Prefer abandonware i2c Legacy i2c will be used by IoT.js runtime Change-Id: Ifc2df3f9567f85d21c121c0bcc129b72e7d3f895 Forwarded: https://github.com/bbx10/node-htu21d/pull/3 Relate-to: https://github.com/kelly/node-i2c/issues/97 Signed-off-by: Philippe Coval --- index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 79c1133..ca26fbb 100644 --- a/index.js +++ b/index.js @@ -22,8 +22,13 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -var i2c = require('i2c'); var fs=require('fs'); +var i2c = null; +try { + i2c = require('@abandonware/i2c'); +} catch(err) { + i2c = require('i2c'); +} var MAX_TEMP_CONVERSION = 50; // milliseconds var MAX_HUMI_CONVERSION = 16; // ms