libnds
Functions
ndsmotion.h File Reference

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

Functions

int motion_acceleration_x (void)
 Gets acceleration value to mili G (where g is 9.8 m/s*s) More...
 
int motion_acceleration_y (void)
 Gets acceleration value to mili G (where g is 9.8 m/s*s) More...
 
int motion_acceleration_z (void)
 Gets acceleration value to mili G (where g is 9.8 m/s*s) More...
 
void motion_deinit (void)
 Deinitializes the DS Motion Sensor.
 
void motion_enable_ain_1 (void)
 This enables the analog input number 1. More...
 
void motion_enable_ain_2 (void)
 This enables the analog input number 2. More...
 
MotionCalibration * motion_get_calibration (void)
 This returns the current calibration settings for saving. More...
 
int motion_init (void)
 Initializes the DS Motion Sensor. More...
 
int motion_read_ain_1 (void)
 This reads the analog input number 1. More...
 
int motion_read_ain_2 (void)
 This reads the analog input number 2. More...
 
signed int motion_read_gyro (void)
 Reads the Z rotational speed. More...
 
signed int motion_read_x (void)
 Reads the X acceleration. More...
 
signed int motion_read_y (void)
 Reads the Y acceleration. More...
 
signed int motion_read_z (void)
 Reads the Z acceleration. More...
 
int motion_rotation (void)
 Converts raw rotation to degrees per second. More...
 
void motion_set_calibration (MotionCalibration *cal)
 This sets the calibration settings. More...
 
void motion_set_offs_gyro (void)
 This should be called when the axis is under no rotation. More...
 
void motion_set_offs_x (void)
 This should be called when the axis is under no acceleration. More...
 
void motion_set_offs_y (void)
 This should be called when the axis is under no acceleration. More...
 
void motion_set_offs_z (void)
 This should be called when the axis is under no acceleration. More...
 
void motion_set_sens_gyro (int sens)
 This should be passed the raw reading at 1g for accurate acceleration calculations. More...
 
void motion_set_sens_x (int sens)
 This should be passed the raw reading at 1g for accurate acceleration calculations. More...
 
void motion_set_sens_y (int sens)
 This should be passed the raw reading at 1g for accurate acceleration calculations. More...
 
void motion_set_sens_z (int sens)
 This should be passed the raw reading at 1g for accurate acceleration calculations. More...
 

Detailed Description

DS Motion Card/DS Motion Pak functionality.

Interface code for the ds motion card, ds motion pak, 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_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_init()

int 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()

signed int motion_read_gyro ( void  )

Reads the Z rotational speed.

Returns
The Z rotational speed.

◆ motion_read_x()

signed int motion_read_x ( void  )

Reads the X acceleration.

Returns
The X acceleration.

◆ motion_read_y()

signed int motion_read_y ( void  )

Reads the Y acceleration.

Returns
The Y acceleration.

◆ motion_read_z()

signed 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.