Espruino/libs/js/LIS2MDL.min.js
2023-06-13 09:22:21 +01:00

2 lines
574 B
JavaScript

function e(a,c,d){this.r=c;this.w=d;if(64!=this.r(b.WHO_AM_I,1)[0])throw Error("WHO_AM_I incorrect");this.w(b.CFG_A,128);this.w(b.CFG_B,1);this.w(b.CFG_C,17)}var b={WHO_AM_I:79,OUTX_L:104,CFG_A:96,CFG_B:97,CFG_C:98};e.prototype.off=function(){this.w(b.CFG_A,3)};e.prototype.read=function(){var a=new DataView(this.r(b.OUTX_L,6).buffer);return{x:a.getInt16(0,1),y:a.getInt16(2,1),z:a.getInt16(4,1)}};exports.LIS2MDL=e;exports.connectI2C=function(a,c){var d=c&&c.addr||30;return new e(c,
function(f,g){a.writeTo(d,f);return a.readFrom(d,g)},function(f,g){a.writeTo(d,[f,g])})}