PebbleOS
Loading...
Searching...
No Matches
Data Structures | Typedefs | Enumerations | Functions
ecompass.h File Reference
#include <pbl/services/battery/battery_monitor.h>

Data Structures

struct  CompassHeadingData
 Structure containing a single heading towards magnetic and true north. More...
 

Typedefs

typedef int32_t CompassHeading
 Represents an angle relative to get to a reference direction, e.g.
 

Enumerations

enum  CompassStatus { CompassStatusUnavailable = -1 , CompassStatusDataInvalid = 0 , CompassStatusCalibrating , CompassStatusCalibrated }
 Enum describing the current state of the Compass Service. More...
 
enum  MagCalStatus { MagCalStatusNoSolution , MagCalStatusSavedSampleMatch , MagCalStatusNewSolutionAvail , MagCalStatusNewLockedSolutionAvail }
 Result of feeding a sample to the hard iron calibration. More...
 

Functions

void ecompass_service_init (void)
 Register the compass with the event service.
 
void ecompass_service_handle (void)
 Process a new magnetometer sample.
 
void ecompass_handle_battery_state_change_event (PreciseBatteryChargeState new_state)
 Handle a battery state change.
 
MagCalStatus ecomp_corr_add_raw_mag_sample (int16_t *sample, int16_t *saved_corr, int16_t *new_corr)
 Feed a raw magnetometer sample to the hard iron calibration.
 
void ecomp_corr_reset (void)
 Drop the samples collected by ecomp_corr_add_raw_mag_sample() and reset its state.
 
bool sys_ecompass_service_subscribed (void)
 Check whether the current task is subscribed to the compass.
 
void sys_ecompass_get_last_heading (CompassHeadingData *data)
 Get the last published heading.
 

Data Structure Documentation

◆ CompassHeadingData

struct CompassHeadingData

Structure containing a single heading towards magnetic and true north.

Data Fields
CompassStatus compass_status Indicates the current state of the Compass Service calibration.
bool is_declination_valid Currently always false (reserved for future implementation).
CompassHeading magnetic_heading Measured angle that increases counter-clockwise from magnetic north (use int clockwise_heading = TRIG_MAX_ANGLE - heading_data.magnetic_heading; for example to find your heading clockwise from magnetic north).
CompassHeading true_heading Currently same value as magnetic_heading (reserved for future implementation).

Typedef Documentation

◆ CompassHeading

typedef int32_t CompassHeading

Represents an angle relative to get to a reference direction, e.g.

(magnetic) north.

The angle value is scaled linearly, such that a value of TRIG_MAX_ANGLE corresponds to 360 degrees or 2 PI radians. Thus, if heading towards north, north is 0, west is TRIG_MAX_ANGLE/4, south is TRIG_MAX_ANGLE/2, and so on.

Enumeration Type Documentation

◆ CompassStatus

Enum describing the current state of the Compass Service.

Enumerator
CompassStatusUnavailable 

The Compass Service is unavailable.

CompassStatusDataInvalid 

Compass is calibrating: data is invalid and should not be used Data will become valid once calibration is complete.

CompassStatusCalibrating 

Compass is calibrating: the data is valid but the calibration is still being refined.

CompassStatusCalibrated 

Compass data is valid and the calibration has completed.