Repository navigation
6. API: Sensor Function
These are the functions to communicate with the sensors.
Turn on/off the sensor LED.
Function Prototype:
EM_ERROR eSensorSetLed( unsigned char ucId,
EM_MODEL eModuleType,
unsigned char ucLedValue );
Parameters:
- ucId - Sensor ID.
- eModuleType - Sensor type.
-
ucLedValue - Sensor LED value.
~ 0 - Off
~ 1 - On
~ 2 - Trigger
Return:
Example:
// Turn on the IR sensor LED.
eSensorSetLed(200, EM_MODEL_IR, 1);
Turn on/off and set the colour of the Head LED.
Function Prototype:
EM_ERROR eHeadSetLed( unsigned char ucId,
unsigned char ucRgb,
unsigned char ucLeftRight );
Parameters:
- ucId - Sensor ID.
- ucRgb - RGB value for the LED (RRRGGGBB).
-
ucLeftRight - Turn on/off left and right LED individually.
~ Bit 0 - Right
~ Bit 1 - Left
Return:
Example:
// Set the colour of head LED to red.
eHeadSetLed(100, 0b11100000, 0b11);
Set the red colour LED of the head module.
Function Prototype:
EM_ERROR eHeadSetRed(unsigned char ucId, unsigned char ucRedValue);
Parameters:
- ucId - Sensor ID.
- ucRedValue - Red LED value (3 bits).
Return:
Example:
// Set the colour of head LED to red.
eHeadSetRed(100, 0b111);
Set the green colour LED of the head module.
Function Prototype:
EM_ERROR eHeadSetGreen(unsigned char ucId, unsigned char ucGreenValue);
Parameters:
- ucId - Sensor ID.
- ucGreenValue - Green LED value (3 bits).
Return:
Example:
// Set the colour of head LED to green.
eHeadSetGreen(100, 0b111);
Set the blue colour LED of the head module.
Function Prototype:
EM_ERROR eHeadSetBlue(unsigned char ucId, unsigned char ucBlueValue);
Parameters:
- ucId - Sensor ID.
- ucBlueValue - Blue LED value (2 bits).
Return:
Example:
// Set the colour of head LED to blue.
eHeadSetBlue(100, 0b11);
Get the IR sensor value on head module.
Function Prototype:
EM_ERROR eHeadGetIrValue(unsigned char ucId, unsigned char *pucValue);
Parameters:
- ucId - Sensor ID.
- pucValue - Buffer to return the value.
Return:
Example:
// Read the IR sensor value from head module.
unsigned char ucHeadIrValue;
eHeadGetIrValue(100, &ucHeadIrValue);
Get the microphone value on head module.
Function Prototype:
EM_ERROR eHeadGetMicValue(unsigned char ucId, unsigned char *pucValue);
Parameters:
- ucId - Sensor ID.
- pucValue - Buffer to return the value.
Return:
Example:
// Read the microphone value from head module.
unsigned char ucMicValue;
eHeadGetMicValue(100, &ucMicValue);
Get the infrared sensor value.
Function Prototype:
EM_ERROR eInfraredSensorGetValue(unsigned char ucId, unsigned char *pucValue);
Parameters:
- ucId - Sensor ID.
- pucValue - Buffer to return the value.
Return:
Example:
// Read the value from infrared sensor.
unsigned char ucValue;
eInfraredSensorGetValue(100, &ucValue);
Get the ultrasonic sensor value.
Function Prototype:
EM_ERROR eUltrasonicSensorGetValue(unsigned char ucId, unsigned short *pusValue);
Parameters:
- ucId - Sensor ID.
- pusValue - Buffer to return the value.
Return:
Example:
// Read the value from ultrasonic sensor.
unsigned short usValue;
eUltrasonicSensorGetValue(100, &usValue);
Get the tactile sensor value.
Function Prototype:
EM_ERROR eTactileSensorGetValue(unsigned char ucId, unsigned char *pucValue);
Parameters:
- ucId - Sensor ID.
-
pucValue - Buffer to return the value.
~ 0 - Released ~ 1 - Pressed
Return:
Example:
// Read the value from tactile sensor.
unsigned char ucValue;
eTactileSensorGetValue(100, &ucValue);