p5.j5
Version:
johnny-five library for p5.js
8 lines • 409 kB
JavaScript
!function(t){var e={};function i(r){if(e[r])return e[r].exports;var n=e[r]={i:r,l:!1,exports:{}};return t[r].call(n.exports,n,n.exports,i),n.l=!0,n.exports}i.m=t,i.c=e,i.d=function(t,e,r){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)i.d(r,n,function(e){return t[e]}.bind(null,n));return r},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=55)}([function(t,e,i){(function(e){const r=i(3),n=i(2),s=i(4),o=new Map,a=new Map,{int16:l,uint16:h,uint24:c,s32:u,u32:d}=s,p="thermometer";function f(t,e){const i=o.get(this),r=Object.create(null);for(const n of this.components)i[n]=new f[n](Object.assign({controller:e.controller||t,freq:e.freq,board:this.board},e)),r[n]={get:()=>i[n]},g[n]&&(r[g[n]]=r[n]);Object.defineProperties(this,r)}f.accelerometer=i(28),f.altimeter=i(37),f.barometer=i(38),f.gyro=i(39),f.hygrometer=i(40),f.magnetometer=i(41),f.orientation=i(42),f.thermometer=i(43);const g={thermometer:"temperature"},E={SHT31D:{ADDRESSES:{value:[68]},REGISTER:{value:{SOFT_RESET:12450,MEASURE_HIGH_REPEATABILITY:9216}},initialize:{value(t,e){const i=t.io,r=E.addressResolver(this,e);i.i2cConfig(e),i.i2cWrite(r,[this.REGISTER.SOFT_RESET>>8,255&this.REGISTER.SOFT_RESET]);const n={temperature:null,humidity:null},s=()=>{i.i2cWrite(r,[this.REGISTER.MEASURE_HIGH_REPEATABILITY>>8,255&this.REGISTER.MEASURE_HIGH_REPEATABILITY]),setTimeout(()=>{i.i2cReadOnce(r,6,t=>{n.temperature=h(t[0],t[1]),n.humidity=h(t[3],t[4]),this.emit("data",n),s()})},16)};s()}},identifier:{value:t=>"sht-31d-"+E.addressResolver(E.SHT31D,t)}},HTU21D:{ADDRESSES:{value:[64]},REGISTER:{value:{HUMIDITY:229,TEMPERATURE:227,SOFT_RESET:254}},initialize:{value(t,e){const i=t.io,r=E.addressResolver(this,e);e.delay=5e4,i.i2cConfig(e),i.i2cWrite(r,this.REGISTER.SOFT_RESET);const n={temperature:null,humidity:null};let s=0;const o=()=>{const t=0===s,e=t?this.REGISTER.TEMPERATURE:this.REGISTER.HUMIDITY;i.i2cReadOnce(r,e,2,e=>{t?n.temperature=h(e[0],e[1]):n.humidity=h(e[0],e[1]),2==++s&&(s=0,this.emit("data",n)),o()})};o()}},identifier:{value:t=>"htu-s1d-"+E.addressResolver(E.HTU21D,t)}},HIH6130:{ADDRESSES:{value:[39]},initialize:{value(t,e){const i=t.io,r=E.addressResolver(this,e);i.i2cConfig(e);const n={humidity:null,temperature:null};let s=36.65;const o=()=>{i.i2cWrite(r,160,[0,0]),setTimeout(()=>{i.i2cWrite(r,128,[0,0]),i.i2cReadOnce(r,4,t=>{const e=t[0]>>6;n.humidity=l(63&t[0],t[1]),n.temperature=l(t[2],t[3]>>2),0===e&&s--,1===e&&s++,this.emit("data",n),o()})},s)};o()}},identifier:{value:t=>"hih6130-"+E.addressResolver(E.HIH6130,t)}},DHT_I2C_NANO_BACKPACK:{ADDRESSES:{value:[10]},REGISTER:{value:{READ:0}},initialize:{value(t,e){const i=t.io;let r=11;const n=E.addressResolver(this,e);i.i2cConfig(e);const s=/(\d{2})/.exec(e.controller),o=s&&s.length&&s[0];o&&(r=+o,Number.isNaN(r)&&(r=11));const a={temperature:null,humidity:null};i.i2cWrite(n,[2,r]),i.i2cRead(n,4,t=>{a.humidity=l(t[0],t[1]),a.temperature=l(t[2],t[3]),this.emit("data",a)})}},identifier:{value:t=>"dht_i2c_nano_backpack-"+E.addressResolver(E.DHT_I2C_NANO_BACKPACK,t)}},MPU6050:{ADDRESSES:{value:[104,105]},REGISTER:{value:{SETUP:[107,0],READ:59}},initialize:{value(t,e){const i=t.io,r=E.addressResolver(this,e),n={accelerometer:{},temperature:{},gyro:{}};i.i2cConfig(e),i.i2cWrite(r,this.REGISTER.SETUP),i.i2cRead(r,this.REGISTER.READ,14,t=>{n.accelerometer={x:l(t[0],t[1]),y:l(t[2],t[3]),z:l(t[4],t[5])},n.temperature=l(t[6],t[7]),n.gyro={x:l(t[8],t[9]),y:l(t[10],t[11]),z:l(t[12],t[13])},this.emit("data",n)})}},identifier:{value:t=>"mpu-6050-"+E.addressResolver(E.MPU6050,t)}},BNO055:{ADDRESSES:{value:[40,41]},REGISTER:{value:{READ:{ACCEL:8,MAG:14,GYRO:20,EULER:26,QUARTERNION:32,TEMP:52},LENGTH:{ACCEL:6,MAG:6,GYRO:6,EULER:6,QUARTERNION:8,TEMP:1},OPR_MODE_ADDR:61,OPR_MODES:{CONFIG:0,ACCONLY:1,MAGONLY:2,GYRONLY:3,ACCMAG:4,ACCGYRO:5,MAGGYRO:6,AMG:7,IMUPLUS:8,COMPASS:9,M4G:10,NDOF_FMC_OFF:11,NDOF:12},PWR_MODE_ADDR:62,PWR_MODES:{NORMAL:0,LOW:1,SUSPEND:2},PAGE_ID_ADDR:7,PAGE_STATES:{ZERO:0},CALIBRATION:53,SYS_TRIGGER:63,UNIT_SEL_ADDR:59,AXIS_MAP_CONFIG_ADDR:65,AXIS_MAP_SIGN_ADDR:66}},initialize:{value(t,e){const i=t.io,r=e.calibrationMask||192,n=E.addressResolver(this,e),s={accelerometer:{x:null,y:null,z:null},gyro:{x:null,y:null,z:null},magnetometer:{x:null,y:null,z:null},orientation:{euler:{heading:null,roll:null,pitch:null},quarternion:{w:null,x:null,y:null,z:null}},temperature:null,calibration:null};i.i2cConfig(e),i.i2cWriteReg(n,this.REGISTER.OPR_MODE_ADDR,this.REGISTER.OPR_MODES.CONFIG),i.i2cWriteReg(n,this.REGISTER.PAGE_ID_ADDR,this.REGISTER.PAGE_STATES.ZERO),i.i2cWriteReg(n,this.REGISTER.SYS_TRIGGER,32);new Promise(t=>{setTimeout(()=>{i.i2cWriteReg(n,this.REGISTER.PWR_MODE_ADDR,this.REGISTER.PWR_MODES.NORMAL),i.i2cWriteReg(n,this.REGISTER.SYS_TRIGGER,e.enableExternalCrystal?128:0);const r=e.axisMap||36;i.i2cWriteReg(n,this.REGISTER.AXIS_MAP_CONFIG_ADDR,r);const s=e.axisSign||0;i.i2cWriteReg(n,this.REGISTER.AXIS_MAP_SIGN_ADDR,s),setTimeout(()=>{i.i2cWriteReg(n,this.REGISTER.OPR_MODE_ADDR,this.REGISTER.OPR_MODES.NDOF),t()},10)},650)}).then(()=>new Promise(t=>{const e=()=>{i.i2cReadOnce(n,this.REGISTER.CALIBRATION,1,i=>{const n=i[0],o=s.calibration!==n;s.calibration=n,o&&this.emit("calibration",s.calibration),(n&r)===r?(this.emit("calibrated"),t()):e()})};e()})).then(()=>{i.i2cRead(n,this.REGISTER.READ.TEMP,2,t=>{s.temperature=t[0];const e=s.calibration!==t[1];s.calibration=t[1],this.emit("data",s),e&&this.emit("calibration",s.calibration)}),i.i2cRead(n,this.REGISTER.READ.ACCEL,18,t=>{s.accelerometer={x:l(t[1],t[0]),y:l(t[3],t[2]),z:l(t[5],t[4])},s.magnetometer={x:l(t[7],t[6]),y:l(t[9],t[8]),z:l(t[11],t[10])},s.gyro={x:l(t[13],t[12]),y:l(t[15],t[14]),z:l(t[17],t[16])},this.emit("data",s)}),i.i2cRead(n,this.REGISTER.READ.EULER,14,t=>{s.orientation.euler={heading:l(t[1],t[0]),roll:l(t[3],t[2]),pitch:l(t[5],t[4])},s.orientation.quarternion={w:l(t[7],t[6]),x:l(t[9],t[8]),y:l(t[11],t[10]),z:l(t[13],t[12])},this.emit("data",s)})})}},identifier:{value:t=>"bno055-"+E.addressResolver(E.BNO055,t)}},MPL115A2:{ADDRESSES:{value:[96]},REGISTER:{value:{COEFFICIENTS:4,PADC_MSB:0,CONVERT:18}},initialize:{value(t,e){const i=t.io,r=E.addressResolver(this,e);i.i2cConfig(e);const n={pressure:null,temperature:null},s={a0:null,b1:null,b2:null,c12:null},o=t=>{const e=h(t[0],t[1])>>6,i=h(t[2],t[3])>>6;n.pressure=s.a0+(s.b1+s.c12*i)*e+s.b2*i,n.temperature=i,this.emit("data",n),a()};var a=()=>{i.i2cWriteReg(r,this.REGISTER.CONVERT,0),i.i2cReadOnce(r,this.REGISTER.PADC_MSB,4,o)};new Promise(t=>{i.i2cReadOnce(r,this.REGISTER.COEFFICIENTS,8,e=>{const i=l(e[0],e[1]),r=l(e[2],e[3]),n=l(e[4],e[5]),o=l(e[6],e[7])>>2;s.a0=i/8,s.b1=r/8192,s.b2=n/16384,s.c12=o/4194304,t()})}).then(a)}},identifier:{value:t=>"mpl115a2-"+E.addressResolver(E.MPL115A2,t)}},MPL3115A2:{ADDRESSES:{value:[96]},REGISTER:{value:{STATUS:0,PRESSURE:1,CONFIG:19,BAR_IN_MSB:20,BAR_IN_LSB:21,CONTROL:38}},MASK:{value:{STATUS:{PRESSURE_DATA_READ:4},CONTROL:{SBYB:1,OS128:56,ALTIMETER:128,PRESSURE:0},CONFIG:{TDEFE:1,PDEFE:2,DREM:4}}},initialize:{value(t,e){const i=t.io;let r=!1,n=null,s=0;const o=E.addressResolver(this,e);let a=0;const l={pressure:0,altitude:0,temperature:0};void 0!==e.elevation&&(n=e.elevation),null!==n&&n<=0&&(s=Math.abs(n)+1,n=1);const u=t=>{i.i2cReadOnce(o,this.REGISTER.STATUS,1,e=>{e[0]&this.MASK.STATUS.PRESSURE_DATA_READ?t():setTimeout(()=>{u(t)},100)})},d=()=>{const t=r?this.MASK.CONTROL.PRESSURE:this.MASK.CONTROL.ALTIMETER,e=this.MASK.CONTROL.SBYB|this.MASK.CONTROL.OS128|t;i.i2cWrite(o,this.REGISTER.CONTROL,e),u(()=>{i.i2cReadOnce(o,this.REGISTER.PRESSURE,6,t=>{const e=c(t[1],t[2],t[3])>>4,i=h(t[4],t[5])>>4;let n;if(l.temperature=i,r)l.pressure=e,this.emit("data",l);else{n=(t[1]<<8|t[2])+(t[3]>>4)/16,a=(3*a+n)/4,l.altitude=a-s}r=!r,d()})})},p=[],f=()=>{i.i2cWrite(o,this.REGISTER.CONTROL,59),i.i2cWrite(o,this.REGISTER.CONTROL,57),setTimeout(()=>{i.i2cReadOnce(o,this.REGISTER.PRESSURE,6,t=>{const e=t[1],r=t[2],s=(t[3]>>4)/4;if(p.push((e<<10|r<<2)+s),4===p.length){const t=(p[0]+p[1]+p[2]+p[3])/4/(1-225577e-10*n)**5.255;i.i2cWrite(o,this.REGISTER.BAR_IN_MSB,t/2>>8),i.i2cWrite(o,this.REGISTER.BAR_IN_LSB,t/2&255),i.i2cWrite(o,this.REGISTER.CONTROL,187),i.i2cWrite(o,this.REGISTER.CONTROL,185),setTimeout(()=>{i.i2cReadOnce(o,this.REGISTER.PRESSURE,6,t=>{const e=t[1],i=t[2],r=t[3];a=(e<<8|i)+(r>>4)/16,d(!1)})},550)}else f()})},500)};i.i2cConfig(Object.assign(e,{settings:{stopTX:!0}})),i.i2cWriteReg(o,45,0),i.i2cWriteReg(o,this.REGISTER.BAR_IN_MSB,0),i.i2cWriteReg(o,this.REGISTER.BAR_IN_LSB,0),i.i2cWriteReg(o,this.REGISTER.CONFIG,this.MASK.CONFIG.TDEFE|this.MASK.CONFIG.PDEFE|this.MASK.CONFIG.DREM),null!==n?f():d()}},identifier:{value:t=>"mpl3115a2-"+E.addressResolver(E.MPL3115A2,t)}},BMP180:{ADDRESSES:{value:[119]},REGISTER:{value:{COEFFICIENTS:170,READ:0,READ_START:244,READ_RESULT:246}},initialize:{value(t,e){const i=t.io;let r=null,n=0;void 0!==e.elevation&&(r=e.elevation),(null!=r&&r<=0||null==r)&&(n=Math.abs(r)+1,r=1);const o=E.addressResolver(this,e),a=e.mode||3,u=[5,8,14,26][a],d=s.constrain(a,0,3),p={a1:null,a2:null,a3:null,a4:null,a5:null,a6:null,b1:null,b2:null,b5:null,mb:null,mc:null,md:null};i.i2cConfig(e);new Promise(t=>{i.i2cReadOnce(o,this.REGISTER.COEFFICIENTS,22,e=>{p.a1=l(e[0],e[1]),p.a2=l(e[2],e[3]),p.a3=l(e[4],e[5]),p.a4=h(e[6],e[7]),p.a5=h(e[8],e[9]),p.a6=h(e[10],e[11]),p.b1=l(e[12],e[13]),p.b2=l(e[14],e[15]),p.mb=l(e[16],e[17]),p.mc=l(e[18],e[19]),p.md=l(e[20],e[21]),t()})}).then(()=>{const t={altitude:null,pressure:null,temperature:null};let e=0;const a=()=>{const h=0===e,f=h?46:52+(d<<6),g=h?2:3,E=h?5:u;i.i2cWriteReg(o,this.REGISTER.READ_START,f),setTimeout(()=>{i.i2cReadOnce(o,this.REGISTER.READ_RESULT,g,i=>{let o,u,f,g,E,m,v,y,R,b,S;if(h)u=l(i[0],i[1]),f=(u-p.a6)*p.a5>>15,g=(p.mc<<11)/(f+p.md)>>0,p.b5=f+g|0,t.temperature=(p.b5+8>>4)/10;else{u=c(i[0],i[1],i[2])>>8-d,y=p.b5-4e3,b=y*y,S=b>>12,f=p.b2*S>>11,g=p.a2*y>>11,E=f+g,m=(2+(4*p.a1+E<<d))/4>>0,f=p.a3*y>>13,g=p.b1*S>>16,E=f+g+2>>2,v=p.a4*(E+32768)>>15,R=(u-m)*(5e4>>d),o=R<s.POW_2_31?2*R/v:R/v*2,o>>=0,f=(o>>8)*(o>>8),f=3038*f>>16,g=-7357*o>>16,o+=f+g+3791>>4,t.pressure=o;const e=44330*(1-o/(o/(1-225577e-10*r)**5.255)**(1/5.255));t.altitude=Math.round(e-n)}2==++e&&(e=0,this.emit("data",t)),a()})},E)};a()})}},identifier:{value:t=>"bmp180-"+E.addressResolver(E.BMP180,t)}},BMP280:{ADDRESSES:{value:[119]},REGISTER:{value:{COEFFICIENTS:136,CONFIG:245,MEASURE:244,PRESSURE:247,TEMPERATURE:250,RESET:224}},initialize:{value(t,e){const i=t.io;let r=null,n=0;void 0!==e.elevation&&(r=e.elevation),(null!=r&&r<=0||null==r)&&(n=Math.abs(r)+1,r=1);const o=E.addressResolver(this,e),a={T1:null,T2:null,T3:null,P1:null,P2:null,P3:null,P4:null,P5:null,P6:null,P7:null,P8:null,P9:null};i.i2cConfig(e),i.i2cWrite(o,this.REGISTER.RESET,182);new Promise(t=>{i.i2cReadOnce(o,this.REGISTER.COEFFICIENTS,24,e=>{a.T1=h(e[1],e[0]),a.T2=l(e[3],e[2]),a.T3=l(e[5],e[4]),a.P1=h(e[7],e[6]),a.P2=l(e[9],e[8]),a.P3=l(e[11],e[10]),a.P4=l(e[13],e[12]),a.P5=l(e[15],e[14]),a.P6=l(e[17],e[16]),a.P7=l(e[19],e[18]),a.P8=l(e[21],e[20]),a.P9=l(e[23],e[22]),t()})}).then(()=>{i.i2cWrite(o,this.REGISTER.MEASURE,63);const t={altitude:null,pressure:null,temperature:null};i.i2cRead(o,this.REGISTER.PRESSURE,6,e=>{let i,o,l,h=0,p=u(c(e[0],e[1],e[2])),f=u(c(e[3],e[4],e[5]));p>>=4,f>>=4;const g=(f>>4)-a.T1;if(o=((f>>3)-(a.T1<<1))*a.T2>>11,l=(g*g>>12)*a.T3>>14,i=o+l,t.temperature=(5*i+128>>8)/100,o=void 0,l=void 0,o=u(i>>1)-64e3,l=((o>>2)*(o>>2)>>11)*u(a.P6),l+=o*u(a.P5)<<1,l=(l>>2)+(u(a.P4)<<16),o=(a.P3*((o>>2)*(o>>2)>>13)>>3)+(u(a.P2)*o>>1)>>18,o=(s.POW_2_15+o)*u(a.P1)>>15,0===o)return 0;h=3125*d(u(s.POW_2_20)-p-(l>>12)),h=h<s.POW_2_31?(h<<1>>>0)/d(o):2*(h/d(o)>>>0),h=d(h)>>>0;const E=h>>3;o=u(a.P9)*u(E*E>>13)>>12,l=u(h>>2)*u(a.P8)>>13,h=d(u(h)+(o+l+a.P7>>4)),t.pressure=h;const m=44330*(1-h/(h/(1-225577e-10*r)**5.255)**(1/5.255));t.altitude=Math.round(m-n),this.emit("data",t)})})}},identifier:{value:t=>"bmp280-"+E.addressResolver(E.BMP280,t)}},BME280:{ADDRESSES:{value:[119]},REGISTER:{value:{COEFFICIENTS_TP:136,COEFFICIENTS_H:225,CONFIG:245,MEASURE_H:242,MEASURE_TP:244,PRESSURE:247,TEMPERATURE:250,HUMIDITY:253,RESET:224}},initialize:{value(t,i){const r=t.io;let n=null,o=0;void 0!==i.elevation&&(n=i.elevation),(null!=n&&n<=0||null==n)&&(o=Math.abs(n)+1,n=1);const a=E.addressResolver(this,i),p={T1:null,T2:null,T3:null,P1:null,P2:null,P3:null,P4:null,P5:null,P6:null,P7:null,P8:null,P9:null,H1:null,H2:null,H3:null,H4:null,H5:null,H6:null};r.i2cConfig(i),r.i2cWrite(a,this.REGISTER.RESET,182);new Promise(t=>{Promise.all([new Promise(t=>{r.i2cReadOnce(a,136,24,e=>{p.T1=h(e[1],e[0]),p.T2=l(e[3],e[2]),p.T3=l(e[5],e[4]),p.P1=h(e[7],e[6]),p.P2=l(e[9],e[8]),p.P3=l(e[11],e[10]),p.P4=l(e[13],e[12]),p.P5=l(e[15],e[14]),p.P6=l(e[17],e[16]),p.P7=l(e[19],e[18]),p.P8=u(l(e[21],e[20])),p.P9=u(l(e[23],e[22])),t()})}),new Promise(t=>{r.i2cReadOnce(a,161,1,e=>{p.H1=s.u8(e[0]),t()})}),new Promise(t=>{r.i2cReadOnce(a,225,8,e=>{p.H2=u(l(e[1],e[0])),p.H3=u(e[2]),p.H4=u(e[3]<<4|15&e[4]),p.H5=u(e[5]<<4|e[4]>>4),p.H6=s.s8(e[6]),t()})})]).then(t)}).then(()=>{r.i2cWrite(a,this.REGISTER.MEASURE_H,5),r.i2cWrite(a,this.REGISTER.MEASURE_TP,183);const t={altitude:null,pressure:null,humidity:null,temperature:null},i=Date.now();r.i2cRead(a,this.REGISTER.PRESSURE,8,r=>{if(!e.env.IS_TEST_MODE&&i+1e3>Date.now())return;let a,l,f,g,E=0,m=u(c(r[0],r[1],r[2])),v=u(c(r[3],r[4],r[5]));const y=u(h(r[6],r[7]));m>>=4,v>>=4;const R=(v>>4)-p.T1;if(l=((v>>3)-(p.T1<<1))*p.T2>>11,f=(R*R>>12)*p.T3>>14,a=l+f,t.temperature=(5*a+128>>8)/100,l=void 0,f=void 0,l=u(a>>1)-64e3,f=((l>>2)*(l>>2)>>11)*u(p.P6),f+=l*u(p.P5)<<1,f=(f>>2)+(u(p.P4)<<16),l=(p.P3*((l>>2)*(l>>2)>>13)>>3)+(u(p.P2)*l>>1)>>18,l=(s.POW_2_15+l)*u(p.P1)>>15,0===l)return 0;E=3125*d(u(s.POW_2_20)-m-(f>>12)),E=E<s.POW_2_31?(E<<1>>>0)/d(l):2*(E/d(l)>>>0),E=d(E)>>>0;const b=E>>3;l=u(p.P9)*u(b*b>>13)>>12,f=u(E>>2)*p.P8>>13,E=d(u(E)+(l+f+p.P7>>4)),t.pressure=E;const S=44330*(1-E/(E/(1-225577e-10*n)**5.255)**(1/5.255));t.altitude=Math.round(S-o),g=u(a-76800),g=((y<<14)-u(p.H4<<20)-p.H5*g+s.POW_2_14>>15)*((((g*p.H6>>10)*((g*p.H3>>11)+s.POW_2_15)>>10)+s.POW_2_21)*p.H2+s.POW_2_13>>14),g-=((g>>15)*(g>>15)>>7)*u(p.H1)>>4,g=s.constrain(g,0,419430400),t.humidity=d(g>>12),this.emit("data",t)})})}},identifier:{value:t=>"bme280-"+E.addressResolver(E.BME280,t)}},SI7020:{ADDRESSES:{value:[64]},REGISTER:{value:{HUMIDITY:229,TEMPERATURE:224}},initialize:{value(t,e){const i=t.io,r=E.addressResolver(this,e);e.delay=5e4,i.i2cConfig(e);const n={temperature:null,humidity:null};i.i2cRead(r,this.REGISTER.TEMPERATURE,2,t=>{n.temperature=h(t[0],t[1]),this.emit("data",n)}),i.i2cRead(r,this.REGISTER.HUMIDITY,2,t=>{n.humidity=h(t[0],t[1]),this.emit("data",n)})}},identifier:{value:t=>"si7020-"+E.addressResolver(E.SI7020,t)}},MS5611:{ADDRESSES:{value:[119]},REGISTER:{value:{COEFFICIENTS:162,READ:0,PRESSURE:64,TEMPERATURE:80,RESET:30}},initialize:{value(t,e){const i=t.io;let r=null,n=0;void 0!==e.elevation&&(r=e.elevation),(null!=r&&r<=0||null==r)&&(n=Math.abs(r)+1,r=1);const o=E.addressResolver(this,e),a={altitude:null,pressure:null,temperature:null},l=e.mode||5,u=[1,2,3,4,5,10][l],d={C1:null,C2:null,C3:null,C4:null,C5:null,C6:null},p=Object.keys(d);e.delay=1e3*u,i.i2cConfig(e),i.i2cWrite(o,this.REGISTER.RESET);new Promise(t=>{setTimeout(()=>{const e=p.map((t,e)=>{const r=this.REGISTER.COEFFICIENTS+2*e;return new Promise(e=>{i.i2cReadOnce(o,r,2,i=>{d[t]=h(i[0],i[1]),e()})})});Promise.all(e).then(t)},50)}).then(()=>{let t,e,h,p,f,g,E,m,v,y,R=0;const b=()=>{const S=0===R,T=(S?80:64)+l;i.i2cWrite(o,T),S?(e=0,h=0,p=0,m=0,v=0,y=0):(t=0,f=0,g=0,E=0),setTimeout(()=>{i.i2cReadOnce(o,this.REGISTER.READ,3,i=>{if(S)e=c(i[0],i[1],i[2]),h=e-d.C5*s.POW_2_8,p=2e3+h*d.C6/s.POW_2_23,p<2e3&&(m=h**2/s.POW_2_31,v=5*(p-2e3)**2/2,y=5*(p-2e3)**2/s.POW_2_2,p<-1500&&(v+=7*(p+1500)**2,y+=11*(p+1500)**2/2)),p-=m,a.temperature=p/100;else{t=c(i[0],i[1],i[2]),f=d.C2*s.POW_2_16+d.C4*h/s.POW_2_7,g=d.C1*s.POW_2_15+d.C3*h/s.POW_2_8,f-=v,g-=y,E=(t*g/s.POW_2_21-f)/s.POW_2_15,a.pressure=E;const e=44330*(1-E/(E/(1-225577e-10*r)**5.255)**(1/5.255));a.altitude=e-n}2==++R&&(R=0,this.emit("data",a)),b()})},u)};b()})}},identifier:{value:t=>"ms5611-"+E.addressResolver(E.MS5611,t)}},TH02:{ADDRESSES:{value:[64]},COMMAND:{value:{MEASURE_HUMIDITY:1,MEASURE_TEMPERATURE:17}},REGISTER:{value:{STATUS:0,READ:1,CONFIG:3}},initialize:{value(t,e){const i=t.io,r=E.addressResolver(this,e),n={temperature:null,humidity:null};let s=0;i.i2cConfig(Object.assign(e,{settings:{stopTX:!0}}));const o=()=>{const t=0===s,e=t?this.COMMAND.MEASURE_TEMPERATURE:this.COMMAND.MEASURE_HUMIDITY;new Promise(t=>{i.i2cWrite(r,this.REGISTER.CONFIG,e);const n=()=>{i.i2cReadOnce(r,this.REGISTER.STATUS,1,e=>{1&e[0]?n():t()})};n()}).then(()=>{Promise.all([new Promise(t=>{i.i2cReadOnce(r,1,1,e=>{t(e[0])})}),new Promise(t=>{i.i2cReadOnce(r,2,1,e=>{t(e[0])})})]).then(e=>{t?n.temperature=(h(e[0],e[1])>>2)/32-50:n.humidity=(h(e[0],e[1])>>4)/16-24,2==++s&&(s=0,this.emit("data",n)),o()})})};o()}},identifier:{value:t=>"th02-"+E.addressResolver(E.TH02,t)}},LSM303C:{ADDRESSES:{value:[29,30]},COMMAND:{value:{ACC_SETUP:[4,63,63,63],MAG_SETUP:[216,96,64,216,8,0]}},REGISTER:{value:{ACC_CTRL_SEQ:[35,32,32,32],ACC_STATUS:39,ACC_OUTX_L:40,ACC_OUTX_H:41,ACC_OUTY_L:42,ACC_OUTY_H:43,ACC_OUTZ_L:44,ACC_OUTZ_H:45,MAG_CTRL_SEQ:[32,33,36,32,35,34],MAG_STATUS:39,MAG_OUTX_L:40,MAG_OUTX_H:41,MAG_OUTY_L:42,MAG_OUTY_H:43,MAG_OUTZ_L:44,MAG_OUTZ_H:45,MAG_TEMP_OUT_L:46,MAG_TEMP_OUT_H:47}},initialize:{value(t,e){const i=t.io,r=this.freq||40,[n,s]=this.ADDRESSES,o={},a={},h={temperature:0,magnetometer:a,accelerometer:o},c=t=>{i.i2cReadOnce(n,this.REGISTER.ACC_OUTX_L,6,e=>{o.x=.06103515625*l(e[1],e[0]),o.y=.06103515625*l(e[3],e[2]),o.z=.06103515625*l(e[5],e[4]),t()})},u=t=>{i.i2cReadOnce(s,this.REGISTER.MAG_OUTX_L,6,e=>{a.x=.00048828125*l(e[1],e[0]),a.y=.00048828125*l(e[3],e[2]),a.z=.00048828125*l(e[5],e[4]),t()})},d=t=>{i.i2cReadOnce(s,this.REGISTER.MAG_TEMP_OUT_L,2,e=>{h.temperature=l(e[1],e[0]),t()})},p=()=>{Promise.all([new Promise(c),new Promise(u),new Promise(d)]).then(()=>{this.emit("data",h),setTimeout(p,r)})};(()=>{i.i2cConfig(Object.assign({},e,{address:n})),this.REGISTER.ACC_CTRL_SEQ.forEach((t,e)=>{i.i2cWrite(n,t,this.COMMAND.ACC_SETUP[e])})})(),(()=>{i.i2cConfig(Object.assign({},e,{address:s})),this.REGISTER.MAG_CTRL_SEQ.forEach((t,e)=>{i.i2cWrite(s,t,this.COMMAND.MAG_SETUP[e])})})(),p()}},identifier:{value:t=>"lsm303c-"+E.addressResolver(E.LSM303C,t)}}};E.BMP085=E.BMP180,E.GY521=E.MPU6050,E.SI7021=E.SI7020,E.DHT11_I2C_NANO_BACKPACK=E.DHT_I2C_NANO_BACKPACK,E.DHT21_I2C_NANO_BACKPACK=E.DHT_I2C_NANO_BACKPACK,E.DHT22_I2C_NANO_BACKPACK=E.DHT_I2C_NANO_BACKPACK,E.get=(t,e,i={})=>{let r,s,o;return a.has(t)||a.set(t,{}),r=a.get(t),s=E[e].identifier.value(i),r[s]||(o=new n,Object.defineProperties(o,E[e]),o.initialize(t,i),r[s]=o),r[s]},E.addressResolver=(t,e)=>{const i=t.ADDRESSES,r=e.address||(Array.isArray(i)?i[0]:i.value[0]);return e.address=r,r},E.clear=()=>{a.clear()};const m={MPU6050:{initialize:{value(t){f.call(this,"MPU6050",t)}},components:{value:["accelerometer","gyro",p]}},BNO055:{initialize:{value(t){o.get(this).calibrationMask=t.calibrationMask||192,E.get(this.board,"BNO055",t).on("calibrated",()=>this.emit("calibrated")).on("calibration",t=>this.emit("calibration",t)),f.call(this,"BNO055",t)}},components:{value:["accelerometer","gyro","magnetometer","orientation",p]},calibration:{get(){return this.orientation.calibration}},isCalibrated:{get(){const{calibrationMask:t}=o.get(this);return(this.orientation.calibration&t)===t}}},MPL115A2:{initialize:{value(t){f.call(this,"MPL115A2",t)}},components:{value:["barometer",p]}},SHT31D:{initialize:{value(t){f.call(this,"SHT31D",t)}},components:{value:["hygrometer",p]}},HTU21D:{initialize:{value(t){f.call(this,"HTU21D",t)}},components:{value:["hygrometer",p]}},HIH6130:{initialize:{value(t){f.call(this,"HIH6130",t)}},components:{value:["hygrometer",p]}},DHT_I2C_NANO_BACKPACK:{initialize:{value(t){f.call(this,"DHT_I2C_NANO_BACKPACK",t)}},components:{value:["hygrometer",p]}},MPL3115A2:{initialize:{value(t){f.call(this,"MPL3115A2",t)}},components:{value:["altimeter","barometer",p]}},BMP180:{initialize:{value(t){f.call(this,"BMP180",t)}},components:{value:["altimeter","barometer",p]}},BMP280:{initialize:{value(t){f.call(this,"BMP280",t)}},components:{value:["altimeter","barometer",p]}},BME280:{initialize:{value(t){f.call(this,"BME280",t)}},components:{value:["altimeter","barometer","hygrometer",p]}},SI7020:{initialize:{value(t){f.call(this,"SI7020",t)}},components:{value:["hygrometer",p]}},MS5611:{initialize:{value(t){f.call(this,"MS5611",t)}},components:{value:["altimeter","barometer",p]}},TH02:{initialize:{value(t){f.call(this,"TH02",t)}},components:{value:["hygrometer",p]}},LSM303C:{initialize:{value(t){f.call(this,"LSM303C",t)}},components:{value:["magnetometer",p,"accelerometer"]}}};m.BMP085=m.BMP180,m.GY521=m.MPU6050,m.SI7021=m.SI7020,m.DHT11_I2C_NANO_BACKPACK=m.DHT_I2C_NANO_BACKPACK,m.DHT21_I2C_NANO_BACKPACK=m.DHT_I2C_NANO_BACKPACK,m.DHT22_I2C_NANO_BACKPACK=m.DHT_I2C_NANO_BACKPACK;class v extends n{constructor(t){super(),r.Component.call(this,t=r.Options(t)),r.Controller.call(this,m,t);o.set(this,{}),this.freq=t.freq||20,"function"==typeof this.initialize&&this.initialize(t),this.isReady=!1,setInterval(()=>{this.isReady&&this.emit("data",this)},this.freq);const e=this.components.slice();this.components&&this.components.length>0&&this.components.forEach(t=>{this[t]instanceof n&&this[t].on("change",()=>{if(e.length){const i=e.indexOf(t);-1!==i&&e.splice(i,1)}e.length||this.isReady||(this.isReady=!0),this.isReady&&this.emit("change",this,t)})})}}v.Drivers=E,e.env.IS_TEST_MODE&&(v.Controllers=m,v.purge=()=>{o.clear()}),t.exports=v}).call(this,i(1))},function(t,e){var i,r,n=t.exports={};function s(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function a(t){if(i===setTimeout)return setTimeout(t,0);if((i===s||!i)&&setTimeout)return i=setTimeout,setTimeout(t,0);try{return i(t,0)}catch(e){try{return i.call(null,t,0)}catch(e){return i.call(this,t,0)}}}!function(){try{i="function"==typeof setTimeout?setTimeout:s}catch(t){i=s}try{r="function"==typeof clearTimeout?clearTimeout:o}catch(t){r=o}}();var l,h=[],c=!1,u=-1;function d(){c&&l&&(c=!1,l.length?h=l.concat(h):u=-1,h.length&&p())}function p(){if(!c){var t=a(d);c=!0;for(var e=h.length;e;){for(l=h,h=[];++u<e;)l&&l[u].run();u=-1,e=h.length}l=null,c=!1,function(t){if(r===clearTimeout)return clearTimeout(t);if((r===o||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(t);try{r(t)}catch(e){try{return r.call(null,t)}catch(e){return r.call(this,t)}}}(t)}}function f(t,e){this.fun=t,this.array=e}function g(){}n.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var i=1;i<arguments.length;i++)e[i-1]=arguments[i];h.push(new f(t,e)),1!==h.length||c||a(p)},f.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=g,n.addListener=g,n.once=g,n.off=g,n.removeListener=g,n.removeAllListeners=g,n.emit=g,n.prependListener=g,n.prependOnceListener=g,n.listeners=function(t){return[]},n.binding=function(t){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(t){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},function(t,e,i){"use strict";var r,n="object"==typeof Reflect?Reflect:null,s=n&&"function"==typeof n.apply?n.apply:function(t,e,i){return Function.prototype.apply.call(t,e,i)};r=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var o=Number.isNaN||function(t){return t!=t};function a(){a.init.call(this)}t.exports=a,a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var l=10;function h(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function c(t){return void 0===t._maxListeners?a.defaultMaxListeners:t._maxListeners}function u(t,e,i,r){var n,s,o,a;if(h(i),void 0===(s=t._events)?(s=t._events=Object.create(null),t._eventsCount=0):(void 0!==s.newListener&&(t.emit("newListener",e,i.listener?i.listener:i),s=t._events),o=s[e]),void 0===o)o=s[e]=i,++t._eventsCount;else if("function"==typeof o?o=s[e]=r?[i,o]:[o,i]:r?o.unshift(i):o.push(i),(n=c(t))>0&&o.length>n&&!o.warned){o.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=t,l.type=e,l.count=o.length,a=l,console&&console.warn&&console.warn(a)}return t}function d(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function p(t,e,i){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:i},n=d.bind(r);return n.listener=i,r.wrapFn=n,n}function f(t,e,i){var r=t._events;if(void 0===r)return[];var n=r[e];return void 0===n?[]:"function"==typeof n?i?[n.listener||n]:[n]:i?function(t){for(var e=new Array(t.length),i=0;i<e.length;++i)e[i]=t[i].listener||t[i];return e}(n):E(n,n.length)}function g(t){var e=this._events;if(void 0!==e){var i=e[t];if("function"==typeof i)return 1;if(void 0!==i)return i.length}return 0}function E(t,e){for(var i=new Array(e),r=0;r<e;++r)i[r]=t[r];return i}Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return l},set:function(t){if("number"!=typeof t||t<0||o(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");l=t}}),a.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},a.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||o(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},a.prototype.getMaxListeners=function(){return c(this)},a.prototype.emit=function(t){for(var e=[],i=1;i<arguments.length;i++)e.push(arguments[i]);var r="error"===t,n=this._events;if(void 0!==n)r=r&&void 0===n.error;else if(!r)return!1;if(r){var o;if(e.length>0&&(o=e[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var l=n[t];if(void 0===l)return!1;if("function"==typeof l)s(l,this,e);else{var h=l.length,c=E(l,h);for(i=0;i<h;++i)s(c[i],this,e)}return!0},a.prototype.addListener=function(t,e){return u(this,t,e,!1)},a.prototype.on=a.prototype.addListener,a.prototype.prependListener=function(t,e){return u(this,t,e,!0)},a.prototype.once=function(t,e){return h(e),this.on(t,p(this,t,e)),this},a.prototype.prependOnceListener=function(t,e){return h(e),this.prependListener(t,p(this,t,e)),this},a.prototype.removeListener=function(t,e){var i,r,n,s,o;if(h(e),void 0===(r=this._events))return this;if(void 0===(i=r[t]))return this;if(i===e||i.listener===e)0==--this._eventsCount?this._events=Object.create(null):(delete r[t],r.removeListener&&this.emit("removeListener",t,i.listener||e));else if("function"!=typeof i){for(n=-1,s=i.length-1;s>=0;s--)if(i[s]===e||i[s].listener===e){o=i[s].listener,n=s;break}if(n<0)return this;0===n?i.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(i,n),1===i.length&&(r[t]=i[0]),void 0!==r.removeListener&&this.emit("removeListener",t,o||e)}return this},a.prototype.off=a.prototype.removeListener,a.prototype.removeAllListeners=function(t){var e,i,r;if(void 0===(i=this._events))return this;if(void 0===i.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==i[t]&&(0==--this._eventsCount?this._events=Object.create(null):delete i[t]),this;if(0===arguments.length){var n,s=Object.keys(i);for(r=0;r<s.length;++r)"removeListener"!==(n=s[r])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=i[t]))this.removeListener(t,e);else if(void 0!==e)for(r=e.length-1;r>=0;r--)this.removeListener(t,e[r]);return this},a.prototype.listeners=function(t){return f(this,t,!0)},a.prototype.rawListeners=function(t){return f(this,t,!1)},a.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):g.call(t,e)},a.prototype.listenerCount=g,a.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}},function(t,e,i){(function(e){const r=i(2),n=i(58),s=i(5),o=i(4),a=i(32),l=i(33),h=i(67);let c,u=!!e.env.IS_TEST_MODE;const d=[],p=/usb|acm|^com/i,f="undefined",g={used:[],attempts:[],detect(t){let r;r=parseFloat(e.versions.nw)>=.13?i(68):i(18),r.list().then(e=>{const i=e.reduce((t,e)=>{let i=!0;return p.test(e.path)||(i=!1),g.used.includes(e.path)&&(i=!1),i&&t.push(e.path),t},[]);if(!i.length){if(u&&this.abort)return;return g.attempts[g.used.length]||(g.attempts[g.used.length]=0,this.info("Board","Looking for connected device")),g.attempts[g.used.length]++,g.attempts[g.used.length]>10?void this.fail("Board","No connected device found"):void setTimeout(()=>{g.detect.call(this,t)},400)}this.info("Available",n.grey(i)),t.call(this,i[0])})},connect(t,e){const r=i(73).Board;let s,o,a,l,h=null;"object"==typeof t&&t.path?(a=t.path,this.info(t.transport||"SerialPort",n.grey(a))):a=t,g.used.push(a);try{s=new r(t,t=>{t&&(h=t),e.call(this,h,h?"error":"ready",s)}),s.name="Firmata",s.defaultLed=13,s.port=a,o=!0}catch(t){h=t}h&&(h=h.message||h),l=o?"connect":"error",e.call(this,h,l,s)}};class E extends r{constructor(t={}){super();const i={};let r=!1;Object.assign(this,t),this.timer=null,this.isConnected=!1,this.isReady=!1,this.io=this.io||null,this.register=[],this.occupied=[],this.Drivers={},this.id||(this.id=o.uid()),typeof this.debug===f&&(this.debug=!0),typeof this.repl===f&&(this.repl=!0),typeof this.sigint===f&&(this.sigint=!0),this.pins=null,this.repl&&(a.ref?(i[this.id]=this,a.ref.on("ready",(function(){a.ref.inject(i)})),this.repl=a.ref):(i[this.id]=i.board=this,this.repl=new a(i))),t.io?(this.io=t.io,this.isReady=t.io.isReady,this.transport=this.io.transport||null,this.port=this.io.name,this.pins=E.Pins(this),this.RESOLUTION=Object.assign({ADC:1023,DAC:null,PWM:255},this.io.RESOLUTION||{})):this.port&&t.port?g.connect.call(this,this.port,m):g.detect.call(this,(function(t){g.connect.call(this,t,m)})),t.port||null===this.io||(this.info("Available",n.grey(this.io.name||"unknown")),["connect","ready"].forEach(t=>{this.io.once(t,()=>{"ready"!==t||this.isConnected?m.call(this,null,t,this.io):r=!0,"connect"===t&&r&&m.call(this,null,"ready",this.io)}),this.io.isReady&&e.nextTick(()=>this.io.emit(t))})),this.once("ready",()=>{const t=e.hrtime();this.millis=function(){return e.hrtime(t)[1]/1e6},["close","disconnect","error","string"].forEach(t=>{this.io.on(t,e=>this.emit(t,e))})}),d.push(this)}}function m(t,i,r){let s=!1;this.io||(this.io=r),"error"===i&&t&&t.message&&(s=!0,this.error("Error",t.message)),"connect"===i&&(this.isConnected=!0,this.port=r.port||r.name,this.info("Connected",n.grey(this.port)),u||(this.timer=setTimeout(()=>{this.error("Device or Firmware Error","A timeout occurred while connecting to the Board. \n\nPlease check that you've properly flashed the board with the correct firmware.\nSee: https://github.com/rwaldron/johnny-five/wiki/Getting-Started#trouble-shooting\n\nIf connecting to a Leonardo or Leonardo clone, press the 'Reset' button on the board, wait approximately 11 seconds for complete reset, then run your program again."),this.emit("error",new Error("A timeout occurred while connecting to the Board."))},this.timeout||1e4))),"ready"===i&&(this.timer&&clearTimeout(this.timer),this.isReady=!0,this.pins=E.Pins(this),this.MODES=this.io.MODES,typeof r.debug!==f&&!1===r.debug&&(this.debug=!1),typeof r.repl!==f&&!1===r.repl&&(this.repl=!1),this.repl&&this.repl.initialize(()=>this.emit("ready")),"Mock"!==r.name&&this.sigint&&e.on("SIGINT",()=>{this.emit("exit"),this.warn("Board","Closing.");const t=setTimeout(()=>{e.reallyExit()},1e3),i=setInterval(()=>{this.io.pending||(clearInterval(i),clearTimeout(t),e.nextTick(e.reallyExit))},1)}),this.RESOLUTION=Object.assign({ADC:1023,DAC:null,PWM:255},r.RESOLUTION||{})),this.repl?"connect"===i&&this.emit(i,t):s||this.emit(i,t)}["digitalWrite","analogWrite","analogRead","digitalRead","pinMode","queryPinState","stepperConfig","stepperStep","sendI2CConfig","sendI2CWriteRequest","sendI2CReadRequest","i2cConfig","i2cWrite","i2cWriteReg","i2cRead","i2cReadOnce","pwmWrite","servoConfig","servoWrite","sysexCommand","sysexResponse","serialConfig","serialWrite","serialRead","serialStop","serialClose","serialFlush","serialListen"].forEach((function(t){E.prototype[t]=function(){return this.io[t].apply(this.io,arguments),this}})),E.prototype.snapshot=function(t){const e=this.snapshot.blacklist,i=this.snapshot.special,r="function"==typeof t;return this.register.reduce((n,s)=>(typeof s.components===f&&n.push(Object.getOwnPropertyNames(s).reduce((n,o)=>{const a=s[o];if(!e.includes(o)&&"function"!=typeof a)if(r){const e=t(o,a,s);void 0!==e&&(n[o]=e)}else n[o]=i[o]?i[o](a):a;return n},Object.create(null))),n),[])},E.prototype.serialize=function(t){return JSON.stringify(this.snapshot(t))},E.prototype.snapshot.blacklist=["board","io","_events","_eventsCount","state"],E.prototype.samplingInterval=function(t){if(!this.io.setSamplingInterval)throw new Error("This IO plugin does not implement an interval adjustment method");return this.io.setSamplingInterval(t),this},E.prototype.snapshot.special={mode:function(t){return["INPUT","OUTPUT","ANALOG","PWM","SERVO"][t]||"unknown"}},E.prototype.shiftOut=function(t,e,i,r){3===arguments.length&&(r=i,i=!0);for(let n=0;n<8;n++)this.io.digitalWrite(e,0),i?this.io.digitalWrite(t,0|!!(r&1<<7-n)):this.io.digitalWrite(t,0|!!(r&1<<n)),this.io.digitalWrite(e,1)};const v={specials:["error","fail","warn","info"],colors:{log:"white",error:"red",fail:"inverse",warn:"yellow",info:"cyan"}};E.prototype.log=function(){var t=Array.from(arguments);v.specials.includes(t[0])||t.unshift("log");var e=t.shift(),i=t.shift(),r=t.shift(),s=v.colors[e],o=Date.now(),a={type:e,timestamp:o,class:i,message:"",data:null};"object"==typeof t[t.length-1]&&(a.data=t.pop()),r+=" "+t.join(", "),a.message=r.trim(),this.debug&&console.log([n.grey(o),n.magenta(i),n[s](r),t.join(", ")].join(" ")),this.emit(e,a),this.emit("message",a)},v.specials.forEach((function(t){E.prototype[t]=function(){var e=[].slice.call(arguments);e.unshift(t),this.log.apply(this,e)}})),E.prototype.wait=function(t,e){return setTimeout(e,t),this},E.prototype.loop=function(t,e){var i=setInterval((function(){e((function(){clearInterval(i)}))}),t);return this},E.map=o.map,E.fmap=o.fmap,E.constrain=o.constrain,E.range=o.range,E.uid=o.uid,E.mount=function(t){var e="number"==typeof t&&t;return t&&t.board?t.board:"number"==typeof e?d[e]||null:d.length?d[0]:null},E.Component=function(t,e){var r;if(typeof t===f&&(t={}),typeof e===f&&(e={}),this.board=E.mount(t),this.io=this.board.io,this.id=t.id||E.uid(),this.custom=t.custom||{},"number"==typeof t.pin||"string"==typeof t.pin)r=[t.pin];else if(Array.isArray(t.pins))r=t.pins.slice();else if("object"==typeof t.pins&&null!==t.pins){var n=t.pins||t.pin;for(var s in r=[],n)r.push(n[s])}t.controller&&("string"==typeof t.controller&&(t.controller=t.controller.replace(/-/g,"")),c||(c=i(8)),c.hasController(t.controller)&&(e={normalizePin:!1,requestPin:!1})),(e=E.Component.initialization(e)).normalizePin&&(t=E.Pins.normalize(t,this.board)),typeof t.pins!==f&&(this.pins=t.pins||[]),typeof t.pin!==f&&(this.pin=t.pin),typeof t.emitter!==f&&(this.emitter=t.emitter),typeof t.address!==f&&(this.address=t.address),typeof t.controller!==f&&(this.controller=t.controller),typeof t.bus!==f&&(this.bus=t.bus),this.board.register.push(this)},E.Component.initialization=function(t){return Object.assign({},{requestPin:!0,normalizePin:!0},t)},E.Controller=function(t,e){let i;if(i="string"==typeof e.controller?t[e.controller]||t[e.controller.toUpperCase()]:e.controller||t.DEFAULT||null,null===i)throw new Error("No Valid Controller Found");let r=i.requirements&&i.requirements.value;r&&r.options&&Object.keys(r.options).forEach((function(t){if(typeof e[t]===f||typeof e[t]!==r.options[t].typeof){if(r.options[t].throws)throw new Error(r.options[t].message);this.board.warn(this.constructor.name,r.options[t].message)}}),this),Object.defineProperties(this,i)},E.Pins=h,E.Options=function(t){return new l(t)},Object.defineProperty(E,"cache",{get:()=>d}),E.Event=function(t){if(typeof t===f)throw new Error("Board.Event missing Event object");this.type=t.type||"data",this.target=t.target||null,Object.assign(this,t)};class y extends s{constructor(t){let e;if(Array.isArray(t)&&(e=t.slice(),t={ports:e}),Array.isArray(t)||"object"!=typeof t||void 0===t.ports||(e=t.ports),!Array.isArray(e))throw new Error("Expected ports to be an array");typeof t.debug===f&&(t.debug=!0),typeof t.repl===f&&(t.repl=!0);const i={},r=e.some(({repl:t})=>!1===t),s=e.some(({debug:t})=>!1===t);super(e.map(t=>{let e;return"string"==typeof t?(e={},p.test(t)?e.port=t:e.id=t):e=t,e.repl=!1,new E(e)})),this.debug=t.debug,this.repl=t.repl,s&&(this.debug=!1),r&&(this.repl=!1);const o=this.map((t,e)=>(i[t.id]=t,new Promise(t=>{this[e].on("error",t=>this.emit("error",t)),this[e].on("fail",t=>this.emit("fail",t)),this[e].on("ready",()=>t(this[e]))})));Promise.all(o).then(()=>{this.each(t=>{t.info("Board ID: ",n.green(t.id))}),this.repl?(this.repl=new a(Object.assign({},i,{board:this})),this.repl.initialize(()=>this.emit("ready",i))):this.emit("ready",i)}).catch(t=>{console.error(n.red(t))})}static get type(){return E}}s.installMethodForwarding(y.prototype,E.prototype),Object.assign(y.prototype,r.prototype),y.prototype.byId=function(t){for(var e=0;e<this.length;e++)if(this[e].id===t)return this[e];return null},y.prototype.log=E.prototype.log,v.specials.forEach((function(t){y.prototype[t]=function(){var e=[].slice.call(arguments);e.unshift(t),this.log.apply(this,e)}})),u&&(g.purge=function(){g.used.length=0},E.Serial=g,E.purge=function(){E.Pins.normalize.clear(),a.isActive=!1,a.isBlocked=!0,a.ref=null,d.length=0},E.testMode=function(t){if(!arguments.length)return u;u=t}),E.Array=y,E.Collection=y,t.exports=E}).call(this,i(1))},function(t,e,i){const r={debounce:i(65),cloneDeep:i(66)},{ceil:n,max:s,min:o,PI:a}=Math;r.toFixed=(t,e)=>+(t||0).toFixed(e),r.map=(t,e,i,r,n)=>(t-e)*(n-r)/(i-e)+r|0,r.scale=r.map;const l=new Float32Array(1);r.fmap=(t,e,i,r,n)=>(l[0]=(t-e)*(n-r)/(i-e)+r,l[0]),r.fscale=r.fmap,r.constrain=(t,e,i)=>o(i,s(e,t)),r.inRange=(t,e,i)=>t>=e&&t<=i,r.range=function(t,e,i){1===arguments.length&&(e=t-1,t=0);const r=s(n(((e=e||0)-(t=t||0))/(i=i||1)),0);let o=0;const a=[];for(;o<=r;)a[o++]=t,t+=i;return a},r.uid=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}).toUpperCase(),r.square=t=>t*t,r.sum=function(t){let e;return e=Array.isArray(t)?t:[].slice.call(arguments),e.reduce((t,e)=>t+e,0)},r.fma=(t,e,i)=>{let r,n=134217729*t;n+=t-n,r=t-n;let s,o=134217729*e;o+=e-o,s=e-o;const a=t*e,l=a+i;return l+(a-(l-i)+(i-(l-a))+(n*o-a+n*s+r*o+r*s))},r._BV=r.bitValue=r.bv=t=>1<<t,r.int16=(t,e)=>{const i=t<<8|e;return i>>15?-1*(1+(65535^i)):i},r.uint16=(t,e)=>t<<8|e,r.int24=(t,e,i)=>{const r=t<<16|e<<8|i;return r>>23?-1*(1+(16777215^r)):r},r.uint24=(t,e,i)=>t<<16|e<<8|i,r.int32=(t,e,i,r)=>{const n=t<<24|e<<16|i<<8|r;return n>>31?-1*(1+(4294967295^n)):n},r.uint32=(t,e,i,r)=>(t<<24|e<<16|i<<8|r)>>>0,r.bitSize=t=>Math.round(Math.log2(t));const h=r.bitSize(Number.MAX_SAFE_INTEGER)+1;for(let t=0;t<h;t++)r["POW_2_"+t]=2**t;[4,8,10,12,16,20,24,32].forEach(t=>{const e=r["POW_2_"+t],i=e/2>>>0,n=i-1;r["u"+t]=t=>(t<0&&(t+=e),r.constrain(t,0,e-1)),r["s"+t]=t=>(t>n&&(t-=e),r.constrain(t,-i,n))}),r.RAD_TO_DEG=180/a,r.DEG_TO_RAD=a/180,r.TAU=2*a,t.exports=r},function(t,e,i){const r=i(2);class n{constructor(t){const e=this.type;let i=[];if(this.length=0,Array.isArray(t))i=t;else if(Array.isArray(t.pins)){const e=Object.keys(t).filter(t=>"pins"!==t);i=t.pins.map(i=>{const r={};return Array.isArray(i)?r.pins=i:r.pin=i,e.reduce((e,i)=>(e[i]=t[i],e),r)})}if(i.length)for(;i.length;){let t=i.shift();"function"==typeof e&&(t instanceof e||t instanceof this.constructor||(t=new e(t))),this.add(t)}}slice(){return new this.constructor([].slice.apply(this,arguments))}}n.prototype[Symbol.iterator]=Array.prototype[Symbol.iterator],n.prototype.add=function(...t){let e=this.length;1===t.length&&t[0]instanceof this.constructor&&(t=t[0]);for(let i=0;i<t.length;i++)this.type?(t[i]instanceof this.type||t[i]instanceof this.constructor)&&(this[e++]=t[i]):this[e++]=t[i];return this.length=e},n.prototype.each=function(t){let e=this.length;for(let i=0;i<e;i++)t.call(this[i],this[i],i);return this},n.prototype.forEach=function(){[].forEach.apply(this,arguments)},n.prototype.includes=function(){return[].includes.apply(this,arguments)},n.prototype.indexOf=function(){return[].indexOf.apply(this,arguments)},n.prototype.map=function(){return[].map.apply(this,arguments)},n.prototype.byId=function(t){return[].find.call(this,(function(e){return void 0!==e.id&&e.id===t}))},n.installMethodForwarding=(t,e,i={})=>{const{skip:r=[]}=i,n="apply|arguments|bind|call|caller|constructor|domain|length|name|prototype|toString".split("|");return Object.getOwnPropertyNames(e).reduce((t,e)=>(r.includes(e)||n.includes(e)||(t[e]=function(...t){const i=this.length;for(let r=0;r<i;r++)this[r][e](...t);return this}),t),t)};const s=()=>{};n.installCallbackReconciliation=(t,e)=>{e.forEach(e=>{t[e]=function(t,i){const r=this.length,n=[];"function"==typeof t&&(i=t,t=1e3),"function"!=typeof i&&(i=s);for(let i=0;i<r;i++)n.push(new Promise(r=>this[i][e](t,()=>r())));return Promise.all(n).then(i),this}})},n.Emitter=class extends n{constructor(t){super(t);let e=null,i=5;Array.isArray(t)||"object"!=typeof t||null===t||(i=t.freq||t.period||i,t.frequency&&(i=1/t.frequency*1e3)),Object.defineProperties(this,{period:{get:()=>i,set(t){i!==t&&(i=t),e&&clearInterval(e),e=setInterval(()=>{this.emit("data",this)},i)}}}),this.period=i,this.on("newListener",t=>{"change"!==t&&"data"!==t&&this.forEach(e=>{e.on(t,i=>this.emit(t,e,i))})})}add(...t){return t.length&&(super.add(...t),t.forEach(t=>{t&&t.on("change",()=>this.emit("change",t))})),this.length}},Object.assign(n.Emitter.prototype,r.prototype),n.prototype[Symbol.iterator]=Array.prototype[Symbol.iterator],t.exports=n},function(t,e){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(t){"object"==typeof window&&(i=window)}t.exports=i},function(t,e,i){"use strict";(function(t){
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <http://feross.org>
* @license MIT
*/
var r=i(69),n=i(70),s=i(34);function o(){return l.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(o()<e)throw new RangeError("Invalid typed array length");return l.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=l.prototype:(null===t&&(t=new l(e)),t.length=e),t}function l(t,e,i){if(!(l.TYPED_ARRAY_SUPPORT||this instanceof l))return new l(t,e,i);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return u(this,t)}return h(this,t,e,i)}function h(t,e,i,r){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,i,r){if(e.byteLength,i<0||e.byteLength<i)throw new RangeError("'offset' is out of bounds");if(e.byteLength<i+(r||0))throw new RangeError("'length' is out of bounds");e=void 0===i&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,i):new Uint8Array(e,i,r);l.TYPED_ARRAY_SUPPORT?(t=e).__proto__=l.prototype:t=d(t,e);return t}(t,e,i,r):"string"==typeof e?function(t,e,i){"string"==typeof i&&""!==i||(i="utf8");if(!l.isEncoding(i))throw new TypeError('"encoding" must be a valid string encoding');var r=0|f(e,i),n=(t=a(t,r)).write(e,i);n!==r&&(t=t.slice(0,n));return t}(t,e,i):function(t,e){if(l.isBuffer(e)){var i=0|p(e.length);return 0===(t=a(t,i)).length||e.copy(t,0,0,i),t}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(r=e.length)!=r?a(t,0):d(t,e);if("Buffer"===e.type&&s(e.data))return d(t,e.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function c(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function u(t,e){if(c(e),t=a(t,e<0?0:0|p(e)),!l.TYPED_ARRAY_SUPPORT)for(var i=0;i<e;++i)t[i]=0;return t}function d(t,e){var i=e.length<0?0:0|p(e.length);t=a(t,i);for(var r=0;r<i;r+=1)t[r]=255&e[r];return t}function p(t){if(t>=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function f(t,e){if(l.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var i=t.length;if(0===i)return 0;for(var r=!1;;)switch(e){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return B(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return F(t).length;default:if(r)return B(t).length;e=(""+e).toLowerCase(),r=!0}}function g(t,e,i){var r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if((i>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return M(this,e,i);case"utf8":case"utf-8":return A(this,e,i);case"ascii":return w(this,e,i);case"latin1":case"binary":return I(this,e,i);case"base64":return _(this,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,i);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function E(t,e,i){var r=t[e];t[e]=t[i],t[i]=r}function m(t,e,i,r,n){if(0===t.length)return-1;if("string"==typeof i?(r=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,isNaN(i)&&(i=n?0:t.length-1),i<0&&(i=t.length+i),i>=t.length){if(n)return-1;i=t.length-1}else if(i<0){if(!n)return-1;i=0}if("string"==typeof e&&(e=l.from(e,r)),l.isBuffer(e))return 0===e.length?-1:v(t,e,i,r,n);if("number"==typeof e)return e&=255,l.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(t,e,i):Uint8Array.prototype.lastIndexOf.call(t,e,i):v(t,[e],i,r,n);throw new TypeError("val must be string, number or Buffer")}function v(t,e,i,r,n){var s,o=1,a=t.length,l=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;o=2,a/=2,l/=2,i/=2}function h(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(n){var c=-1;for(s=i;s<a;s++)if(h(t,s)===h(e,-1===c?0:s-c)){if(-1===c&&(c=s),s-c+1===l)return c*o}else-1!==c&&(s-=s-c),c=-1}else for(i+l>a&&(i=a-l),s=i;s>=0;s--){for(var u=!0,d=0;d<l;d++)if(h(t,s+d)!==h(e,d)){u=!1;break}if(u)return s}return-1}function y(t,e,i,r){i=Number(i)||0;var n=t.length-i;r?(r=Number(r))>n&&(r=n):r=n;var s=e.length;if(s%2!=0)throw new TypeError("Invalid hex string");r>s/2&&(r=s/2);for(var o=0;o<r;++o){var a=parseInt(e.substr(2*o,2),16);if(isNaN(a))return o;t[i+o]=a}return o}function R(t,e,i,r){return z(B(e,t.length-i),t,i,r)}function b(t,e,i,r){return z(function(t){for(var e=[],i=0;i<t.length;++i)e.push(255&t.charCodeAt(i));return e}(e),t,i,r)}function S(t,e,i,r){return b(t,e,i,r)}function T(t,e,i,r){return z(F(e),t,i,r)}function O(t,e,i,r){return z(function(t,e){for(var i,r,n,s=[],o=0;o<t.length&&!((e-=2)<0);++o)i=t.charCodeAt(o),r=i>>8,n=i%256,s.push(n),s.push(r);return s}(e,t.length-i),t,i,r)}function _(t,e,i){return 0===e&&i===t.length?r.fromByteArray(t):r.fromByteArray(t.slice(e,i))}function A(t,e,i){i=Math.min(t.length,i);for(var r=[],n=e;n<i;){var s,o,a,l,h=t[n],c=null,u=h>239?4:h>223?3:h>191?2:1;if(n+u<=i)switch(u){case 1:h<128&&(c=h);break;case 2:128==(192&(s=t[n+1]))&&(l=(31&h)<<6|63&s)>127&&(c=l);break;case 3:s=t[n+1],o=t[n+2],128==(192&s)&&128==(192&o)&&(l=(15&h)<<12|(63&s)<<6|63&o)>2047&&(l<55296||l>57343)&&(c=l);break;case 4:s=t[n+1],o=t[n+2],a=t[n+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(l=(15&h)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&l<1114112&&(c=l)}null===c?(c=65533,u=1):c>65535&&(c-=65536,r.push(c>>>10&1023|55296),c=56320|1023&c),r.push(c),n+=u}return function(t){var e=t.length;if(e<=4096)return String.fromCharCode.apply(String,t);var i="",r=0;for(;r<e;)i+=String.fromCharCode.apply(String,t.slice(r,r+=4096));return i}(r)}e.Buffer=l,e.SlowBuffer=function(t){+t!=t&&(t=0);return l.alloc(+t)},e.INSPECT_MAX_BYTES=50,l.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Arra