Вы здесь

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: 
Голосов пока нет

Языки

Вход на сайт