Start of trail aaaf5050_mc_k12_close navigation bar

Table of Contents

aaaf5050_mc_k12_open

Opens a Kingbright AAAF5050-MC-K12 LED strip.

Description

The aaaf5050_mc_k12_open function opens a Kingbright AAAF5050-MC-K12 LED strip. The handle to the LED strip returned by this function is used by the other AAAF5050-MC-K12 functions in the Devices API to refer to the LED strip. This handle must be closed using the aaaf5050_mc_k12_close function when the display is no longer in use.

Prototype

t_error
aaaf5050_mc_k12_open(const char* uri, t_uint max_leds, t_aaaf5050_mc_k12* led_handle);
    

Parameters

const char * uri

A string containing the URI identifying the communication protocol and associated parameters to use to communicate with the LED strip. This LED strip is the one used on the Quanser QCar 2.

On the QCar 2, a suitable URI for the Kingbright AAAF5050-MC-K12 LED strip is spi://localhost:1?memsize=420,word=8,baud=3333333,lsb=off,frame=1.

t_uint max_leds

The maximum number of LEDs in the LED strip. For the Quanser QCar 2, this parameter should be 33.

t_aaaf5050_mc_k12 * led_handle

A handle to the LED strip is returned in the t_aaaf5050_mc_k12 variable passed in this parameter. This argument cannot be NULL. Pass the address of a variable of type t_aaaf5050_mc_k12.

Return value

The return value is 0 if the LED strip is opened successfully. Otherwise a negative error code is returned. Error codes are defined in quanser_errors.h. A suitable error message may be retrieved using msg_get_error_message.

Error codes

QERR_INVALID_ARGUMENT

One of the arguments is invalid.

QERR_OUT_OF_MEMORY

There is not enough memory to complete the operation.

Requirements

Include Files

Libraries

quanser_led.h

quanser_devices.lib;quanser_communications.lib;quanser_runtime.lib;quanser_common.lib

Examples

t_aaaf5050_mc_k12 led_strip;
t_error result = 
    aaaf5050_mc_k12_open("spi://localhost:1?memsize=420,word=8,baud=3333333,lsb=off,frame=1", 33, &led_strip);
if (result == 0) {
    ...
    aaaf5050_mc_k12_close(led_strip);
} else {
    TCHAR message[512];
    msg_get_error_message(NULL, result, message, sizeof(message));
    _tprintf(_T("Failed to open LED strip. %s (error %d)\n"), message, -result);
}
    

See Also

 

navigation bar