Table of Contents
ws0010_draw_image
Draws an image on the Surenoo WS0010 OLED display.
Description
The ws0010_draw_image function draws an image on the Surenoo WS0010 OLED display. The display resolution is 80x16 pixels. The pixel coordinates of the top, left corner of the image may be specified. The image may be larger than the display, in which case it is truncated at the edge of the display. The top, left corner is pixel coordinates (0,0). For example,
ws0010_draw_image(display, 0, 0, width, height, image);
will draw a width x height image starting in the top, left corner of the display. This function may only be used if the display was opened in graphics mode.
Prototype
t_error ws0010_draw_image(t_ws0010 display, t_int pixel_row, t_int pixel_column, t_uint image_width, t_uint image_height, const t_uint8* image);
Parameters
t_ws0010 display
A handle to the display returned by the ws0010_open function.
t_int pixel_row
The pixel row at which to start drawing. This value may be negative, in which case the image will be offset by that many pixels off the top edge of the display. A value of zero indicates the top edge of the display. The display is 16 pixels high.
t_int column
The pixel column number at which to drawing the image. This value may be negative, in which case the image will be offset by that many pixels off the left edge of the display. A value of zero indicates the left edge of the display. The display is 80 pixels wide.
t_uint image_width
The width of the image.
t_uint image_height
The height of the image.
const t_uint8* image
The pixels of the image stored column-by-column in memory (MATLAB grayscale format). Each pixel is one byte. A pixel value less than or equal to 127 will display as black. Otherwise the pixel will be white. Due to the low resolution of the display and large pixels, Floyd-Steinberg dithering is not that effective in simulating grayscale images.
Return value
If an error occurs then a negative error code is returned. Otherwise the result is non-negative.
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_GRAPHICS_MODE
The display was opened in text mode so the ws0010_draw_image function 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", true, &display); if (result == 0) { static t_uint8 image[5][5] = { { 0, 255, 0, 255, 0 }, { 0, 255, 0, 255, 0 }, { 0, 0, 0, 0, 0 }, { 255, 0, 0, 0, 255 }, { 255, 255, 255, 255, 255 }, }; ws0010_draw_image(display, 0, 0, image, ARRAY_LENGTH(image), ARRAY_LENGTH(image[0]), &image[0][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
Copyright ©2024 Quanser Inc. This page was generated 2024-10-17. Submit feedback to Quanser about this page.
Link to this page.