/* * limit_lib.c * * Created on: 15 рту. 2024 у. * Author: yura */ #include "IQmathLib.h" #include "math_pi.h" _iq linear_decrease(float current, int alarm_level, int warnig_level) { float delta = current - warnig_level; float max_delta = alarm_level - warnig_level; if (delta <= 0 || max_delta <= 0) { return CONST_IQ_1; } else { if (delta>max_delta) return 0; else return CONST_IQ_1 - _IQ(delta / max_delta); } } _iq linear_decrease_iq(_iq current, _iq alarm_level, _iq warnig_level) { _iq delta = current - warnig_level; _iq max_delta = alarm_level - warnig_level; if (delta <= 0 || max_delta <= 0) { return CONST_IQ_1; } else { if (delta>=max_delta) return 0; else return CONST_IQ_1 - _IQdiv(delta, max_delta); } }