diff --git a/components/badge23/captouch.c b/components/badge23/captouch.c index d2592faec89ed155363da22e6869ef89b670c1ed..4b7539954afb761a6d1da674e0f0472e02aea20d 100644 --- a/components/badge23/captouch.c +++ b/components/badge23/captouch.c @@ -220,17 +220,13 @@ static int8_t captouch_configure_stage_afe_offset(uint8_t top, uint8_t stage, in int8_t sat = 0; struct ad714x_chip * chip = chip_bot; if(top) chip = chip_top; - int8_t afe = chip->pos_afe_offsets[stage] - chip->neg_afe_offsets[stage]; + if((afe >= 63) && (delta_afe > 0)) sat = 1; + if((afe <= 63) && (delta_afe < 0)) sat = -1; afe += delta_afe; - if(afe >= 63){ - afe = 63; - sat = 1; - } - if(afe <= -63){ - afe = -63; - sat = -1; - } + if(afe >= 63) afe = 63; + if(afe <= -63)afe = -63; + if(afe>0){ chip->pos_afe_offsets[stage] = afe; chip->neg_afe_offsets[stage] = 0;