Start of trail ws0010_close navigation bar

Table of Contents

ws0010_open

Opens a Surenoo WS0010 OLED display.

Description

The ws0010_open function opens a Surenoo WS0010 OLED display. The handle to the display returned by this function is used by the other WS0010 functions in the Devices API to refer to the OLED display. This handle must be closed using the ws0010_close function when the display is no longer in use.

Prototype

t_error
ws0010_open(const char* uri, t_boolean graphics_mode, t_ws0010* display);
    

Parameters

const char * uri

A string containing the URI identifying the communication protocol and associated parameters to use to communicate with the display. This display is the one used on the Quanser QBot Platform.

On the QBot Platform, a suitable URI for the Surenoo WS0010 display is lcd://qbot_platform:1. On Windows, using a Quanser QPIDe data acquisition card with the display connected to the SPI lines on the control header, a suitable URI would be: spi://localhost:0?baud=2e6,word=10,polarity=1,phase=1,frame=56.

t_boolean graphics_mode

A boolean indicating whether the display will be used in graphics mode (true) or text mode (false). In text mode, use the ws0010_print or ws0010_wprint function to print to the display. In graphics mode, use the ws0010_draw_image function to draw on the display.

Note that the WS0010 display has pixel gaps between characters and lines, so in graphics mode there will be black lines at regular intervals across the image. Its resolution is 80x16 pixels.

t_ws0010 * display

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

Return value

The return value is 0 if the display 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_lcd_display.h

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

Examples

t_ws0010 display;
t_error result = 
    ws0010_open("lcd://qbot_platform:1", &display);
if (result == 0) {
    ...
    ws0010_close(display);
} else {
    TCHAR message[512];
    msg_get_error_message(NULL, result, message, sizeof(message));
    _tprintf(_T("Failed to open OLED display. %s (error %d)\n"), message, -result);
}
    

See Also

 

navigation bar