KXTJ3 Class
Item Index
Methods
- KXTJ3
- SensorInit
- GetWhoAmI
- SensorActive
- SensorStandby
- SetGRange
- SetResolution
- SetOdr
- SetOdrForWakeup
- SelfTestDigitalCommunication
- SensorSelfTest
- SensorSoftwareReset
- GetAccelerationRawVector
- GetAccelerationVector
- GetAccelerationSamplePeriod
- GetWakeUpSamplePeriod
- EnableDataReadyInterrupt
- DisableDataReadyInterrupt
- EnableWakeUpInterrupt
- DisableWakeUpInterrupt
- EnableInterruptPin
- DisableInterruptPin
- SetInterruptPolarity
- SetInerruptResponse
- GetInterruptStatus
- ReadInterruptSource1
- GetInterruptSource
- InstallIsr
- UninstallIsr
- ClearInterrupt
- EnableWakeUpSingleAxisDirection
- DisableWakeUpSingleAxisDirection
- GetWakeUpAxisDirection
- EnableWakeUpLatch
- DisableWakeUpLatch
- SetWakeUpMotionCounter
- SetWakeUpMotionTime
- GetWakeUpMotionTime
- SetWakeUpNonActivityCounter
- SetWakeUpNonActivityTime
- GetWakeUpNonActivityTime
- SetWakeUpThresholdCounter
- SetWakeUpThresholdGRange
- GetWakeUpThresholdGRange
Methods
KXTJ3
-
bus
-
addr
If no errors occur, the device is initialized with default values and set to active state
Parameters:
-
bus
NumberI2C bus
-
addr
NumberI2C address of the sensor
Returns:
SensorInit
-
odr
-
resolution
-
g_range
Sensor is set to standby mode during the initialization and back to active after initialization.
Parameters:
-
odr
KXTJ3_ODR_TOne of the KXTJ3_ODR_T values
-
resolution
KXTJ3_RESOLUTION_TOne of the KXTJ3_RESOLUTION_T values
-
g_range
KXTJ3_G_RANGE_TOne of the KXTJ3_G_RANGE_T values
GetWhoAmI
()
Number
Returns:
Who am I value of the sensor
SensorActive
()
SensorStandby
()
SetGRange
-
g_range
Sensor needs to be in standby mode when setting the acceleration range value
Be cautious not to set g_range to 14-bits modes with the resolution being on LOW_RES
Parameters:
-
g_range
KXTJ3_G_RANGE_TOne of the KXTJ3_G_RANGE_T values
SetResolution
-
resolution
LOW_RES valid only for ODR <= 200 Hz
Be cautious not to set resolution to LOW_RES with the G_RANG being on 14-bits modes
Sensor needs to be in standby mode when setting the sensor resolution
Parameters:
-
resolution
KXTJ3_RESOLUTION_TOne of the KXTJ3_RESOLUTION_T values
SetOdr
-
odr
Sensor needs to be in standby mode when setting the ODR
Parameters:
-
odr
KXTJ3_ODR_TOne of the KXTJ3_ODR_T values
SetOdrForWakeup
-
odr
Sensor needs to be in standby mode when setting the ODR
Parameters:
-
odr
KXTJ3_ODR_WAKEUP_TOne of the KXTJ3_ODR_WAKEUP_T values
SelfTestDigitalCommunication
()
This method is called by SensorSelfTest also
Sensor must be in standby mode before performing this action
SensorSelfTest
()
The method prints out the values before and during test and the average difference for each axis
See the datasheet for more information
SensorSoftwareReset
()
You should call kxtj3_sensor_init() after the software reset
See the datasheet for more details
GetAccelerationRawVector
()
Std::vector float
Gets raw acceleration data from the sensor.
Returns:
Acceleration vector [x, y, z]
GetAccelerationVector
()
Std::vector float
Gets acceleration data in (m/s^2) from the sensor.
Returns:
Acceleration vector [x, y, z]
GetAccelerationSamplePeriod
()
Number
Returns:
Floating point value of the sampling period
GetWakeUpSamplePeriod
()
Number
Returns:
Floating point value of the sampling period
EnableDataReadyInterrupt
()
Sensor must be in standby mode before performing this action
DisableDataReadyInterrupt
()
Sensor must be in standby mode before performing this action
EnableWakeUpInterrupt
()
Sensor must be in standby mode before performing this action
DisableWakeUpInterrupt
()
Sensor must be in standby mode before performing this action
EnableInterruptPin
-
polarity
-
response_type
For Wakeup function, the response type is always latched unless set wakeup latch off Sensor needs to be in standby mode when enabling the interrupt
See datasheet for more details
Parameters:
-
polarity
KXTJ3_INTERRUPT_POLARITY_TSelect the polarity of the interrupt. One of the KXTJ3_INTERRUPT_POLARITY_T values.
-
response_type
KXTJ3_INTERRUPT_RESPONSE_TSelect the response type of the interrupt. One of the KXTJ3_INTERRUPT_RESPONSE_T values.
DisableInterruptPin
()
Sensor needs to be in standby mode when disabling the interrupt pin
SetInterruptPolarity
-
polarity
Polarity ACTIVE_HIGH or ACTIVE_LOW
Sensor must be in standby mode before performing this action
Parameters:
-
polarity
KXTJ3_INTERRUPT_POLARITY_TSelect the polarity of the interrupt. One of the KXTJ3_INTERRUPT_POLARITY_T values.
SetInerruptResponse
-
response_type
Response either latch until cleared by reading INT_REL register, or transmit one pulse Pulse width of 0.03-0.05ms
For Wakeup function, the response type is always latched unless set wakeup latch off
Sensor must be in standby mode before performing this action
See datasheet for more details
Parameters:
-
response_type
KXTJ3_INTERRUPT_RESPONSE_TSelect the response type of the interrupt. One of the KXTJ3_INTERRUPT_RESPONSE_T values
GetInterruptStatus
()
Boolean
See datasheet for more details
Returns:
Return true if an interrupt event has occurred (DRDY or WUFS is 1), returns false if no interrupts have occurred
ReadInterruptSource1
()
Number
See datasheet for more details
Returns:
Value of the interrupt source register
GetInterruptSource
()
KXTJ3_INTERRUPT_SOURCE_T
See datasheet for more details
Returns:
One of the KXTJ3_INTERRUPT_SOURCE_T values/types
InstallIsr
-
edge
-
pin
-
isr
-
isr_args
Parameters:
-
edge
Mraa_gpio_edge_tOne of the mraa_gpio_edge_t values. Interrupt trigger edge.
-
pin
NumberThe GPIO pin to use as the interrupt pin
-
isr
FunctionPointer to the method to be called, when the interrupt occurs
-
isr_args
Void *The arguments to be passed to the method
UninstallIsr
()
ClearInterrupt
()
See datasheet for more details
EnableWakeUpSingleAxisDirection
-
axis
Sensor must be in standby mode before performing this action
Parameters:
-
axis
KXTJ3_WAKEUP_SOURCE_TThe axis to enable, takes one of KXTJ3_WAKEUP_SOURCE_T value
DisableWakeUpSingleAxisDirection
-
axis
Sensor must be in standby mode before performing this action
Parameters:
-
axis
KXTJ3_WAKEUP_SOURCE_TThe axis to enable, takes one of KXTJ3_WAKEUP_SOURCE_T value
GetWakeUpAxisDirection
()
Kxtj3_wakeup_axes
See datasheet for more details
Returns:
A kxtj3_wakeup_axes struct with values of true/false for a wakeup for each axis and its direction
EnableWakeUpLatch
()
When this bit is set, the wakeup interrupt has to be cleared manually (cannot use interrupt response with pulse)
Sensor must be in standby mode before performing this action
DisableWakeUpLatch
()
The wakeup threshold is advised to not be very low to avoid interrupt being triggered in an almost continuous manner
Sensor must be in standby mode before performing this action
When this bit is cleared, and the interrupt response type is set to Pulse, then upon a wakeup event the wakeup interrupt signal will pulse and return low, but only once. Then, the interrupt output will not reset until data is read or interrupt cleared.
SetWakeUpMotionCounter
-
count
The count is limited to values from 1 to 255
Every count is calculated as (1 / Wakeup_ODR_FREQUENCY) where Wakeup_ODR_FREQUENCY is the current odr_in_Hz value from odr_map_in_Hz_wakeup value
Sensor must be in standby mode before performing this action
See datasheet for more details
Parameters:
-
count
NumberThe timer count from 1 to 255
SetWakeUpMotionTime
-
desired_time
the desired time should be such that (0 < desired_time * wakeup_odr_frequency <= 255)
Sensor must be in standby mode before performing this action
See datasheet for more details
Parameters:
-
desired_time
NumberThe desired time in seconds
GetWakeUpMotionTime
()
Number
Returns:
Time value in seconds
SetWakeUpNonActivityCounter
-
count
The count is limited to values from 1 to 255
Every count is calculated as (1 / Wakeup_ODR_FREQUENCY) where Wakeup_ODR_FREQUENCY is the current odr_in_Hz value from odr_map_in_Hz_wakeup value
Sensor must be in standby mode before performing this action
See datasheet for more details
Parameters:
-
count
NumberThe timer count from 1 to 255
SetWakeUpNonActivityTime
-
desired_time
the desired time should be such that (0 < desired_time * wakeup_odr_frequency <= 255)
Sensor must be in standby mode before performing this action
See datasheet for more details
Parameters:
-
desired_time
NumberThe desired time in seconds
GetWakeUpNonActivityTime
()
Number
Returns:
Time value in seconds
SetWakeUpThresholdCounter
-
count
The count is limited to values from 1 to 4096, that it is 16g threshold with (3.9mg/count) It is advised to not set the threshold to a very low value which may cause bad behaviour in the wakeup interrupt
Sensor must be in standby mode before performing this action
See datasheet for more details
Parameters:
-
count
NumberThe timer count from 1 to 4096, that it is 16g threshold with (3.9mg/count)
SetWakeUpThresholdGRange
-
g_threshold
The count is limited to values up to 16g, with steps of 3.9mg. It is advised to not set the threshold to a very low value which may cause bad behaviour in the wakeup interrupt
Sensor must be in standby mode before performing this action
See datasheet for more details
Parameters:
-
g_threshold
NumberThe acceleration threshold (in g) in g, from 3.9mg to 16g, steps of 3.9mg/count.
GetWakeUpThresholdGRange
()
Number
Returns:
Threshold value in g