#ifndef __FILTER_H
#define __FILTER_H

#include "uType.h"
#include <stdint.h>

//#define FILTER_SAMPLE_SIZE  10    // 原始采样数量
//#define FILTER_VALID_SIZE   8     // 去掉最大最小后剩余的有效样本数

#define SLIDING_WINDOW_SIZE    10    // 滑动窗口大小，可调
#define FILTER_SAMPLE_SIZE     FILTER_BUFFER_SIZE
#define FILTER_VALID_SIZE      (FILTER_SAMPLE_SIZE - 2)  // 去除最大最小值


typedef struct {
    float buffer[SLIDING_WINDOW_SIZE];
    uint8_t index;
    uint8_t full;
} SlidingWindowFilter;
	
void SlidingFilter_Init(SlidingWindowFilter* filter);
float SlidingFilter_Update(SlidingWindowFilter* filter, float new_sample);
	

#endif  // __FILTER_H
