summaryrefslogtreecommitdiff
path: root/monitor.c
diff options
context:
space:
mode:
Diffstat (limited to 'monitor.c')
-rw-r--r--monitor.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/monitor.c b/monitor.c
index 4c14bf8..41e5403 100644
--- a/monitor.c
+++ b/monitor.c
@@ -155,7 +155,7 @@ int I2C_Get_Monitor_Word(int channel)
int I2C_Check_Monitors(void)
{
int monitor_word;
- float new_val, avg_val, step_size;
+ float new_val, avg_val, step_size, max_dev_in_steps;
int channel;
int ampl_range,point_found,UseNegData,entry,word_out,atten_range;
@@ -218,8 +218,10 @@ int I2C_Check_Monitors(void)
step_size=globals.Flash.monitor_step[channel];
- /* reset average if change is bigger than MAX_STEP_DEV_FROM_AVG steps */
- if (fabs((new_val-avg_val)/step_size) > MAX_STEP_DEV_FROM_AVG) {
+ /* reset average if change is bigger than DEFAULT_MAX_STEP_DEV_FROM_AVG steps */
+
+ max_dev_in_steps = MAX(globals.Flash.max_mon_steps_before_reset_average[channel], DEFAULT_MAX_STEP_DEV_FROM_AVG);
+ if (fabs((new_val-avg_val)/step_size) > max_dev_in_steps) {
globals.ChannelState[channel].num_mon_vals = 1;
avg_val = new_val;
}