upm  0.1.8
Sensor/Actuator repository for libmraa (v0.4.5)
 All Data Structures Files Functions Variables Macros Pages
Public Member Functions | Data Fields
ST7735 Class Reference

C++ API for ST7735 SPI LCD module. More...

Detailed Description

This file defines the ST7735 C++ interface for libst7735

upm::ST7735 * lcd = new upm::ST7735(7, 4, 9, 8);
lcd->fillScreen (ST7735_RED);
lcd->refresh ();
lcd->fillScreen (ST7735_CYAN);
lcd->refresh ();
lcd->fillScreen (ST7735_BLACK);
lcd->refresh ();
lcd->drawLine(10, 10, 10, 100, ST7735_MAGENTA);
lcd->drawLine(20, 20, 10, 100, ST7735_YELLOW);
lcd->drawLine(30, 30, 50, 100, ST7735_WHITE);
lcd->refresh ();
lcd->drawPixel (20, 20, ST7735_GREEN);
lcd->refresh ();
lcd->drawTriangle (50, 50, 80, 80, 60, 90, ST7735_GREEN);
lcd->refresh ();
lcd->drawCircle (100, 110, 10, ST7735_BLUE);
lcd->refresh ();
lcd->setTextWrap(0x0);
lcd->setCursor(0, 30);
lcd->setTextColor(ST7735_RED, ST7735_RED);
lcd->setTextSize(1);
lcd->print("Hello World!");
lcd->setCursor(10, 50);
lcd->setTextColor(ST7735_RED, ST7735_YELLOW);
lcd->setTextSize(2);
lcd->print("BIG");
lcd->refresh ();
std::cout << "exiting application" << std::endl;
delete lcd;

Public Member Functions

 ST7735 (uint8_t csLCD, uint8_t cSD, uint8_t rs, uint8_t rst)
 
 ~ST7735 ()
 
std::string name ()
 
void initModule ()
 
void configModule ()
 
void write (uint8_t value)
 
void data (uint8_t value)
 
void executeCMDList (const uint8_t *addr)
 
void setAddrWindow (uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1)
 
void drawPixel (int16_t x, int16_t y, uint16_t color)
 
void refresh ()
 
mraa_result_t lcdCSOn ()
 
mraa_result_t lcdCSOff ()
 
mraa_result_t sdCSOn ()
 
mraa_result_t sdCSOff ()
 
mraa_result_t rsHIGH ()
 
mraa_result_t rsLOW ()
 
- Public Member Functions inherited from GFX
 GFX (int width, int height, uint8_t *screenBuffer, const unsigned char *font)
 
 ~GFX ()
 
void drawChar (int16_t x, int16_t y, uint8_t data, uint16_t color, uint16_t bg, uint8_t size)
 
void print (std::string msg)
 
mraa_result_t setPixel (int x, int y, uint16_t color)
 
void fillScreen (uint16_t color)
 
void fillRect (int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
 
void drawFastVLine (int16_t x, int16_t y, int16_t h, uint16_t color)
 
void drawLine (int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color)
 
void drawTriangle (int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)
 
void drawCircle (int16_t x, int16_t y, int16_t r, uint16_t color)
 
void setCursor (int16_t x, int16_t y)
 
void setTextColor (uint16_t textColor, uint16_t textBGColor)
 
void setTextSize (uint8_t size)
 
void setTextWrap (uint8_t wrap)
 

Data Fields

uint8_t m_map [160 *128 *2]
 
- Data Fields inherited from GFX
int m_height
 
int m_width
 
int m_textSize
 
int m_textColor
 
int m_textBGColor
 
int m_cursorX
 
int m_cursorY
 
int m_wrap
 
uint8_t * m_map
 

Additional Inherited Members

- Protected Attributes inherited from GFX
const int16_t WIDTH
 
const int16_t HEIGHT
 
const unsigned char * m_font
 

Constructor & Destructor Documentation

ST7735 ( uint8_t  csLCD,
uint8_t  cSD,
uint8_t  rs,
uint8_t  rst 
)

Instanciates a ST7735 object

Parameters
csLCDLCD chip select pin
cSDSD card chip select pin
rsdata/command pin
rstreset pin

Here is the call graph for this function:

~ST7735 ( )

ST7735 object destructor

Member Function Documentation

std::string name ( )
inline

Return name of the component

void initModule ( )

Initialize the modules GPIOs

Here is the call graph for this function:

Here is the caller graph for this function:

void configModule ( )

Configure the chip via SPI interface

Here is the call graph for this function:

Here is the caller graph for this function:

void write ( uint8_t  value)

Send command to SPI bus (rs must be LOW)

Parameters
valuecommand number

Here is the call graph for this function:

Here is the caller graph for this function:

void data ( uint8_t  value)

Send data to SPI bus (rs must be HIGH)

Parameters
valuecommand number

Here is the call graph for this function:

Here is the caller graph for this function:

void executeCMDList ( const uint8_t *  addr)

Execute set of commands and data

Parameters
addrpointer to start of the commands/data section

Here is the call graph for this function:

Here is the caller graph for this function:

void setAddrWindow ( uint8_t  x0,
uint8_t  y0,
uint8_t  x1,
uint8_t  y1 
)
virtual

Set the window size inside the screen where the pixels data will be written.

Parameters
x0first coordinate
y0first coordinate
x1second coordinate
y1second coordinate

Implements GFX.

Here is the call graph for this function:

Here is the caller graph for this function:

void drawPixel ( int16_t  x,
int16_t  y,
uint16_t  color 
)
virtual

Send pixel collor (RGB) to the chip.

Parameters
xaxis on horizontal scale
yaxis on vertical scale
colorrgb (16bit) color (R[0-4], G[5-10], B[11-15])

Implements GFX.

Here is the call graph for this function:

void refresh ( )
virtual

Copy the buffer to the chip via SPI interface.

Implements GFX.

Here is the call graph for this function:

Here is the caller graph for this function:

mraa_result_t lcdCSOn ( )

LCD chip select LOW.

Here is the caller graph for this function:

mraa_result_t lcdCSOff ( )

LCD chip select HIGH.

Here is the caller graph for this function:

mraa_result_t sdCSOn ( )

CD card chip select LOW.

mraa_result_t sdCSOff ( )

CD card select HIGH.

mraa_result_t rsHIGH ( )

Data select HIGH.

Here is the caller graph for this function:

mraa_result_t rsLOW ( )

Data select LOW.

Here is the caller graph for this function:

Field Documentation

uint8_t m_map[160 *128 *2]

Screens buffer

Inheritance diagram for ST7735:
Inheritance graph
[legend]
Collaboration diagram for ST7735:
Collaboration graph
[legend]

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