ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
MMC56X3 Class Reference

A class for managing the Adafruit MMC56x3 magnetometer sensor. More...

#include <MMC56X3.h>

Collaboration diagram for MMC56X3:

Static Public Member Functions

static bool Initialize (uint8_t address=MMC56X3_DEFAULT_ADDRESS)
 Initializes the MMC56x3 sensor.
 
static void Update ()
 Updates the magnetic field data from the sensor.
 
static Vector3D GetMagneticField ()
 Retrieves the current magnetic field vector.
 
static float IsDetected ()
 Checks if a magnet is detected.
 
static float GetMagnitude ()
 Calculates the magnitude of the magnetic field.
 
static Vector3D EstimateMagnetPosition ()
 Estimates the position of a detected magnet.
 

Static Private Attributes

static Adafruit_MMC5603 mag
 Instance of the Adafruit MMC5603 sensor.
 
static sensors_event_t magEvent
 Sensor event data for magnetic field measurements.
 
static RunningAverageFilter< 10 > xFilter = RunningAverageFilter<10>(0.1f)
 Filter for the X-axis magnetic field data.
 
static RunningAverageFilter< 10 > yFilter = RunningAverageFilter<10>(0.1f)
 Filter for the Y-axis magnetic field data.
 
static RunningAverageFilter< 10 > zFilter = RunningAverageFilter<10>(0.1f)
 Filter for the Z-axis magnetic field data.
 
static TimeStep timeStep = TimeStep(100)
 Time utility for regular updates.
 
static TimeStep timeStepCal = TimeStep(1)
 Time utility for calibration intervals.
 
static Vector3D magneticField = Vector3D()
 Processed magnetic field vector.
 
static bool didBegin = false
 Flag indicating if the sensor has been initialized.
 
static MinFilter< 10 > minF = MinFilter<10>(false)
 Minimum filter for noise reduction.
 
static float minimum = 0.0f
 Minimum threshold for detection.
 

Detailed Description

A class for managing the Adafruit MMC56x3 magnetometer sensor.

The MMC56X3 class provides methods for initializing the sensor, retrieving magnetic field data, detecting magnets, and estimating magnet positions.

Definition at line 29 of file MMC56X3.h.

Member Function Documentation

◆ EstimateMagnetPosition()

Vector3D EstimateMagnetPosition ( )
static

Estimates the position of a detected magnet.

Returns
A Vector3D representing the estimated magnet position.

Definition at line 56 of file MMC56X3.cpp.

References GetMagnitude(), magneticField, Update(), Vector3D::X, Vector3D::Y, and Vector3D::Z.

◆ GetMagneticField()

Vector3D GetMagneticField ( )
static

Retrieves the current magnetic field vector.

Returns
A Vector3D representing the magnetic field.

Definition at line 43 of file MMC56X3.cpp.

References magneticField, and Update().

◆ GetMagnitude()

float GetMagnitude ( )
static

Calculates the magnitude of the magnetic field.

Returns
The magnitude of the magnetic field as a float.

Definition at line 52 of file MMC56X3.cpp.

References magneticField, Vector3D::X, Vector3D::Y, and Vector3D::Z.

Referenced by EstimateMagnetPosition(), IsDetected(), and Update().

◆ Initialize()

bool Initialize ( uint8_t  address = MMC56X3_DEFAULT_ADDRESS)
static

Initializes the MMC56x3 sensor.

Parameters
addressThe I2C address of the sensor (default is MMC56X3_DEFAULT_ADDRESS).
Returns
True if initialization is successful, false otherwise.

Definition at line 15 of file MMC56X3.cpp.

References didBegin, and mag.

◆ IsDetected()

float IsDetected ( )
static

Checks if a magnet is detected.

Returns
A float value representing the detection confidence.

Definition at line 48 of file MMC56X3.cpp.

References GetMagnitude(), and minimum.

◆ Update()

Member Data Documentation

◆ didBegin

bool didBegin = false
staticprivate

Flag indicating if the sensor has been initialized.

Definition at line 39 of file MMC56X3.h.

Referenced by Initialize(), and Update().

◆ mag

Adafruit_MMC5603 mag
staticprivate

Instance of the Adafruit MMC5603 sensor.

Definition at line 31 of file MMC56X3.h.

Referenced by Initialize(), and Update().

◆ magEvent

sensors_event_t magEvent
staticprivate

Sensor event data for magnetic field measurements.

Definition at line 32 of file MMC56X3.h.

Referenced by Update().

◆ magneticField

Vector3D magneticField = Vector3D()
staticprivate

Processed magnetic field vector.

Definition at line 38 of file MMC56X3.h.

Referenced by EstimateMagnetPosition(), GetMagneticField(), GetMagnitude(), and Update().

◆ minF

MinFilter< 10 > minF = MinFilter<10>(false)
staticprivate

Minimum filter for noise reduction.

Definition at line 40 of file MMC56X3.h.

Referenced by Update().

◆ minimum

float minimum = 0.0f
staticprivate

Minimum threshold for detection.

Definition at line 41 of file MMC56X3.h.

Referenced by IsDetected(), and Update().

◆ timeStep

TimeStep timeStep = TimeStep(100)
staticprivate

Time utility for regular updates.

Definition at line 36 of file MMC56X3.h.

Referenced by Update().

◆ timeStepCal

TimeStep timeStepCal = TimeStep(1)
staticprivate

Time utility for calibration intervals.

Definition at line 37 of file MMC56X3.h.

Referenced by Update().

◆ xFilter

RunningAverageFilter< 10 > xFilter = RunningAverageFilter<10>(0.1f)
staticprivate

Filter for the X-axis magnetic field data.

Definition at line 33 of file MMC56X3.h.

Referenced by Update().

◆ yFilter

RunningAverageFilter< 10 > yFilter = RunningAverageFilter<10>(0.1f)
staticprivate

Filter for the Y-axis magnetic field data.

Definition at line 34 of file MMC56X3.h.

Referenced by Update().

◆ zFilter

RunningAverageFilter< 10 > zFilter = RunningAverageFilter<10>(0.1f)
staticprivate

Filter for the Z-axis magnetic field data.

Definition at line 35 of file MMC56X3.h.

Referenced by Update().


The documentation for this class was generated from the following files: