LSM303AGR
-
namespace LSM303AGR
STMicroelectronics LSM303AGR sensor.
The STMicroelectronics LSM303AGR is a ultra-low power 3D accelerometer and 3D magnetometer.
For technical documents and a complete description of the sensor features please refer to the official documentation at: https://www.st.com/en/mems-and-sensors/lsm303agr.html
To create a STMicroelectronics LSM303AGR sensor use the HUX_DECLARE_SENSOR
construct:
HUX_DECLARE_SENSOR(sensor_name, hux::sensors::STMicroelectronics::LSM303AGR);
Simulation data
To define simulation data for a STMicroelectronics LSM303AGR sensor use the HUX_DECLARE_SIMULATION_DATA
construct,
making sure that the simulation data match the following data type:
-
typedef hux::tuple<std::vector<float>, std::vector<float>, std::vector<float>, std::vector<float>, std::vector<float>, std::vector<float>, std::vector<hux::uint64_t>> hux::sensors::STMicroelectronics::LSM303AGR::simulation_data_t
The type of data required for simulation purposes.
A hux::tuple of std::vector of the following types:
float: Acceleration on the X axis in g units
float: Acceleration on the Y axis in g units
float: Acceleration on the Z axis in g units
float: Magnetic field strength on the X axis in gauss
float: Magnetic field strength on the Y axis in gauss
float: Magnetic field strength on the Z axis in gauss
hux::uint64_t: Unix timestamp in milliseconds of the data generated by the sensor
This example shows how to load simulation data for a STMicroelectronics LSM303AGR sensor from a CSV file whose columns are separated by semicolon (“;”):
HUX_DECLARE_SIMULATION_DATA(sim_data,
hux::simulation::load_csv<float, float, float, float, float, float, hux::uint64_t>("dataset.csv", ";"))
);
HUX_DECLARE_SENSOR(sensor_name, hux::sensors::STMicroelectronics::LSM303AGR, sim_data);
Sources
The STMicroelectronics LSM303AGR sensor offers the following sources:
-
inline constexpr const auto get_accX()
Acceleration on the X axis in g units.
- Returns
The accX axis Source
-
inline constexpr const auto get_accY()
Acceleration on the Y axis in g units.
- Returns
The accY axis Source
-
inline constexpr const auto get_accZ()
Acceleration on the Z axis in g units.
- Returns
The accZ axis Source
-
inline constexpr const auto get_magX()
Magnetic field strength on the X axis in gauss.
- Returns
The magX axis Source
-
inline constexpr const auto get_magY()
Magnetic field strength on the Y axis in gauss.
- Returns
The magY axis Source
-
inline constexpr const auto get_magZ()
Magnetic field strength on the Z axis in gauss.
- Returns
The magZ axis Source
-
inline constexpr const auto get_timestamp()
Unix timestamp in milliseconds of the data generated by the sensor.
- Returns
The Unix timestamp in milliseconds of the data generated by the sensor
Configurations
Initial configuration
To define an initial configuration for a STMicroelectronics LSM303AGR sensor
use the HUX_DECLARE_SENSOR_CONFIGURATION
construct:
HUX_DECLARE_SENSOR_CONFIGURATION(conf_name, hux::sensors::STMicroelectronics::LSM303AGR,
.PARAM_1 = VALUE_1,
.PARAM_2 = VALUE_2,
...
);
HUX_DECLARE_SENSOR(sensor_name, hux::sensors::STMicroelectronics::LSM303AGR, {}, conf_name);
where PARAM_1, PARAM_2, … can be any of the following:
Note
If a parameter is not specified within the sensor configuration its default value is used.
Valid configuration values
Each sensor model has its own configuration values that are permitted by the manufacturer and supported by Huxon. The valid configuration values for the configuration parameters of the STMicroelectronics LSM303AGR are listed below:
-
struct configs
Available configuration values for STMicroelectronics LSM303AGR.
Public Static Attributes
-
static constexpr float acc_odr_1 = 1.0
-
static constexpr float acc_odr_10 = 10.0
-
static constexpr float acc_odr_25 = 25.0
-
static constexpr float acc_odr_50 = 50.0
-
static constexpr float acc_odr_100 = 100.0
-
static constexpr float acc_fs_2 = 2
-
static constexpr float acc_fs_4 = 4
-
static constexpr float acc_fs_8 = 8
-
static constexpr float acc_fs_16 = 16
-
static constexpr float mag_odr_10 = 10.0
-
static constexpr float mag_odr_20 = 20.0
-
static constexpr float mag_odr_50 = 50.0
-
static constexpr float mag_odr_100 = 100.0
-
static constexpr float acc_odr_1 = 1.0
Dynamic configuration
The Huxon language provides the capability to reconfigure sensor parameters dynamically while the application is running. This allow to change the behavior of a sensor in response to specific events.
To dynamically reconfigure a STMicroelectronics LSM303AGR sensor, it is necessary to create a configurator through
the HUX_SENSOR_CONFIGURATOR_BUILDER
and register it to the sensor using HUX_REGISTER_SENSOR_CONFIGURATOR
:
HUX_DECLARE_SENSOR(sensor_name, hux::sensors::STMicroelectronics::LSM303AGR);
...
auto configurator = HUX_SENSOR_CONFIGURATOR_BUILDER(hux::sensors::STMicroelectronics::LSM303AGR)
.add_PARAM1_cfg_chan(param1_channel)
.add_PARAM2_cfg_chan(param2_channel)
...
.finalize();
HUX_REGISTER_SENSOR_CONFIGURATOR(sensor_name, configurator);
where param1_channel, param2_channel, … are channels that generate configuration values, while the configurator builder methods: add_PARAM1_cfg_chan, add_PARAM2_cfg_chan, … bind such channels to the parameters they will configure. The configurator builder methods can be any of the following:
-
template<hux::channels::IsChannelOf<float> channel_t>
inline constexpr const auto add_ACC_ODR_cfg_chan(channel_t channel) const Configures a channel for the ODR (Output Data Rate) parameter of the accelerometer.
Please refer to the official sensor documentation (https://www.st.com/en/mems-and-sensors/lsm303agr.html) for details on this parameter
- Template Parameters
channel_t – The type of input channel supplying the configuration values for the parameter
- Parameters
channel – The input channel supplying the configuration values for the parameter
- Returns
The updated builder instance (for further method invocation chaining)
-
template<hux::channels::IsChannelOf<float> channel_t>
inline constexpr const auto add_ACC_FS_cfg_chan(channel_t channel) const Configures a channel for the FS (Full Scale) parameter of the accelerometer.
Please refer to the official sensor documentation (https://www.st.com/en/mems-and-sensors/lsm303agr.html) for details on this parameter
- Template Parameters
channel_t – The type of input channel supplying the configuration values for the parameter
- Parameters
channel – The input channel supplying the configuration values for the parameter
- Returns
The updated builder instance (for further method invocation chaining)
-
template<hux::channels::IsChannelOf<float> channel_t>
inline constexpr const auto add_MAG_ODR_cfg_chan(channel_t channel) const Configures a channel for the ODR (Output Data Rate) parameter of the magnetometer.
Please refer to the official sensor documentation (https://www.st.com/en/mems-and-sensors/lsm303agr.html) for details on this parameter
- Template Parameters
channel_t – The type of input channel supplying the configuration values for the parameter
- Parameters
channel – The input channel supplying the configuration values for the parameter
- Returns
The updated builder instance (for further method invocation chaining)