APIS for operating LEDs are available in coredll. dll, but are not declared in the SDK.
First, it contains the nled. h header file and two functions (obtain the led information and set the led status)
# Include <nled. h> extern "C"
{
Bool nledgetdeviceinfo (int nid, pvoid poutput );
Bool nledsetdevice (int nid, pvoid poutput );
}
The following function can obtain the total number of LEDs on the device. If your PPC supports vibration, the vibration motor will also be treated as an LED.
// ================================================ ======== //
// Function: obtain the total number of LEDs on the device
// Parameter: None
// Return: Total number of LEDs on the device
// Date: 2009/03/05. -- 2009/03/05.
// ================================================ ======== //
Int getledcount ()
{
Nled_count_info NCI;
Int wcount = 0;
If (nledgetdeviceinfo (nled_count_info_id, (pvoid) & NCI ))
Wcount = (INT) NCI. cleds;
Return wcount;
}
The following function sets the led status
// ================================================ ======== //
// Function: Set the led status on the device
// Parameter: wled, wstatus
// (Entry): wled: indicates the LED number. The first led is zero (0 ).
// (Entry): wstatus: indicates the led status 0 (off), 1 (on), 2 (flashing)
// Return: None
// Date: 2009/03/05. -- 2009/03/05.
// ================================================ ======== //
Void setledstatus (INT wled, int wstatus)
{
Nled_settings_info NSI;
NSI. lednum = (INT) wled;
NSI. offonblink = (INT) wstatus;
Nledsetdevice (nled_settings_info_id, & NSI );
}
Taking led0 as an Example
Disable: setledstatus (0, 0 );
Light up: setledstatus (0, 1 );
Blinking: setledstatus (0, 2 );
// ================================================ ========================================== //
// Function: Set Vibration
// Parameter: bstart
// (Exit) bstart: True indicates the start vibration, and false indicates the stop vibration.
// Return: None
// Date: 2009/03/26. -- 2009/03/26.
// ================================================ ========================================== //
Void startstopvibrate (bool bstart)
{
Nled_settings_info settings;
Memset (& settings, 0, sizeof (nled_settings_info ));
Settings. lednum = 1;
If (bstart)
Settings. offonblink = 1;
Else
Settings. offonblink = 0;
Nledsetdevice (nled_settings_info_id, & settings );
}