Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
YDisplayLayer Class Reference

#include <yocto_display.h>

Public Member Functions

virtual int clear (void)
 
virtual int clearConsole (void)
 
virtual int consoleOut (string text)
 
virtual int drawBar (int x1, int y1, int x2, int y2)
 
virtual int drawBitmap (int x, int y, int w, string bitmap, int bgcol)
 
int drawBitmap (int x, int y, int w, const std::vector< unsigned char > &data, int bgcol)
 
virtual int drawCircle (int x, int y, int r)
 
virtual int drawDisc (int x, int y, int r)
 
virtual int drawImage (int x, int y, string imagename)
 
virtual int drawPixel (int x, int y)
 
virtual int drawRect (int x1, int y1, int x2, int y2)
 
virtual int drawText (int x, int y, Y_ALIGN anchor, string text)
 
int flush_now ()
 
virtual YDisplayget_display (void)
 
virtual int get_displayHeight (void)
 
virtual int get_displayWidth (void)
 
virtual int get_layerHeight (void)
 
virtual int get_layerWidth (void)
 
virtual int hide (void)
 
virtual int lineTo (int x, int y)
 
virtual int moveTo (int x, int y)
 
virtual int reset (void)
 
virtual int resetHiddenFlag (void)
 
virtual int selectColorPen (int color)
 
virtual int selectEraser (void)
 
virtual int selectFont (string fontname)
 
virtual int selectGrayPen (int graylevel)
 
virtual int setAntialiasingMode (bool mode)
 
virtual int setConsoleBackground (int bgcol)
 
virtual int setConsoleMargins (int x1, int y1, int x2, int y2)
 
virtual int setConsoleWordWrap (bool wordwrap)
 
virtual int setLayerPosition (int x, int y, int scrollTime)
 
virtual int unhide (void)
 
 YDisplayLayer (YDisplay *parent, int id)
 
virtual ~YDisplayLayer ()
 

Static Public Attributes

static const Y_ALIGN ALIGN_BASELINE_CENTER = Y_ALIGN_BASELINE_CENTER
 
static const Y_ALIGN ALIGN_BASELINE_DECIMAL = Y_ALIGN_BASELINE_DECIMAL
 
static const Y_ALIGN ALIGN_BASELINE_LEFT = Y_ALIGN_BASELINE_LEFT
 
static const Y_ALIGN ALIGN_BASELINE_RIGHT = Y_ALIGN_BASELINE_RIGHT
 
static const Y_ALIGN ALIGN_BOTTOM_CENTER = Y_ALIGN_BOTTOM_CENTER
 
static const Y_ALIGN ALIGN_BOTTOM_DECIMAL = Y_ALIGN_BOTTOM_DECIMAL
 
static const Y_ALIGN ALIGN_BOTTOM_LEFT = Y_ALIGN_BOTTOM_LEFT
 
static const Y_ALIGN ALIGN_BOTTOM_RIGHT = Y_ALIGN_BOTTOM_RIGHT
 
static const Y_ALIGN ALIGN_CENTER = Y_ALIGN_CENTER
 
static const Y_ALIGN ALIGN_CENTER_DECIMAL = Y_ALIGN_CENTER_DECIMAL
 
static const Y_ALIGN ALIGN_CENTER_LEFT = Y_ALIGN_CENTER_LEFT
 
static const Y_ALIGN ALIGN_CENTER_RIGHT = Y_ALIGN_CENTER_RIGHT
 
static const Y_ALIGN ALIGN_TOP_CENTER = Y_ALIGN_TOP_CENTER
 
static const Y_ALIGN ALIGN_TOP_DECIMAL = Y_ALIGN_TOP_DECIMAL
 
static const Y_ALIGN ALIGN_TOP_LEFT = Y_ALIGN_TOP_LEFT
 
static const Y_ALIGN ALIGN_TOP_RIGHT = Y_ALIGN_TOP_RIGHT
 

Private Member Functions

int command_flush (string cmd)
 
int command_push (string cmd)
 

Private Attributes

string _cmdbuff
 
YDisplay_display
 
bool _hidden
 
int _id
 

Detailed Description

YDisplayLayer Class: DisplayLayer object interface

A DisplayLayer is an image layer containing objects to display (bitmaps, text, etc.). The content is displayed only when the layer is active on the screen (and not masked by other overlapping layers).

Definition at line 127 of file yocto_display.h.

Constructor & Destructor Documentation

virtual YDisplayLayer::~YDisplayLayer ( )
inlinevirtual

Definition at line 152 of file yocto_display.h.

YDisplayLayer::YDisplayLayer ( YDisplay parent,
int  id 
)

Definition at line 51 of file yocto_display.cpp.

Member Function Documentation

int YDisplayLayer::clear ( void  )
virtual

Erases the whole content of the layer (makes it fully transparent). This method does not change any other attribute of the layer. To reinitialize the layer attributes to defaults settings, use the method reset() instead.

Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 136 of file yocto_display.cpp.

int YDisplayLayer::clearConsole ( void  )
virtual

Blanks the console area within console margins, and resets the console pointer to the upper left corner of the console.

Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 487 of file yocto_display.cpp.

int YDisplayLayer::command_flush ( string  cmd)
private

Definition at line 87 of file yocto_display.cpp.

int YDisplayLayer::command_push ( string  cmd)
private

Definition at line 70 of file yocto_display.cpp.

int YDisplayLayer::consoleOut ( string  text)
virtual

Outputs a message in the console area, and advances the console pointer accordingly. The console pointer position is automatically moved to the beginning of the next line when a newline character is met, or when the right margin is hit. When the new text to display extends below the lower margin, the console area is automatically scrolled up.

Parameters
text: the message to display
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 426 of file yocto_display.cpp.

int YDisplayLayer::drawBar ( int  x1,
int  y1,
int  x2,
int  y2 
)
virtual

Draws a filled rectangular bar at a specified position.

Parameters
x1: the distance from left of layer to the left border of the rectangle, in pixels
y1: the distance from top of layer to the top border of the rectangle, in pixels
x2: the distance from left of layer to the right border of the rectangle, in pixels
y2: the distance from top of layer to the bottom border of the rectangle, in pixels
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 257 of file yocto_display.cpp.

int YDisplayLayer::drawBitmap ( int  x,
int  y,
int  w,
string  bitmap,
int  bgcol 
)
virtual

Draws a bitmap at the specified position. The bitmap is provided as a binary object, where each pixel maps to a bit, from left to right and from top to bottom. The most significant bit of each byte maps to the leftmost pixel, and the least significant bit maps to the rightmost pixel. Bits set to 1 are drawn using the layer selected pen color. Bits set to 0 are drawn using the specified background gray level, unless -1 is specified, in which case they are not drawn at all (as if transparent).

Parameters
x: the distance from left of layer to the left of the bitmap, in pixels
y: the distance from top of layer to the top of the bitmap, in pixels
w: the width of the bitmap, in pixels
bitmap: a binary object
bgcol: the background gray level to use for zero bits (0 = black, 255 = white), or -1 to leave the pixels unchanged
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 374 of file yocto_display.cpp.

int YDisplayLayer::drawBitmap ( int  x,
int  y,
int  w,
const std::vector< unsigned char > &  data,
int  bgcol 
)

Definition at line 96 of file yocto_display.cpp.

int YDisplayLayer::drawCircle ( int  x,
int  y,
int  r 
)
virtual

Draws an empty circle at a specified position.

Parameters
x: the distance from left of layer to the center of the circle, in pixels
y: the distance from top of layer to the center of the circle, in pixels
r: the radius of the circle, in pixels
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 273 of file yocto_display.cpp.

int YDisplayLayer::drawDisc ( int  x,
int  y,
int  r 
)
virtual

Draws a filled disc at a given position.

Parameters
x: the distance from left of layer to the center of the disc, in pixels
y: the distance from top of layer to the center of the disc, in pixels
r: the radius of the disc, in pixels
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 289 of file yocto_display.cpp.

int YDisplayLayer::drawImage ( int  x,
int  y,
string  imagename 
)
virtual

Draws a GIF image at the specified position. The GIF image must have been previously uploaded to the device built-in memory. If you experience problems using an image file, check the device logs for any error message such as missing image file or bad image file format.

Parameters
x: the distance from left of layer to the left of the image, in pixels
y: the distance from top of layer to the top of the image, in pixels
imagename: the GIF file name
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 349 of file yocto_display.cpp.

int YDisplayLayer::drawPixel ( int  x,
int  y 
)
virtual

Draws a single pixel at the specified position.

Parameters
x: the distance from left of layer, in pixels
y: the distance from top of layer, in pixels
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 223 of file yocto_display.cpp.

int YDisplayLayer::drawRect ( int  x1,
int  y1,
int  x2,
int  y2 
)
virtual

Draws an empty rectangle at a specified position.

Parameters
x1: the distance from left of layer to the left border of the rectangle, in pixels
y1: the distance from top of layer to the top border of the rectangle, in pixels
x2: the distance from left of layer to the right border of the rectangle, in pixels
y2: the distance from top of layer to the bottom border of the rectangle, in pixels
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 240 of file yocto_display.cpp.

int YDisplayLayer::drawText ( int  x,
int  y,
Y_ALIGN  anchor,
string  text 
)
virtual

Draws a text string at the specified position. The point of the text that is aligned to the specified pixel position is called the anchor point, and can be chosen among several options. Text is rendered from left to right, without implicit wrapping.

Parameters
x: the distance from left of layer to the text anchor point, in pixels
y: the distance from top of layer to the text anchor point, in pixels
anchor: the text anchor point, chosen among the Y_ALIGN enumeration: Y_ALIGN_TOP_LEFT, Y_ALIGN_CENTER_LEFT, Y_ALIGN_BASELINE_LEFT, Y_ALIGN_BOTTOM_LEFT, Y_ALIGN_TOP_CENTER, Y_ALIGN_CENTER, Y_ALIGN_BASELINE_CENTER, Y_ALIGN_BOTTOM_CENTER, Y_ALIGN_TOP_DECIMAL, Y_ALIGN_CENTER_DECIMAL, Y_ALIGN_BASELINE_DECIMAL, Y_ALIGN_BOTTOM_DECIMAL, Y_ALIGN_TOP_RIGHT, Y_ALIGN_CENTER_RIGHT, Y_ALIGN_BASELINE_RIGHT, Y_ALIGN_BOTTOM_RIGHT.
text: the text string to draw
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 330 of file yocto_display.cpp.

int YDisplayLayer::flush_now ( void  )

Definition at line 58 of file yocto_display.cpp.

YDisplay * YDisplayLayer::get_display ( void  )
virtual

Gets parent YDisplay. Returns the parent YDisplay object of the current YDisplayLayer.

Returns
an YDisplay object

Definition at line 546 of file yocto_display.cpp.

int YDisplayLayer::get_displayHeight ( void  )
virtual

Returns the display height, in pixels.

Returns
an integer corresponding to the display height, in pixels

On failure, throws an exception or returns Y_DISPLAYHEIGHT_INVALID.

Definition at line 570 of file yocto_display.cpp.

int YDisplayLayer::get_displayWidth ( void  )
virtual

Returns the display width, in pixels.

Returns
an integer corresponding to the display width, in pixels

On failure, throws an exception or returns Y_DISPLAYWIDTH_INVALID.

Definition at line 558 of file yocto_display.cpp.

int YDisplayLayer::get_layerHeight ( void  )
virtual

Returns the height of the layers to draw on, in pixels.

Returns
an integer corresponding to the height of the layers to draw on, in pixels

On failure, throws an exception or returns Y_LAYERHEIGHT_INVALID.

Definition at line 594 of file yocto_display.cpp.

int YDisplayLayer::get_layerWidth ( void  )
virtual

Returns the width of the layers to draw on, in pixels.

Returns
an integer corresponding to the width of the layers to draw on, in pixels

On failure, throws an exception or returns Y_LAYERWIDTH_INVALID.

Definition at line 582 of file yocto_display.cpp.

int YDisplayLayer::hide ( void  )
virtual

Hides the layer. The state of the layer is perserved but the layer is not displayed on the screen until the next call to unhide(). Hiding the layer can positively affect the drawing speed, since it postpones the rendering until all operations are completed (double-buffering).

Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 521 of file yocto_display.cpp.

int YDisplayLayer::lineTo ( int  x,
int  y 
)
virtual

Draws a line from current drawing pointer position to the specified position. The specified destination pixel is included in the line. The pointer position is then moved to the end point of the line.

Parameters
x: the distance from left of layer to the end point of the line, in pixels
y: the distance from top of layer to the end point of the line, in pixels
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 408 of file yocto_display.cpp.

int YDisplayLayer::moveTo ( int  x,
int  y 
)
virtual

Moves the drawing pointer of this layer to the specified position.

Parameters
x: the distance from left of layer, in pixels
y: the distance from top of layer, in pixels
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 391 of file yocto_display.cpp.

int YDisplayLayer::reset ( void  )
virtual

Reverts the layer to its initial state (fully transparent, default settings). Reinitializes the drawing pointer to the upper left position, and selects the most visible pen color. If you only want to erase the layer content, use the method clear() instead.

Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 120 of file yocto_display.cpp.

int YDisplayLayer::resetHiddenFlag ( void  )
virtual

Definition at line 599 of file yocto_display.cpp.

int YDisplayLayer::selectColorPen ( int  color)
virtual

Selects the pen color for all subsequent drawing functions, including text drawing. The pen color is provided as an RGB value. For grayscale or monochrome displays, the value is automatically converted to the proper range.

Parameters
color: the desired pen color, as a 24-bit RGB value
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 153 of file yocto_display.cpp.

int YDisplayLayer::selectEraser ( void  )
virtual

Selects an eraser instead of a pen for all subsequent drawing functions, except for bitmap copy functions. Any point drawn using the eraser becomes transparent (as when the layer is empty), showing the other layers beneath it.

Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 187 of file yocto_display.cpp.

int YDisplayLayer::selectFont ( string  fontname)
virtual

Selects a font to use for the next text drawing functions, by providing the name of the font file. You can use a built-in font as well as a font file that you have previously uploaded to the device built-in memory. If you experience problems selecting a font file, check the device logs for any error message such as missing font file or bad font file format.

Parameters
fontname: the font file name
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 307 of file yocto_display.cpp.

int YDisplayLayer::selectGrayPen ( int  graylevel)
virtual

Selects the pen gray level for all subsequent drawing functions, including text drawing. The gray level is provided as a number between 0 (black) and 255 (white, or whichever the lighest color is). For monochrome displays (without gray levels), any value lower than 128 is rendered as black, and any value equal or above to 128 is non-black.

Parameters
graylevel: the desired gray level, from 0 to 255
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 172 of file yocto_display.cpp.

int YDisplayLayer::setAntialiasingMode ( bool  mode)
virtual

Enables or disables anti-aliasing for drawing oblique lines and circles. Anti-aliasing provides a smoother aspect when looked from far enough, but it can add fuzzyness when the display is looked from very close. At the end of the day, it is your personal choice. Anti-aliasing is enabled by default on grayscale and color displays, but you can disable it if you prefer. This setting has no effect on monochrome displays.

Parameters
mode: true to enable antialiasing, false to disable it.
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 208 of file yocto_display.cpp.

int YDisplayLayer::setConsoleBackground ( int  bgcol)
virtual

Sets up the background color used by the clearConsole function and by the console scrolling feature.

Parameters
bgcol: the background gray level to use when scrolling (0 = black, 255 = white), or -1 for transparent
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 459 of file yocto_display.cpp.

int YDisplayLayer::setConsoleMargins ( int  x1,
int  y1,
int  x2,
int  y2 
)
virtual

Sets up display margins for the consoleOut function.

Parameters
x1: the distance from left of layer to the left margin, in pixels
y1: the distance from top of layer to the top margin, in pixels
x2: the distance from left of layer to the right margin, in pixels
y2: the distance from top of layer to the bottom margin, in pixels
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 443 of file yocto_display.cpp.

int YDisplayLayer::setConsoleWordWrap ( bool  wordwrap)
virtual

Sets up the wrapping behaviour used by the consoleOut function.

Parameters
wordwrap: true to wrap only between words, false to wrap on the last column anyway.
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 474 of file yocto_display.cpp.

int YDisplayLayer::setLayerPosition ( int  x,
int  y,
int  scrollTime 
)
virtual

Sets the position of the layer relative to the display upper left corner. When smooth scrolling is used, the display offset of the layer is automatically updated during the next milliseconds to animate the move of the layer.

Parameters
x: the distance from left of display to the upper left corner of the layer
y: the distance from top of display to the upper left corner of the layer
scrollTime: number of milliseconds to use for smooth scrolling, or 0 if the scrolling should be immediate.
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 506 of file yocto_display.cpp.

int YDisplayLayer::unhide ( void  )
virtual

Shows the layer. Shows the layer again after a hide command.

Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 535 of file yocto_display.cpp.

Member Data Documentation

string YDisplayLayer::_cmdbuff
private

Definition at line 143 of file yocto_display.h.

YDisplay* YDisplayLayer::_display
private

Definition at line 141 of file yocto_display.h.

bool YDisplayLayer::_hidden
private

Definition at line 144 of file yocto_display.h.

int YDisplayLayer::_id
private

Definition at line 142 of file yocto_display.h.

const Y_ALIGN YDisplayLayer::ALIGN_BASELINE_CENTER = Y_ALIGN_BASELINE_CENTER
static

Definition at line 162 of file yocto_display.h.

const Y_ALIGN YDisplayLayer::ALIGN_BASELINE_DECIMAL = Y_ALIGN_BASELINE_DECIMAL
static

Definition at line 166 of file yocto_display.h.

const Y_ALIGN YDisplayLayer::ALIGN_BASELINE_LEFT = Y_ALIGN_BASELINE_LEFT
static

Definition at line 158 of file yocto_display.h.

const Y_ALIGN YDisplayLayer::ALIGN_BASELINE_RIGHT = Y_ALIGN_BASELINE_RIGHT
static

Definition at line 170 of file yocto_display.h.

const Y_ALIGN YDisplayLayer::ALIGN_BOTTOM_CENTER = Y_ALIGN_BOTTOM_CENTER
static

Definition at line 163 of file yocto_display.h.

const Y_ALIGN YDisplayLayer::ALIGN_BOTTOM_DECIMAL = Y_ALIGN_BOTTOM_DECIMAL
static

Definition at line 167 of file yocto_display.h.

const Y_ALIGN YDisplayLayer::ALIGN_BOTTOM_LEFT = Y_ALIGN_BOTTOM_LEFT
static

Definition at line 159 of file yocto_display.h.

const Y_ALIGN YDisplayLayer::ALIGN_BOTTOM_RIGHT = Y_ALIGN_BOTTOM_RIGHT
static

Definition at line 171 of file yocto_display.h.

const Y_ALIGN YDisplayLayer::ALIGN_CENTER = Y_ALIGN_CENTER
static

Definition at line 161 of file yocto_display.h.

const Y_ALIGN YDisplayLayer::ALIGN_CENTER_DECIMAL = Y_ALIGN_CENTER_DECIMAL
static

Definition at line 165 of file yocto_display.h.

const Y_ALIGN YDisplayLayer::ALIGN_CENTER_LEFT = Y_ALIGN_CENTER_LEFT
static

Definition at line 157 of file yocto_display.h.

const Y_ALIGN YDisplayLayer::ALIGN_CENTER_RIGHT = Y_ALIGN_CENTER_RIGHT
static

Definition at line 169 of file yocto_display.h.

const Y_ALIGN YDisplayLayer::ALIGN_TOP_CENTER = Y_ALIGN_TOP_CENTER
static

Definition at line 160 of file yocto_display.h.

const Y_ALIGN YDisplayLayer::ALIGN_TOP_DECIMAL = Y_ALIGN_TOP_DECIMAL
static

Definition at line 164 of file yocto_display.h.

const Y_ALIGN YDisplayLayer::ALIGN_TOP_LEFT = Y_ALIGN_TOP_LEFT
static

Definition at line 156 of file yocto_display.h.

const Y_ALIGN YDisplayLayer::ALIGN_TOP_RIGHT = Y_ALIGN_TOP_RIGHT
static

Definition at line 168 of file yocto_display.h.


The documentation for this class was generated from the following files:


yoctopuce_altimeter
Author(s): Anja Sheppard
autogenerated on Mon Jun 10 2019 15:49:13