The code have at least one problem - bit fields for registers are not shown for module user (or I do not know how to use it). I do not know JS so I do not know how to correct the code. Could you help me?
I think I can not write description in style of "Writing Modules" because I use own board with a few sensors and do not know about boards available to others. But. of course, I can write code example:
var i2c=new I2C();
i2c.setup({ sda:D12, scl:D13} );
//var sensor = require("VCNL4200").connect(i2c,{address:0x51}); //0x51 is default address so may be omitted
var sensor = require("VCNL4200").connect(i2c);
//sensor.Configure(); //It is possible to use it for some default mode, but it should be investigated what to set as default
sensor.setAmbiConf(0);
sensor.setProxiConf12(0x2A,0x0B);
sensor.setProxiConf3MS(0x70,0x27); //0x27 to use INT pin as proximity signal, 0x7 to use INT as interrupt
sensor.setProxiLowThreshold(1000);
sensor.setProxiHighThreshold(3000);
sensor.logAll();
function log (){
console.log(
" Proximity: " + sensor.getProximity() +
" Ambient: " + sensor.getAmbient() +
" White: " + sensor.getWhite() +
" Int: " + sensor.getInterruptFlags().toString(16));
}
setInterval(log, 1000);
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.
The code have at least one problem - bit fields for registers are not shown for module user (or I do not know how to use it). I do not know JS so I do not know how to correct the code. Could you help me?
I think I can not write description in style of "Writing Modules" because I use own board with a few sensors and do not know about boards available to others. But. of course, I can write code example: