It is a little difficult to say without more info but look at this:
local gx, gy = getAcceleration()
fx = gx * filter + fx * (1-filter)
This gets the acceleration of device. Based on fact that filter has no physical units, fx
is an acceleration too (although sometimes developers take shortcuts and drop units by making assumptions about time periods and such but I don't think it is the case here).
- If filter is 0, new fx is just previous fx, everytime this
update(event)
is called (there is no info about how fx is computed, it may get updated in other parts of program too). - If filter is 1, fx is gx (device accel) only, without any consideration of previous fx value.
So it looks like filter
is a relative weight to give to device accel: when weight is zero, there is no device accel used so fx
is just whatever has been computed so far; when weight is 1 then fx
is entirely due to device accel so it is just gx
. For all other intermediate values, updated fx
is a proportional mixture of gravity and the previous value of fx: filter=0.25 means use 1/4 the effect of device accel, and the rest (1-1/4 or 3/4) the fx
computed thus far.