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...
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
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:
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...