Adafruit RA8875 Arduino Library
Public Member Functions | List of all members
Adafruit_RA8875 Class Reference

Class that stores state and functions for interacting with the RA8875 display controller. More...

#include <Adafruit_RA8875.h>

Inheritance diagram for Adafruit_RA8875:

Public Member Functions

 Adafruit_RA8875 (uint8_t cs, uint8_t rst)
 
boolean begin (enum RA8875sizes s)
 
void softReset (void)
 
void displayOn (boolean on)
 
void sleep (boolean sleep)
 
void textMode (void)
 
void textSetCursor (uint16_t x, uint16_t y)
 
void textColor (uint16_t foreColor, uint16_t bgColor)
 
void textTransparent (uint16_t foreColor)
 
void textEnlarge (uint8_t scale)
 
void textWrite (const char *buffer, uint16_t len=0)
 
void cursorBlink (uint8_t rate)
 
void graphicsMode (void)
 
void setXY (uint16_t x, uint16_t y)
 
void pushPixels (uint32_t num, uint16_t p)
 
void fillRect (void)
 
void drawPixel (int16_t x, int16_t y, uint16_t color)
 
void drawPixels (uint16_t *p, uint32_t count, int16_t x, int16_t y)
 
void drawFastVLine (int16_t x, int16_t y, int16_t h, uint16_t color)
 
void drawFastHLine (int16_t x, int16_t y, int16_t w, uint16_t color)
 
void fillScreen (uint16_t color)
 
void drawLine (int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color)
 
void drawRect (int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
 
void fillRect (int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
 
void drawCircle (int16_t x, int16_t y, int16_t r, uint16_t color)
 
void fillCircle (int16_t x, int16_t y, int16_t r, 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 fillTriangle (int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)
 
void drawEllipse (int16_t xCenter, int16_t yCenter, int16_t longAxis, int16_t shortAxis, uint16_t color)
 
void fillEllipse (int16_t xCenter, int16_t yCenter, int16_t longAxis, int16_t shortAxis, uint16_t color)
 
void drawCurve (int16_t xCenter, int16_t yCenter, int16_t longAxis, int16_t shortAxis, uint8_t curvePart, uint16_t color)
 
void fillCurve (int16_t xCenter, int16_t yCenter, int16_t longAxis, int16_t shortAxis, uint8_t curvePart, uint16_t color)
 
void drawRoundRect (int16_t x, int16_t y, int16_t w, int16_t h, int16_t r, uint16_t color)
 
void fillRoundRect (int16_t x, int16_t y, int16_t w, int16_t h, int16_t r, uint16_t color)
 
void setScrollWindow (int16_t x, int16_t y, int16_t w, int16_t h, uint8_t mode)
 
void scrollX (int16_t dist)
 
void scrollY (int16_t dist)
 
void GPIOX (boolean on)
 
void PWM1config (boolean on, uint8_t clock)
 
void PWM2config (boolean on, uint8_t clock)
 
void PWM1out (uint8_t p)
 
void PWM2out (uint8_t p)
 
void touchEnable (boolean on)
 
boolean touched (void)
 
boolean touchRead (uint16_t *x, uint16_t *y)
 
uint32_t eepromReadS32 (int location)
 
void eepromWriteS32 (int location, int32_t value)
 
bool readCalibration (int location, tsMatrix_t *matrixPtr)
 
void writeCalibration (int location, tsMatrix_t *matrixPtr)
 
void writeReg (uint8_t reg, uint8_t val)
 
uint8_t readReg (uint8_t reg)
 
void writeData (uint8_t d)
 
uint8_t readData (void)
 
void writeCommand (uint8_t d)
 
uint8_t readStatus (void)
 
boolean waitPoll (uint8_t r, uint8_t f)
 
uint16_t width (void)
 
uint16_t height (void)
 
void setRotation (int8_t rotation)
 
int8_t getRotation (void)
 
virtual size_t write (uint8_t b)
 
virtual size_t write (const uint8_t *buffer, size_t size)
 

Detailed Description

Class that stores state and functions for interacting with the RA8875 display controller.

Constructor & Destructor Documentation

◆ Adafruit_RA8875()

Adafruit_RA8875::Adafruit_RA8875 ( uint8_t  CS,
uint8_t  RST 
)

Constructor for a new RA8875 instance

Parameters
CSLocation of the SPI chip select pin
RSTLocation of the reset pin

Member Function Documentation

◆ begin()

boolean Adafruit_RA8875::begin ( enum RA8875sizes  s)

Initialises the LCD driver and any HW required by the display

Parameters
sThe display size, which can be either: 'RA8875_480x80' (3.8" displays) or 'RA8875_480x128' (3.9" displays) or 'RA8875_480x272' (4.3" displays) or 'RA8875_800x480' (5" and 7" displays)
Returns
True if we reached the end

◆ softReset()

void Adafruit_RA8875::softReset ( void  )

Performs a SW-based reset of the RA8875

◆ displayOn()

void Adafruit_RA8875::displayOn ( boolean  on)

Turns the display on or off

Parameters
onWhether to turn the display on or not

◆ sleep()

void Adafruit_RA8875::sleep ( boolean  sleep)

Puts the display in sleep mode, or disables sleep mode if enabled

Parameters
sleepWhether to sleep or not

◆ textMode()

void Adafruit_RA8875::textMode ( void  )

Sets the display in text mode (as opposed to graphics mode)

◆ textSetCursor()

void Adafruit_RA8875::textSetCursor ( uint16_t  x,
uint16_t  y 
)

Sets the display in text mode (as opposed to graphics mode)

Parameters
xThe x position of the cursor (in pixels, 0..1023)
yThe y position of the cursor (in pixels, 0..511)

◆ textColor()

void Adafruit_RA8875::textColor ( uint16_t  foreColor,
uint16_t  bgColor 
)

Sets the fore and background color when rendering text

Parameters
foreColorThe RGB565 color to use when rendering the text
bgColorThe RGB565 colot to use for the background

◆ textTransparent()

void Adafruit_RA8875::textTransparent ( uint16_t  foreColor)

Sets the fore color when rendering text with a transparent bg

Parameters
foreColorThe RGB565 color to use when rendering the text

◆ textEnlarge()

void Adafruit_RA8875::textEnlarge ( uint8_t  scale)

Sets the text enlarge settings, using one of the following values:

0 = 1x zoom 1 = 2x zoom 2 = 3x zoom 3 = 4x zoom

Parameters
scaleThe zoom factor (0..3 for 1-4x zoom)

◆ textWrite()

void Adafruit_RA8875::textWrite ( const char *  buffer,
uint16_t  len = 0 
)

Renders some text on the screen when in text mode

Parameters
bufferThe buffer containing the characters to render
lenThe size of the buffer in bytes

◆ cursorBlink()

void Adafruit_RA8875::cursorBlink ( uint8_t  rate)

Enable Cursor Visibility and Blink Here we set bits 6 and 5 in 40h As well as the set the blink rate in 44h The rate is 0 through max 255 the lower the number the faster it blinks (00h is 1 frame time, FFh is 256 Frames time. Blink Time (sec) = BTCR[44h]x(1/Frame_rate)

Parameters
rateThe frame rate to blink

◆ graphicsMode()

void Adafruit_RA8875::graphicsMode ( void  )

Sets the display in graphics mode (as opposed to text mode)

◆ setXY()

void Adafruit_RA8875::setXY ( uint16_t  x,
uint16_t  y 
)

Sets the current X/Y position on the display before drawing

Parameters
xThe 0-based x location
yThe 0-base y location

◆ pushPixels()

void Adafruit_RA8875::pushPixels ( uint32_t  num,
uint16_t  p 
)

HW accelerated function to push a chunk of raw pixel data

Parameters
numThe number of pixels to push
pThe pixel color to use

◆ fillRect() [1/2]

void Adafruit_RA8875::fillRect ( void  )

Fill the screen with the current color

◆ drawPixel()

void Adafruit_RA8875::drawPixel ( int16_t  x,
int16_t  y,
uint16_t  color 
)

Draws a single pixel at the specified location

Parameters
xThe 0-based x location
yThe 0-base y location
colorThe RGB565 color to use when drawing the pixel

◆ drawPixels()

void Adafruit_RA8875::drawPixels ( uint16_t *  p,
uint32_t  num,
int16_t  x,
int16_t  y 
)

Draws a series of pixels at the specified location without the overhead

Parameters
pAn array of RGB565 color pixels
numThe number of the pixels to draw
xThe 0-based x location
yThe 0-base y location

◆ drawFastVLine()

void Adafruit_RA8875::drawFastVLine ( int16_t  x,
int16_t  y,
int16_t  h,
uint16_t  color 
)

Draw a vertical line

Parameters
xThe X position
yThe Y position
hHeight
colorThe color

◆ drawFastHLine()

void Adafruit_RA8875::drawFastHLine ( int16_t  x,
int16_t  y,
int16_t  w,
uint16_t  color 
)

Draw a horizontal line

Parameters
xThe X position
yThe Y position
wWidth
colorThe color

◆ fillScreen()

void Adafruit_RA8875::fillScreen ( uint16_t  color)

Fills the screen with the spefied RGB565 color

Parameters
colorThe RGB565 color to use when drawing the pixel

◆ drawLine()

void Adafruit_RA8875::drawLine ( int16_t  x0,
int16_t  y0,
int16_t  x1,
int16_t  y1,
uint16_t  color 
)

Draws a HW accelerated line on the display

Parameters
x0The 0-based starting x location
y0The 0-base starting y location
x1The 0-based ending x location
y1The 0-base ending y location
colorThe RGB565 color to use when drawing the pixel

◆ drawRect()

void Adafruit_RA8875::drawRect ( int16_t  x,
int16_t  y,
int16_t  w,
int16_t  h,
uint16_t  color 
)

Draws a HW accelerated rectangle on the display

Parameters
xThe 0-based x location of the top-right corner
yThe 0-based y location of the top-right corner
wThe rectangle width
hThe rectangle height
colorThe RGB565 color to use when drawing the pixel

◆ fillRect() [2/2]

void Adafruit_RA8875::fillRect ( int16_t  x,
int16_t  y,
int16_t  w,
int16_t  h,
uint16_t  color 
)

Draws a HW accelerated filled rectangle on the display

Parameters
xThe 0-based x location of the top-right corner
yThe 0-based y location of the top-right corner
wThe rectangle width
hThe rectangle height
colorThe RGB565 color to use when drawing the pixel

◆ drawCircle()

void Adafruit_RA8875::drawCircle ( int16_t  x,
int16_t  y,
int16_t  r,
uint16_t  color 
)

Draws a HW accelerated circle on the display

Parameters
xThe 0-based x location of the center of the circle
yThe 0-based y location of the center of the circle
rThe circle's radius
colorThe RGB565 color to use when drawing the pixel

◆ fillCircle()

void Adafruit_RA8875::fillCircle ( int16_t  x,
int16_t  y,
int16_t  r,
uint16_t  color 
)

Draws a HW accelerated filled circle on the display

Parameters
xThe 0-based x location of the center of the circle
yThe 0-based y location of the center of the circle
rThe circle's radius
colorThe RGB565 color to use when drawing the pixel

◆ drawTriangle()

void Adafruit_RA8875::drawTriangle ( int16_t  x0,
int16_t  y0,
int16_t  x1,
int16_t  y1,
int16_t  x2,
int16_t  y2,
uint16_t  color 
)

Draws a HW accelerated triangle on the display

Parameters
x0The 0-based x location of point 0 on the triangle
y0The 0-based y location of point 0 on the triangle
x1The 0-based x location of point 1 on the triangle
y1The 0-based y location of point 1 on the triangle
x2The 0-based x location of point 2 on the triangle
y2The 0-based y location of point 2 on the triangle
colorThe RGB565 color to use when drawing the pixel

◆ fillTriangle()

void Adafruit_RA8875::fillTriangle ( int16_t  x0,
int16_t  y0,
int16_t  x1,
int16_t  y1,
int16_t  x2,
int16_t  y2,
uint16_t  color 
)

Draws a HW accelerated filled triangle on the display

Parameters
x0The 0-based x location of point 0 on the triangle
y0The 0-based y location of point 0 on the triangle
x1The 0-based x location of point 1 on the triangle
y1The 0-based y location of point 1 on the triangle
x2The 0-based x location of point 2 on the triangle
y2The 0-based y location of point 2 on the triangle
colorThe RGB565 color to use when drawing the pixel

◆ drawEllipse()

void Adafruit_RA8875::drawEllipse ( int16_t  xCenter,
int16_t  yCenter,
int16_t  longAxis,
int16_t  shortAxis,
uint16_t  color 
)

Draws a HW accelerated ellipse on the display

Parameters
xCenterThe 0-based x location of the ellipse's center
yCenterThe 0-based y location of the ellipse's center
longAxisThe size in pixels of the ellipse's long axis
shortAxisThe size in pixels of the ellipse's short axis
colorThe RGB565 color to use when drawing the pixel

◆ fillEllipse()

void Adafruit_RA8875::fillEllipse ( int16_t  xCenter,
int16_t  yCenter,
int16_t  longAxis,
int16_t  shortAxis,
uint16_t  color 
)

Draws a HW accelerated filled ellipse on the display

Parameters
xCenterThe 0-based x location of the ellipse's center
yCenterThe 0-based y location of the ellipse's center
longAxisThe size in pixels of the ellipse's long axis
shortAxisThe size in pixels of the ellipse's short axis
colorThe RGB565 color to use when drawing the pixel

◆ drawCurve()

void Adafruit_RA8875::drawCurve ( int16_t  xCenter,
int16_t  yCenter,
int16_t  longAxis,
int16_t  shortAxis,
uint8_t  curvePart,
uint16_t  color 
)

Draws a HW accelerated curve on the display

Parameters
xCenterThe 0-based x location of the ellipse's center
yCenterThe 0-based y location of the ellipse's center
longAxisThe size in pixels of the ellipse's long axis
shortAxisThe size in pixels of the ellipse's short axis
curvePartThe corner to draw, where in clock-wise motion: 0 = 180-270° 1 = 270-0° 2 = 0-90° 3 = 90-180°
colorThe RGB565 color to use when drawing the pixel

◆ fillCurve()

void Adafruit_RA8875::fillCurve ( int16_t  xCenter,
int16_t  yCenter,
int16_t  longAxis,
int16_t  shortAxis,
uint8_t  curvePart,
uint16_t  color 
)

Draws a HW accelerated filled curve on the display

Parameters
xCenterThe 0-based x location of the ellipse's center
yCenterThe 0-based y location of the ellipse's center
longAxisThe size in pixels of the ellipse's long axis
shortAxisThe size in pixels of the ellipse's short axis
curvePartThe corner to draw, where in clock-wise motion: 0 = 180-270° 1 = 270-0° 2 = 0-90° 3 = 90-180°
colorThe RGB565 color to use when drawing the pixel

◆ drawRoundRect()

void Adafruit_RA8875::drawRoundRect ( int16_t  x,
int16_t  y,
int16_t  w,
int16_t  h,
int16_t  r,
uint16_t  color 
)

Draws a HW accelerated rounded rectangle on the display

Parameters
xThe 0-based x location of the rectangle's upper left corner
yThe 0-based y location of the rectangle's upper left corner
wThe size in pixels of the rectangle's width
hThe size in pixels of the rectangle's height
rThe radius of the curves in the corners of the rectangle
colorThe RGB565 color to use when drawing the pixel

◆ fillRoundRect()

void Adafruit_RA8875::fillRoundRect ( int16_t  x,
int16_t  y,
int16_t  w,
int16_t  h,
int16_t  r,
uint16_t  color 
)

Draws a HW accelerated filled rounded rectangle on the display

Parameters
xThe 0-based x location of the rectangle's upper left corner
yThe 0-based y location of the rectangle's upper left corner
wThe size in pixels of the rectangle's width
hThe size in pixels of the rectangle's height
rThe radius of the curves in the corners of the rectangle
colorThe RGB565 color to use when drawing the pixel

◆ setScrollWindow()

void Adafruit_RA8875::setScrollWindow ( int16_t  x,
int16_t  y,
int16_t  w,
int16_t  h,
uint8_t  mode 
)

Set the scroll window

Parameters
xX position of the scroll window
yY position of the scroll window
wWidth of the Scroll Window
hHeight of the Scroll window
modeLayer to Scroll

◆ scrollX()

void Adafruit_RA8875::scrollX ( int16_t  dist)

Scroll in the X direction

Parameters
distThe distance to scroll

◆ scrollY()

void Adafruit_RA8875::scrollY ( int16_t  dist)

Scroll in the Y direction

Parameters
distThe distance to scroll

◆ GPIOX()

void Adafruit_RA8875::GPIOX ( boolean  on)

Set the Extra General Purpose IO Register

Parameters
onWhether to turn Extra General Purpose IO on or not

◆ PWM1config()

void Adafruit_RA8875::PWM1config ( boolean  on,
uint8_t  clock 
)

Configure the PWM 1 Clock

Parameters
onWhether to enable the clock
clockThe Clock Divider

◆ PWM2config()

void Adafruit_RA8875::PWM2config ( boolean  on,
uint8_t  clock 
)

Configure the PWM 2 Clock

Parameters
onWhether to enable the clock
clockThe Clock Divider

◆ PWM1out()

void Adafruit_RA8875::PWM1out ( uint8_t  p)

Set the duty cycle of the PWM 1 Clock

Parameters
pThe duty Cycle (0-255)

◆ PWM2out()

void Adafruit_RA8875::PWM2out ( uint8_t  p)

Set the duty cycle of the PWM 2 Clock

Parameters
pThe duty Cycle (0-255)

◆ touchEnable()

void Adafruit_RA8875::touchEnable ( boolean  on)

Enables or disables the on-chip touch screen controller

Parameters
onWhether to turn touch sensing on or not

◆ touched()

boolean Adafruit_RA8875::touched ( void  )

Checks if a touch event has occured

Returns
True is a touch event has occured (reading it via touchRead() will clear the interrupt in memory)

◆ touchRead()

boolean Adafruit_RA8875::touchRead ( uint16_t *  x,
uint16_t *  y 
)

Reads the last touch event

Parameters
xPointer to the uint16_t field to assign the raw X value
yPointer to the uint16_t field to assign the raw Y value
Returns
True if successful
Note
Calling this function will clear the touch panel interrupt on the RA8875, resetting the flag used by the 'touched' function

◆ eepromReadS32()

uint32_t Adafruit_RA8875::eepromReadS32 ( int  location)

Read from the EEPROM location

Parameters
locationThe location of the EEPROM to read
Returns
The value

◆ eepromWriteS32()

void Adafruit_RA8875::eepromWriteS32 ( int  location,
int32_t  value 
)

Write to the EEPROM location

Parameters
locationThe location of the EEPROM to write to
valueThe value to write

◆ readCalibration()

bool Adafruit_RA8875::readCalibration ( int  location,
tsMatrix_t matrixPtr 
)

Read Calibration Data from the EEPROM location

Parameters
locationThe location of the EEPROM to read from
matrixPtrThe pointer to the Matrix Variable
Returns
success

◆ writeCalibration()

void Adafruit_RA8875::writeCalibration ( int  location,
tsMatrix_t matrixPtr 
)

Write Calibration Data to the EEPROM location

Parameters
locationThe location of the EEPROM to write to
matrixPtrThe pointer to the Matrix Variable

◆ writeReg()

void Adafruit_RA8875::writeReg ( uint8_t  reg,
uint8_t  val 
)

Write data to the specified register

Parameters
regRegister to write to
valValue to write

◆ readReg()

uint8_t Adafruit_RA8875::readReg ( uint8_t  reg)

Set the register to read from

Parameters
regRegister to read
Returns
The value

◆ writeData()

void Adafruit_RA8875::writeData ( uint8_t  d)

Write data to the current register

Parameters
dData to write

◆ readData()

uint8_t Adafruit_RA8875::readData ( void  )

Read the data from the current register

Returns
The Value

◆ writeCommand()

void Adafruit_RA8875::writeCommand ( uint8_t  d)

Write a command to the current register

Parameters
dThe data to write as a command

◆ readStatus()

uint8_t Adafruit_RA8875::readStatus ( void  )

Read the status from the current register

Returns
The value

◆ waitPoll()

boolean Adafruit_RA8875::waitPoll ( uint8_t  regname,
uint8_t  waitflag 
)

Waits for screen to finish by polling the status!

Parameters
regnameThe register name to check
waitflagThe value to wait for the status register to match
Returns
True if the expected status has been reached

◆ width()

uint16_t Adafruit_RA8875::width ( void  )

Returns the display width in pixels

Returns
The 1-based display width in pixels

◆ height()

uint16_t Adafruit_RA8875::height ( void  )

Returns the display height in pixels

Returns
The 1-based display height in pixels

◆ setRotation()

void Adafruit_RA8875::setRotation ( int8_t  rotation)

Sets the current rotation (0-3)

Parameters
rotationThe Rotation Setting

◆ getRotation()

int8_t Adafruit_RA8875::getRotation ( void  )

Returns the current rotation (0-3)

Returns
The Rotation Setting

◆ write() [1/2]

virtual size_t Adafruit_RA8875::write ( uint8_t  b)
inlinevirtual

Alias of textWrite to Play nice with Arduino's Print class

Parameters
bThe string to write
Returns
The number of bytes written

◆ write() [2/2]

virtual size_t Adafruit_RA8875::write ( const uint8_t *  buffer,
size_t  size 
)
inlinevirtual

Alias of textWrite to Play nice with Arduino's Print class

Parameters
bufferThe buffer to write
sizeThe size of the buffer
Returns
The number of bytes written

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