• I think what you might need is VCNL4200.prototype.ALS = ALS - then you can do:


    if that's what you were asking?

    However I'd strongly advise against that as it will make the module use a lot of memory and isn't very easy for people to use or understand (they basically have to look at the datasheet for everything, and then figure out how to do what the datasheet said using your code).

    Could you maybe try something like:

    // Sets whatever this is, time is 50, 100, 200 or 400 (milliseconds)
    VCNL4200.prototype.setAmbiConf = function ( time ) {
      var times = { 50 : 0, 100 : 64, 200 : 128, 400 : 192 };
      this.w(C.ALS_CONF_REG, [times[time],0]);

    And the same for other functions that expect certain values - so doing the decoding inside the function itself. It's better if the functions actually abstract away from the underlying registers...


Avatar for Gordon @Gordon started