@@ -26,6 +26,8 @@ void atr_init(ATR *atr) {
2626 atr -> on_step_size = 0.0f ;
2727 atr -> off_step_size = 0.0f ;
2828 atr -> speed_boost_mult = 0.0f ;
29+ atr -> tt_boost_uphill_margin = 0.0f ;
30+ atr -> tt_boost_downhill_threshold = 0.0f ;
2931 atr_reset (atr );
3032}
3133
@@ -48,6 +50,12 @@ void atr_configure(ATR *atr, const RefloatConfig *config) {
4850 // most +6000 for 100% speed boost
4951 atr -> speed_boost_mult = 1.0f / ((fabsf (config -> atr_speed_boost ) - 0.4f ) * 5000 + 3000.0f );
5052 }
53+
54+ // If ATR Thresholds are in place, they should be negated from the Transition Boost margin
55+ // for the effective condition (change in accel_diff needed) to be the same
56+ atr -> tt_boost_uphill_margin =
57+ fmaxf (0 , 2 - config -> atr_threshold_down - config -> atr_threshold_up );
58+ atr -> tt_boost_downhill_threshold = fmaxf (0 , 3 - config -> atr_threshold_down );
5159}
5260
5361void atr_update (ATR * atr , const MotorData * motor , const RefloatConfig * config ) {
@@ -140,20 +148,18 @@ void atr_update(ATR *atr, const MotorData *motor, const RefloatConfig *config) {
140148 // When Transition Boost condition is met, use the highest allowed step size
141149 float atr_transition_step_size = fmaxf (atr_tb_step_size , atr_on_step_size );
142150
143- const float TT_BOOST_UPHILL_MARGIN = 2 ;
144- const float TT_BOOST_DOWNHILL_THRESHOLD = 3 ;
145-
146151 bool should_transition_boost ;
147152 if (atr -> target * atr -> setpoint >= 0 ) {
148153 // If Target and Setpoint are of same sign or 0, we are not transitioning
149154 should_transition_boost = false;
150155 } else if (forward ? (atr -> setpoint < 0 && atr -> target > 0 )
151156 : (atr -> setpoint > 0 && atr -> target < 0 )) {
152157 // Transitioning Downhill to Uphill: check margin between target and setpoint
153- should_transition_boost = fabsf (atr -> target - atr -> setpoint ) >= TT_BOOST_UPHILL_MARGIN ;
158+ should_transition_boost =
159+ fabsf (atr -> target - atr -> setpoint ) >= atr -> tt_boost_uphill_margin ;
154160 } else {
155161 // Transitioning Uphill to Downhill: check target magnitude (stricter condition)
156- should_transition_boost = fabsf (atr -> target ) >= TT_BOOST_DOWNHILL_THRESHOLD ;
162+ should_transition_boost = fabsf (atr -> target ) >= atr -> tt_boost_downhill_threshold ;
157163 }
158164
159165 // Winding Down: Setpoint is moving toward 0
0 commit comments