fix
This commit is contained in:
@ -30,8 +30,14 @@ static void counterZeroCrossingAveragerTask(void *arg) {
|
|||||||
uint64_t counterCurrentValue;
|
uint64_t counterCurrentValue;
|
||||||
xQueueReceive(zeroCrossingQueue, &counterCurrentValue, portMAX_DELAY);
|
xQueueReceive(zeroCrossingQueue, &counterCurrentValue, portMAX_DELAY);
|
||||||
if (counterCurrentValue == QUEUE_MARKER) {
|
if (counterCurrentValue == QUEUE_MARKER) {
|
||||||
|
if (counterCnt > 0) {
|
||||||
uint32_t counterSecondAverage = ((uint32_t)(counterSum)) / ((uint32_t)(counterCnt));
|
uint32_t counterSecondAverage = ((uint32_t)(counterSum)) / ((uint32_t)(counterCnt));
|
||||||
ESP_LOGI(TAG, "second average is %lu", counterSecondAverage);
|
ESP_LOGI(TAG, "second average is %lu", counterSecondAverage);
|
||||||
|
} else {
|
||||||
|
ESP_LOGW(TAG, "counterCnt is zero");
|
||||||
|
}
|
||||||
|
counterCnt = 0;
|
||||||
|
counterSum = 0;
|
||||||
} else {
|
} else {
|
||||||
counterSum += 1;
|
counterSum += 1;
|
||||||
counterCnt += counterValue;
|
counterCnt += counterValue;
|
||||||
|
Reference in New Issue
Block a user