average
This commit is contained in:
@ -28,9 +28,25 @@ void my_errorHandler() {
|
||||
show(LED_RED, ON);
|
||||
}
|
||||
|
||||
|
||||
uint32_t mainsCntSum = 0;
|
||||
uint32_t mainsCntCnt = 0;
|
||||
void second_tick(void *handle) {
|
||||
uint32_t tmpSum = 0;
|
||||
uint32_t tmpCnt = 0;
|
||||
|
||||
HAL_NVIC_DisableIRQ(TIM1_CC_IRQn);
|
||||
tmpSum = mainsCntSum;
|
||||
mainsCntSum = 0;
|
||||
tmpCnt = mainsCntCnt;
|
||||
mainsCntCnt = 0;
|
||||
HAL_NVIC_EnableIRQ(TIM1_CC_IRQn);
|
||||
|
||||
uint32_t cnt = tmpSum / tmpCnt;
|
||||
double f = 1.0 / ((double)cnt) * 1.0e6;
|
||||
|
||||
t_seconds *seconds = wizGetSeconds();
|
||||
coloredMsg(LOG_GREEN, "Tick %d %lu %lu", seconds->valid, seconds->missedUpdates, seconds->seconds);
|
||||
coloredMsg(LOG_GREEN, "Tick %f %d %lu %lu", f, seconds->valid, seconds->missedUpdates, seconds->seconds);
|
||||
}
|
||||
|
||||
|
||||
@ -96,8 +112,10 @@ void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim) {
|
||||
} else if (state == 1) {
|
||||
show(DEBUG_2, OFF);
|
||||
uint32_t captured = (savedV < v) ? (v - savedV) : ((htim->Init.Period - savedV) + v);
|
||||
double f = 1.0 / ((double)captured) * 1.0e6;
|
||||
logMsg("CCR: %ld, %f", captured, f);
|
||||
//double f = 1.0 / ((double)captured) * 1.0e6;
|
||||
//logMsg("CCR: %ld, %f", captured, f);
|
||||
mainsCntSum += captured;
|
||||
mainsCntCnt += 1;
|
||||
state = 0;
|
||||
} else {
|
||||
state = 0;
|
||||
|
Reference in New Issue
Block a user