Fix another calcuation error

Fix another calcuation error
This commit is contained in:
Theo Arends 2018-11-25 17:31:53 +01:00
parent 5ebef45465
commit 243ec16d80
1 changed files with 7 additions and 10 deletions

View File

@ -2585,15 +2585,6 @@ void GpioInit(void)
XdrvCall(FUNC_PRE_INIT);
}
void UpdateLoopLoadAvg(uint32_t loop_activity)
{
uint32_t loop_delay = Settings.param[P_LOOP_SLEEP_DELAY];
if (!loop_delay) { loop_delay = 1; } // We cannot devide by 0
uint32_t loops_per_second = 1000 / loop_delay; // We need to keep track of this many loops per second
uint32_t this_cycle_ratio = 100 * loop_activity / loop_delay;
loop_load_avg = loop_load_avg - (loop_load_avg / loops_per_second) + this_cycle_ratio; // Take away one loop average away and add the new one
}
extern "C" {
extern struct rst_info resetInfo;
}
@ -2799,5 +2790,11 @@ void loop(void)
delay(my_activity /2); // If wifi down and my_activity > setoption36 then force loop delay to 1/3 of my_activity period
}
}
UpdateLoopLoadAvg(my_activity);
if (!my_activity) { my_activity++; } // We cannot divide by 0
uint32_t loop_delay = Settings.param[P_LOOP_SLEEP_DELAY];
if (!loop_delay) { loop_delay++; } // We cannot divide by 0
uint32_t loops_per_second = 1000 / loop_delay; // We need to keep track of this many loops per second
uint32_t this_cycle_ratio = 100 * my_activity / loop_delay;
loop_load_avg = loop_load_avg - (loop_load_avg / loops_per_second) + this_cycle_ratio; // Take away one loop average away and add the new one
}