Chris Taylor / Mbed 2 deprecated RETRO-SpaceRaiders Featured

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

LCD_ST7735 Class Reference

LCD_ST7735 Class Reference

LCD_ST7735 is a simple driver for the ST7735 LCD controller. More...

#include <LCD_ST7735.h>

Public Types

enum  Orientation { Rotate0, Rotate90, Rotate180, Rotate270 }
 

Orientation of the display.

More...
enum  PanelColorFilter { RGB = 0, BGR = 8 }
 

Type of color filter of the panel.

More...

Public Member Functions

 LCD_ST7735 (PinName backlightPin, PinName resetPin, PinName dsPin, PinName mosiPin, PinName misoPin, PinName clkPin, PinName csPin, PanelColorFilter colorFilter=BGR)
 Creates an instance of the LCD_ST7735 driver.
void setOrientation (Orientation orientation, bool flip)
 Set the orientation of the display.
int getWidth ()
 Get the width of the display given the current orientation.
int getHeight ()
 Get the height of the display given the current orientation.
void setBacklight (bool state)
 Control the display's backlight.
void clearScreen (uint16_t color=0x0000)
 Clear the screen.
void setPixel (int x, int y, uint16_t color)
 Set a pixel on the display to the specified color.
void drawLine (int x1, int y1, int x2, int y2, uint16_t color)
 Draw a line on the display.
void drawRect (int x1, int y1, int x2, int y2, uint16_t color)
 Draw a rectangle on the display.
void drawCircle (int x, int y, int r, uint16_t color)
 Draw a circle on the display.
void drawEllipse (int x, int y, int rx, int ry, uint16_t color)
 Draw an ellipse on the display.
void fillRect (int x1, int y1, int x2, int y2, uint16_t fillColor)
 Draw a filled rectangle on the display.
void fillRect (int x1, int y1, int x2, int y2, uint16_t borderColor, uint16_t fillColor)
 Draw a filled rectangle on the display.
void fillCircle (int x, int y, int r, uint16_t borderColor, uint16_t fillColor)
 Draw a filled circle on the display.
void fillEllipse (int x, int y, int rx, int ry, uint16_t borderColor, uint16_t fillColor)
 Draw a filled ellipse on the display.
void drawBitmap (int x, int y, const uint16_t *pbmp)
 Draw a bitmap on the screen.
void drawBitmap (int x, int y, const uint16_t *pbmp, int srcX, int srcY, int srcWidth, int srcHeight)
 Extracts a portion of a bitmap and draws it on the screen.
void drawBitmap (int x, int y, Bitmap4bpp &bmp, int srcX, int srcY, int srcWidth, int srcHeight)
 Extracts a portion of a bitmap and draws it on the screen.
void drawBitmap (int x, int y, Bitmap1bpp &bmp, int srcX, int srcY, int srcWidth, int srcHeight, uint16_t foregroundColor, uint16_t backgroundColor)
 Extracts a portion of a bitmap and draws it on the screen.
void drawBitmap (int x, int y, const uint8_t *pbmp, int srcX, int srcY, int srcWidth, int srcHeight, uint16_t foregroundColor, uint16_t backgroundColor)
 Extracts a portion of a bitmap and draws it on the screen.
void setForegroundColor (uint16_t color)
 Set the foreground color used to render text.
void setBackgroundColor (uint16_t color)
 Set the background color used to render text.
void drawString (const uint8_t *pFont, int x, int y, const char *pString)
 Draw a string to the screen using the currently active foreground and background colors.
void selectDevice ()
 Select the device on the SPI bus.

Detailed Description

LCD_ST7735 is a simple driver for the ST7735 LCD controller.

It provides basic drawing primitives sa well as text and font capabilities. The driver is currently hardcoded to support 65K colors using a 565 RGB pixel format.

Definition at line 14 of file LCD_ST7735.h.


Member Enumeration Documentation

Orientation of the display.

Enumerator:
Rotate0 

No rotation of the display image.

Rotate90 

Rotate the display image 90 degrees.

Rotate180 

Rotate the display image 180 degrees.

Rotate270 

Rotate the display image 270 degrees.

Definition at line 18 of file LCD_ST7735.h.

Type of color filter of the panel.

Enumerator:
RGB 

RGB color filter panel.

BGR 

BGR color filter panel.

Definition at line 31 of file LCD_ST7735.h.


Constructor & Destructor Documentation

LCD_ST7735 ( PinName  backlightPin,
PinName  resetPin,
PinName  dsPin,
PinName  mosiPin,
PinName  misoPin,
PinName  clkPin,
PinName  csPin,
PanelColorFilter  colorFilter = BGR 
)

Creates an instance of the LCD_ST7735 driver.

Parameters:
backlightPinpin used to control the backlight
resetPinpin used to reset the display controller
dsPinpin used to put the display controller into data mode
mosiPinSPI channel MOSI pin
misoPinSPI channel MISO pin
clkPinSPI channel clock pin
csPinSPI chip select pin

Definition at line 22 of file LCD_ST7735.cpp.


Member Function Documentation

void clearScreen ( uint16_t  color = 0x0000 )

Clear the screen.

Parameters:
colorThe color used to clear the screen. Defaults to black if not passed.

Definition at line 101 of file LCD_ST7735.cpp.

void drawBitmap ( int  x,
int  y,
const uint16_t *  pbmp,
int  srcX,
int  srcY,
int  srcWidth,
int  srcHeight 
)

Extracts a portion of a bitmap and draws it on the screen.

Parameters:
xThe X coordinate location to draw the bitmap.
yThe Y coordinate location to draw the bitmap.
pbmpPointer to the bitmap.
srcXX offset into the source bitmap of the portion to extract
srcYY offset into the source bitmap of the portion to extract
srcWidthWidth of the bitmap portion to draw
srcHeightHeight of the bitmap portion to draw
Note:
The bitmap is an single dimensional uint8_t (unsigned short) array. The first to elements of the array indicate the width and height of the bitmap repectively. The rest of the entries int the array make up the pixel data for the array.

Definition at line 363 of file LCD_ST7735.cpp.

void drawBitmap ( int  x,
int  y,
Bitmap4bpp &  bmp,
int  srcX,
int  srcY,
int  srcWidth,
int  srcHeight 
)

Extracts a portion of a bitmap and draws it on the screen.

Parameters:
xThe X coordinate location to draw the bitmap.
yThe Y coordinate location to draw the bitmap.
bmprefence to a 4-bpp bitmap.
srcXX offset into the source bitmap of the portion to extract
srcYY offset into the source bitmap of the portion to extract
srcWidthWidth of the bitmap portion to draw
srcHeightHeight of the bitmap portion to draw

Definition at line 397 of file LCD_ST7735.cpp.

void drawBitmap ( int  x,
int  y,
Bitmap1bpp &  bmp,
int  srcX,
int  srcY,
int  srcWidth,
int  srcHeight,
uint16_t  foregroundColor,
uint16_t  backgroundColor 
)

Extracts a portion of a bitmap and draws it on the screen.

Parameters:
xThe X coordinate location to draw the bitmap.
yThe Y coordinate location to draw the bitmap.
bmprefence to a 1-bpp bitmap.
srcXX offset into the source bitmap of the portion to extract
srcYY offset into the source bitmap of the portion to extract
srcWidthWidth of the bitmap portion to draw
srcHeightHeight of the bitmap portion to draw
foregroundColorColor to use for pixels in the bitmap
backgroundColorColor to use for off pixels in the bitmap

Definition at line 441 of file LCD_ST7735.cpp.

void drawBitmap ( int  x,
int  y,
const uint8_t *  pbmp,
int  srcX,
int  srcY,
int  srcWidth,
int  srcHeight,
uint16_t  foregroundColor,
uint16_t  backgroundColor 
)

Extracts a portion of a bitmap and draws it on the screen.

Parameters:
xThe X coordinate location to draw the bitmap.
yThe Y coordinate location to draw the bitmap.
pbmpPointer to the bitmap.
srcXX offset into the source bitmap of the portion to extract
srcYY offset into the source bitmap of the portion to extract
srcWidthWidth of the bitmap portion to draw
srcHeightHeight of the bitmap portion to draw
foregroundColorColor to use for pixels in the bitmap
backgroundColorColor to use for off pixels in the bitmap
Note:
The bitmap is an single dimensional uint8_t (unsigned short) array. The first two uint16_t elements of the array indicate the width and height of the bitmap repectively. The rest of the entries int the array make up the pixel data for the array.

Definition at line 496 of file LCD_ST7735.cpp.

void drawBitmap ( int  x,
int  y,
const uint16_t *  pbmp 
)

Draw a bitmap on the screen.

Parameters:
xThe X coordinate location to draw the bitmap.
yThe Y coordinate location to draw the bitmap.
pbmpPointer to the bitmap.
Note:
The bitmap is an single dimensional uint8_t (unsigned short) array. The first to elements of the array indicate the width and height of the bitmap repectively. The rest of the entries int the array make up the pixel data for the array.

Definition at line 355 of file LCD_ST7735.cpp.

void drawCircle ( int  x,
int  y,
int  r,
uint16_t  color 
)

Draw a circle on the display.

Parameters:
xThe X coordinate of the center of the circle
yThe Y coordinate of the center of the circle
rThe radius of the circle
colorThe color used to draw the circle

Definition at line 178 of file LCD_ST7735.cpp.

void drawEllipse ( int  x,
int  y,
int  rx,
int  ry,
uint16_t  color 
)

Draw an ellipse on the display.

Parameters:
xThe X coordinate of the center of the ellipse
yThe Y coordinate of the center of the ellipse
rxThe X radius of the ellipse
ryThe X radius of the ellipse
colorThe color used to draw the ellipse

Definition at line 207 of file LCD_ST7735.cpp.

void drawLine ( int  x1,
int  y1,
int  x2,
int  y2,
uint16_t  color 
)

Draw a line on the display.

Parameters:
x1The X coordinate of the starting point on the line
y1The Y coordinate of the starting point on the line
x2The X coordinate of the end point on the line
y2The Y coordinate of the end point on the line
colorThe color used to draw the pixel

Definition at line 121 of file LCD_ST7735.cpp.

void drawRect ( int  x1,
int  y1,
int  x2,
int  y2,
uint16_t  color 
)

Draw a rectangle on the display.

Parameters:
x1The X coordinate of the upper left corner
y1The Y coordinate of the upper left corner
x2The X coordinate of the lower right corner
y2The Y coordinate of the lower right corner
colorThe color used to draw the rectangle

Definition at line 167 of file LCD_ST7735.cpp.

void drawString ( const uint8_t *  pFont,
int  x,
int  y,
const char *  pString 
)

Draw a string to the screen using the currently active foreground and background colors.

Parameters:
pFontPointer to the font used to render the string to the display
xThe X coordinate location to draw the string.
yThe Y coordinate location to draw the string.
pStringASCIIZ string to draw to the display.
Note:
The font is currently limited to an 8x8 font. See the font_IBM.h file for an example font.

Definition at line 567 of file LCD_ST7735.cpp.

void fillCircle ( int  x,
int  y,
int  r,
uint16_t  borderColor,
uint16_t  fillColor 
)

Draw a filled circle on the display.

Parameters:
xThe X coordinate of the center of the circle
yThe Y coordinate of the center of the circle
borderColorThe color used to draw the circumference of the circle
fillColorThe color used to fill the circle

Definition at line 275 of file LCD_ST7735.cpp.

void fillEllipse ( int  x,
int  y,
int  rx,
int  ry,
uint16_t  borderColor,
uint16_t  fillColor 
)

Draw a filled ellipse on the display.

Parameters:
xThe X coordinate of the center of the ellipse
yThe Y coordinate of the center of the ellipse
rxThe X radius of the ellipse
ryThe X radius of the ellipse
borderColorThe color used to draw the circumference of the circle
fillColorThe color used to fill the circle

Definition at line 311 of file LCD_ST7735.cpp.

void fillRect ( int  x1,
int  y1,
int  x2,
int  y2,
uint16_t  fillColor 
)

Draw a filled rectangle on the display.

Parameters:
x1The X coordinate of the upper left corner
y1The Y coordinate of the upper left corner
x2The X coordinate of the lower right corner
y2The Y coordinate of the lower right corner
fillColorThe color used to fill the rectangle

Definition at line 243 of file LCD_ST7735.cpp.

void fillRect ( int  x1,
int  y1,
int  x2,
int  y2,
uint16_t  borderColor,
uint16_t  fillColor 
)

Draw a filled rectangle on the display.

Parameters:
x1The X coordinate of the upper left corner
y1The Y coordinate of the upper left corner
x2The X coordinate of the lower right corner
y2The Y coordinate of the lower right corner
borderColorThe color used to draw the rectangle frame
fillColorThe color used to fill the rectangle

Definition at line 257 of file LCD_ST7735.cpp.

int getHeight (  )

Get the height of the display given the current orientation.

Definition at line 91 of file LCD_ST7735.cpp.

int getWidth (  )

Get the width of the display given the current orientation.

Definition at line 86 of file LCD_ST7735.cpp.

void selectDevice (  )

Select the device on the SPI bus.

selectDevice needs to be called before accessing the screen if there are multiple devices on the SPI bus.

Definition at line 577 of file LCD_ST7735.cpp.

void setBackgroundColor ( uint16_t  color )

Set the background color used to render text.

Parameters:
colorColor used when drawing background portions of the text
Note:
The color can be changed multiple times to render text with various background colors on the display

Definition at line 561 of file LCD_ST7735.cpp.

void setBacklight ( bool  state )

Control the display's backlight.

Parameters:
statetrue to turn the backlight on, false to turn it off

Definition at line 96 of file LCD_ST7735.cpp.

void setForegroundColor ( uint16_t  color )

Set the foreground color used to render text.

Parameters:
colorColor used when drawing text to the display
Note:
The color can be changed multiple times to render text in various colors on the display

Definition at line 555 of file LCD_ST7735.cpp.

void setOrientation ( Orientation  orientation,
bool  flip 
)

Set the orientation of the display.

Parameters:
orientationOrientation of the display.
flipFlips the display direction

Definition at line 50 of file LCD_ST7735.cpp.

void setPixel ( int  x,
int  y,
uint16_t  color 
)

Set a pixel on the display to the specified color.

Parameters:
xThe X coordinate of the pixel (0..127)
yThe Y coordinate of the pixel (0..159)
colorColor to set the pixel to.

Definition at line 114 of file LCD_ST7735.cpp.