Android Question Magnetic sensor filter...

Spectre

Active Member
Licensed User
Longtime User
Sorry for the question .... you can filter or compensate for the magnetic sensor so that there are continuous fluctuations of values?
best regards... spectre.
 

Spectre

Active Member
Licensed User
Longtime User
Hi Erel...
You would get more uniform data(smoother). and stable situation.

You would get more linear data. and stable situation.
 
Upvote 0

Spectre

Active Member
Licensed User
Longtime User
Hi Erel....
May "Filter"....

B4X:
 Sub MovingAVG(Magnetic As Int)
  Dim x As Int
   
     
      Dim MagData As List  'store mag raw data to sensor
   
        MagData.Initialize
        MagData.Add(Magnetic)
        Dim  maDuration As Int = 30 'length of  average for calculate
        Dim MagList As List
        MagList.Initialize
        Dim MayAvg As Int 'storage for values and average
        For x  = 0 To MagData.size - 1 'iterate through random data
            MagList.Add( MagData.Get(x)) 'insert into list
            MayAvg = 0 'reset and calculate the avg
                For y = 0 To MagList.size - 1
                    MayAvg = MayAvg + MagList.Get(y) 'ad values
                Next
            MayAvg = MayAvg / MagList.size 'divide by the count
            Log (MayAvg)
            Return MayAvg
            If MagList.size = maDuration Then
                MagList.RemoveAt(MagList.size - 1) 'remove  oldest value on List
            End If
        Next
    End Sub
 
Upvote 0
Top