VL53L5CX: Fix memory leak. Add get_resolution.

pull/347/head
Phil Howard 2022-04-20 19:18:53 +01:00
rodzic fcd4914cbb
commit 4b86faaf12
2 zmienionych plików z 15 dodań i 0 usunięć

Wyświetl plik

@ -29,8 +29,16 @@ namespace pimoroni {
bool VL53L5CX::set_resolution(Resolution resolution) {
/* One of VL53L5CX_RESOLUTION_4X4 or VL53L5CX_RESOLUTION_8X8 */
uint8_t status = vl53l5cx_set_resolution(configuration, (uint8_t)resolution);
if(status == VL53L5CX_STATUS_OK) {
this->resolution = resolution;
}
return status == VL53L5CX_STATUS_OK;
}
VL53L5CX::Resolution VL53L5CX::get_resolution() {
//Resolution resolution = RESOLUTION_4X4;
//vl53l5cx_get_resolution(configuration, (uint8_t *)&resolution);
return this->resolution;
}
bool VL53L5CX::set_integration_time_ms(uint32_t integration_time_ms) {
/* Integration time between 2ms and 1000ms */
uint8_t status = vl53l5cx_set_integration_time_ms(configuration, integration_time_ms);

Wyświetl plik

@ -39,13 +39,19 @@ namespace pimoroni {
},
};
}
~VL53L5CX() {
delete configuration;
}
bool init();
bool start_ranging();
bool stop_ranging();
bool set_i2c_address(uint8_t i2c_address);
bool set_ranging_mode(RangingMode ranging_mode);
bool set_ranging_frequency_hz(uint8_t ranging_frequency_hz);
bool set_resolution(Resolution resolution);
Resolution get_resolution();
bool set_integration_time_ms(uint32_t integration_time_ms);
bool set_sharpener_percent(uint8_t sharpener_percent);
bool set_target_order(TargetOrder target_order);
@ -58,5 +64,6 @@ namespace pimoroni {
}
private:
VL53L5CX_Configuration *configuration;
Resolution resolution = RESOLUTION_8X8;
};
}