TFTLCD with FastIO
Fork of TFTLCD by
SSD1289_LCD Class Reference
Represents a LCD instance. More...
#include <ssd1289.h>
Inherits LCD.
Public Member Functions | |
SSD1289_LCD (PinName CS, PinName RESET, PinName RS, PinName WR, BusOut *DATA_PORT, PinName BL=NC, PinName RD=NC, backlight_t blType=Constant, float defaultBackLightLevel=1.0) | |
Creates a new instance of the class. | |
virtual void | Initialize (orientation_t orientation=LANDSCAPE, colordepth_t colors=RGB16) |
Initialize display. | |
virtual void | Sleep (void) |
Puts the display to sleep. | |
virtual void | WakeUp (void) |
Wakes up the display from sleep mode. | |
virtual void | SetForeground (unsigned int color=COLOR_WHITE) |
Set the foreground color for painting. | |
virtual void | SetBackground (unsigned int color=COLOR_BLACK) |
Set the background color for painting. | |
virtual void | SetFont (const font_t *font) |
Sets the font to be used for painting of text on the screen. | |
unsigned short | GetWidth (void) |
Gets the display width. | |
unsigned short | GetHeight (void) |
Gets the display height. | |
uint8_t | GetFontWidth (void) |
Gets the font width. | |
uint8_t | GetFontHeight (void) |
Gets the font height. | |
virtual void | FillScreen (int color=-1) |
Fills the whole screen with a single color. | |
virtual void | SetBacklightLevel (float level) |
Sets the backlight intensity in percent as a float value in the range [0.0,1.0]. | |
virtual void | ClearScreen (void) |
Clears the screen. | |
virtual void | DrawPixel (unsigned short x, unsigned short y, int color=-2) |
Draws a pixel at the specified location. | |
virtual void | DrawLine (unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, int color=-2) |
Draws a line. | |
virtual void | DrawRect (unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, int color=-2) |
Paints a rectangle. | |
virtual void | DrawRoundRect (unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, int color=-2) |
Paints a rectangle and fills it with the paint color. | |
virtual void | FillRect (unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, int color=-2) |
Paints a rectangle with rounded corners. | |
virtual void | FillRoundRect (unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, int color=-2) |
Paints a rectangle with rounded corners and fills it with the paint color. | |
virtual void | DrawCircle (unsigned short x, unsigned short y, unsigned short radius, int color=-2) |
Paints a circle. | |
virtual void | FillCircle (unsigned short x, unsigned short y, unsigned short radius, int color=-2) |
Paints a circle and fills it with the paint color. | |
virtual void | Print (const char *str, unsigned short x, unsigned short y, int fgColor=-2, int bgColor=-1, unsigned short deg=0) |
Print a text on the screen. | |
virtual void | DrawBitmap (unsigned short x, unsigned short y, const bitmap_t *img, unsigned char scale=1) |
Draw an image on the screen. | |
virtual void | DrawBitmap (unsigned short x, unsigned short y, const bitmap_t *img, unsigned short deg, unsigned short rox, unsigned short roy) |
Draw an image on the screen. | |
Protected Member Functions | |
virtual void | WriteCmd (unsigned short cmd) |
Sends a command to the display. | |
virtual void | WriteData (unsigned short data) |
Sends pixel data to the display. | |
virtual void | SetXY (unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2) |
Assigns a chunk of the display memory to receive data. | |
virtual void | SetPixelColor (unsigned int color, colordepth_t mode=RGB24) |
Sets the color of the pixel at the address pointer of the controller. | |
virtual void | Activate (void) |
Activates the display for command/data transfer. | |
virtual void | Deactivate (void) |
Deactivates the display after data has been transmitted. | |
virtual void | WriteCmdData (unsigned short cmd, unsigned short data) |
Sends both command and data to the display controller. | |
virtual void | ClearXY (void) |
Resets the memory address for the next display write operation to the screen origins (0,0). | |
virtual void | DrawHLine (unsigned short x, unsigned short y, unsigned short len, int color=-2) |
Draws a horizontal line. | |
virtual void | DrawVLine (unsigned short x, unsigned short y, unsigned short len, int color=-2) |
Draws a vertical line. | |
virtual void | PrintChar (char c, unsigned short x, unsigned short y, int fgColor=-2, int bgColor=-1) |
Prints a character at the given position and using the given color. | |
virtual void | RotateChar (char c, unsigned short x, unsigned short y, int pos, int fgColor=-2, int bgColor=-1, unsigned short deg=0) |
Prints a character at the given position and using the given color and with the given rotation. |
Detailed Description
Represents a LCD instance.
This is the utility class, through which the display can be manipulated and graphics objects can be shown to the user. A known display, which works with this library is the ITDB02-3.2S from iTeadStudio - a RGB TFT with 240x320 pixels resolution and 65K colors, using 16-bit interface.
The display needs 20 to 22 pins to work with mbed, so it is possibly not the best of choices out there, but other than that it uses +3.3V for power and logic, as well as the backlight, thus can be interfaced directly to the mbed without the need of shields or level shifters as with Arduino.
How to use:
// include the library, this will also pull in the header for the provided fonts #include "ssd1289.h" // prepare the data bus for writing commands and pixel data BusOut dataBus( p30, p29, p28, p27, p26, p25, p24, p23, p22, p21, p20, p19, p18, p17, p16, p15 ); // 16 pins // create the lcd instance SSD1289_LCD lcd( p14, p13, p12, p11, &dataBus ); // control pins and data bus int main() { // initialize display - place it in standard portrait mode and set background to black and // foreground to white color. lcd.Initialize(); // set current font to the smallest 8x12 pixels font. lcd.SetFont( Font8x12 ); // print something on the screen lcd.Print( "Hello, World!", CENTER, 25 ); // align text to center horizontally and use starndard colors while ( 1 ) { } }
- Version:
- 0.1
Definition at line 80 of file ssd1289.h.
Constructor & Destructor Documentation
SSD1289_LCD | ( | PinName | CS, |
PinName | RESET, | ||
PinName | RS, | ||
PinName | WR, | ||
BusOut * | DATA_PORT, | ||
PinName | BL = NC , |
||
PinName | RD = NC , |
||
backlight_t | blType = Constant , |
||
float | defaultBackLightLevel = 1.0 |
||
) |
Creates a new instance of the class.
- Parameters:
-
CS Pin for the ChipSelect signal. RESET Pin for the RESET line. RS Pin for the RS signal. WR Pin for the WR signal. DATA_PORT Address of the data bus for transfer of commands and pixel data. BL Pin for controlling the backlight. By default not used. RD Pin for the RD signal. This line is not needed by the driver, so if you would like to use the pin on the mbed for something else, just pull-up the respective pin on the LCD high, and do not assign a value to this parameter when creating the controller instance. blType The backlight type, the default is to utilize the pin - if supplied - as a simple on/off switch defaultBacklightLevel If using PWM to control backlight, this would be the default brightness in percent after LCD initialization.
Definition at line 25 of file ssd1289.cpp.
Member Function Documentation
void Activate | ( | void | ) | [protected, virtual, inherited] |
Activates the display for command/data transfer.
Usually achieved by pulling the CS pin of the display low.
Definition at line 507 of file lcd_base.cpp.
void ClearScreen | ( | void | ) | [virtual, inherited] |
Clears the screen.
This is the same as calling FillScreen() or FillScreen( -1 ) to use the background color.
Definition at line 151 of file lcd_base.cpp.
void ClearXY | ( | void | ) | [protected, virtual, inherited] |
Resets the memory address for the next display write operation to the screen origins (0,0).
Definition at line 526 of file lcd_base.cpp.
void Deactivate | ( | void | ) | [protected, virtual, inherited] |
Deactivates the display after data has been transmitted.
Usually achieved by pulling the CS pin of the display high.
Definition at line 513 of file lcd_base.cpp.
void DrawBitmap | ( | unsigned short | x, |
unsigned short | y, | ||
const bitmap_t * | img, | ||
unsigned short | deg, | ||
unsigned short | rox, | ||
unsigned short | roy | ||
) | [virtual, inherited] |
Draw an image on the screen.
The pixels of the picture must be in the RGB-565 format. The data can be provided as an array in a source or a header file. To convert an image file to the appropriate format, a special utility must be utilized. One such tool is provided by Henning Karlsen, the author of the UTFT display liberary and can be downloaded for free from his web site: http://henningkarlsen.com/electronics/library.php?id=52
- Parameters:
-
x Horizontal offset of the first pixel of the image. y Vertical offset of the first pixel of the image. img Image data pointer. deg Angle to rotate the image before painting on screen, in degrees. rox roy
Definition at line 462 of file lcd_base.cpp.
void DrawBitmap | ( | unsigned short | x, |
unsigned short | y, | ||
const bitmap_t * | img, | ||
unsigned char | scale = 1 |
||
) | [virtual, inherited] |
Draw an image on the screen.
The pixels of the picture must be in the RGB-565 format. The data can be provided as an array in a source or a header file. To convert an image file to the appropriate format, a special utility must be utilized. One such tool is provided by Henning Karlsen, the author of the UTFT display liberary and can be downloaded for free from his web site: http://henningkarlsen.com/electronics/library.php?id=52
- Parameters:
-
x Horizontal offset of the first pixel of the image. y Vertical offset of the first pixel of the image. img Image data pointer. scale A value of 1 will produce an image with its original size, while a different value will scale the image.
Definition at line 400 of file lcd_base.cpp.
void DrawCircle | ( | unsigned short | x, |
unsigned short | y, | ||
unsigned short | radius, | ||
int | color = -2 |
||
) | [virtual, inherited] |
Paints a circle.
- Parameters:
-
x The offset of the circle's center from the left edge of the screen. y The offset of the circle's center from the top edge of the screen. radius The circle's radius. color The color to use for painting. -1 indicated background, -2 foreground, or custom color.
Definition at line 318 of file lcd_base.cpp.
void DrawHLine | ( | unsigned short | x, |
unsigned short | y, | ||
unsigned short | len, | ||
int | color = -2 |
||
) | [protected, virtual, inherited] |
Draws a horizontal line.
This is a utility function to draw horizontal-only lines for reduced code complexity and faster execution.
- Parameters:
-
x X coordinate of the starting point of the line. y Y coordinate of the starting point of the line. len Length of the line. color The color to use to draw the line. By default the global foreground color is used ( -2 ), -1 switches to the default background color, or any custom color can be used.
Definition at line 531 of file lcd_base.cpp.
void DrawLine | ( | unsigned short | x1, |
unsigned short | y1, | ||
unsigned short | x2, | ||
unsigned short | y2, | ||
int | color = -2 |
||
) | [virtual, inherited] |
Draws a line.
- Parameters:
-
x1 Horizontal offset of the beginning point of the line. y1 Vertical offset of the beginning point of the line. x2 Horizontal offset of the end point of the line. y2 Verical offset of the end point of the line. color The color to use for painting, or -1 for background, or -2 for foreground.
Definition at line 165 of file lcd_base.cpp.
void DrawPixel | ( | unsigned short | x, |
unsigned short | y, | ||
int | color = -2 |
||
) | [virtual, inherited] |
Draws a pixel at the specified location.
By default the function will use the preset foreground color, but the background or a custom color could be used as well.
- Parameters:
-
x The horizontal offset of the pixel from the upper left corner of the screen. y The vertical offset of the pixel from the upper left corner of the screen. color The color to be used. Use a custom color, or -1 for background and -2 for foreground color.
Definition at line 156 of file lcd_base.cpp.
void DrawRect | ( | unsigned short | x1, |
unsigned short | y1, | ||
unsigned short | x2, | ||
unsigned short | y2, | ||
int | color = -2 |
||
) | [virtual, inherited] |
Paints a rectangle.
- Parameters:
-
x1 The horizontal offset of the beginning point of one of the rectangle's diagonals. y1 The vertical offset of the beginning point of one of the rectangle's diagonals. x2 The horizontal offset of the end point of the same of the rectangle's diagonals. y2 The vertical offset of the end point of the same of the rectangle's diagonals. color The color to use for painting. -1 indicated background, -2 foreground, or custom color.
Definition at line 247 of file lcd_base.cpp.
void DrawRoundRect | ( | unsigned short | x1, |
unsigned short | y1, | ||
unsigned short | x2, | ||
unsigned short | y2, | ||
int | color = -2 |
||
) | [virtual, inherited] |
Paints a rectangle and fills it with the paint color.
- Parameters:
-
x1 The horizontal offset of the beginning point of one of the rectangle's diagonals. y1 The vertical offset of the beginning point of one of the rectangle's diagonals. x2 The horizontal offset of the end point of the same of the rectangle's diagonals. y2 The vertical offset of the end point of the same of the rectangle's diagonals. color The color to use for painting. -1 indicated background, -2 foreground, or custom color.
Definition at line 258 of file lcd_base.cpp.
void DrawVLine | ( | unsigned short | x, |
unsigned short | y, | ||
unsigned short | len, | ||
int | color = -2 |
||
) | [protected, virtual, inherited] |
Draws a vertical line.
This is a utility function to draw vertical-only lines for reduced code complexity and faster execution.
- Parameters:
-
x X coordinate of the starting point of the line. y Y coordinate of the starting point of the line. len Height of the line. color The color to use to draw the line. By default the global foreground color is used ( -2 ), -1 switches to the default background color, or any custom color can be used.
Definition at line 542 of file lcd_base.cpp.
void FillCircle | ( | unsigned short | x, |
unsigned short | y, | ||
unsigned short | radius, | ||
int | color = -2 |
||
) | [virtual, inherited] |
Paints a circle and fills it with the paint color.
- Parameters:
-
x The offset of the circle's center from the left edge of the screen. y The offset of the circle's center from the top edge of the screen. radius The circle's radius. color The color to use for painting. -1 indicated background, -2 foreground, or custom color.
Definition at line 368 of file lcd_base.cpp.
void FillRect | ( | unsigned short | x1, |
unsigned short | y1, | ||
unsigned short | x2, | ||
unsigned short | y2, | ||
int | color = -2 |
||
) | [virtual, inherited] |
Paints a rectangle with rounded corners.
- Parameters:
-
x1 The horizontal offset of the beginning point of one of the rectangle's diagonals. y1 The vertical offset of the beginning point of one of the rectangle's diagonals. x2 The horizontal offset of the end point of the same of the rectangle's diagonals. y2 The vertical offset of the end point of the same of the rectangle's diagonals. color The color to use for painting. -1 indicated background, -2 foreground, or custom color.
Definition at line 276 of file lcd_base.cpp.
void FillRoundRect | ( | unsigned short | x1, |
unsigned short | y1, | ||
unsigned short | x2, | ||
unsigned short | y2, | ||
int | color = -2 |
||
) | [virtual, inherited] |
Paints a rectangle with rounded corners and fills it with the paint color.
- Parameters:
-
x1 The horizontal offset of the beginning point of one of the rectangle's diagonals. y1 The vertical offset of the beginning point of one of the rectangle's diagonals. x2 The horizontal offset of the end point of the same of the rectangle's diagonals. y2 The vertical offset of the end point of the same of the rectangle's diagonals. color The color to use for painting. -1 indicated background, -2 foreground, or custom color.
Definition at line 288 of file lcd_base.cpp.
void FillScreen | ( | int | color = -1 ) |
[virtual, inherited] |
Fills the whole screen with a single color.
- Parameters:
-
color The color to be used. The value must be in RGB-565 format.
- Remarks:
- The special values -1 and -2 signify the preset background and foreground colors, respectively. The backround color is the default.
Definition at line 140 of file lcd_base.cpp.
uint8_t GetFontHeight | ( | void | ) | [inherited] |
uint8_t GetFontWidth | ( | void | ) | [inherited] |
unsigned short GetHeight | ( | void | ) | [inherited] |
Gets the display height.
- Returns:
- Display height in pixels.
Definition at line 100 of file lcd_base.cpp.
unsigned short GetWidth | ( | void | ) | [inherited] |
Gets the display width.
- Returns:
- Display width in pixels.
Definition at line 93 of file lcd_base.cpp.
void Initialize | ( | orientation_t | orientation = LANDSCAPE , |
colordepth_t | colors = RGB16 |
||
) | [virtual] |
Initialize display.
Wakes up the display from sleep, initializes power parameters. This function must be called first, befor any painting on the display is done, otherwise the positioning of graphical elements will not work properly and any paynt operation will not be visible or produce garbage.
- Parameters:
-
oritentation The display orientation, landscape is default. colors The correct color depth to use for the pixel data. Value is disregarded.
Implements LCD.
Definition at line 33 of file ssd1289.cpp.
void Print | ( | const char * | str, |
unsigned short | x, | ||
unsigned short | y, | ||
int | fgColor = -2 , |
||
int | bgColor = -1 , |
||
unsigned short | deg = 0 |
||
) | [virtual, inherited] |
Print a text on the screen.
- Parameters:
-
str The text. x The horizontal offset form the left edge of the screen. The special values LEFT, CENTER, or RIGHT can be used instead of pixel offset to indicate the text's horizontal alignment. y The vertical offset of the text from the top of the screen. fgColor The foreground to use for painting the text; -1 indicates background color, -2 the foreground setting, or custom color. bgColor The color to use for painting the empty pixels; -1 indicates the background color, -2 the foreground setting, or custom color. deg If different than 0, the text will be rotated at an angle this many degrees around its starting point. Default is not to ratate.
Definition at line 382 of file lcd_base.cpp.
void PrintChar | ( | char | c, |
unsigned short | x, | ||
unsigned short | y, | ||
int | fgColor = -2 , |
||
int | bgColor = -1 |
||
) | [protected, virtual, inherited] |
Prints a character at the given position and using the given color.
- Parameters:
-
c The character. x X coordinate of the character position. y Y coordinate of the character position. fgColor Foreground color for drawing. By default the global foreground color is used ( -2 ), -1 switches to the default background color, or any custom color can be used. bgColor Background color for drawing. By default the global background color is used ( -1 ), -2 switches to the default foreground color, or any custom color can be used.
Definition at line 553 of file lcd_base.cpp.
void RotateChar | ( | char | c, |
unsigned short | x, | ||
unsigned short | y, | ||
int | pos, | ||
int | fgColor = -2 , |
||
int | bgColor = -1 , |
||
unsigned short | deg = 0 |
||
) | [protected, virtual, inherited] |
Prints a character at the given position and using the given color and with the given rotation.
- Parameters:
-
c The character. x X coordinate of the character position. y Y coordinate of the character position. pos Position of the character in the string from which it originates (used to rotate a whole string). fgColor Foreground color for drawing. By default the global foreground color is used ( -2 ), -1 switches to the default background color, or any custom color can be used. bgColor Background color for drawing. By default the global background color is used ( -1 ), -2 switches to the default foreground color, or any custom color can be used. deg The angle at which to rotate.
Definition at line 581 of file lcd_base.cpp.
void SetBackground | ( | unsigned int | color = COLOR_BLACK ) |
[virtual, inherited] |
Set the background color for painting.
This is the default color to be used for "empty" pixels while painting. If a particular function allows for a different value to be specified when the function is called, the new value will be used only for this single call and will not change this setting.
- Parameters:
-
color The background color (24-bit color depth).
- See also:
- RGB(r,g,b)
Definition at line 82 of file lcd_base.cpp.
void SetBacklightLevel | ( | float | level ) | [virtual, inherited] |
Sets the backlight intensity in percent as a float value in the range [0.0,1.0].
- Parameters:
-
level The backligh intensity in percent, where 0.0 is off and 1.0 is full brightness.
Definition at line 120 of file lcd_base.cpp.
void SetFont | ( | const font_t * | font ) | [virtual, inherited] |
Sets the font to be used for painting of text on the screen.
- Parameters:
-
font A pointer to the font data.
- See also:
- Comments in file fonts.h
Definition at line 87 of file lcd_base.cpp.
void SetForeground | ( | unsigned int | color = COLOR_WHITE ) |
[virtual, inherited] |
Set the foreground color for painting.
This is the default foreground color to be used in painting operations. If a specific output function allows for a different color to be specified in place, the new setting will be used for that single operation only and will not change this value.
- Parameters:
-
color The color to be used (24-bit color depth).
- See also:
- RGB(r,g,b)
Definition at line 76 of file lcd_base.cpp.
void SetPixelColor | ( | unsigned int | color, |
colordepth_t | mode = RGB24 |
||
) | [protected, virtual] |
Sets the color of the pixel at the address pointer of the controller.
This function is to be provided by each implementation separately in order to account for different color depth used by the controller.
- Parameters:
-
color The color of the pixel. mode The depth (palette) of the color.
Implements LCD.
Definition at line 244 of file ssd1289.cpp.
void SetXY | ( | unsigned short | x1, |
unsigned short | y1, | ||
unsigned short | x2, | ||
unsigned short | y2 | ||
) | [protected, virtual] |
Assigns a chunk of the display memory to receive data.
When data is sent to the display after this function completes, the opertion will start from the begining of the assigned address (pixel position) and the pointer will be automatically incremented so that the next data write operation will continue with the next pixel from the memory block. If more data is written than available pixels, at the end of the block the pointer will jump back to its beginning and commence again, until the next address change command is sent to the display.
- Parameters:
-
x1 The X coordinate of the pixel at the beginning of the block. y1 The Y coordinate of the pixel at the beginning of the block. x2 The X coordinate of the pixel at the end of the block. y2 The Y coordinate of the pixel at the end of the block.
- Remarks:
- Addressing commands are controller-specific and this function needs to be implemented separately for each available controller.
Implements LCD.
Definition at line 223 of file ssd1289.cpp.
void Sleep | ( | void | ) | [virtual] |
Puts the display to sleep.
When the display is in sleep mode, its power consumption is minimized. Before new pixel data can be written to the display memory, the controller needs to be brought out of sleep mode.
- See also:
- WakeUp( void );
- Remarks:
- The result of this operation might not be exactly as expected. Putting the display to sleep will cause the controller to switch to the standard color of the LCD, so depending on whether the display is normally white, or normally dark, the screen might or might not go dark. Additional power saving can be achieved, if the backlight of the used display is not hardwired on the PCB and can be controlled via the BL pin.
Reimplemented from LCD.
Definition at line 197 of file ssd1289.cpp.
void WakeUp | ( | void | ) | [virtual] |
Wakes up the display from sleep mode.
This function needs to be called before any other, when the display has been put into sleep mode by a previois call to Sleep( void ).
Reimplemented from LCD.
Definition at line 203 of file ssd1289.cpp.
void WriteCmd | ( | unsigned short | cmd ) | [protected, virtual] |
Sends a command to the display.
- Parameters:
-
cmd The display command.
- Remarks:
- Commands are controller-specific and this function needs to be implemented separately for each available controller.
Implements LCD.
Definition at line 209 of file ssd1289.cpp.
void WriteCmdData | ( | unsigned short | cmd, |
unsigned short | data | ||
) | [protected, virtual, inherited] |
Sends both command and data to the display controller.
This is a helper utility function which combines the 2 functions above into one single convenience step.
- Parameters:
-
cmd The display command. data The display pixel data.
Definition at line 519 of file lcd_base.cpp.
void WriteData | ( | unsigned short | data ) | [protected, virtual] |
Sends pixel data to the display.
- Parameters:
-
data The display data.
- Remarks:
- Sending data is controller-specific and this function needs to be implemented separately for each available controller.
Implements LCD.
Definition at line 216 of file ssd1289.cpp.
Generated on Tue Jul 12 2022 18:24:01 by 1.7.2