Question about custom coding to shutdown the motor

I had a question about custom coding the vesc. I am customizing the code to work in such a way that when the current consumed by the motor is less than X amps, i would like to shutdown the VESC. I know that there is an existing function which says that if the vesc is doing nothing shut it down, which doesn’t seem the perfect solution for my use case. In my application, I want the motor running and if there is no load, the motor starts consuming lesser current. I would like to use that value and then compare that value to a predefined value in the code and if it is lesser than that value shut it down. Do you know how to do that? I am using the I batt value from the RT screen and trying to compare that value and check if that works but have been unsuccessful so far.