You are reading a single comment by @ClearMemory041063 and its replies. Click here to read the full conversation.
  • Thanks @luwar.
    I did some trials using the following module code located in my local projects/modules directory

    /***************************************­***************************************
    Starting to recode this for Espruino 11/30/2016
    LSM9DS1_Registers.h
    SFE_LSM9DS1 Library - LSM9DS1 Register Map
    Jim Lindblom @ SparkFun Electronics
    Original Creation Date: April 21, 2015
    https://github.com/sparkfun/LSM9DS1_Brea­kout
    
    This file defines all registers internal to the gyro/accel and magnetometer
    devices in the LSM9DS1.
    
    Development environment specifics:
    	IDE: Arduino 1.6.0
    	Hardware Platform: Arduino Uno
    	LSM9DS1 Breakout Version: 1.0
    
    This code is beerware; if you see me (or any other SparkFun employee) at the
    local, and you've found our code helpful, please buy us a round!
    
    Distributed as-is; no warranty is given.
    ****************************************­**************************************/
    
    ////////////////////////////////////////­/
    // LSM9DS1 Accel/Gyro (XL/G) Registers //
    ////////////////////////////////////////­/
    var Regs={
     ACT_THS:0x04,
     ACT_DUR:0x05,
      INT_GEN_CFG_XL:	(0x06),
      INT_GEN_THS_X_XL:	(0x07),
      INT_GEN_THS_Y_XL:	(0x08),
      INT_GEN_THS_Z_XL:	(0x09),
      INT_GEN_DUR_XL:	(0x0A),
      REFERENCE_G:		(0x0B),
      INT1_CTRL:		(0x0C),
      INT2_CTRL:		(0x0D),
      WHO_AM_I_XG:		(0x0F),
      CTRL_REG1_G:		(0x10),
      CTRL_REG2_G:		(0x11),
      CTRL_REG3_G:		(0x12),
      ORIENT_CFG_G:		(0x13),
      INT_GEN_SRC_G:	(0x14),
      OUT_TEMP_L:		(0x15),
      OUT_TEMP_H:		(0x16),
      STATUS_REG_0:		(0x17),
      OUT_X_L_G:		(0x18),
      OUT_X_H_G:		(0x19),
      OUT_Y_L_G:		(0x1A),
      OUT_Y_H_G:		(0x1B),
      OUT_Z_L_G:		(0x1C),
      OUT_Z_H_G:		(0x1D),
      CTRL_REG4:		(0x1E),
      CTRL_REG5_XL:		(0x1F),
      CTRL_REG6_XL:		(0x20),
      CTRL_REG7_XL:		(0x21),
      CTRL_REG8:		(0x22),
      CTRL_REG9:		(0x23),
      CTRL_REG10:		(0x24),
      INT_GEN_SRC_XL:	(0x26),
      STATUS_REG_1:		(0x27),
      OUT_X_L_XL:		(0x28),
      OUT_X_H_XL:		(0x29),
      OUT_Y_L_XL:		(0x2A),
      OUT_Y_H_XL:		(0x2B),
      OUT_Z_L_XL:		(0x2C),
      OUT_Z_H_XL:		(0x2D),
      FIFO_CTRL:		(0x2E),
      FIFO_SRC: 		(0x2F),
      INT_GEN_CFG_G:	(0x30),
      INT_GEN_THS_XH_G:	(0x31),
      INT_GEN_THS_XL_G:	(0x32),
      INT_GEN_THS_YH_G:	(0x33),
      INT_GEN_THS_YL_G:	(0x34),
      INT_GEN_THS_ZH_G:	(0x35),
      INT_GEN_THS_ZL_G:	(0x36),
      INT_GEN_DUR_G:	(0x37)
    };
    
    ///////////////////////////////
    // LSM9DS1 Magneto Registers //
    ///////////////////////////////
    var Mags={
      OFFSET_X_REG_L_M:	0x05,
      OFFSET_X_REG_H_M:	0x06,
      OFFSET_Y_REG_L_M:	0x07,
      OFFSET_Y_REG_H_M:	0x08,
      OFFSET_Z_REG_L_M:	0x09,
      OFFSET_Z_REG_H_M:	0x0A,
      WHO_AM_I_M:			0x0F,
      CTRL_REG1_M:			0x20,
      CTRL_REG2_M:			0x21,
      CTRL_REG3_M:			0x22,
      CTRL_REG4_M:			0x23,
      CTRL_REG5_M:			0x24,
      STATUS_REG_M:		0x27,
      OUT_X_L_M:			0x28,
      OUT_X_H_M:			0x29,
      OUT_Y_L_M:			0x2A,
      OUT_Y_H_M:			0x2B,
      OUT_Z_L_M:			0x2C,
      OUT_Z_H_M:			0x2D,
      INT_CFG_M:			0x30,
      INT_SRC_M:			0x30,
      INT_THS_L_M:			0x32,
      INT_THS_H_M:		0x33
    };
    
    ////////////////////////////////
    // LSM9DS1 WHO_AM_I Responses //
    ////////////////////////////////
    var WHO_AM_I_AG_RSP=0x68;
    var WHO_AM_I_M_RSP=0x3D;
    
    
    ////////////////////////////////////////­/////
    function LSM9DS1(i2c) {
      this.i2c = i2c;
      this.addr = 0x48;
      this.gain = 2048;
    }
    // Create an instance of LSM9DS1
    exports.connect = function(i2c1) {
      return new LSM9DS1(i2c1);
    };
    

    I invoke this experimental module using the following:

    /* 
    Test Module for the LSM9DS1
    */
    console.log(process.memory());
    I2C1.setup({ scl :B6, sda: B9} );
    var W=require("LSM9DS1").connect(I2C1);
    console.log(process.memory());
    

    The output with No Module minification

    >{ "free": 4565, "usage": 535, "total": 5100, "history": 0,
      "stackEndAddress": 536959408, "flash_start": 134217728, "flash_binary_end": 379112, "flash_code_start": 134234112, "flash_length": 393216 }
    { "free": 4535, "usage": 565, "total": 5100, "history": 0,
      "stackEndAddress": 536959408, "flash_start": 134217728, "flash_binary_end": 379112, "flash_code_start": 134234112, "flash_length": 393216 }
    

    Module minification Esprima (offline)

    >{ "free": 4765, "usage": 335, "total": 5100, "history": 0,
      "stackEndAddress": 536959408, "flash_start": 134217728, "flash_binary_end": 379112, "flash_code_start": 134234112, "flash_length": 393216 }
    { "free": 4735, "usage": 365, "total": 5100, "history": 0,
    

    Module minification Closure (online) –Whitespace only

    >{ "free": 4762, "usage": 338, "total": 5100, "history": 0,
      "stackEndAddress": 536959408, "flash_start": 134217728, "flash_binary_end": 379112, "flash_code_start": 134234112, "flash_length": 393216 }
    { "free": 4732, "usage": 368, "total": 5100, "history": 0,
      "stackEndAddress": 536959408, "flash_start": 134217728, "flash_binary_end": 379112, "flash_code_start": 134234112, "flash_length": 393216 }
    

    Module minification Closure (online) – Simple optimizations

    >{ "free": 4765, "usage": 335, "total": 5100, "history": 0,
      "stackEndAddress": 536959408, "flash_start": 134217728, "flash_binary_end": 379112, "flash_code_start": 134234112, "flash_length": 393216 }
    { "free": 4735, "usage": 365, "total": 5100, "history": 0,
      "stackEndAddress": 536959408, "flash_start": 134217728, "flash_binary_end": 379112, "flash_code_start": 134234112, "flash_length": 393216 }
    

    Module minification Closure (online) – Advanced

    >{ "free": 5027, "usage": 73, "total": 5100, "history": 0,
      "stackEndAddress": 536959408, "flash_start": 134217728, "flash_binary_end": 379112, "flash_code_start": 134234112, "flash_length": 393216 }
    { "free": 4999, "usage": 101, "total": 5100, "history": 0,
      "stackEndAddress": 536959408, "flash_start": 134217728, "flash_binary_end": 379112, "flash_code_start": 134234112, "flash_length": 393216 }
    

    From the Usage values the Advanced option seems to do the best job..

About