How to add an option to VL53L0X module #5862
Replies: 1 comment
-
Posted at 2018-01-19 by PaddeK Post the code here or in a github and i will have a look at it and modify it if necessary. Posted at 2018-01-22 by SergeP Thank you. By the way, "Upload a file" does not work in last Firefox. File selection window opens, but nothing happens after I choose file. Where to write about the bug? Attachments: Posted at 2018-01-23 by SergeP The same after some debug. A few bugs were killed. Attachments: Posted at 2018-01-23 by @gfwilliams That looks really good to me! If you could add a page with an example in the style of http://www.espruino.com/Writing+Modules (or other files) it'd be really handy - or if not just paste one here and I'd be happy to make a page up for you. Do you have a link to the VL53L0X changes you mentioned as well? Posted at 2018-01-23 by SergeP 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?
Posted at 2018-01-23 by SergeP I have just got VL53L0X board, so I have not still working code for the board. I think I would better send modifications after writing some:) Posted at 2018-01-23 by @gfwilliams I think what you might need is
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... Posted at 2018-01-23 by SergeP The register is to set not only the time but a few other parameters as well. So I can write function to set time only, of course. It can get register, then add time and set the register back. But may be it is easier to users to look at the datasheet, isn't it? While the datasheet is not well-understandable, but I do not think adding separate functions or parameters with strange names makes it more understandable. Posted at 2018-01-23 by SergeP I am working on VL53L0X module and I have seen a potential holywar: these modules have different semantic of I2C addresses. One uses 7-bit address, as in Linux and in some datasheets while another uses 8-bit shifted address like in some other datasheets. Posted at 2018-01-24 by @gfwilliams It should all be uniform, with 7 bit addresses (like are used for the I2C class at http://www.espruino.com/Reference#I2C). Which ones use shifted addresses? I'll see about changing them. Posted at 2018-01-24 by SergeP It seems, VL53L0X module. Because the options.address is shifted before use. Posted at 2018-01-24 by PaddeK I am currently looking at the VCNL4200 module from @sergep as promised. But without a VCNL4200 sensor at hand someone has to check the final version. Posted at 2018-01-24 by SergeP I have just done translation of some part of VL53L0X library to JS. But I can not check it. May be because of small memory on ESP8266 - I am not sure. Or may be there are many bugs there. Could you help me?
Posted at 2018-01-24 by SergeP Module file. Name is changed during writing because I do not know which module source has priority if names are equal. Attachments: Posted at 2018-01-24 by SergeP I have found one big bug. Update is here. Result is nearly the same Attachments: Posted at 2018-01-24 by SergeP Many bugs fixed. Still too big for my current device. Attachments: Posted at 2018-01-24 by SergeP Now I have version with most bugs fixed which passes Closure minification in advanced mode and works after. Attachments: Posted at 2018-01-24 by SergeP It was epic battle! Posted at 2018-01-26 by @gfwilliams Thanks! I'll look at shifting the address back. Using the closure compiler in advanced mode is a nightmare. Honestly I only ever use 'simple optimisations' (even when minifying modules) because it's so painful :) Yes, I guess it might be an idea to have the more complex module as a second one given the difference in size is quite large. Do you have any examples of how to use this new module in its Also, do you know what the difference is between There are so many repeated calls of Posted at 2018-01-26 by PaddeK I finally had some time to look into the VCNL4200 code. According to the datasheet i found the module should not work. I got my VL53L0X today so i could help work on that if you like. Posted at 2018-01-29 by @gfwilliams
Many chips use the top bit of the register address to specify a write to that register - so that could be a reason? Posted at 2018-01-29 by PaddeK Yes that could explain it.. i guess someone with the sensor at hand will find out for us :) Posted at 2018-01-31 by SergeP Hi! Sorry, I had no time at all before and have too little time now. But I hope tomorrow I will have enough. About readRangeSingleMillimeters/readRangeContinuousMillimeters and the original performSingleMeasurement. Yes, I forget to remove one because had both in my test, and had already not enough time. By the way, both functions looks like can not work if switch GPIO to other modes and I even know why (I did not implement setGPIOMode() still and did it by accessing registers using w2(). Moreover, it was my general goal to test effects of GPIO modes). Posted at 2018-02-02 by SergeP Hi! Posted at 2018-02-02 by SergeP @gfwilliams Attachments: Posted at 2018-02-02 by SergeP It looks to be very interesting to change many calls of this.w to some array. But I do not know how to do it well - I am afraid I will use even more memory for arrays. Attachments: Posted at 2018-02-02 by PaddeK Try to replace
With
Or even
Posted at 2018-02-05 by @gfwilliams @PaddeK I guess it's worth a try, but I'm not convinced that works. Usually the first byte is the address and all subsequent bytes just increment the address. Try:
Posted at 2018-02-05 by PaddeK Hmm could be.. my experience with i2c devices is limited. I hope he tries it though because its so much shorter especially the base64 variation :) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-01-19 by SergeP
Hi!
I want to make tiny modification of VL53L0X module - add an option that means "address is changed already, use new address but do not send address change command to device" - I try to use few VL53L0X thru I2C address changer and one without changer and the address change command will prefer the last one from correct work.
The code is easy so I can make the modification in local copy. But my JS skills are not good so I think I can not write well-readable code in JS and Espruino tradition.
How to write it in good style? Well-designed interface is important in the place.
May be the option will be useful for other modules as well.
I am going to modify the module further to add features I need - continuous measurement mode etc. And I think I can put the code somewhere - GitHub branch or even here - and somebody who know JS can modify my code to add good JS style.
By the way, it seems to me, Mongoose OS Pololu VL53L0 code looks to be better for reverse-engineering then original ST.
Beta Was this translation helpful? Give feedback.
All reactions