The VL53L8CX uses a surprising amount of ROM. There is an 80K buffer of firmware that gets downloaded at the start. Then a 3K configuration. We probably should have flashed that bit, but we've created a good number of variants doing it this way, and it's worked for our really big applications.
So we generally run into ROM constraints before the RAM ones.
You can save a bit by reducing the number of return values by uncommenting those odd defines in Platform.H.
You will get the return structure down from 5200 bytes to a more manageable 1K or so.
But that does not save RAM.
And I think you cut too deep. You really need the number of targets and the status.
#define VL53L8CX_DISABLE_NB_TARGET_DETECTED 1
#define VL53L8CX_DISABLE_SIGNAL_PER_SPAD 1
#define VL53L8CX_DISABLE_RANGE_SIGMA_MM 1
// #define VL53L8CX_DISABLE_DISTANCE_MM
#define VL53L8CX_DISABLE_REFLECTANCE_PERCENT 1
#define VL53L8CX_DISABLE_TARGET_STATUS 1
The proper way to know you have a target is:
If the NB_Target_detected is greater than 0 AND the Target_Status is 5, 6, 9 and sometimes 12, you have a valid target.
So you need those 2 parameters and the distance. Signal strength can be handy as well. Do consider that one. We put this in to reduce I2C traffic. The RAM reduction is secondary.
I'm thinking that RAM comes out of your stack. So, it might not be obvious when you do your download.
- john
If this or any post solves your issue, please mark them as 'Accept as Solution' It really helps. And if you notice anything wrong do not hesitate to 'Report Inappropriate Content'. Someone will review it.