From 73a6184407996fe3553daf70182f5e116f0b8a54 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Tue, 20 Jan 2026 21:17:59 -0500 Subject: [PATCH] trigger_analog: Check if trigger_analog is allocated in trigger_analog_update() Check if the trigger_analog struct has been allocated in trigger_analog_update() itself. This makes the code easier to use in the sensor code. Signed-off-by: Kevin O'Connor --- src/sensor_ads1220.c | 4 +--- src/sensor_hx71x.c | 2 +- src/trigger_analog.c | 3 +++ 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/sensor_ads1220.c b/src/sensor_ads1220.c index 93d52b6ae..fdf770cf6 100644 --- a/src/sensor_ads1220.c +++ b/src/sensor_ads1220.c @@ -97,9 +97,7 @@ ads1220_read_adc(struct ads1220_adc *ads1220, uint8_t oid) counts |= 0xFF000000; // endstop is optional, report if enabled and no errors - if (ads1220->ta) { - trigger_analog_update(ads1220->ta, counts); - } + trigger_analog_update(ads1220->ta, counts); add_sample(ads1220, oid, counts); } diff --git a/src/sensor_hx71x.c b/src/sensor_hx71x.c index 2c09e97af..7d869d9d5 100644 --- a/src/sensor_hx71x.c +++ b/src/sensor_hx71x.c @@ -178,7 +178,7 @@ hx71x_read_adc(struct hx71x_adc *hx71x, uint8_t oid) } // probe is optional, report if enabled - if (hx71x->last_error == 0 && hx71x->ta) { + if (hx71x->last_error == 0) { trigger_analog_update(hx71x->ta, counts); } diff --git a/src/trigger_analog.c b/src/trigger_analog.c index df64a4f40..fafc63fc6 100644 --- a/src/trigger_analog.c +++ b/src/trigger_analog.c @@ -76,6 +76,9 @@ trigger_error(struct trigger_analog *ta, uint8_t error_code) void trigger_analog_update(struct trigger_analog *ta, const int32_t sample) { + if (!ta) + return; + // only process samples when homing uint8_t is_homing = is_flag_set(FLAG_IS_HOMING, ta); if (!is_homing) {