Library to control a Graphics TFT connected to 4-wire SPI - revised for the Raio RA8875 Display Controller.
Dependents: FRDM_RA8875_mPaint RA8875_Demo RA8875_KeyPadDemo SignalGenerator ... more
Fork of SPI_TFT by
GraphicsDisplay Class Reference
The GraphicsDisplay class. More...
#include <GraphicsDisplay.h>
Inherits TextDisplay.
Inherited by RA8875.
Public Member Functions | |
GraphicsDisplay (const char *name) | |
The constructor. | |
virtual RetCode_t | pixel (loc_t x, loc_t y, color_t color)=0 |
Draw a pixel in the specified color. | |
virtual RetCode_t | pixelStream (color_t *p, uint32_t count, loc_t x, loc_t y)=0 |
Write a stream of pixels to the display. | |
virtual color_t | getPixel (loc_t x, loc_t y)=0 |
Get a pixel from the display. | |
virtual RetCode_t | getPixelStream (color_t *p, uint32_t count, loc_t x, loc_t y)=0 |
Get a stream of pixels from the display. | |
virtual uint16_t | width ()=0 |
get the screen width in pixels | |
virtual uint16_t | height ()=0 |
get the screen height in pixels | |
virtual RetCode_t | SetGraphicsCursor (loc_t x, loc_t y)=0 |
Prepare the controller to write binary data to the screen by positioning the memory cursor. | |
virtual RetCode_t | SetGraphicsCursor (point_t p)=0 |
Prepare the controller to write binary data to the screen by positioning the memory cursor. | |
virtual point_t | GetGraphicsCursor (void)=0 |
Read the current graphics cursor position as a point. | |
virtual RetCode_t | SetGraphicsCursorRead (loc_t x, loc_t y)=0 |
Prepare the controller to read binary data from the screen by positioning the memory read cursor. | |
virtual rect_t | SetWindow (rect_t r)=0 |
Set the window, constraining where items are written to the screen. | |
virtual rect_t | SetWindow (loc_t x1=0, loc_t y1=0, loc_t x2=(loc_t)-1, loc_t y2=(loc_t)-1)=0 |
Set the window, constraining where items are written to the screen. | |
virtual rect_t | GetWindow ()=0 |
Get the current window setting, which constrains what is written to the screen. | |
virtual RetCode_t | fillrect (loc_t x1, loc_t y1, loc_t x2, loc_t y2, color_t color, fill_t fillit=FILL)=0 |
Draw a filled rectangle in the specified color. | |
virtual uint16_t | SelectDrawingLayer (uint16_t layer)=0 |
Select the drawing layer for subsequent commands. | |
virtual uint16_t | GetDrawingLayer (void)=0 |
Get the currently active drawing layer. | |
virtual RetCode_t | WriteCommand (unsigned char command, unsigned int data=0xFFFF)=0 |
a function to write the command and data to the RA8875 chip. | |
virtual RetCode_t | WriteData (unsigned char data)=0 |
a function to write the data to the RA8875 chip. | |
virtual RetCode_t | cls (uint16_t layers=0) |
Clear the screen. | |
virtual RetCode_t | _putp (color_t pixel) |
method to put a single color pixel to the screen. | |
virtual RetCode_t | fill (loc_t x, loc_t y, dim_t w, dim_t h, color_t color) |
method to fill a region. | |
virtual RetCode_t | blit (loc_t x, loc_t y, dim_t w, dim_t h, const int *color) |
method to stream bitmap data to the display | |
virtual const uint8_t * | getCharMetrics (const unsigned char c, dim_t *width, dim_t *height) |
This method returns the width in pixels of the chosen character from the previously selected external font. | |
virtual int | fontblit (loc_t x, loc_t y, const unsigned char c) |
This method transfers one character from the external font data to the screen. | |
color_t | RGBQuadToRGB16 (RGBQUAD *colorPaletteArray, uint16_t index) |
This method returns the color value from a palette. | |
RGBQUAD | RGB16ToRGBQuad (color_t c) |
This method converts a 16-bit color value into a 24-bit RGB Quad. | |
rect_t | GetImageRect (loc_t x, loc_t y, const char *FileName=NULL) |
This method gets the rectangle that would render a specified image file. | |
rect_t | GetImageRect (point_t pt, const char *FileName) |
This method gets the rectangle that would render a specified image file. | |
RetCode_t | RenderImageFile (point_t pt, const char *FileName, rect_t *getDim=NULL) |
This method attempts to render a specified graphics image file at the specified screen location. | |
RetCode_t | RenderImageFile (loc_t x, loc_t y, const char *FileName, rect_t *getDim=NULL) |
This method attempts to render a specified graphics image file at the specified screen location. | |
RetCode_t | RenderJpegFile (loc_t x, loc_t y, const char *Name_JPG) |
This method reads a disk file that is in jpeg format and puts it on the screen. | |
RetCode_t | RenderBitmapFile (loc_t x, loc_t y, const char *Name_BMP, rect_t *getDim=NULL) |
This method reads a disk file that is in bitmap format and puts it on the screen. | |
RetCode_t | RenderIconFile (loc_t x, loc_t y, const char *Name_ICO) |
This method reads a disk file that is in ico format and puts it on the screen. | |
RetCode_t | RenderGIFFile (loc_t x, loc_t y, const char *Name_GIF) |
Render a GIF file on screen. | |
RetCode_t | GetGIFMetrics (gif_screen_descriptor_t *imageDescriptor, const char *Name_GIF) |
GetGIFMetrics. | |
virtual int | character (int x, int y, int value) |
prints one character at the specified coordinates. | |
virtual int | columns (void) |
get the number of columns based on the currently active font | |
virtual int | rows (void) |
get the number of rows based on the currently active font | |
virtual RetCode_t | SelectUserFont (const uint8_t *font=NULL) |
Select a User Font for all subsequent text. | |
virtual bool | claim (FILE *stream) |
redirect output from a stream (stoud, sterr) to display | |
virtual point_t | locate (textloc_t column, textloc_t row)=0 |
locate the cursor at a character position. | |
virtual color_t | foreground (color_t color)=0 |
set the foreground color | |
virtual color_t | background (color_t color)=0 |
set the background color | |
Protected Member Functions | |
virtual RetCode_t | _StartGraphicsStream (void)=0 |
Pure virtual method indicating the start of a graphics stream. | |
virtual RetCode_t | _EndGraphicsStream (void)=0 |
Pure virtual method indicating the end of a graphics stream. | |
RetCode_t | _RenderBitmap (loc_t x, loc_t y, uint32_t fileOffset, FILE *fh, rect_t *getDim=NULL) |
Protected method to render an image given a file handle and coordinates. | |
RetCode_t | _RenderGIF (loc_t x, loc_t y, FILE *fh) |
Protected method to render a GIF given a file handle and coordinates. | |
virtual RetCode_t | booleanStream (loc_t x, loc_t y, dim_t w, dim_t h, const uint8_t *boolStream)=0 |
Pure virtual method to write a boolean stream to the display. | |
virtual int | _putc (int value) |
a method to put a character to the display. | |
virtual int | _getc () |
a method to get a character from the stdin | |
Protected Attributes | |
const unsigned char * | font |
reference to an external font somewhere in memory | |
short | _x |
keeps track of current X location | |
short | _y |
keeps track of current Y location | |
uint8_t | fontScaleX |
tracks the font scale factor for Soft fonts. Range: 1 .. 4 | |
uint8_t | fontScaleY |
tracks the font scale factor for soft fonts. Range: 1 .. 4 | |
rect_t | windowrect |
window commands are held here for speed of access | |
uint16_t | _column |
character column location | |
uint16_t | _row |
character row location | |
color_t | _foreground |
presently set foreground color | |
color_t | _background |
presently set background color | |
char * | _path |
stream name when redirecting stdio |
Detailed Description
The GraphicsDisplay class.
This graphics display class supports both graphics and text operations. Typically, a subclass is derived from this which has localizations to adapt to a specific hardware platform (e.g. a display controller chip), that overrides methods in here to either add more capability or perhaps to improve performance, by leveraging specific hardware capabilities.
Definition at line 40 of file GraphicsDisplay.h.
Constructor & Destructor Documentation
GraphicsDisplay | ( | const char * | name ) |
The constructor.
Definition at line 90 of file GraphicsDisplay.cpp.
Member Function Documentation
virtual RetCode_t _EndGraphicsStream | ( | void | ) | [protected, pure virtual] |
Pure virtual method indicating the end of a graphics stream.
This is called to conclude a stream of pixel data that was sent. This may cause register configuration changes in the derived class in order to stop the hardware from accept the streaming data.
- Note:
- this method must be supported in the derived class.
- Returns:
- RetCode_t value.
Implemented in RA8875.
int _getc | ( | ) | [protected, virtual, inherited] |
a method to get a character from the stdin
- Returns:
- the fetched character.
Definition at line 86 of file TextDisplay.cpp.
int _putc | ( | int | value ) | [protected, virtual, inherited] |
a method to put a character to the display.
- Parameters:
-
value is the character value to send to the display
- Returns:
- the character that was sent.
Reimplemented in RA8875.
Definition at line 41 of file TextDisplay.cpp.
RetCode_t _putp | ( | color_t | pixel ) | [virtual] |
method to put a single color pixel to the screen.
This method may be called as many times as necessary after
- See also:
- _StartGraphicsStream() is called, and it should be followed by _EndGraphicsStream.
- Parameters:
-
[in] pixel is a color value to be put on the screen.
- Returns:
- success/failure code.
- See also:
- RetCode_t.
Reimplemented in RA8875.
Definition at line 187 of file GraphicsDisplay.cpp.
RetCode_t _RenderBitmap | ( | loc_t | x, |
loc_t | y, | ||
uint32_t | fileOffset, | ||
FILE * | fh, | ||
rect_t * | getDim = NULL |
||
) | [protected] |
Protected method to render an image given a file handle and coordinates.
- Parameters:
-
[in] x is the horizontal pixel coordinate [in] y is the vertical pixel coordinate [in] fileOffset is the offset into the file where the image data starts [in] fh is the file handle to the stream already opened for the data. [in] getDim when not NULL is filled in from the size of the image, and the image is not drawn.
- Returns:
- success or error code.
Definition at line 329 of file GraphicsDisplay.cpp.
RetCode_t _RenderGIF | ( | loc_t | x, |
loc_t | y, | ||
FILE * | fh | ||
) | [protected] |
Protected method to render a GIF given a file handle and coordinates.
- Parameters:
-
[in] x is the horizontal pixel coordinate [in] y is the vertical pixel coordinate [in] fh is the file handle to the stream already opened for the data.
- Returns:
- success or error code.
Definition at line 418 of file GraphicsDisplayGIF.cpp.
virtual RetCode_t _StartGraphicsStream | ( | void | ) | [protected, pure virtual] |
Pure virtual method indicating the start of a graphics stream.
This is called prior to a stream of pixel data being sent. This may cause register configuration changes in the derived class in order to prepare the hardware to accept the streaming data.
- Note:
- this method must be supported in the derived class.
- Returns:
- RetCode_t value.
Implemented in RA8875.
virtual color_t background | ( | color_t | color ) | [pure virtual, inherited] |
set the background color
- Note:
- this method may be overridden in a derived class.
- Parameters:
-
[in] color is color to use for background drawing.
- Returns:
- color_t value that was the previous color.
Implemented in RA8875.
RetCode_t blit | ( | loc_t | x, |
loc_t | y, | ||
dim_t | w, | ||
dim_t | h, | ||
const int * | color | ||
) | [virtual] |
method to stream bitmap data to the display
This method fills a region from a stream of color data.
- Parameters:
-
[in] x is the left-edge of the region. [in] y is the top-edge of the region. [in] w specifies the width of the region. [in] h specifies the height of the region. [in] color is a pointer to a color stream with w x h values.
- Returns:
- success/failure code.
- See also:
- RetCode_t.
Definition at line 224 of file GraphicsDisplay.cpp.
virtual RetCode_t booleanStream | ( | loc_t | x, |
loc_t | y, | ||
dim_t | w, | ||
dim_t | h, | ||
const uint8_t * | boolStream | ||
) | [protected, pure virtual] |
Pure virtual method to write a boolean stream to the display.
This takes a bit stream in memory and using the current color settings it will stream it to the display. Along the way, each bit is translated to either the foreground or background color value and then that pixel is pushed onward.
This is similar, but different, to the pixelStream API, which is given a stream of color values.
- Parameters:
-
[in] x is the horizontal position on the display. [in] y is the vertical position on the display. [in] w is the width of the rectangular region to fill. [in] h is the height of the rectangular region to fill. [in] boolStream is the inline memory image from which to extract the bitstream.
- Returns:
- RetCode_t value.
Implemented in RA8875.
int character | ( | int | x, |
int | y, | ||
int | value | ||
) | [virtual] |
prints one character at the specified coordinates.
This will print the character at the specified pixel coordinates.
- Parameters:
-
[in] x is the horizontal offset in pixels. [in] y is the vertical offset in pixels. [in] value is the character to print.
- Returns:
- number of pixels to index to the right if a character was printed, 0 otherwise.
Implements TextDisplay.
Definition at line 182 of file GraphicsDisplay.cpp.
bool claim | ( | FILE * | stream ) | [virtual, inherited] |
redirect output from a stream (stoud, sterr) to display
- Note:
- this method may be overridden in a derived class.
- Parameters:
-
[in] stream that shall be redirected to the TextDisplay
- Returns:
- true if the claim succeeded.
Definition at line 107 of file TextDisplay.cpp.
RetCode_t cls | ( | uint16_t | layers = 0 ) |
[virtual] |
Clear the screen.
The behavior is to clear the whole screen.
- Parameters:
-
[in] layers is ignored, but supports maintaining the same API for the graphics layer.
- Returns:
- success/failure code.
- See also:
- RetCode_t.
Implements TextDisplay.
Reimplemented in RA8875.
Definition at line 208 of file GraphicsDisplay.cpp.
int columns | ( | void | ) | [virtual] |
get the number of columns based on the currently active font
- Returns:
- number of columns.
Implements TextDisplay.
Reimplemented in RA8875.
Definition at line 605 of file GraphicsDisplay.cpp.
RetCode_t fill | ( | loc_t | x, |
loc_t | y, | ||
dim_t | w, | ||
dim_t | h, | ||
color_t | color | ||
) | [virtual] |
method to fill a region.
This method fills a region with the specified color. It essentially is an alias for fillrect, however this uses width and height rather than a second x,y pair.
- Parameters:
-
[in] x is the left-edge of the region. [in] y is the top-edge of the region. [in] w specifies the width of the region. [in] h specifies the height of the region. [in] color is the color value to use to fill the region
- Returns:
- success/failure code.
- See also:
- RetCode_t.
Definition at line 203 of file GraphicsDisplay.cpp.
virtual RetCode_t fillrect | ( | loc_t | x1, |
loc_t | y1, | ||
loc_t | x2, | ||
loc_t | y2, | ||
color_t | color, | ||
fill_t | fillit = FILL |
||
) | [pure virtual] |
Draw a filled rectangle in the specified color.
- Note:
- As a side effect, this changes the current foreground color for subsequent operations.
- this method must be supported in the derived class.
- Parameters:
-
[in] x1 is the horizontal start of the line. [in] y1 is the vertical start of the line. [in] x2 is the horizontal end of the line. [in] y2 is the vertical end of the line. [in] color defines the foreground color. [in] fillit is optional to NOFILL the rectangle. default is FILL.
- Returns:
- success/failure code.
- See also:
- RetCode_t.
Implemented in RA8875.
int fontblit | ( | loc_t | x, |
loc_t | y, | ||
const unsigned char | c | ||
) | [virtual] |
This method transfers one character from the external font data to the screen.
The font being used has already been set with the SelectUserFont API.
- Note:
- the font data is in a special format as generate by the mikroe font creator. See http://www.mikroe.com/glcd-font-creator/
- Parameters:
-
[in] x is the horizontal pixel coordinate [in] y is the vertical pixel coordinate [in] c is the character to render
- Returns:
- how far the cursor should advance to the right in pixels.
- zero if the character could not be rendered.
Definition at line 278 of file GraphicsDisplay.cpp.
virtual color_t foreground | ( | color_t | color ) | [pure virtual, inherited] |
set the foreground color
- Note:
- this method may be overridden in a derived class.
- Parameters:
-
[in] color is color to use for foreground drawing.
- Returns:
- color_t value that was the previous color.
Implemented in RA8875.
const uint8_t * getCharMetrics | ( | const unsigned char | c, |
dim_t * | width, | ||
dim_t * | height | ||
) | [virtual] |
This method returns the width in pixels of the chosen character from the previously selected external font.
- Parameters:
-
[in] c is the character of interest. [in,out] width is a pointer to where the width will be stored. This parameter is NULL tested and will only be written if not null which is convenient if you only want the height. [in,out] height is a pointer to where the height will be stored. This parameter is NULL tested and will only be written if not null which is convenient if you only want the width.
- Returns:
- a pointer to the raw character data or NULL if not found.
Definition at line 253 of file GraphicsDisplay.cpp.
virtual uint16_t GetDrawingLayer | ( | void | ) | [pure virtual] |
Get the currently active drawing layer.
This returns a value, 0 or 1, based on the screen configuration and the currently active drawing layer.
uint16_t prevLayer; prevLayer = lcd.SelectDrawingLayer(x); lcd.circle(400,25, 25, BrightRed); lcd.SelectDrawingLayer(prevLayer);
- Attention:
- The user manual refers to Layer 1 and Layer 2, however the actual register values are value 0 and 1. This API as well as others that reference the layers use the values 0 and 1 for cleaner integration in the code.
- Returns:
- the current drawing layer; 0 or 1.
Implemented in RA8875.
RetCode_t GetGIFMetrics | ( | gif_screen_descriptor_t * | imageDescriptor, |
const char * | Name_GIF | ||
) |
GetGIFMetrics.
Get the GIF Image metrics.
- Parameters:
-
[out] imageDescriptor contains the image metrics on success. [in] Name_GIF is the filename of the GIF file of interest.
- Returns:
- noerror, or a variety of error codes.
Definition at line 562 of file GraphicsDisplayGIF.cpp.
virtual point_t GetGraphicsCursor | ( | void | ) | [pure virtual] |
Read the current graphics cursor position as a point.
- Returns:
- the graphics cursor as a point.
Implemented in RA8875.
rect_t GetImageRect | ( | loc_t | x, |
loc_t | y, | ||
const char * | FileName = NULL |
||
) |
This method gets the rectangle that would render a specified image file.
This is the more programmer "obvious" method of getting the size of an image file.
- Note:
- The present implementation calls the RenderImageFile API with the optional getDim parameter.
- Not all image file formats are supported. Check the return value.
- Parameters:
-
[in] x is the horizontal pixel coordinate of the top-left corner. [in] y is the vertical pixel coordinate of the top-left corner. [in] FileName refers to the fully qualified path and file on a mounted file system. The filename is optional, in which case it simply returns a rect_t with all elements set to zero.
- Returns:
- a rect_t that would contain the specified image. When the specified file cannot be found, or where this method is not yet supported, all elements of the returned rect_r will be zero.
Definition at line 456 of file GraphicsDisplay.cpp.
This method gets the rectangle that would render a specified image file.
This is the more programmer "obvious" method of getting the size of an image file.
- Note:
- The present implementation calls the RenderImageFile API with the optional getDim parameter.
- Not all image file formats are supported. Check the return value.
- Parameters:
-
[in] pt is the point defining the top-left corner. [in] FileName refers to the fully qualified path and file on a mounted file system. The filename is optional, in which case it simply returns a rect_t with all elements set to zero.
- Returns:
- a rect_t that would contain the specified image. When the specified file cannot be found, or where this method is not yet supported, all elements of the returned rect_r will be zero.
Definition at line 464 of file GraphicsDisplay.cpp.
virtual color_t getPixel | ( | loc_t | x, |
loc_t | y | ||
) | [pure virtual] |
Get a pixel from the display.
- Note:
- this method must be supported in the derived class.
- Parameters:
-
[in] x is the horizontal offset to this pixel. [in] y is the vertical offset to this pixel.
- Returns:
- the pixel.
- See also:
- color_t
Implemented in RA8875.
virtual RetCode_t getPixelStream | ( | color_t * | p, |
uint32_t | count, | ||
loc_t | x, | ||
loc_t | y | ||
) | [pure virtual] |
Get a stream of pixels from the display.
- Note:
- this method must be supported in the derived class.
- Parameters:
-
[out] p is a pointer to a color_t array to accept the stream. [in] count is the number of pixels to read. [in] x is the horizontal offset to this pixel. [in] y is the vertical offset to this pixel.
- Returns:
- success/failure code.
- See also:
- RetCode_t.
Implemented in RA8875.
rect_t GetWindow | ( | ) | [pure virtual] |
Get the current window setting, which constrains what is written to the screen.
- Returns:
- the current window definition.
Implemented in RA8875.
Definition at line 114 of file GraphicsDisplay.cpp.
virtual uint16_t height | ( | ) | [pure virtual] |
get the screen height in pixels
- Note:
- this method must be supported in the derived class.
- Returns:
- screen height in pixels.
Implemented in RA8875.
point_t locate | ( | textloc_t | column, |
textloc_t | row | ||
) | [pure virtual, inherited] |
locate the cursor at a character position.
Based on the currently active font, locate the cursor on screen.
- Note:
- this method may be overridden in a derived class.
- Parameters:
-
[in] column is the horizontal offset from the left side. [in] row is the vertical offset from the top.
- Returns:
- point_t value that was the last location.
Implemented in RA8875.
Definition at line 75 of file TextDisplay.cpp.
virtual RetCode_t pixel | ( | loc_t | x, |
loc_t | y, | ||
color_t | color | ||
) | [pure virtual] |
Draw a pixel in the specified color.
- Note:
- this method must be supported in the derived class.
- Parameters:
-
[in] x is the horizontal offset to this pixel. [in] y is the vertical offset to this pixel. [in] color defines the color for the pixel.
- Returns:
- success/failure code.
- See also:
- RetCode_t.
Implemented in RA8875.
virtual RetCode_t pixelStream | ( | color_t * | p, |
uint32_t | count, | ||
loc_t | x, | ||
loc_t | y | ||
) | [pure virtual] |
Write a stream of pixels to the display.
- Note:
- this method must be supported in the derived class.
- Parameters:
-
[in] p is a pointer to a color_t array to write. [in] count is the number of pixels to write. [in] x is the horizontal position on the display. [in] y is the vertical position on the display.
- Returns:
- success/failure code.
- See also:
- RetCode_t.
Implemented in RA8875.
RetCode_t RenderBitmapFile | ( | loc_t | x, |
loc_t | y, | ||
const char * | Name_BMP, | ||
rect_t * | getDim = NULL |
||
) |
This method reads a disk file that is in bitmap format and puts it on the screen.
Supported formats:
- 1-bit color format (2 colors)
- 4-bit color format (16 colors)
- 8-bit color format (256 colors)
- 16-bit color format (65k colors)
- 24-bit color format (16M colors)
- compression: no.
- Note:
- This is a slow operation, typically due to the use of the file system, and partially because bmp files are stored from the bottom up, and the memory is written from the top down; as a result, it constantly 'seeks' on the file system for the next row of information.
As a performance test, a sample picture was timed. A family picture was converted to Bitmap format; shrunk to 352 x 272 pixels and save in 8-bit color format. The resulting file size was 94.5 KByte. The SPI port interface was set to 20 MHz. The original bitmap rendering software was purely in software, pushing 1 pixel at a time to the write function, which did use SPI hardware (not pin wiggling) to transfer commands and data to the display. Then, the driver was improved to leverage the capability of the derived display driver. As a final check, instead of the [known slow] local file system, a randomly chosen USB stick was used. The performance results are impressive (but depend on the listed factors).
- 34 seconds, LocalFileSystem, Software Rendering
- 9 seconds, LocalFileSystem, Hardware Rending for RA8875
- 3 seconds, MSCFileSystem, Hardware Rendering for RA8875
- Parameters:
-
[in] x is the horizontal pixel coordinate [in] y is the vertical pixel coordinate [in] Name_BMP is the filename on the mounted file system. [in] getDim when not NULL is filled in initialized to the x,y origin, and from the size of the image, which is not drawn.
- Returns:
- success or error code.
Definition at line 496 of file GraphicsDisplay.cpp.
RetCode_t RenderGIFFile | ( | loc_t | x, |
loc_t | y, | ||
const char * | Name_GIF | ||
) |
Render a GIF file on screen.
This function reads a GIF file, and places it on-screen at the specified coordinates.
- Parameters:
-
[in] x is the left edge of the on-screen coordinates. [in] y is the top edge of the on-screen coordinates. [in] Name_GIF is a pointer to the fully qualified filename.
- Returns:
- noerror, or a variety of error codes.
Definition at line 580 of file GraphicsDisplayGIF.cpp.
RetCode_t RenderIconFile | ( | loc_t | x, |
loc_t | y, | ||
const char * | Name_ICO | ||
) |
This method reads a disk file that is in ico format and puts it on the screen.
Reading the disk is slow, but a typical icon file is small so it should be ok.
- Note:
- An Icon file can have more than one icon in it. This implementation only processes the first image in the file.
- Parameters:
-
[in] x is the horizontal pixel coordinate [in] y is the vertical pixel coordinate [in] Name_ICO is the filename on the mounted file system.
- Returns:
- success or error code.
Definition at line 567 of file GraphicsDisplay.cpp.
This method attempts to render a specified graphics image file at the specified screen location.
This supports several variants of the following file types:
- Bitmap file format,
- Icon file format.
- Jpeg file format.
- Note:
- The specified image width and height, when adjusted for the x and y origin, must fit on the screen, or the image will not be shown (it does not clip the image).
- The file extension is tested, and if it ends in a supported format, the appropriate handler is called to render that image.
- Parameters:
-
[in] pt is the pixel coordinate of the top-left corner. [in] FileName refers to the fully qualified path and file on a mounted file system. [in] getDim when not NULL the image is not drawn. Instead, the getDim is filled in as the rectangle that would be drawn relative to the provided x,y origin. This basically provides a GetImageRect on a specified file.
- Returns:
- success or error code.
Definition at line 472 of file GraphicsDisplay.cpp.
RetCode_t RenderImageFile | ( | loc_t | x, |
loc_t | y, | ||
const char * | FileName, | ||
rect_t * | getDim = NULL |
||
) |
This method attempts to render a specified graphics image file at the specified screen location.
This supports several variants of the following file types:
- Bitmap file format,
- Icon file format.
- Jpeg file format.
- Note:
- The specified image width and height, when adjusted for the x and y origin, must fit on the screen, or the image will not be shown (it does not clip the image).
- The file extension is tested, and if it ends in a supported format, the appropriate handler is called to render that image.
- Parameters:
-
[in] x is the horizontal pixel coordinate of the top-left corner. [in] y is the vertical pixel coordinate of the top-left corner. [in] FileName refers to the fully qualified path and file on a mounted file system. [in] getDim when not NULL caused the image to not be drawn. Instead, getDim is filled in as the rectangle that would be drawn relative to the provided x,y origin. This basically provides a GetImageRect on a specified file.
- See also:
- GetImageRect is the recommended and more obvious API.
- Returns:
- success or error code.
Definition at line 476 of file GraphicsDisplay.cpp.
RetCode_t RenderJpegFile | ( | loc_t | x, |
loc_t | y, | ||
const char * | Name_JPG | ||
) |
This method reads a disk file that is in jpeg format and puts it on the screen.
- Parameters:
-
[in] x is the horizontal pixel coordinate [in] y is the vertical pixel coordinate [in] Name_JPG is the filename on the mounted file system.
- Returns:
- success or error code.
Definition at line 523 of file GraphicsDisplay.cpp.
RGBQUAD RGB16ToRGBQuad | ( | color_t | c ) |
This method converts a 16-bit color value into a 24-bit RGB Quad.
- Parameters:
-
[in] c is the 16-bit color.
- See also:
- color_t.
- Returns:
- an RGBQUAD value.
- See also:
- RGBQUAD
Definition at line 316 of file GraphicsDisplay.cpp.
color_t RGBQuadToRGB16 | ( | RGBQUAD * | colorPaletteArray, |
uint16_t | index | ||
) |
This method returns the color value from a palette.
This method accepts a pointer to a Bitmap color palette, which is a table in memory composed of RGB Quad values (r, g, b, 0), and an index into that table. It then extracts the color information and down-samples it to a color_t value which it returns.
- Note:
- This method probably has very little value outside of the internal methods for reading BMP files.
- Parameters:
-
[in] colorPaletteArray is the handle to the color palette array to use. [in] index is the index into the color palette.
- Returns:
- the color in color_t format.
Definition at line 298 of file GraphicsDisplay.cpp.
int rows | ( | void | ) | [virtual] |
get the number of rows based on the currently active font
- Returns:
- number of rows.
Implements TextDisplay.
Reimplemented in RA8875.
Definition at line 610 of file GraphicsDisplay.cpp.
virtual uint16_t SelectDrawingLayer | ( | uint16_t | layer ) | [pure virtual] |
Select the drawing layer for subsequent commands.
If the screen configuration is 480 x 272, or if it is 800 x 480 and 8-bit color, the the display supports two layers, which can be independently drawn on and shown. Additionally, complex operations involving both layers are permitted.
//lcd.SetLayerMode(OnlyLayer0); // default is layer 0
lcd.rect(400,130, 475,155,Brown);
lcd.SelectDrawingLayer(1);
lcd.circle(400,25, 25, BrightRed);
wait(1);
lcd.SetLayerMode(ShowLayer1);
- Attention:
- The user manual refers to Layer 1 and Layer 2, however the actual register values are value 0 and 1. This API as well as others that reference the layers use the values 0 and 1 for cleaner iteration in the code.
- Parameters:
-
[in] layer is 0 or 1 to select the layer for subsequent commands.
- Returns:
- The previous drawing layer.
Implemented in RA8875.
virtual RetCode_t SelectUserFont | ( | const uint8_t * | font = NULL ) |
[virtual] |
Select a User Font for all subsequent text.
- Note:
- Tool to create the fonts is accessible from its creator available at http://www.mikroe.com. For version 1.2.0.0, choose the "Export for TFT and new GLCD" format.
- Parameters:
-
[in] font is a pointer to a specially formed font resource.
- Returns:
- RetCode_t value.
Reimplemented in RA8875.
virtual RetCode_t SetGraphicsCursor | ( | point_t | p ) | [pure virtual] |
Prepare the controller to write binary data to the screen by positioning the memory cursor.
- Parameters:
-
[in] p is the point representing the cursor position to set
- Returns:
- RetCode_t value.
Implemented in RA8875.
virtual RetCode_t SetGraphicsCursor | ( | loc_t | x, |
loc_t | y | ||
) | [pure virtual] |
Prepare the controller to write binary data to the screen by positioning the memory cursor.
- Note:
- this method must be supported in the derived class.
- Parameters:
-
[in] x is the horizontal position in pixels (from the left edge) [in] y is the vertical position in pixels (from the top edge)
- Returns:
- success/failure code.
- See also:
- RetCode_t.
Implemented in RA8875.
virtual RetCode_t SetGraphicsCursorRead | ( | loc_t | x, |
loc_t | y | ||
) | [pure virtual] |
Prepare the controller to read binary data from the screen by positioning the memory read cursor.
- Parameters:
-
[in] x is the horizontal position in pixels (from the left edge) [in] y is the vertical position in pixels (from the top edge)
- Returns:
- success/failure code.
- See also:
- RetCode_t.
Implemented in RA8875.
rect_t SetWindow | ( | loc_t | x1 = 0 , |
loc_t | y1 = 0 , |
||
loc_t | x2 = (loc_t)-1 , |
||
loc_t | y2 = (loc_t)-1 |
||
) | [pure virtual] |
Set the window, constraining where items are written to the screen.
After setting the window, text and graphics are constrained to this window. Text will wrap from the right edge back to the left and down one row and from the bottom to the top. Graphics drawing will be clipped at the edge of the window.
- Note:
- if no parameters are provided, it restores the window to full screen.
- If the initial text write is outside the window, it will be shown where the cursor positions it. Once the write hits the right edge of the defined window, it will then wrap back to the left edge. Once it hits the bottom, it wraps to the top of the window. For this reason, it is common to set the text cursor to the window.
lcd.SetWindow(10,10, 80,80);
lcd.SetTextCursor(10,10);
lcd.puts("012345678901234567890123456789012345678901234567890");
lcd.SetWindow(); restore to full screen
- Parameters:
-
[in] x1 is the left edge in pixels. [in] y1 is the top edge in pixels. [in] x2 is the right edge in pixels. [in] y2 is the bottom edge in pixels.
- Returns:
- the previous window definition.
Implemented in RA8875.
Definition at line 123 of file GraphicsDisplay.cpp.
Set the window, constraining where items are written to the screen.
After setting the window, text and graphics are constrained to this window. Text will wrap from the right edge back to the left and down one row and from the bottom to the top. Graphics drawing will be clipped at the edge of the window.
- Note:
- If the initial text write is outside the window, it will be shown where the cursor position it. Once the write hits the right edge of the defined window, it will then wrap back to the left edge. Once it hits the bottom, it wraps to the top of the window. For this reason, it is common to set the text cursor to the window.
rect_t r = {10,10, 90,90}; r = lcd.SetWindow(r); lcd.SetTextCursor(r.p1.x, r.p1.y); lcd.puts("012345678901234567890123456789012345678901234567890"); lcd.SetWindow(r); restore to previous window setting
- Parameters:
-
[in] r is the rect_t used to set the window.
- Returns:
- the previous window definition.
Implemented in RA8875.
Definition at line 118 of file GraphicsDisplay.cpp.
virtual uint16_t width | ( | ) | [pure virtual] |
get the screen width in pixels
- Note:
- this method must be supported in the derived class.
- Returns:
- screen width in pixels.
Implemented in RA8875.
virtual RetCode_t WriteCommand | ( | unsigned char | command, |
unsigned int | data = 0xFFFF |
||
) | [pure virtual] |
virtual RetCode_t WriteData | ( | unsigned char | data ) | [pure virtual] |
Field Documentation
color_t _background [protected, inherited] |
presently set background color
Definition at line 153 of file TextDisplay.h.
uint16_t _column [protected, inherited] |
character column location
Definition at line 148 of file TextDisplay.h.
color_t _foreground [protected, inherited] |
presently set foreground color
Definition at line 152 of file TextDisplay.h.
char* _path [protected, inherited] |
stream name when redirecting stdio
Definition at line 154 of file TextDisplay.h.
uint16_t _row [protected, inherited] |
character row location
Definition at line 149 of file TextDisplay.h.
short _x [protected] |
keeps track of current X location
Definition at line 774 of file GraphicsDisplay.h.
short _y [protected] |
keeps track of current Y location
Definition at line 775 of file GraphicsDisplay.h.
const unsigned char* font [protected] |
reference to an external font somewhere in memory
Definition at line 771 of file GraphicsDisplay.h.
uint8_t fontScaleX [protected] |
tracks the font scale factor for Soft fonts. Range: 1 .. 4
Definition at line 777 of file GraphicsDisplay.h.
uint8_t fontScaleY [protected] |
tracks the font scale factor for soft fonts. Range: 1 .. 4
Definition at line 778 of file GraphicsDisplay.h.
rect_t windowrect [protected] |
window commands are held here for speed of access
Definition at line 780 of file GraphicsDisplay.h.
Generated on Tue Jul 12 2022 17:28:36 by 1.7.2