LED Interface

All DLN-series adapters are fitted with a single status LED and several user-controlled LEDs. The number of user-controlled LEDs depends on the DLN adapter model.The status LED shows the current state of your device.Each of the user-controlled LEDs can be adjusted to a specific state by using the DlnLedSetState() function. For details, read LED States.

You can find out the number of available user-controlled LEDs by using the DlnLedGetCount() function.

You can purchase DLN-4 devices with an optional enclosure. Such enclosures have no openings for LEDs. Therefore, you will not be able to see the LEDs through the enclosure.
Rating: 
Средняя: 2 (1 оценка)

LED States

DLN-series adapters allow you to control LEDs’ behavior by defining the value of the DLN_LED_STATE type defined in the dln_led.h file.The list of its possible LED states is given in the following table:

Led States
StateLED Behavior

DLN_LED_STATE_OFF

Off

DLN_LED_STATE_ON

On

DLN_LED_SLOW_BLINK

Blinking slowly

DLN_LED_FAST_BLINK

Blinking rapidly

DLN_LED_DOUBLE_BLINK

Blinking in a double-blink pattern

DLN_LED_TRIPLE_BLINK

Blinking in a triple-blink pattern

To specify a LED state, use the DlnLedSetState() function. You can check the current state of a LED by using the DlnLedGetState() function.

Rating: 
Средняя: 2.5 (2 оценок)

Simple LED Module Example

This example shows how to manipulate LEDs on the DLN-series adapters. You can find the complete example in the “..\Program Files\Diolan\DLN\examples\c_cpp\examples\simple” folder after DLN setup package installation.

C/C++
#include "..\..\..\common\dln_generic.h"
#include "..\..\..\common\dln_led.h"
#pragma comment(lib, "..\\..\\..\\bin\\dln.lib")


int _tmain(int argc, _TCHAR* argv[])
{
	// Open device
	HDLN device;
	DlnOpenUsbDevice(&device);

	// Set LED1
	DlnLedSetState(device, 0, DLN_LED_STATE_FAST_BLINK);
	// Set LED2
	DlnLedSetState(device, 1, DLN_LED_STATE_TRIPLE_BLINK);

	// Close device
	DlnCloseHandle(device);
	return 0;
}

  • Line 1:

    The dln_generic..h header file declares functions and data structures for the generic interface. In current example this header is used to call DlnOpenUsbDevice() and DlnCloseHandle() functions.

  • Line 2:

    The dln_led.h header file declares functions and data structures for the LED interface. In current example this header is used to to call DlnLedSetState() function.

  • Line 3:

    Use dln.lib library while project linking.

  • Line 10:DlnOpenUsbDevice(&device);

    The function establishes the connection with the DLN adapter. This application uses the USB connectivity of the adapter. For additional options, refer to the Device Opening & Identification section.

  • Line 13:DlnLedSetState(device, 0, DLN_LED_STATE_FAST_BLINK);

    Set LED 0 to fast blink state. You can read more about available LED states at LED States section.

  • Line 15:DlnLedSetState(device, 1, DLN_LED_STATE_TRIPLE_BLINK);

    Set LED 1 to triple blink state.

  • Line 18:DlnCloseHandle(device);

    The application closes the handle to the connected DLN-series adapter.

Rating: 
Голосов пока нет

LED Functions

This section describes the LED functions. They are used to control and monitor the LED module of a DLN-series adapter.

Actual control of the device is due to use of commands and responses. Each function utilizes respective commands and responses. You can send such commands directly if necessary.

DlnLedGetCount()

Retrieves the total number of user-controlled LEDs

DlnLedSetState()

Configures the LED state.

DlnLedGetState()

Retrieves the current LED state.

All the functions are declared in the dln_led.h file.

Rating: 
Средняя: 1 (1 оценка)

DlnLedGetCount() Function

The DlnLedGetCount() function retrieves the total number of user-controlled LEDs available in the device.

Syntax
C/C++
DLN_RESULT DlnLedGetCount(
   HDLN handle,
   uint8_t* count
);
Parameters
handle

A handle to the DLN-series adapter.

count

A pointer to an unsigned 8-bit integer. After the function execution, this integer stores the number of user-controlled LEDs.

Return Value
DLN_RES_SUCCESS (0x00)

The function was successful.

Remarks

The DlnLedGetCount() function is declared in the dln_led.h file.

DlnLedGetState() Function

The DlnLedGetState() function retrieves the current state of the LED.

Syntax
C/C++
DLN_RESULT DlnLedGetState(
   HDLN handle,
   uint8_t ledNumber
   DLN_LED_STATE* state
);
Parameters
handle

A handle to the DLN-series adapter.

ledNumber

A number of the LED which state you want to know.

state

A pointer to the DLN_LED_STATE type, where the LED state is stored.

Return Value
DLN_RES_SUCCESS (0x00)

The function was successful.

DLN_RES_INVALID_LED_NUMBER (0xA6)

The specified LED number is not valid. Use the DlnLedGetCount()function to find the maximum possible LED number.

Remarks

The DlnLedGetState() function is declared in the dln_led.h file.

DlnLedSetState() Function

The DlnLedSetState() function sets a new state of the specified user-controlled LED.

Syntax
C/C++
DLN_RESULT DlnLedSetState(
   HDLN handle,
   uint8_t ledNumber,
   DLN_LED_STATE state
);
Parameters
handle

A handle to the DLN-series adapter.

ledNumber

The id of the LED which state you want to change.

state

The state of a LED that you want to set.

Return Value
DLN_RES_SUCCESS (0x00)

The function was successful.

DLN_RES_INVALID_LED_NUMBER (0xA6)

The specified LED number is not valid. Use the DlnLedGetCount()function to find the maximum possible LED number.

Remarks

The DlnLedSetState() function is declared in the dln_led.h file.