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 <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2026-01-20 21:17:59 -05:00
parent 87c8b505a7
commit 73a6184407
3 changed files with 5 additions and 4 deletions

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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) {