ws0010_close ws0010_wprint navigation bar

Table of Contents

ws0010_print

Prints to the Surenoo WS0010 OLED display.

Description

The ws0010_print function prints text to the Surenoo WS0010 OLED display.

Unrecognized characters are skipped. If more than 16 characters would be printed on a line then the line is truncated. A newline will cause the characters to be displayed on the next line. Up to two lines may be displayed.

Printing starts at the given line and column. Line 0 is the first line and column 0 is the first column. For example:

    ws0010_print(display, 0, 0, "Hello world", 12);
        

will print "Hello world" starting in the top, left corner of the display. The format string is UTF-8 and does support Unicode (particularly, Katakana characters).

Prototype

t_int
ws0010_print(t_ws0010 display, t_uint line, t_uint column, const char* message, size_t length);
    

Parameters

t_ws0010 display

A handle to the display returned by the ws0010_open function.

t_uint line

The line number at which to start printing. Line numbers may range from 0 to 1.

t_uint column

The column number at which to start printing. Column numbers may range from 0 to 15. If the text extends beyond the last column it is truncated.

const char * message

The message to print as a Unicode UTF-8 string. Some Katakana characters are supported. Printing will stop if an invalid character is encountered.

A newline, '\n', in the message will cause the output to move to the next line of the display. Hence, the string "Hello\nworld" will print "world" below "Hello".

If a formfeed, '\f', character is encountered in the message it will cause the display to be cleared. Hence, a formfeed is usually only used as the first character in the message text.

A character in the range '\020' to '\027' will use the corresponding user-defined glyph created using the ws0010_set_character function.

size_t length

The maximum number of code units to print from the message argument.

Return value

The return value is the number of code units printed if the operation is successful. 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_DISPLAY_NOT_IN_TEXT_MODE

The display was opened in graphics mode so the text functions cannot be used.

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", false, &display);
if (result == 0) {
    const char message[] = "Hello amigo!\nCiao for now!";
    ws0010_print(display, 0, 0, message, ARRAY_LENGTH(message));
    ...
    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