fix: update_moving_average window 参数 uint8_t→uint16_t

WINDOW_ORIGIN=500 超出 uint8_t 范围,会被截断为 244。
改为 uint16_t 支持 WINDOW_ORIGIN 最大到 60000+。
This commit is contained in:
wangfq
2026-06-29 15:55:58 +08:00
parent 9391d46ff4
commit 353fd575fc
2 changed files with 2 additions and 2 deletions

View File

@@ -180,7 +180,7 @@ void poll_sw_state(void);
uint32_t get_flt_value(uint32_t new_value, uint32_t last_Value); uint32_t get_flt_value(uint32_t new_value, uint32_t last_Value);
uint8_t update_moving_average(uint32_t* p_sum, uint16_t* p_cnt, uint8_t update_moving_average(uint32_t* p_sum, uint16_t* p_cnt,
uint32_t* p_origin, uint32_t new_value, uint32_t* p_origin, uint32_t new_value,
uint8_t window); uint16_t window);
void poll_yellow_led(void); void poll_yellow_led(void);
void poll_green_led(void); void poll_green_led(void);
void LEDA_ON_OFF(void); void LEDA_ON_OFF(void);

View File

@@ -175,7 +175,7 @@ uint32_t get_flt_value(uint32_t new_value, uint32_t last_Value)
*===========================================================================*/ *===========================================================================*/
uint8_t update_moving_average(uint32_t* p_sum, uint16_t* p_cnt, uint8_t update_moving_average(uint32_t* p_sum, uint16_t* p_cnt,
uint32_t* p_origin, uint32_t new_value, uint32_t* p_origin, uint32_t new_value,
uint8_t window) uint16_t window)
{ {
if (!p_sum || !p_cnt || !p_origin || window == 0) { if (!p_sum || !p_cnt || !p_origin || window == 0) {
return 0; return 0;