nn::hid::CTR::GyroscopeReader Classclass GyroscopeReader : private ADLFireWall::NonCopyable
Class for loading sampling data from the gyro sensor.
Samples the angular velocity of the gyro sensor an average of every 10 milliseconds. Use the nn::hid::CTR::Gyroscope class to know when sampling occurs, allowing you to accurately monitor sampling timing.
nn::hid::CTR::GyroscopeStatus structure. This structure contains not just the angular velocity, but also information about the attitude calculated from the angular velocity. Attitude is calculated when the nn::hid::CTR::GyroscopeReader::Read or nn::hid::CTR::GyroscopeReader::ReadLatest functions are called, and either one must be called regularly (ideally every frame). Data stored in the internal buffer can become discontinuous, resulting in less accurate attitude information, if too much time elapses between calls to either of these functions.
Gyro sensor sampling halts when the system is asleep, and when there are no instances of the GyroscopeReader class. It takes up to approximately 160 milliseconds for the system to transition to a state where sampling is possible. No sampling is done during this transition time, and calls to the nn::hid::CTR::GyroscopeReader::Read or nn::hid::CTR::GyroscopeReader::ReadLatest functions have no effect. To be sure to obtain sampling results, Nintendo recommends calling the nn::hid::CTR::Gyroscope::WaitSampling function, which waits until results have been sampled at least once. Starting from the second instance, this sampling wait time is the same as the wait until the next sample, which is a maximum of approximately 10 milliseconds.
This class includes the following correction processing for getting information more accurately.
| Acceleration Correction | Uses the accelerometer to improve the accuracy of CTR attitude calculations. |
|---|---|
| Zero-Point Drift Correction | The gyro sensor's zero point can drift due to environmental factors. This correction automatically detects zero-point drift and adjusts angular velocity values accordingly. |
This class includes the following features to process output values.
| Zero-Point Play Tolerance | Sampling results within an optional radius from the zero point are output as the zero point. Use this when you want to ignore small movements. |
|---|---|
| Axial Rotation | Apply an optional rotational matrix to sampling results before output. Use this to output gyro sensor values that mimic a tilt. |
The default gyro sensor axes are as follows.
| X+ | A clockwise rotation about the direction indicated by the Left Button on the +Control Pad. |
|---|---|
| Y+ | A clockwise rotation about the direction indicated by the touch screen face. |
| Z+ | A clockwise rotation about the direction indicated by the Up Button on the +Control Pad. |
This class maintains an internal instance of the AccelerometerReader class for acceleration correction. The accelerometer is consequently started up once this instance is generated.
| Constructors/Destructors | ||
|---|---|---|
GyroscopeReader
|
Constructor. | |
~GyroscopeReader
|
Destructor. | |
| Reading Sampling Data | ||
Read
|
Loads sampling data from the gyro sensor, starting with the most recent data. Does not load any data that has been previously loaded. | |
ReadLatest
|
Loads the most recent sampling data from the gyro sensor. This function, unlike the nn::hid::CTR::GyroscopeReader::Read function, can load the same sampling data more than once. |
|
| Reset | ||
Reset
|
Initializes the internal state. | |
| Output Value Settings | ||
SetAngle
|
Resets the angle member of the GyroscopeStatus structure (obtained by the Read function) to an arbitrary value. |
|
SetDirection
|
Resets the direction member of the GyroscopeStatus structure (obtained by the Read function) to an arbitrary value. |
|
SetAngleMagnification
|
Sets individual scaling factors to apply for each axis when calculating angular velocity. | |
SetDirectionMagnification
|
Sets the scaling factor to apply to the angular velocity used when calculating the direction member of the GyroscopeStatus structure, which is obtained by the Read function. |
|
| Zero-Point Play Tolerance | ||
EnableZeroPlay
|
Enables zero-point play tolerance. | |
DisableZeroPlay
|
Disables the zero-point play tolerance. | |
IsEnableZeroPlay
|
Checks whether zero-point play tolerance is enabled. | |
GetZeroPlayEffect
|
Gets the strength of correction applied by the zero-point play tolerance. | |
SetZeroPlayParam
|
Sets the zero-point (at-rest) play tolerance. | |
GetZeroPlayParam
|
Gets the zero-point play tolerance. | |
ResetZeroPlayParam
|
Initializes the zero-point play tolerance. | |
| Zero-Point Drift Correction | ||
EnableZeroDrift
|
Enables zero-point drift correction. | |
DisableZeroDrift
|
Disables zero-point drift correction. | |
IsEnableZeroDrift
|
Checks whether zero-point drift correction is enabled. | |
GetZeroDriftEffect
|
Gets the strength of zero-point drift correction. | |
ResetZeroDriftMode
|
Initializes the zero-point drift correction mode. | |
SetZeroDriftMode
|
Sets the zero-point drift correction mode. | |
GetZeroDriftMode
|
Gets the zero-point drift correction mode. | |
| Acceleration Correction | ||
EnableAccRevise
|
Enables acceleration correction. | |
DisableAccRevise
|
Disables acceleration correction. | |
IsEnableAccRevise
|
Checks whether acceleration correction is enabled. | |
GetAccReviseEffect
|
Gets the strength of acceleration correction. | |
SetAccReviseParam
|
Sets the weight and enabled range for acceleration correction. | |
GetAccReviseParam
|
Gets the weight and enabled range for acceleration correction. | |
ResetAccReviseParam
|
Initializes the weight and enabled range for acceleration correction. | |
| Axial Rotation | ||
EnableAxisRotation
|
Enables axial rotation. | |
DisableAxisRotation
|
Disables axial rotation. | |
IsEnableAxisRotation
|
Checks whether axial rotation is enabled or disabled. | |
SetAxisRotationMatrix
|
Sets the rotation matrix used for axial rotation. | |
GetAxisRotationMatrix
|
Gets the rotation matrix used for axial rotation. | |
ResetAxisRotationMatrix
|
Initializes the rotation matrix used for axial rotation. When this function is called, the rotation matrix is set to a nn::math::MTX34 identity matrix. This setting is equivalent to disabling axial rotation. |
|
ADLFireWall::NonCopyable
nn::hid::CTR::GyroscopeReader
CONFIDENTIAL