fix(as5600): check before delete

This commit is contained in:
Tyeth Gundry 2025-08-26 18:31:45 +01:00
parent d2d51db455
commit 7a275e5d02

View file

@ -47,7 +47,12 @@ public:
@brief Destructor for an AS5600 sensor.
*/
/*******************************************************************************/
~WipperSnapper_I2C_Driver_AS5600() { delete _as5600; }
~WipperSnapper_I2C_Driver_AS5600() {
if (_as5600) {
delete _as5600;
_as5600 = nullptr;
}
}
/*******************************************************************************/
/*!
@ -129,7 +134,6 @@ public:
*/
/*******************************************************************************/
bool getEventRaw(sensors_event_t *rawEvent) {
ulong start = millis();
if (!readSensor()) {
return false;
}