____                 _
|  __|___ ___ ___ _ _|_|___ ___
|  __|_ -| . |  _| | | |   | . |
|____|___|  _|_| |___|_|_|_|___|
         |_| espruino.com
 2v00 (c) 2018 G.Williams
Found ESPRUINOWIFI, 2v00
>
Connected to COM3
TypeError: Cannot read property 'length' of undefined in MPU6050
>Uncaught SyntaxError: Got '=' expected ','
 at line 263 col 65
...ction(bank, prefetchEnabled=false, userBank=false) {
                              ^
Uncaught InternalError: Timeout on I2C Write Transmit Mode 2
 at line 1 col 32
this.i2c.writeTo(this.addr, reg);
                               ^
in function "readBytes" called from line 1 col 30
var b = this.readBytes(reg, 1)[0];
                             ^
in function "writeBits" called from line 1 col 76
...C.PWR1_CLKSEL_LENGTH, clock);
                              ^
in function "setClockSource" called from line 1 col 38
this.setClockSource(C.CLOCK_PLL_XGYRO);
                                     ^
in function "initialize" called from line 6 col 19
  this.initialize();
                  ^
in function "MPU6050" called from line 1 col 23
new MPU6050(_i2c,_addr);
                      ^
in function "connect" called from line 1 col 42
var mpu = require("MPU6050").connect(I2C1);
                                         ^
Uncaught Error: Cannot read property 'getAcceleration' of undefined
 at line 1 col 4
mpu.getAcceleration();
   ^
Uncaught Error: Cannot read property 'getGravity' of undefined
 at line 1 col 4
mpu.getGravity();
   ^
Uncaught Error: Cannot read property 'getRotation' of undefined
 at line 1 col 4
mpu.getRotation();
   ^
Uncaught Error: Cannot read property 'getDegreesPerSecond' of undefined
 at line 1 col 4
mpu.getDegreesPerSecond();
   ^
>dump()
var mpu = undefined;
I2C1.setup({"scl":B6,"sda":B7});
pinMode(B6, "af_opendrain", true);
pinMode(B7, "af_opendrain", true);
=undefined
>
>mpu
=undefined
> 

We have chrome.serial - not using 'serialport' module
serial_audio: Audio Sample rate : 48000
serial_audio: Audio Serial Baud 9600 Bit time 5
UTF8 Library loaded successfully
GET chrome.storage.sync = {"AUTO_SAVE_CODE":true,"BAUD_RATE":9600,"BLOCKLY_EXTENSIONS":"||","BLOCKLY_LANGUAGE":"en","BLOCKLY_TO_JS":false,"BOARD_JSON_URL":"http://www.espruino.com/json","CODE":"I2C1.setup({scl:B6,sda:B7});\nvar mpu = require(\"MPU6050\").connect(I2C1);\nmpu.getAcceleration(); // returns an [x,y,z] array with raw accl. data\nmpu.getGravity();  // returns acceleration array in G's\nmpu.getRotation(); // returns an [x,y,z] array with raw gyro data\nmpu.getDegreesPerSecond(); // returns gyro array in degrees/s\n","COMPILATION":true,"COMPILATION_URL":"https://www.espruino.com/service/compiler","DISABLE_CODE_HINTS":false,"ENABLE_Testing":true,"ENV_ON_CONNECT":true,"FONT_SIZE":"12","KEYMAP":"sublime","MINIFICATION_DeadCode":true,"MINIFICATION_LEVEL":"","MINIFICATION_Literal":true,"MINIFICATION_Mangle":true,"MINIFICATION_Unreachable":true,"MINIFICATION_Unused":true,"MODULE_AS_FUNCTION":true,"MODULE_EXTENSIONS":".js|.min.js","MODULE_MINIFICATION_LEVEL":"ESPRIMA","MODULE_PROXY_ENABLED":false,"MODULE_PROXY_PORT":"","MODULE_PROXY_URL":"","MODULE_URL":"http://www.espruino.com/modules/","NPM_MODULES":false,"OFFLINE_DATA":"","OFFLINE_DATA_DOWNLOAD":"","OFFLINE_DATA_UPLOAD":"","OFFLINE_ENABLED":true,"PRETOKENISE":false,"RESET_BEFORE_SEND":false,"SAVE_ON_SEND":"0","SERIAL_AUDIO":"0","SERIAL_FLOW_CONTROL":true,"SERIAL_IGNORE":"/dev/ttyS*|/dev/*.SOC|/dev/*.MALS","SERIAL_TCPIP":"","SERIAL_THROTTLE_SEND":false,"SET_TIME_ON_WRITE":false,"SHOW_CODE_LINK_ICON":false,"SHOW_WEBCAM_ICON":"0","STORE_LINE_NUMBERS":true,"Sound_Error":"","Sound_Info":"","Sound_Success":"","Sound_Warning":"","Speak_Error":false,"Speak_Info":false,"Speak_Success":false,"Speak_Warning":false,"UI_MODE":"compact","WEBCAM_CONSTRAINTS":0,"WEB_BLUETOOTH":true,"WEB_SERIAL":false,"projectEntry":"C72ABC67D7196E4428950FFDC387C2F9:EspruinoPico"}
Initialising SettingsConsole
Initialising Utils
Initialising Config
Initialising Notifications
Initialising Status
Initialising App
Initialising File
Initialising Code
Initialising Serial
  - Initialising Serial Chrome Serial
  - Initialising Serial Chrome Socket
  - Initialising Serial Web Audio
  - Initialising Serial Web Bluetooth
  - Initialising Serial Web Serial
Initialising Terminal
Initialising CodeWriter
Initialising Modules
Initialising Env
Initialising Flasher
Initialising EditorBlockly
Initialising EditorJavaScript
Initialising Send
Initialising MenuPortSelector
Initialising MenuSettings
Initialising MenuFlasher
Initialising SettingsAbout
Initialising SettingsFlasher
Initialising BoardJSON
Initialising VersionChecker
Initialising Compiler
Initialising Assembler
Initialising GetGitHub
Initialising Unicode
Initialising Minify
Initialising Pretokenise
Initialising SaveOnSend
Initialising SetTime
Initialising Tutorial
Initialising Webcam
Initialising FontSize
Initialising UiMode
Initialising URLHandler
Initialising CodeLink
Initialising Project
Initialising Testing
Initialising Notification_Sound
Initialising Tern
Initialising Debugger
Initialising Tour
Initialising SettingsProfile
Initialising HelpLinks
Initialising Offline
Initialising CoreModules
Loaded code from storage.
GET chrome.storage.local.OFFLINE_DATA = 625705 bytes
No navigator.serial - Web Serial not enabled
>>> Connecting...
Set Slow Write = true
[object Object]
Connected [object Object]
Found a prompt... great!
>>> Sending...
---> "\u0010print(\"<\",\"<<\",JSON.stringify(process.env),\">>\",\">\")\n"
>>> Sent
Got "< << {\"VERSION\":\"2v00\",\"GIT_COMMIT\":\"ff35517\",\"BOARD\":\"ESPRUINOWIFI\",\"FLASH\":524288,\"RAM\":131072,\"SERIAL\":\"40004d00-0b513532-39333638\",\"CONSOLE\":\"USB\",\"MODULES\":\"Flash,Storage,heatshrink,fs,net,dgram,tls,http,NetworkJS,WIZnet,tv,crypto,neopixel,Wifi,AT\",\"EXPTR\":536871132} >> >\r\n>"
[notify_info] Found ESPRUINOWIFI, 2v00
Loading http://www.espruino.com/json/ESPRUINOWIFI.json
Searching for json/ESPRUINOWIFI.json
json/ESPRUINOWIFI.json found in offline archive
Board JSON loaded
Firmware >1.43 supports faster writes over USB
Set Slow Write = false
FIRMWARE: Current 2v00, Available 2v00
Device found {"bitrate":9600,"bufferSize":4096,"connectionId":7,"ctsFlowControl":false,"dataBits":"eight","name":"","parityBit":"no","paused":true,"persistent":false,"receiveTimeout":0,"sendTimeout":0,"stopBits":"one"}
[success] Connected to COM3
>>> Connected to COM3
>>> Loading modules
loadModule(MPU6050)
Searching for modules//MPU6050.js
modules//MPU6050.js not found in offline archive
 - MPU6050 requires []
>>> Minifyingn MPU6050
ERROR: [notify_error] TypeError: Cannot read property 'length' of undefined in MPU6050
ERROR: TypeError: Cannot read property 'length' of undefined     at b [as traverse] (chrome-extension://bleoifhkdalbjfbobjackfdifdneehpo/main.js:107330:32633)     at Object.k [as traverse] (chrome-extension://bleoifhkdalbjfbobjackfdifdneehpo/main.js:107330:26492)     at f (chrome-extension://bleoifhkdalbjfbobjackfdifdneehpo/main.js:107330:4674)     at Object.l [as optimize] (chrome-extension://bleoifhkdalbjfbobjackfdifdneehpo/main.js:107330:1940)     at obfuscate (chrome-extension://bleoifhkdalbjfbobjackfdifdneehpo/main.js:112414:27)     at minifyCodeEsprima (chrome-extension://bleoifhkdalbjfbobjackfdifdneehpo/main.js:112395:18)     at minify (chrome-extension://bleoifhkdalbjfbobjackfdifdneehpo/main.js:112548:23)     at Array.<anonymous> (chrome-extension://bleoifhkdalbjfbobjackfdifdneehpo/main.js:112366:7)     at cb (chrome-extension://bleoifhkdalbjfbobjackfdifdneehpo/main.js:92868:15)     at chrome-extension://bleoifhkdalbjfbobjackfdifdneehpo/main.js:100138:9
>>> Minification complete
>>> Minifying
>>> Minification complete
Found a prompt... great!
>>> Sending...
---> "\u0010Modules.addCached(\"MPU6050\",function(){\u001b\n/* Copyright (c) 2014 Lars Toft Jacobsen. See the file LICENSE for copying permission. */\u001b\n/*\u001b\nModule for the Invensense MPU6050 digital gyro + accelerometer sensor fusion IC.\u001b\nOnly I2C is supported.\u001b\n\u001b\nParts of the module is based on the driver written by Jeff Rowberg:\u001b\nI2Cdev device library code is placed under the MIT license\u001b\nCopyright (c) 2012 Jeff Rowberg\u001b\n\u001b\nPermission is hereby granted, free of charge, to any person obtaining a copy\u001b\nof this software and associated documentation files (the \"Software\"), to deal\u001b\nin the Software without restriction, including without limitation the rights\u001b\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\u001b\ncopies of the Software, and to permit persons to whom the Software is\u001b\nfurnished to do so, subject to the following conditions:\u001b\n\u001b\nThe above copyright notice and this permission notice shall be included in\u001b\nall copies or substantial portions of the Software.\u001b\n*/\u001b\n\u001b\n/* Module constants*/\u001b\nvar C = {\u001b\n  ADDRESS_AD0_LOW     : 0x68, // address pin low (GND)\u001b\n  ADDRESS_AD0_HIGH    : 0x69, // address pin high (VCC)\u001b\n\u001b\n  PWR1_CLKSEL_BIT     : 2,\u001b\n  PWR1_CLKSEL_LENGTH  : 3,\u001b\n  PWR1_SLEEP_BIT      : 6,\u001b\n\u001b\n  CLOCK_INTERNAL      : 0x00,\u001b\n  CLOCK_PLL_XGYRO     : 0x01,\u001b\n  CLOCK_PLL_YGYRO     : 0x02,\u001b\n  CLOCK_PLL_ZGYRO     : 0x03,\u001b\n  CLOCK_PLL_EXT32K    : 0x04,\u001b\n  CLOCK_PLL_EXT19M    : 0x05,\u001b\n  CLOCK_KEEP_RESET    : 0x07,\u001b\n\u001b\n  GYRO_FS_250         : 0x00,\u001b\n  GYRO_FS_500         : 0x01,\u001b\n  GYRO_FS_1000        : 0x02,\u001b\n  GYRO_FS_2000        : 0x03,\u001b\n\u001b\n  GCONFIG_FS_SEL_BIT  : 4,\u001b\n  GCONFIG_FS_SEL_LENGTH : 2,\u001b\n\u001b\n  ACONFIG_AFS_SEL_BIT : 4,\u001b\n  ACONFIG_AFS_SEL_LENGTH  : 2,\u001b\n\u001b\n  ACCEL_FS_2          : 0x00,\u001b\n  ACCEL_FS_4          : 0x01,\u001b\n  ACCEL_FS_8          : 0x02,\u001b\n  ACCEL_FS_16         : 0x03,\u001b\n\u001b\n  PWR1_DEVICE_RESET_BIT : 7,\u001b\n  DMP_MEMORY_CHUNK_SIZE : 16,\u001b\n\u001b\n  TC_PWR_MODE_BIT   : 7,\u001b\n  TC_OFFSET_BIT     : 6,\u001b\n  TC_OFFSET_LENGTH  : 6,\u001b\n  TC_OTP_BNK_VLD_BIT  : 0,\u001b\n\u001b\n  USERCTRL_I2C_MST_EN_BIT : 5,\u001b\n  USERCTRL_I2C_MST_RESET_BIT : 1\u001b\n};\u001b\n\u001b\n/* Register addresses*/\u001b\nvar R = {\u001b\n  XG_OFFS_TC          : 0x00, //[7] PWR_MODE, [6:1] XG_OFFS_TC, [0] OTP_BNK_VLD\u001b\n  YG_OFFS_TC          : 0x01, //[7] PWR_MODE, [6:1] YG_OFFS_TC, [0] OTP_BNK_VLD\u001b\n  ZG_OFFS_TC          : 0x02, //[7] PWR_MODE, [6:1] ZG_OFFS_TC, [0] OTP_BNK_VLD\u001b\n  SMPLRT_DIV          : 0x19,\u001b\n  CONFIG              : 0x1A,\u001b\n  GYRO_CONFIG         : 0x1B,\u001b\n  ACCEL_CONFIG        : 0x1C,\u001b\n  MOT_THR             : 0x1F,\u001b\n  MOT_DUR             : 0x20,\u001b\n  ZRMOT_THR           : 0x21,\u001b\n  ZRMOT_DUR           : 0x22,\u001b\n  FIFO_EN             : 0x23,\u001b\n  I2C_MST_CTRL        : 0x24,\u001b\n  I2C_SLV0_ADDR       : 0x25,\u001b\n  I2C_SLV0_REG        : 0x26,\u001b\n  I2C_SLV0_CTRL       : 0x27,\u001b\n  I2C_MST_STATUS      : 0x36,\u001b\n  INT_PIN_CFG         : 0x37,\u001b\n  INT_ENABLE          : 0x38,\u001b\n  INT_STATUS          : 0x3A,\u001b\n  ACCEL_XOUT_H        : 0x3B,\u001b\n  ACCEL_XOUT_L        : 0x3C,\u001b\n  ACCEL_YOUT_H        : 0x3D,\u001b\n  ACCEL_YOUT_L        : 0x3E,\u001b\n  ACCEL_ZOUT_H        : 0x3F,\u001b\n  ACCEL_ZOUT_L        : 0x40,\u001b\n  TEMP_OUT_H          : 0x41,\u001b\n  TEMP_OUT_L          : 0x42,\u001b\n  GYRO_XOUT_H         : 0x43,\u001b\n  GYRO_XOUT_L         : 0x44,\u001b\n  GYRO_YOUT_H         : 0x45,\u001b\n  GYRO_YOUT_L         : 0x46,\u001b\n  GYRO_ZOUT_H         : 0x47,\u001b\n  GYRO_ZOUT_L         : 0x48,\u001b\n  I2C_SLV0_DO         : 0x63,\u001b\n  I2C_MST_DELAY_CTRL  : 0x67,\u001b\n  SIGNAL_PATH_RESET   : 0x68,\u001b\n  USER_CTRL           : 0x6A,\u001b\n  PWR_MGMT_1          : 0x6B,\u001b\n  PWR_MGMT_2          : 0x6C,\u001b\n  BANK_SEL            : 0x6D,\u001b\n  MEM_START_ADDR      : 0x6E,\u001b\n  MEM_R_W             : 0x6F,\u001b\n  WHO_AM_I            : 0x75\u001b\n};\u001b\n\u001b\nexports.connect = function (_i2c,_addr) {\u001b\n  return new MPU6050(_i2c,_addr);\u001b\n};\u001b\n\u001b\n/* MPU6050 Object */\u001b\nfunction MPU6050(_i2c, _addr) {\u001b\n  this.i2c = _i2c;\u001b\n  this.addr =\u001b\n    (undefined===_addr || false===_addr) ? C.ADDRESS_AD0_LOW :\u001b\n    (true===_addr) ? C.ADDRESS_AD0_HIGH :\u001b\n    _addr;\u001b\n  this.initialize();\u001b\n}\u001b\n\u001b\n\u001b\n/* Initialize the chip */\u001b\nMPU6050.prototype.initialize = function() {\u001b\n  this.setClockSource(C.CLOCK_PLL_XGYRO);\u001b\n  this.setFullScaleAccelRange(C.ACCEL_FS_2);\u001b\n  this.setFullScaleGyroRange(C.GYRO_FS_250);\u001b\n  this.setSleepEnabled(false);\u001b\n};\u001b\n\u001b\nMPU6050.prototype.reset = function() {\u001b\n  this.writeBit(R.PWR_MGMT_1, C.PWR1_DEVICE_RESET_BIT, true);\u001b\n}\u001b\n\u001b\nMPU6050.prototype.readBytes = function(reg, length) {\u001b\n  this.i2c.writeTo(this.addr, reg);\u001b\n  return this.i2c.readFrom(this.addr, length);\u001b\n}\u001b\n\u001b\nMPU6050.prototype.writeBytes = function(reg, data) {\u001b\n  this.i2c.writeTo(this.addr, [reg].concat(data));\u001b\n}\u001b\n\u001b\n/** Read a single bit from an 8-bit device register.\u001b\n * @param reg Register to read from\u001b\n * @param bit Bit position to read (0-7)\u001b\n * @return The bit value read.\u001b\n */\u001b\nMPU6050.prototype.readBit = function(reg, bit) {\u001b\n    var b = this.readBytes(reg, 1)[0];\u001b\n    b &= (1 << bit);\u001b\n    return b;\u001b\n}\u001b\n\u001b\n/* Set a single bit in a register */\u001b\nMPU6050.prototype.writeBit = function(reg, bit, val) {\u001b\n  var b = this.readBytes(reg, 1)[0];\u001b\n  b = (val != 0) ? (b | (1 << bit)) : (b & ~(1 << bit));\u001b\n  this.writeBytes(reg, b);\u001b\n};\u001b\n\u001b\n/** Read multiple bits from an 8-bit device register.\u001b\n * @param reg Register to read from\u001b\n * @param bitStart First bit position to read (0-7)\u001b\n * @param length Number of bits to read (not more than 8)\u001b\n * @return The right-aligned value (i.e. '101' read from any bitStart position will equal 0x05)\u001b\n */\u001b\nMPU6050.prototype.readBits = function(reg, bitStart, length) {\u001b\n  var b = this.readBytes(reg, 1)[0];\u001b\n  // 01101001 read byte\u001b\n  // 76543210 bit numbers\u001b\n  //    xxx   args: bitStart=4, length=3\u001b\n  //    010   masked\u001b\n  //   -> 010 shifted\u001b\n  var mask = ((1 << length) - 1) << (bitStart - length + 1);\u001b\n  b &= mask;\u001b\n  b >>= (bitStart - length + 1);\u001b\n  return b;\u001b\n}\u001b\n\u001b\n/* Set more bits in a register */\u001b\nMPU6050.prototype.writeBits = function(reg, bitStart, length, val) {\u001b\n  var b = this.readBytes(reg, 1)[0];\u001b\n\u001b\n  //      010 value to write\u001b\n  // 76543210 bit numbers\u001b\n  //    xxx   args: bitStart=4, length=3\u001b\n  // 00011100 mask byte\u001b\n  // 10101111 original value (sample)\u001b\n  // 10100011 original & ~mask\u001b\n  // 10101011 masked | value\u001b\n  var mask = ((1 << length) - 1) << (bitStart - length + 1);\u001b\n  val <<= (bitStart - length + 1); // shift data into correct position\u001b\n  val &= mask; // zero all non-important bits in data\u001b\n  b &= ~(mask); // zero all important bits in existing byte\u001b\n  b |= val; // combine data with existing byte\u001b\n\u001b\n  this.writeBytes(reg, b);\u001b\n};\u001b\n\u001b\n/* Read 2 bytes from register reg\u001b\nand combine to signed integer */\u001b\nMPU6050.prototype.readS16 = function(reg) {\u001b\n  this.i2c.writeTo(this.addr, reg);\u001b\n  var d = this.i2c.readFrom(this.addr, 2);\u001b\n  var i = (d[0] << 8) | d[1];\u001b\n  return (i>32767) ? i - 65536 : i;\u001b\n};\u001b\n\u001b\n/* Read 6 bytes and return 3 signed integer values */\u001b\nMPU6050.prototype.readSXYZ = function(reg) {\u001b\n  this.i2c.writeTo(this.addr, reg);\u001b\n  var bytes = this.i2c.readFrom(this.addr, 6);\u001b\n  var x = (bytes[0] << 8) | bytes[1];\u001b\n  var y = (bytes[2] << 8) | bytes[3];\u001b\n  var z = (bytes[4] << 8) | bytes[5];\u001b\n  x = (x>32767) ? x - 65536 : x;\u001b\n  y = (y>32767) ? y - 65536 : y;\u001b\n  z = (z>32767) ? z - 65536 : z;\u001b\n  return [x, y ,z];\u001b\n};\u001b\n\u001b\n/* Set the clock source */\u001b\nMPU6050.prototype.setClockSource = function(clock) {\u001b\n  this.writeBits(R.PWR_MGMT_1, C.PWR1_CLKSEL_BIT, C.PWR1_CLKSEL_LENGTH, clock);\u001b\n};\u001b\n\u001b\n/* Set full scale for accelerometer*/\u001b\nMPU6050.prototype.setFullScaleAccelRange = function(fs) {\u001b\n  this.writeBits(R.ACCEL_CONFIG, C.ACONFIG_AFS_SEL_BIT, C.ACONFIG_AFS_SEL_LENGTH, fs);\u001b\n  this.acc_lsb_sens = Math.pow(2, 14-fs); // Set LSB sensitivity\u001b\n};\u001b\n\u001b\n/* Set full scale for gyro */\u001b\nMPU6050.prototype.setFullScaleGyroRange = function(fs) {\u001b\n  this.writeBits(R.GYRO_CONFIG, C.GCONFIG_FS_SEL_BIT, C.GCONFIG_FS_SEL_LENGTH, fs);\u001b\n  this.gyro_lsb_sens = 131 / Math.pow(2, fs); // Set LSB sensitivity\u001b\n};\u001b\n\u001b\nMPU6050.prototype.setSleepEnabled = function(enable) {\u001b\n  this.writeBit(R.PWR_MGMT_1, C.PWR1_SLEEP_BIT, enable);\u001b\n};\u001b\n\u001b\n/* Get raw rotation */\u001b\nMPU6050.prototype.getRotation = function() {\u001b\n  return this.readSXYZ(R.GYRO_XOUT_H);\u001b\n};\u001b\n\u001b\n/* Get rotation measuren in degrees/s */\u001b\nMPU6050.prototype.getDegreesPerSecond = function() {\u001b\n  var rot = this.getRotation();\u001b\n  var mpu = this;\u001b\n  return rot.map(function(e) {\u001b\n    return e / mpu.gyro_lsb_sens;\u001b\n  });\u001b\n};\u001b\n\u001b\n/* Get raw acceleration */\u001b\nMPU6050.prototype.getAcceleration = function() {\u001b\n  return this.readSXYZ(R.ACCEL_XOUT_H);\u001b\n};\u001b\n\u001b\n/* Get acceleration in G's */\u001b\nMPU6050.prototype.getGravity = function() {\u001b\n  var acc = this.getAcceleration();\u001b\n  var mpu = this;\u001b\n  return acc.map(function(e) {\u001b\n    return e / mpu.acc_lsb_sens;\u001b\n  });\u001b\n};\u001b\n\u001b\n/* Get temperature in degrees C from built-in sensor */\u001b\nMPU6050.prototype.getTemperature = function() {\u001b\n  return this.readS16(R.TEMP_OUT_H) / 340 + 36.53;\u001b\n};\u001b\n\u001b\n\u001b\nMPU6050.prototype.setMemoryBank = function(bank, prefetchEnabled=false, userBank=false) {\u001b\n  bank &= 0x1F;\u001b\n  if(userBank) bank |= 0x20;\u001b\n  if(prefetchEnabled) bank |= 0x40;\u001b\n  this.writeBytes(R.BANK_SEL, bank);\u001b\n}\u001b\n\u001b\nMPU6050.prototype.setMemoryStartAddress = function(address) {\u001b\n  this.writeBytes(R.MEM_START_ADDR, address);\u001b\n}\u001b\n\u001b\nMPU6050.prototype.writeMemoryBlock = function(data, bank, address) {\u001b\n  this.setMemoryBank(bank);\u001b\n  this.setMemoryStartAddress(address);\u001b\n\u001b\n  var chunkSize = C.DMP_MEMORY_CHUNK_SIZE;\u001b\n  var dataSize = data.length;\u001b\n\u001b\n  for(var i = 0; i < dataSize;) {\u001b\n    // determine correct chunk size according to bank position and data size\u001b\n    chunkSize = C.DMP_MEMORY_CHUNK_SIZE;\u001b\n    // make sure we don't go past the data size\u001b\n    if (i + chunkSize > dataSize) chunkSize = dataSize - i;\u001b\n    // make sure this chunk doesn't go past the bank boundary (256 bytes)\u001b\n    if (chunkSize > 256 - address) chunkSize = 256 - address;\u001b\n\u001b\n    // write the chunk of data as specified\u001b\n    var dataToBeWritten = data.slice(i, i + chunkSize);\u001b\n    this.writeBytes(R.MEM_R_W, dataToBeWritten);\u001b\n\u001b\n    // VERIFY\u001b\n    this.setMemoryBank(bank);\u001b\n    this.setMemoryStartAddress(address);\u001b\n    var dataWritten = this.readBytes(R.MEM_R_W, chunkSize);\u001b\n    if(dataWritten.toString() != dataToBeWritten.toString()) {\u001b\n      console.log(\"WriteMemoryBlock FAILED for bank: \" + bank + \" / address: \" + address + \" / chunkSize: \" + chunkSize + \" / dataSize: \" + dataSize + \" / i: \" + i);\u001b\n      console.log(\"Data TO BE written: \" + dataToBeWritten);\u001b\n      console.log(\"Data READ BACK: \" + dataWritten);\u001b\n      return false;\u001b\n    }\u001b\n\u001b\n    i += chunkSize;\u001b\n\u001b\n    address += chunkSize;\u001b\n    address = address % 256;\u001b\n\u001b\n    // if we aren't done, update bank (if necessary) and address\u001b\n    if (i < dataSize) {\u001b\n      if (address == 0) bank++; // this means we've done 256 bytes, time to go to next bank\u001b\n\u001b\n      this.setMemoryBank(bank);\u001b\n      this.setMemoryStartAddress(address);\u001b\n    }\u001b\n  }\u001b\n\u001b\n  return true;\u001b\n}\u001b\n\u001b\nMPU6050.prototype.readMemoryBlock = function(dataSize, bank, address) {\u001b\n    this.setMemoryBank(bank);\u001b\n    this.setMemoryStartAddress(address);\u001b\n\u001b\n    var chunkSize = C.DMP_MEMORY_CHUNK_SIZE;\u001b\n    var result = new Uint8Array(dataSize);\u001b\n\u001b\n    for (var i = 0; i < dataSize;) {\u001b\n      // determine correct chunk size according to bank position and data size\u001b\n      chunkSize = C.DMP_MEMORY_CHUNK_SIZE;\u001b\n      // make sure we don't go past the data size\u001b\n      if (i + chunkSize > dataSize) chunkSize = dataSize - i;\u001b\n      // make sure this chunk doesn't go past the bank boundary (256 bytes)\u001b\n      if (chunkSize > 256 - address) chunkSize = 256 - address;\u001b\n\u001b\n      // read the chunk of data as specified\u001b\n      result.set(this.readBytes(R.MEM_R_W, chunkSize), i);\u001b\n\u001b\n      // increase byte index by [chunkSize]\u001b\n      i += chunkSize;\u001b\n\u001b\n      address += chunkSize;\u001b\n      address = address % 256;\u001b\n\u001b\n      // if we aren't done, update bank (if necessary) and address\u001b\n      if (i < dataSize) {\u001b\n        if (address == 0) bank++; // this means we've done 256 bytes, time to go to next bank\u001b\n\u001b\n        this.setMemoryBank(bank);\u001b\n        this.setMemoryStartAddress(address);\u001b\n      }\u001b\n    }\u001b\n}\u001b\n\u001b\n\u001b\n//Set the I2C address of the specified slave (0-3).\u001b\nMPU6050.prototype.setSlaveAddress = function(num, address) {\u001b\n    if (num > 3) return;\u001b\n    this.writeBytes(R.I2C_SLV0_ADDR + num * 3, address);\u001b\n}\u001b\n\u001b\nMPU6050.prototype.setI2CMasterModeEnabled = function(enabled) {\u001b\n    this.writeBit(R.USER_CTRL, C.USERCTRL_I2C_MST_EN_BIT, enabled);\u001b\n}\u001b\n\u001b\n/**\u001b\n * This bit resets the I2C Master when set to 1 while I2C_MST_EN equals 0.\u001b\n * This bit automatically clears to 0 after the reset has been triggered.\u001b\n */\u001b\nMPU6050.prototype.resetI2CMaster = function() {\u001b\n    this.writeBit(R.USER_CTRL, C.USERCTRL_I2C_MST_RESET_BIT, true);\u001b\n}\u001b\n\u001b\n\u001b\n// XG_OFFS_TC register\u001b\n\u001b\nMPU6050.prototype.getOTPBankValid = function() {\u001b\n  return this.readBit(R.XG_OFFS_TC, C.TC_OTP_BNK_VLD_BIT);\u001b\n}\u001b\n\u001b\nMPU6050.prototype.setOTPBankValid = function(enabled) {\u001b\n  this.writeBit(R.XG_OFFS_TC, C.TC_OTP_BNK_VLD_BIT, enabled);\u001b\n}\u001b\n\u001b\nMPU6050.prototype.getXGyroOffsetTC = function() {\u001b\n    return this.readBits(R.XG_OFFS_TC, C.TC_OFFSET_BIT, C.TC_OFFSET_LENGTH);\u001b\n}\u001b\nMPU6050.prototype.setXGyroOffsetTC = function(offset) {\u001b\n    this.writeBits(R.XG_OFFS_TC, C.TC_OFFSET_BIT, C.TC_OFFSET_LENGTH, offset);\u001b\n}\u001b\n\u001b\n// YG_OFFS_TC register\u001b\n\u001b\nMPU6050.prototype.getYGyroOffsetTC = function() {\u001b\n    return this.readBits(R.YG_OFFS_TC, C.TC_OFFSET_BIT, C.TC_OFFSET_LENGTH);\u001b\n}\u001b\nMPU6050.prototype.setYGyroOffsetTC = function(offset) {\u001b\n    this.writeBits(R.YG_OFFS_TC, C.TC_OFFSET_BIT, C.TC_OFFSET_LENGTH, offset);\u001b\n}\u001b\n\u001b\n// ZG_OFFS_TC register\u001b\n\u001b\nMPU6050.prototype.getZGyroOffsetTC = function() {\u001b\n    return this.readBits(R.ZG_OFFS_TC, C.TC_OFFSET_BIT, C.TC_OFFSET_LENGTH);\u001b\n}\u001b\nMPU6050.prototype.setZGyroOffsetTC = function(offset) {\u001b\n    this.writeBits(R.ZG_OFFS_TC, C.TC_OFFSET_BIT, C.TC_OFFSET_LENGTH, offset);\u001b\n}\u001b\n});\n\u0010I2C1.setup({scl:B6,sda:B7});\n\u0010var mpu = require(\"MPU6050\").connect(I2C1);\n\u0010mpu.getAcceleration();\n\u0010mpu.getGravity();\n\u0010mpu.getRotation();\n\u0010mpu.getDegreesPerSecond();\n\n"
>>> Sent
Splitting for Ctrl-C, delay 250