4 /////////// Super Simple Fixed Point Lowpass ////////////////
11 int32_t Beta
= 3; // Length = 16
12 int32_t FP_Shift
= 5; //Number of fractional bits
13 bool NeedReset
= true; // wait for the first data to upcoming.
15 LPF(int Beta_
, int FP_Shift_
)
32 int32_t ICACHE_RAM_ATTR
update(int32_t Indata
)
42 RawData
<<= FP_Shift
; // Shift to fixed point
43 SmoothDataFP
= (SmoothDataFP
<< Beta
) - SmoothDataFP
;
44 SmoothDataFP
+= RawData
;
45 SmoothDataFP
>>= Beta
;
46 // Don't do the following shift if you want to do further
47 // calculations in fixed-point using SmoothData
48 SmoothDataINT
= SmoothDataFP
>> FP_Shift
;
52 void ICACHE_RAM_ATTR
reset()
58 void ICACHE_RAM_ATTR
init(int32_t Indata
)
62 SmoothDataINT
= Indata
;
63 SmoothDataFP
= SmoothDataINT
<< FP_Shift
;
66 int32_t value() const { return SmoothDataINT
; }