I would like to port the mbed library of the VCNL40x0 sensor family to Arduino and provide it for the community. I know that there is an Adafruit VCNL4010 library but it does not support all functions of the sensor, for example interrupts, high threshold, low threshold.
I have already started to port it but it seems to be to difficult for a beginner like me. I would be very grateful if you could show me how to port one of the read and set methods so I can do it for the rest and learn how to do it.
My progress so far:
VCNL40x0.cpp
VCNL40x0.h
VCNL40x0test.ino
My code has lots of errors and I don't really know where and how to continue. So I really appreciate your help!
Well, dumping your code in the rubbish bin was probably not the correct way to start. Use Reply, not the Quick Reply field, and post you code AND errors HERE.
I have made some progress, the sketch compiles but I think it is not working in the way it should and I think I know the problem.
For example I have this function:
vcnl.writeCurrent(10);
I am able to set the current with it and this seems to work because Serial.println(vcnl.readCurrent()); returns the correct value.
But if I use one of the other functions I am making something wrong. For example vcnl.setCommandRegister (COMMAND_ALL_DISABLE);
COMMAND_ALL_DISABLE is declared in the .h file: #define COMMAND_ALL_DISABLE 0x00
So this should pass 0x00 to the function in the .cpp file.
I would be really grateful if you could show me an example how to achieve this!