ESPHome  2025.3.2
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
Data Structures | Enumerations | Functions | Variables
esphome::msa3xx Namespace Reference

Data Structures

class  MSA3xxComponent
 
union  Orientation
 
union  RegMotionInterrupt
 
union  RegOrientationStatus
 
union  RegOutputDataRate
 
union  RegPowerModeBandwidth
 
union  RegRangeResolution
 
union  RegSwapPolarity
 
union  RegTapDuration
 

Enumerations

enum  Model : uint8_t { Model::MSA301 = 0x26, Model::MSA311 = 0x62 }
 
enum  RegisterMap : uint8_t {
  RegisterMap::SOFT_RESET = 0x00, RegisterMap::PART_ID = 0x01, RegisterMap::ACC_X_LSB = 0x02, RegisterMap::ACC_X_MSB = 0x03,
  RegisterMap::ACC_Y_LSB = 0x04, RegisterMap::ACC_Y_MSB = 0x05, RegisterMap::ACC_Z_LSB = 0x06, RegisterMap::ACC_Z_MSB = 0x07,
  RegisterMap::MOTION_INTERRUPT = 0x09, RegisterMap::DATA_INTERRUPT = 0x0A, RegisterMap::TAP_ACTIVE_STATUS = 0x0B, RegisterMap::ORIENTATION_STATUS = 0x0C,
  RegisterMap::RESOLUTION_RANGE_CONFIG = 0x0D, RegisterMap::RANGE_RESOLUTION = 0x0F, RegisterMap::ODR = 0x10, RegisterMap::POWER_MODE_BANDWIDTH = 0x11,
  RegisterMap::SWAP_POLARITY = 0x12, RegisterMap::INT_SET_0 = 0x16, RegisterMap::INT_SET_1 = 0x17, RegisterMap::INT_MAP_0 = 0x19,
  RegisterMap::INT_MAP_1 = 0x1A, RegisterMap::INT_CONFIG = 0x20, RegisterMap::INT_LATCH = 0x21, RegisterMap::FREEFALL_DURATION = 0x22,
  RegisterMap::FREEFALL_THRESHOLD = 0x23, RegisterMap::FREEFALL_HYSTERESIS = 0x24, RegisterMap::ACTIVE_DURATION = 0x27, RegisterMap::ACTIVE_THRESHOLD = 0x28,
  RegisterMap::TAP_DURATION = 0x2A, RegisterMap::TAP_THRESHOLD = 0x2B, RegisterMap::ORIENTATION_CONFIG = 0x2C, RegisterMap::Z_BLOCK = 0x2D,
  RegisterMap::OFFSET_COMP_X = 0x38, RegisterMap::OFFSET_COMP_Y = 0x39, RegisterMap::OFFSET_COMP_Z = 0x3A
}
 
enum  Range : uint8_t { Range::RANGE_2G = 0b00, Range::RANGE_4G = 0b01, Range::RANGE_8G = 0b10, Range::RANGE_16G = 0b11 }
 
enum  Resolution : uint8_t { Resolution::RES_14BIT = 0b00, Resolution::RES_12BIT = 0b01, Resolution::RES_10BIT = 0b10, Resolution::RES_8BIT = 0b11 }
 
enum  PowerMode : uint8_t { PowerMode::NORMAL = 0b00, PowerMode::LOW_POWER = 0b01, PowerMode::SUSPEND = 0b11 }
 
enum  Bandwidth : uint8_t {
  Bandwidth::BW_1_95HZ = 0b0000, Bandwidth::BW_3_9HZ = 0b0011, Bandwidth::BW_7_81HZ = 0b0100, Bandwidth::BW_15_63HZ = 0b0101,
  Bandwidth::BW_31_25HZ = 0b0110, Bandwidth::BW_62_5HZ = 0b0111, Bandwidth::BW_125HZ = 0b1000, Bandwidth::BW_250HZ = 0b1001,
  Bandwidth::BW_500HZ = 0b1010
}
 
enum  DataRate : uint8_t {
  DataRate::ODR_1HZ = 0b0000, DataRate::ODR_1_95HZ = 0b0001, DataRate::ODR_3_9HZ = 0b0010, DataRate::ODR_7_81HZ = 0b0011,
  DataRate::ODR_15_63HZ = 0b0100, DataRate::ODR_31_25HZ = 0b0101, DataRate::ODR_62_5HZ = 0b0110, DataRate::ODR_125HZ = 0b0111,
  DataRate::ODR_250HZ = 0b1000, DataRate::ODR_500HZ = 0b1001, DataRate::ODR_1000HZ = 0b1010
}
 
enum  OrientationXY : uint8_t { OrientationXY::PORTRAIT_UPRIGHT = 0b00, OrientationXY::PORTRAIT_UPSIDE_DOWN = 0b01, OrientationXY::LANDSCAPE_LEFT = 0b10, OrientationXY::LANDSCAPE_RIGHT = 0b11 }
 

Functions

const char * model_to_string (Model model)
 
const char * power_mode_to_string (PowerMode power_mode)
 
const char * res_to_string (Resolution resolution)
 
const char * range_to_string (Range range)
 
const char * bandwidth_to_string (Bandwidth bandwidth)
 
const char * orientation_xy_to_string (OrientationXY orientation)
 
const char * orientation_z_to_string (bool orientation)
 
void binary_event_debounce (bool state, bool old_state, uint32_t now, uint32_t &last_ms, Trigger<> &trigger, uint32_t cooldown_ms, void *bs, const char *desc)
 

Variables

const uint8_t MSA_3XX_PART_ID = 0x13
 
const float GRAVITY_EARTH = 9.80665f
 
const float LSB_COEFF = 1000.0f / (GRAVITY_EARTH * 3.9)
 
const float G_OFFSET_MIN = -4.5f
 
const float G_OFFSET_MAX = 4.5f
 
const uint8_t RESOLUTION [] = {14, 12, 10, 8}
 
const uint32_t TAP_COOLDOWN_MS = 500
 
const uint32_t DOUBLE_TAP_COOLDOWN_MS = 500
 
const uint32_t ACTIVITY_COOLDOWN_MS = 500
 

Enumeration Type Documentation

◆ Bandwidth

enum esphome::msa3xx::Bandwidth : uint8_t
strong
Enumerator
BW_1_95HZ 
BW_3_9HZ 
BW_7_81HZ 
BW_15_63HZ 
BW_31_25HZ 
BW_62_5HZ 
BW_125HZ 
BW_250HZ 
BW_500HZ 

Definition at line 91 of file msa3xx.h.

◆ DataRate

enum esphome::msa3xx::DataRate : uint8_t
strong
Enumerator
ODR_1HZ 
ODR_1_95HZ 
ODR_3_9HZ 
ODR_7_81HZ 
ODR_15_63HZ 
ODR_31_25HZ 
ODR_62_5HZ 
ODR_125HZ 
ODR_250HZ 
ODR_500HZ 
ODR_1000HZ 

Definition at line 103 of file msa3xx.h.

◆ Model

enum esphome::msa3xx::Model : uint8_t
strong
Enumerator
MSA301 
MSA311 

Definition at line 27 of file msa3xx.h.

◆ OrientationXY

enum esphome::msa3xx::OrientationXY : uint8_t
strong
Enumerator
PORTRAIT_UPRIGHT 
PORTRAIT_UPSIDE_DOWN 
LANDSCAPE_LEFT 
LANDSCAPE_RIGHT 

Definition at line 117 of file msa3xx.h.

◆ PowerMode

enum esphome::msa3xx::PowerMode : uint8_t
strong
Enumerator
NORMAL 
LOW_POWER 
SUSPEND 

Definition at line 85 of file msa3xx.h.

◆ Range

enum esphome::msa3xx::Range : uint8_t
strong
Enumerator
RANGE_2G 
RANGE_4G 
RANGE_8G 
RANGE_16G 

Definition at line 71 of file msa3xx.h.

◆ RegisterMap

enum esphome::msa3xx::RegisterMap : uint8_t
strong
Enumerator
SOFT_RESET 
PART_ID 
ACC_X_LSB 
ACC_X_MSB 
ACC_Y_LSB 
ACC_Y_MSB 
ACC_Z_LSB 
ACC_Z_MSB 
MOTION_INTERRUPT 
DATA_INTERRUPT 
TAP_ACTIVE_STATUS 
ORIENTATION_STATUS 
RESOLUTION_RANGE_CONFIG 
RANGE_RESOLUTION 
ODR 
POWER_MODE_BANDWIDTH 
SWAP_POLARITY 
INT_SET_0 
INT_SET_1 
INT_MAP_0 
INT_MAP_1 
INT_CONFIG 
INT_LATCH 
FREEFALL_DURATION 
FREEFALL_THRESHOLD 
FREEFALL_HYSTERESIS 
ACTIVE_DURATION 
ACTIVE_THRESHOLD 
TAP_DURATION 
TAP_THRESHOLD 
ORIENTATION_CONFIG 
Z_BLOCK 
OFFSET_COMP_X 
OFFSET_COMP_Y 
OFFSET_COMP_Z 

Definition at line 33 of file msa3xx.h.

◆ Resolution

enum esphome::msa3xx::Resolution : uint8_t
strong
Enumerator
RES_14BIT 
RES_12BIT 
RES_10BIT 
RES_8BIT 

Definition at line 78 of file msa3xx.h.

Function Documentation

◆ bandwidth_to_string()

const char* esphome::msa3xx::bandwidth_to_string ( Bandwidth  bandwidth)

Definition at line 78 of file msa3xx.cpp.

◆ binary_event_debounce()

void esphome::msa3xx::binary_event_debounce ( bool  state,
bool  old_state,
uint32_t  now,
uint32_t &  last_ms,
Trigger<> &  trigger,
uint32_t  cooldown_ms,
void *  bs,
const char *  desc 
)

Definition at line 373 of file msa3xx.cpp.

◆ model_to_string()

const char* esphome::msa3xx::model_to_string ( Model  model)

Definition at line 24 of file msa3xx.cpp.

◆ orientation_xy_to_string()

const char* esphome::msa3xx::orientation_xy_to_string ( OrientationXY  orientation)

Definition at line 103 of file msa3xx.cpp.

◆ orientation_z_to_string()

const char* esphome::msa3xx::orientation_z_to_string ( bool  orientation)

Definition at line 118 of file msa3xx.cpp.

◆ power_mode_to_string()

const char* esphome::msa3xx::power_mode_to_string ( PowerMode  power_mode)

Definition at line 35 of file msa3xx.cpp.

◆ range_to_string()

const char* esphome::msa3xx::range_to_string ( Range  range)

Definition at line 63 of file msa3xx.cpp.

◆ res_to_string()

const char* esphome::msa3xx::res_to_string ( Resolution  resolution)

Definition at line 48 of file msa3xx.cpp.

Variable Documentation

◆ ACTIVITY_COOLDOWN_MS

const uint32_t esphome::msa3xx::ACTIVITY_COOLDOWN_MS = 500

Definition at line 22 of file msa3xx.cpp.

◆ DOUBLE_TAP_COOLDOWN_MS

const uint32_t esphome::msa3xx::DOUBLE_TAP_COOLDOWN_MS = 500

Definition at line 21 of file msa3xx.cpp.

◆ G_OFFSET_MAX

const float esphome::msa3xx::G_OFFSET_MAX = 4.5f

Definition at line 16 of file msa3xx.cpp.

◆ G_OFFSET_MIN

const float esphome::msa3xx::G_OFFSET_MIN = -4.5f

Definition at line 15 of file msa3xx.cpp.

◆ GRAVITY_EARTH

const float esphome::msa3xx::GRAVITY_EARTH = 9.80665f

Definition at line 13 of file msa3xx.cpp.

◆ LSB_COEFF

const float esphome::msa3xx::LSB_COEFF = 1000.0f / (GRAVITY_EARTH * 3.9)

Definition at line 14 of file msa3xx.cpp.

◆ MSA_3XX_PART_ID

const uint8_t esphome::msa3xx::MSA_3XX_PART_ID = 0x13

Definition at line 11 of file msa3xx.cpp.

◆ RESOLUTION

const uint8_t esphome::msa3xx::RESOLUTION[] = {14, 12, 10, 8}

Definition at line 18 of file msa3xx.cpp.

◆ TAP_COOLDOWN_MS

const uint32_t esphome::msa3xx::TAP_COOLDOWN_MS = 500

Definition at line 20 of file msa3xx.cpp.