add control for averaging each cycle or not

using mean_thI for obtaining diff_th1, diff_th2