The tcDspDisplay class allows the user to draw, erase, write text and bitmaps on a simple memory mapped display interface. More...
#include <core/DspDisplay.h>
Classes | |
struct | tsScreenCoords |
Structure used to store screen coordinates (in pixels). More... | |
struct | tsScreenOffset |
Structure used to store screen offsets (in pixels). More... | |
Public Types | |
enum | teScreenId { eeScreenDefault = -1, eeScreen1 = 0, eeScreen2 = 1, eeScreen3 = 2, eeScreen4 = 3, eeScreen5 = 4, eeScreen6 = 5, eeScreen7 = 6, eeScreen8 = 7 } |
Screen offset enumeration. More... | |
Public Member Functions | |
tcDspDisplay (tcDspDisplayDriver *apDriver, int anNumScreens, void *aaBaseAddr[], tcDspFont *apDefaultFont, bool abRotate=false) | |
This constructor is used to create an instance of a display. | |
tcDspDisplay (int anWidth, int anHeight, int anBpp, void *apCmdAddr, int anNumScreens, void *aaBaseAddr[], tcDspFont *apDefaultFont, int anViewableScreens=-1) | |
This constructor is used to create an instance of a display. | |
~tcDspDisplay () | |
This destructor destroys an instance of a display. | |
int | getWidth (void) |
Retrieves display width in pixels. | |
int | getHeight (void) |
Retrieves display height in pixels. | |
void | rotate (bool abRotate) |
Enables or disables 90 degree display rotation. | |
bool | isRotated (void) |
Indicates whether display is currently rotated 90 degrees. | |
void | setDefaultFont (tcDspFont *apFont) |
This routine updates the default font, which is used when no other font is explicitly specified. | |
void | setDefaultColor (int anColor) |
This routine updates the default color, which is used when a 1 bpp bitmap is displayed on a multiple-bpp display, or when any operation is made with gnDefaultColor specified. | |
int | convertRGBtoColor (unsigned char anRed, unsigned char anGreen, unsigned char anBlue) |
This is a convenience routine to convert red, green, and blue color values to an integer appropriate for the display bit depth. | |
tsScreenCoords | putString (const unsigned char *apString, tsScreenCoords asPosition, teScreenId aeScreen=eeScreenDefault, tcDspFont *apFont=NULL, bool abTransBg=false) |
This routine puts a NULL-terminated string of characters on the specified screen using the specified font. | |
tsScreenCoords | putString (const unsigned char *apString, int anX, int anY, teScreenId aeScreen=eeScreenDefault, tcDspFont *apFont=NULL, bool abTransBg=false) |
This routine is an alternate interface to the putString method. | |
tsScreenCoords | putString (const char *apString, tsScreenCoords asPosition, teScreenId aeScreen=eeScreenDefault, tcDspFont *apFont=NULL, bool abTransBg=false) |
This routine provides an alternate interface to the putString method. | |
tsScreenCoords | putString (const char *apString, int anX, int anY, teScreenId aeScreen=eeScreenDefault, tcDspFont *apFont=NULL, bool abTransBg=false) |
This routine is an alternate interface to the putString method. | |
tsScreenOffset | getStringExtent (const unsigned char *apString, tcDspFont *apFont=NULL) |
This routine computes the XY extent of the given string using the specified font. | |
tsScreenOffset | getStringExtent (const char *apString, tcDspFont *apFont=NULL) |
This routine provides an alternate interface to the getStringExtent method. | |
teScreenId | setActiveScreen (teScreenId aeScreen) |
This routine updates the active screen (the one that gets written to by default). | |
teScreenId | setVisibleScreen (teScreenId aeScreen=eeScreenDefault) |
This routine sets the screen that the hardware is currently displaying. | |
bool | clearScreen (teScreenId aeScreen=eeScreenDefault, tsScreenCoords *apStart=NULL, tsScreenOffset *apOffset=NULL) |
This routine clears an area of the specified screen. | |
tsScreenCoords | drawLine (tsScreenCoords asPosition, tsScreenOffset asOffset, int anColor, teScreenId aeScreen=eeScreenDefault) |
This routine draws a line from the given position to the given offset (which may be negative). | |
tsScreenCoords | drawLine (int anX, int anY, int anDx, int anDy, int anColor, teScreenId aeScreen=eeScreenDefault) |
This routine provides an alternate interface to the DrawLine method. | |
tsScreenCoords | drawRectangle (tsScreenCoords asPosition, tsScreenOffset asOffset, int anColor, teScreenId aeScreen=eeScreenDefault) |
This routine draws a rectangle of the specified size and specified color on the specified screen. | |
tsScreenCoords | drawRectangle (int anX, int anY, int anDx, int anDy, int anColor, teScreenId aeScreen=eeScreenDefault) |
This routine provides an alternate interface to the DrawRectangle method. | |
tsScreenCoords | drawBitmap (tsScreenCoords asPosition, int anWidth, int anHeight, const unsigned char *apBitmap, int anDepth, teScreenId aeScreen=eeScreenDefault, bool abTransBg=false) |
This routine places a bitmap of the specified width and height on the indicated screen. | |
tsScreenCoords | drawBitmap (int anX, int anY, int anWidth, int anHeight, const unsigned char *apBitmap, int anDepth, teScreenId aeScreen=eeScreenDefault, bool abTransBg=false) |
This routine provides an alternate interface to the drawBitmap method. | |
bool | setPixel (tsScreenCoords asPosition, int anColor, teScreenId aeScreen=eeScreenDefault) |
This routine sets the value of the specified pixel on the specified screen to the specified color (taking into account the configured display depth). | |
bool | setPixel (int anX, int anY, int anColor, teScreenId aeScreen=eeScreenDefault) |
This routine provides an alternate interface to the setPixel method. | |
void | screenCopy (teScreenId aeDest, teScreenId aeSrc) |
This routine copies a source screen to a destination screen. | |
void | screenXOR (teScreenId aeDest, teScreenId aeSrc1, teScreenId aeSrc2) |
This routine XORs two source screens together and stores the results in a destination screen. | |
void | screenAND (teScreenId aeDest, teScreenId aeSrc1, teScreenId aeSrc2) |
This routine ANDs two source screens together and stores the results in a destination screen. | |
void | screenOR (teScreenId aeDest, teScreenId aeSrc1, teScreenId aeSrc2) |
This routine ORs two source screens together and stores the results in a destination screen. | |
Static Public Attributes | |
static const int | gnMAX_SCREENS = 8 |
Maximum screen buffers allowed. | |
static const int | gnMAX_DEPTH = 16 |
Maximum pixel depth (bpp). | |
static const int | gnDefaultColor = -1 |
Indicates that the default color is to be used. |
The tcDspDisplay class allows the user to draw, erase, write text and bitmaps on a simple memory mapped display interface.
Support is provided for multiple display screens, including virtual screens that are not mapped directly to the hardware. Any of the hardware-mapped pages may be made visible. ScreenXOR, ScreenOR, and ScreenAND functions are provided to combine screens.
tcDspDisplay::tcDspDisplay | ( | tcDspDisplayDriver * | apDriver, | |
int | anNumScreens, | |||
void * | aaBaseAddr[], | |||
tcDspFont * | apDefaultFont, | |||
bool | abRotate = false | |||
) |
This constructor is used to create an instance of a display.
The width, height, and pixel depth of the display are passed in. Also, a number of memory mapped "screens" of the specified size are created, at provided memory addresses. A default font is also provided.
This constructor is used for a display whose frame buffer(s) are in local memory and are accessed by an instance of tcDspDisplayDriver.
[in] | apDriver | Pointer to instance of tcDspDisplayDriver |
[in] | anNumScreens | Number of screens to create. |
[in] | aaBaseAddr | Array of base addresses for memory-mapped screens. |
[in] | apDefaultFont | Default font for text display. |
[in] | abRotate | True to rotate display 90-degrees (make a vertically scanned display horizontal). |
tcDspDisplay::tcDspDisplay | ( | int | anWidth, | |
int | anHeight, | |||
int | anBpp, | |||
void * | apCmdAddr, | |||
int | anNumScreens, | |||
void * | aaBaseAddr[], | |||
tcDspFont * | apDefaultFont, | |||
int | anViewableScreens = -1 | |||
) |
This constructor is used to create an instance of a display.
The width, height, and pixel depth of the display are passed in. Also, a number of memory mapped "screens" of the specified size are created, at provided memory addresses. A default font is also provided.
Optionally, some of the provided screens may be "virtual." That is, they exist only in RAM and must be copied into one of the first "anViewableScreens" screens in order to become visible.
This constructor is used for a display whose frame buffer(s) are in FPGA memory.
[in] | anWidth | Width of screens in pixels. |
[in] | anHeight | Height of screens in pixels. |
[in] | anBpp | Color depth of screens. |
[in] | apCmdAddr | Address used to send drawing commands. |
[in] | anNumScreens | Number of screens to create. |
[in] | aaBaseAddr | Array of base addresses for memory-mapped screens. |
[in] | apDefaultFont | Default font for text display. |
[in] | anViewableScreens | Number of created screens that are visible. |
tcDspDisplay::~tcDspDisplay | ( | ) |
This destructor destroys an instance of a display.
It clears the screen, then calls setVisibleScreen to blank the display.
int tcDspDisplay::getWidth | ( | void | ) |
int tcDspDisplay::getHeight | ( | void | ) |
void tcDspDisplay::rotate | ( | bool | abRotate | ) |
Enables or disables 90 degree display rotation.
[in] | abRotate | If true, rotates display 90-degrees. |
bool tcDspDisplay::isRotated | ( | void | ) |
Indicates whether display is currently rotated 90 degrees.
void tcDspDisplay::setDefaultFont | ( | tcDspFont * | apFont | ) |
This routine updates the default font, which is used when no other font is explicitly specified.
[in] | apFont | Font to use for text drawing. |
void tcDspDisplay::setDefaultColor | ( | int | anColor | ) |
This routine updates the default color, which is used when a 1 bpp bitmap is displayed on a multiple-bpp display, or when any operation is made with gnDefaultColor specified.
[in] | anColor | Default color to use (only the least significant mnDepth bits are valid). |
int tcDspDisplay::convertRGBtoColor | ( | unsigned char | anRed, | |
unsigned char | anGreen, | |||
unsigned char | anBlue | |||
) |
This is a convenience routine to convert red, green, and blue color values to an integer appropriate for the display bit depth.
If the display has a depth that does not support RGB colors, the current default color is returned.
[in] | anRed | Relative red color level |
[in] | anGreen | Relative green color level |
[in] | anBlue | Relative blue color level |
tcDspDisplay::tsScreenCoords tcDspDisplay::putString | ( | const unsigned char * | apString, | |
tsScreenCoords | asPosition, | |||
teScreenId | aeScreen = eeScreenDefault , |
|||
tcDspFont * | apFont = NULL , |
|||
bool | abTransBg = false | |||
) |
This routine puts a NULL-terminated string of characters on the specified screen using the specified font.
The position of the end of the string is returned.
[in] | apString | The string to display. |
[in] | asPosition | Position of the start of the string. |
[in] | aeScreen | Screen ID to write to. |
[in] | apFont | Font to use for writing. |
[in] | abTransBg | Transparent background if True. |
tcDspDisplay::tsScreenCoords tcDspDisplay::putString | ( | const unsigned char * | apString, | |
int | anX, | |||
int | anY, | |||
teScreenId | aeScreen = eeScreenDefault , |
|||
tcDspFont * | apFont = NULL , |
|||
bool | abTransBg = false | |||
) |
This routine is an alternate interface to the putString method.
[in] | apString | The string to display. |
[in] | anX | X-coordinate of the string's origin. |
[in] | anY | Y-coordinate of the string's origin. |
[in] | aeScreen | Screen ID to write to. |
[in] | apFont | Font to use for writing. |
[in] | abTransBg | Transparent background if True. |
tcDspDisplay::tsScreenCoords tcDspDisplay::putString | ( | const char * | apString, | |
tsScreenCoords | asPosition, | |||
teScreenId | aeScreen = eeScreenDefault , |
|||
tcDspFont * | apFont = NULL , |
|||
bool | abTransBg = false | |||
) |
This routine provides an alternate interface to the putString method.
[in] | apString | The string to display. |
[in] | asPosition | Position of the start of the string. |
[in] | aeScreen | Screen ID to write to. |
[in] | apFont | Font to use for writing. |
[in] | abTransBg | Transparent background if True. |
tcDspDisplay::tsScreenCoords tcDspDisplay::putString | ( | const char * | apString, | |
int | X, | |||
int | Y, | |||
teScreenId | aeScreen = eeScreenDefault , |
|||
tcDspFont * | apFont = NULL , |
|||
bool | abTransBg = false | |||
) |
This routine is an alternate interface to the putString method.
[in] | apString | The string to display. |
[in] | X | X-coordinate of the string's origin. |
[in] | Y | Y-coordinate of the string's origin. |
[in] | aeScreen | Screen ID to write to. |
[in] | apFont | Font to use for writing. |
[in] | abTransBg | Transparent background if True. |
tcDspDisplay::tsScreenOffset tcDspDisplay::getStringExtent | ( | const unsigned char * | apString, | |
tcDspFont * | apFont = NULL | |||
) |
This routine computes the XY extent of the given string using the specified font.
[in] | apString | The string to use for calculation. |
[in] | apFont | Font to use for calculation. |
tcDspDisplay::tsScreenOffset tcDspDisplay::getStringExtent | ( | const char * | apString, | |
tcDspFont * | apFont = NULL | |||
) |
This routine provides an alternate interface to the getStringExtent method.
[in] | apString | The string to use for calculation. |
[in] | apFont | Font to use for calculation. |
tcDspDisplay::teScreenId tcDspDisplay::setActiveScreen | ( | teScreenId | aeScreen | ) |
This routine updates the active screen (the one that gets written to by default).
[in] | aeScreen | The desired new active (default) screen ID. |
tcDspDisplay::teScreenId tcDspDisplay::setVisibleScreen | ( | teScreenId | aeScreen = eeScreenDefault |
) |
This routine sets the screen that the hardware is currently displaying.
It returns the current setting, which will match the request if successful.
[in] | aeScreen | The desired new visible screen. |
bool tcDspDisplay::clearScreen | ( | teScreenId | aeScreen = eeScreenDefault , |
|
tsScreenCoords * | apStart = NULL , |
|||
tsScreenOffset * | apOffset = NULL | |||
) |
This routine clears an area of the specified screen.
If no screen is specified, the active screen is used. If no area is specified, the entire screen is cleared.
[in] | aeScreen | The screen to clear. |
[in] | apStart | Upper-left corner of rectangle to clear. |
[in] | apOffset | Distance from the upper-left corner to clear. |
tcDspDisplay::tsScreenCoords tcDspDisplay::drawLine | ( | tsScreenCoords | asPosition, | |
tsScreenOffset | asOffset, | |||
int | anColor, | |||
teScreenId | aeScreen = eeScreenDefault | |||
) |
This routine draws a line from the given position to the given offset (which may be negative).
The line is drawn in the color provided on the specified screen (or the active screen if none is specified).
[in] | asPosition | Starting position of the line. |
[in] | asOffset | Endpoint offset from the starting position. |
[in] | anColor | The desired line color. |
[in] | aeScreen | The screen to draw on. |
tcDspDisplay::tsScreenCoords tcDspDisplay::drawLine | ( | int | anX, | |
int | anY, | |||
int | anDx, | |||
int | anDy, | |||
int | anColor, | |||
teScreenId | aeScreen = eeScreenDefault | |||
) |
This routine provides an alternate interface to the DrawLine method.
[in] | anX | Starting X-coordinate of the line. |
[in] | anY | Starting Y-Coordinate of the line. |
[in] | anDx | Endpoint X-coordinate offset of the line. |
[in] | anDy | Endpoint Y-coordinate offset of the line. |
[in] | anColor | The desired line color. |
[in] | aeScreen | The screen to draw on. |
tcDspDisplay::tsScreenCoords tcDspDisplay::drawRectangle | ( | tsScreenCoords | asPosition, | |
tsScreenOffset | asOffset, | |||
int | anColor, | |||
teScreenId | aeScreen = eeScreenDefault | |||
) |
This routine draws a rectangle of the specified size and specified color on the specified screen.
[in] | asPosition | Upper-leftmost vertex of the rectangle. |
[in] | asOffset | Offset from the starting position of the opposite vertex. |
[in] | anColor | The desired line color. |
[in] | aeScreen | The screen to draw on. |
tcDspDisplay::tsScreenCoords tcDspDisplay::drawRectangle | ( | int | anX, | |
int | anY, | |||
int | anDx, | |||
int | anDy, | |||
int | anColor, | |||
teScreenId | aeScreen = eeScreenDefault | |||
) |
This routine provides an alternate interface to the DrawRectangle method.
[in] | anX | Starting X-coordinate of the rectangle. |
[in] | anY | Starting Y-Coordinate of the rectangle. |
[in] | anDx | X-coordinate offset of the opposite vertex. |
[in] | anDy | Y-coordinate offset of the opposite vertex. |
[in] | anColor | The desired line color. |
[in] | aeScreen | The screen to draw on. |
tcDspDisplay::tsScreenCoords tcDspDisplay::drawBitmap | ( | tsScreenCoords | asPosition, | |
int | anWidth, | |||
int | anHeight, | |||
const unsigned char * | apBitmap, | |||
int | anDepth, | |||
teScreenId | aeScreen = eeScreenDefault , |
|||
bool | abTransBg = false | |||
) |
This routine places a bitmap of the specified width and height on the indicated screen.
[in] | asPosition | Position to start drawing the bitmap. |
[in] | anWidth | Width of the bitmap. |
[in] | anHeight | Height of the bitmap. |
[in] | apBitmap | Pointer to the bitmap to draw. |
[in] | anDepth | Bit depth of the bitmap. |
[in] | aeScreen | Screen to draw on. |
[in] | abTransBg | Background (black) is transparent if True. |
tcDspDisplay::tsScreenCoords tcDspDisplay::drawBitmap | ( | int | anX, | |
int | anY, | |||
int | anWidth, | |||
int | anHeight, | |||
const unsigned char * | apBitmap, | |||
int | anDepth, | |||
teScreenId | aeScreen = eeScreenDefault , |
|||
bool | abTransBg = false | |||
) |
This routine provides an alternate interface to the drawBitmap method.
[in] | anX | X-Coordate to start the bitmap. |
[in] | anY | Y-Coordinate to start the bitmap. |
[in] | anWidth | Width of the bitmap. |
[in] | anHeight | Height of the bitmap. |
[in] | apBitmap | Pointer to the bitmap to draw. |
[in] | anDepth | Bit depth of the bitmap. |
[in] | aeScreen | Screen to draw on. |
[in] | abTransBg | Background (black) is transparent if True. |
bool tcDspDisplay::setPixel | ( | tsScreenCoords | asPosition, | |
int | anColor, | |||
teScreenId | aeScreen = eeScreenDefault | |||
) |
This routine sets the value of the specified pixel on the specified screen to the specified color (taking into account the configured display depth).
[in] | asPosition | Position to draw the pixel. |
[in] | anColor | Color of the pixel. |
[in] | aeScreen | Screen to draw on. |
bool tcDspDisplay::setPixel | ( | int | anX, | |
int | anY, | |||
int | anColor, | |||
teScreenId | aeScreen = eeScreenDefault | |||
) |
This routine provides an alternate interface to the setPixel method.
[in] | anX | X-Coordinate of the pixel. |
[in] | anY | Y-Coordinate of the pixel. |
[in] | anColor | Color of the pixel. |
[in] | aeScreen | Screen to draw on. |
void tcDspDisplay::screenCopy | ( | teScreenId | aeDest, | |
teScreenId | aeSrc | |||
) |
This routine copies a source screen to a destination screen.
[in] | aeDest | Destination screen ID. |
[in] | aeSrc | Source screen ID. |
void tcDspDisplay::screenXOR | ( | teScreenId | aeDest, | |
teScreenId | aeSrc1, | |||
teScreenId | aeSrc2 | |||
) |
This routine XORs two source screens together and stores the results in a destination screen.
It is acceptable for one of the source screens to be the destination screen.
[in] | aeDest | Destination screen ID. |
[in] | aeSrc1 | First source screen ID. |
[in] | aeSrc2 | Second source screen ID. |
void tcDspDisplay::screenAND | ( | teScreenId | aeDest, | |
teScreenId | aeSrc1, | |||
teScreenId | aeSrc2 | |||
) |
This routine ANDs two source screens together and stores the results in a destination screen.
It is acceptable for one of the source screens to be the destination screen.
[in] | aeDest | Destination screen ID. |
[in] | aeSrc1 | First source screen ID. |
[in] | aeSrc2 | Second source screen ID. |
void tcDspDisplay::screenOR | ( | teScreenId | aeDest, | |
teScreenId | aeSrc1, | |||
teScreenId | aeSrc2 | |||
) |
This routine ORs two source screens together and stores the results in a destination screen.
It is acceptable for one of the source screens to be the destination screen.
[in] | aeDest | Destination screen ID. |
[in] | aeSrc1 | First source screen ID. |
[in] | aeSrc2 | Second source screen ID. |
const int MityDSP::tcDspDisplay::gnMAX_SCREENS = 8 [static] |
Maximum screen buffers allowed.
const int MityDSP::tcDspDisplay::gnMAX_DEPTH = 16 [static] |
Maximum pixel depth (bpp).
const int MityDSP::tcDspDisplay::gnDefaultColor = -1 [static] |
Indicates that the default color is to be used.