nRF51 SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages

Emulates a mouse using one of the nRF51's timer peripherals. More...

Enumerations

enum  mouse_sensor_sample_period_t {
  MOUSE_SENSOR_SAMPLE_PERIOD_4_MS,
  MOUSE_SENSOR_SAMPLE_PERIOD_8_MS
}
 Enumerator used for setting the mouse sensor sample period. More...
 

Functions

bool mouse_sensor_init (mouse_sensor_sample_period_t sample_period)
 Function for initializing the mouse sensor. More...
 
void mouse_sensor_enable (void)
 Enable mouse sensor. More...
 
void mouse_sensor_disable (void)
 Disable mouse sensor.
 
bool mouse_sensor_data_is_ready (void)
 Function for polling if the mouse sensor has data available for readout. More...
 
bool mouse_sensor_read (uint8_t *out_mouse_packet)
 Function for reading motion samples from the the mouse sensor. More...
 
void mouse_sensor_new_sample_generated_cb (void)
 Callback function called when a new sample is generated by the mouse sensor. When the mouse sensor is enabled, this function will be called at a rate as specified by mouse_sensor_init().
 

Detailed Description

Enumeration Type Documentation

Enumerator
MOUSE_SENSOR_SAMPLE_PERIOD_4_MS 

Generate new mouse sample every 4 ms.

MOUSE_SENSOR_SAMPLE_PERIOD_8_MS 

Generate new mouse sample every 8 ms.

Function Documentation

bool mouse_sensor_init ( mouse_sensor_sample_period_t  sample_period)
Parameters
sample_periodspecifies the mouse sensor sample period.
Return values
trueIf initialization succeeded.
falseIf initialization failed.
void mouse_sensor_enable ( void  )

When enabled, the mouse sensor will start generating mouse movement samples at the rate given by mouse_sensor_init(void).

bool mouse_sensor_data_is_ready ( void  )
Return values
trueIf there is data available for reading.
falseIf no data is available for reading.
See Also
mouse_sensor_read(void)
bool mouse_sensor_read ( uint8_t *  out_mouse_packet)

The mouse sensor will generate a new sample at a rate given by mouse_sensor_init(). If multiple samples are generated by the mouse sensor between each call of this function, the samples will be accumulated. Thus, the mouse packet returned by this function will tell the relative movement of the mouse since the previous time this function was called. The internal accumulator is cleared whenever the mouse sensor is read.

Parameters
out_mouse_packetreturns an assembled mouse movement packet (no buttons) as specified in "nrfdvl_params.h" .

The length of the mouse packet is given by NRFR_MOUSE_MOV_PACKET_LENGTH.

Return values
trueIf a new packet was written to out_mouse_packet *.
falseIf no new mouse data was available.