libnds
Loading...
Searching...
No Matches
Data Structures | Typedefs | Enumerations | Functions
ndsmotion.h File Reference

DS Motion Card/DS Motion Pak functionality. More...

#include <stdbool.h>

Data Structures

struct  MotionCalibration
 Struct that contains data read from a motion sensor. More...
 

Typedefs

typedef struct MotionCalibration MotionCalibration
 Struct that contains data read from a motion sensor.
 

Enumerations

enum  MotionType {
  MOTION_TYPE_NONE ,
  MOTION_TYPE_PAK ,
  MOTION_TYPE_PAK_ATTINY ,
  MOTION_TYPE_CARD ,
  MOTION_TYPE_MK6
}
 List of types of motion sensors supported. More...
 

Functions

int motion_acceleration_x (void)
 Gets acceleration value to mili G (where g is 9.8 m/s*s)
 
int motion_acceleration_y (void)
 Gets acceleration value to mili G (where g is 9.8 m/s*s)
 
int motion_acceleration_z (void)
 Gets acceleration value to mili G (where g is 9.8 m/s*s)
 
bool motion_accelerometer_supported (void)
 Check if the accelerometer is supported on this device.
 
bool motion_ain_supported (void)
 Check if the analog input is supported on this device.
 
void motion_deinit (void)
 Deinitializes the DS Motion Sensor.
 
void motion_enable_ain_1 (void)
 This enables the analog input number 1.
 
void motion_enable_ain_2 (void)
 This enables the analog input number 2.
 
MotionCalibrationmotion_get_calibration (void)
 This returns the current calibration settings for saving.
 
const char * motion_get_name (MotionType type)
 Get the name of a given motion sensor type, or "None".
 
MotionType motion_get_type (void)
 Get the type of the current initialized DS Motion Sensor.
 
bool motion_gyroscope_supported (void)
 Check if the gyroscope is likely supported on this device.
 
MotionType motion_init (void)
 Initializes the DS Motion Sensor.
 
int motion_read_ain_1 (void)
 This reads the analog input number 1.
 
int motion_read_ain_2 (void)
 This reads the analog input number 2.
 
int motion_read_gyro (void)
 Reads the Z rotational speed.
 
int motion_read_x (void)
 Reads the X acceleration.
 
int motion_read_y (void)
 Reads the Y acceleration.
 
int motion_read_z (void)
 Reads the Z acceleration.
 
int motion_rotation (void)
 Converts raw rotation to degrees per second.
 
void motion_set_calibration (MotionCalibration *cal)
 This sets the calibration settings.
 
void motion_set_offs_gyro (void)
 This should be called when the axis is under no rotation.
 
void motion_set_offs_x (void)
 This should be called when the axis is under no acceleration.
 
void motion_set_offs_y (void)
 This should be called when the axis is under no acceleration.
 
void motion_set_offs_z (void)
 This should be called when the axis is under no acceleration.
 
void motion_set_sens_gyro (int sens)
 This should be passed the raw reading at 1g for accurate acceleration calculations.
 
void motion_set_sens_x (int sens)
 This should be passed the raw reading at 1g for accurate acceleration calculations.
 
void motion_set_sens_y (int sens)
 This should be passed the raw reading at 1g for accurate acceleration calculations.
 
void motion_set_sens_z (int sens)
 This should be passed the raw reading at 1g for accurate acceleration calculations.
 

Detailed Description

DS Motion Card/DS Motion Pak functionality.

Interface code for the ds motion card, ds motion pak, MK6.

Enumeration Type Documentation

◆ MotionType

enum MotionType

List of types of motion sensors supported.

Enumerator
MOTION_TYPE_NONE 

No sensor present.

MOTION_TYPE_PAK 

DS Motion Pak (homebrew)

MOTION_TYPE_PAK_ATTINY 

DS Motion Pack (retail)

MOTION_TYPE_CARD 

DS Motion Card.

MOTION_TYPE_MK6 

MK6.

Function Documentation

◆ motion_acceleration_x()

int motion_acceleration_x ( void  )

Gets acceleration value to mili G (where g is 9.8 m/s*s)

Returns
The X acceleration value.

◆ motion_acceleration_y()

int motion_acceleration_y ( void  )

Gets acceleration value to mili G (where g is 9.8 m/s*s)

Returns
The Y acceleration value.

◆ motion_acceleration_z()

int motion_acceleration_z ( void  )

Gets acceleration value to mili G (where g is 9.8 m/s*s)

Returns
The Z acceleration value.

◆ motion_accelerometer_supported()

bool motion_accelerometer_supported ( void  )

Check if the accelerometer is supported on this device.

Returns
True if the accelerometer is supported.

◆ motion_ain_supported()

bool motion_ain_supported ( void  )

Check if the analog input is supported on this device.

Returns
True if the analog input is supported.

◆ motion_enable_ain_1()

void motion_enable_ain_1 ( void  )

This enables the analog input number 1.

Required before reading analog input number 1.

◆ motion_enable_ain_2()

void motion_enable_ain_2 ( void  )

This enables the analog input number 2.

Required before reading analog input number 2.

◆ motion_get_calibration()

MotionCalibration * motion_get_calibration ( void  )

This returns the current calibration settings for saving.

Returns
The calibration settings.

◆ motion_get_name()

const char * motion_get_name ( MotionType  type)

Get the name of a given motion sensor type, or "None".

Parameters
typeThe type of the motion sensor.
Returns
Pointer to the string. Don't call free() with this pointer.

◆ motion_get_type()

MotionType motion_get_type ( void  )

Get the type of the current initialized DS Motion Sensor.

Returns
The motion sensor type, or 0 if there is no sensor initialized or present.

◆ motion_gyroscope_supported()

bool motion_gyroscope_supported ( void  )

Check if the gyroscope is likely supported on this device.

Note that some cartridges may come with the gyroscope not populated; this only allows ruling out devices which are guaranteed not to have a gyroscope.

Returns
True if the gyroscope is likely supported.

◆ motion_init()

MotionType motion_init ( void  )

Initializes the DS Motion Sensor.

Run this before using any of the DS Motion Sensor functions. Save the return value and pass it to the other functions.

Returns
The motion sensor type, or 0 if there is no sensor present.

◆ motion_read_ain_1()

int motion_read_ain_1 ( void  )

This reads the analog input number 1.

Analog input number 1 needs to be enabled before reading.

Returns
Analog input number 1.

◆ motion_read_ain_2()

int motion_read_ain_2 ( void  )

This reads the analog input number 2.

Analog input number 2 needs to be enabled before reading.

Returns
Analog input number 2.

◆ motion_read_gyro()

int motion_read_gyro ( void  )

Reads the Z rotational speed.

Returns
The Z rotational speed.

◆ motion_read_x()

int motion_read_x ( void  )

Reads the X acceleration.

Returns
The X acceleration.

◆ motion_read_y()

int motion_read_y ( void  )

Reads the Y acceleration.

Returns
The Y acceleration.

◆ motion_read_z()

int motion_read_z ( void  )

Reads the Z acceleration.

Returns
The Z acceleration.

◆ motion_rotation()

int motion_rotation ( void  )

Converts raw rotation to degrees per second.

Returns
Degrees per second.

◆ motion_set_calibration()

void motion_set_calibration ( MotionCalibration cal)

This sets the calibration settings.

Intended to restore previously saved calibration settings

Parameters
calThe calibration settings

◆ motion_set_offs_gyro()

void motion_set_offs_gyro ( void  )

This should be called when the axis is under no rotation.

Default is 1680.

◆ motion_set_offs_x()

void motion_set_offs_x ( void  )

This should be called when the axis is under no acceleration.

Default is 2048.

◆ motion_set_offs_y()

void motion_set_offs_y ( void  )

This should be called when the axis is under no acceleration.

Default is 2048.

◆ motion_set_offs_z()

void motion_set_offs_z ( void  )

This should be called when the axis is under no acceleration.

Default is 2048.

◆ motion_set_sens_gyro()

void motion_set_sens_gyro ( int  sens)

This should be passed the raw reading at 1g for accurate acceleration calculations.

Default is 825

Parameters
sensThe raw reading at 1g for accurate acceleration calculations.

◆ motion_set_sens_x()

void motion_set_sens_x ( int  sens)

This should be passed the raw reading at 1g for accurate acceleration calculations.

Default is 819

Parameters
sensThe raw reading at 1g for accurate acceleration calculations.

◆ motion_set_sens_y()

void motion_set_sens_y ( int  sens)

This should be passed the raw reading at 1g for accurate acceleration calculations.

Default is 819

Parameters
sensThe raw reading at 1g for accurate acceleration calculations.

◆ motion_set_sens_z()

void motion_set_sens_z ( int  sens)

This should be passed the raw reading at 1g for accurate acceleration calculations.

Default is 819

Parameters
sensThe raw reading at 1g for accurate acceleration calculations.