adafruit_ra8875.ra8875

A Driver Library for the RA8875

  • Author(s): Melissa LeBlanc-Williams

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_ra8875.ra8875.RA8875(spi, cs, rst=None, width=800, height=480, baudrate=6000000, polarity=0, phase=0)

Graphics Library Class for the Display. Contains all the hardware accelerated geometry Functions. For full display functionality, use this class. Valid display sizes are currently 800x480 and 480x272.

circle(x_center, y_center, radius, color)

Draw a circle (HW Accelerated)

Parameters:
  • x_center (int) – The X coordinate of the center of the circle
  • y_center (int) – The Y coordinate of the center of the circle
  • radius (int) – The radius of the circle
  • color (int) – The color of the circle
curve(x_center, y_center, h_axis, v_axis, curve_part, color)

Draw a Curve (HW Accelerated) This is basically a quarter of an ellipse.

Parameters:
  • x_center (int) – The X coordinate of the focal point of the curve
  • y_center (int) – The Y coordinate of the focal point of the curve
  • h_axis (int) – The length of the horizontal axis of the full ellipse
  • v_axis (int) – The length of the vertical axis of the full ellipse
  • curve_part (byte) – A number between 0-3 specifying the quarter section
  • color (int) – The color of the curve
ellipse(x_center, y_center, h_axis, v_axis, color)

Draw an ellipse (HW Accelerated)

Parameters:
  • x_center (int) – The X coordinate of the center of the ellipse
  • y_center (int) – The Y coordinate of the center of the ellipse
  • h_axis (int) – The length of the horizontal axis
  • v_axis (int) – The length of the vertical axis
  • color (int) – The color of the ellipse
fill(color)

Fill the Entire Screen (HW Accelerated)

Parameters:color (int) – The color to Fill the screen
fill_circle(x_center, y_center, radius, color)

Draw a filled circle (HW Accelerated)

Parameters:
  • x_center (int) – The X coordinate of the center of the circle
  • y_center (int) – The Y coordinate of the center of the circle
  • radius (int) – The radius of the circle
  • color (int) – The color of the circle
fill_curve(x_center, y_center, h_axis, v_axis, curve_part, color)

Draw a Filled Curve (HW Accelerated) This is basically a quarter of an ellipse.

Parameters:
  • x_center (int) – The X coordinate of the focal point of the curve
  • y_center (int) – The Y coordinate of the focal point of the curve
  • h_axis (int) – The length of the horizontal axis of the full ellipse
  • v_axis (int) – The length of the vertical axis of the full ellipse
  • curve_part (byte) – A number between 0-3 specifying the quarter section
  • color (int) – The color of the curve
fill_ellipse(x_center, y_center, h_axis, v_axis, color)

Draw a Filled Ellipse (HW Accelerated)

Parameters:
  • x_center (int) – The X coordinate of the center of the ellipse
  • y_center (int) – The Y coordinate of the center of the ellipse
  • h_axis (int) – The length of the horizontal axis
  • v_axis (int) – The length of the vertical axis
  • color (int) – The color of the ellipse
fill_rect(x, y, width, height, color)

Draw a filled rectangle (HW Accelerated)

Parameters:
  • x (int) – The X coordinate of the left side of the rectangle
  • y (int) – The Y coordinate of the top side of the rectangle
  • width (int) – The width of the rectangle
  • height (int) – The height of the rectangle
  • color (int) – The color of the rectangle
fill_round_rect(x, y, width, height, radius, color)

Draw a filled rounded rectangle

Parameters:
  • x (int) – The X coordinate of the left side of the rectangle
  • y (int) – The Y coordinate of the top side of the rectangle
  • width (int) – The width of the rectangle
  • height (int) – The height of the rectangle
  • radius (int) – The radius of the corners
  • color (int) – The color of the rectangle
fill_triangle(x1, y1, x2, y2, x3, y3, color)

Draw a Filled Triangle (HW Accelerated)

Parameters:
  • x1 (int) – The X coordinate of the first point of the triangle
  • y1 (int) – The Y coordinate of the first point of the triangle
  • x2 (int) – The X coordinate of the second point of the triangle
  • y2 (int) – The Y coordinate of the second point of the triangle
  • x3 (int) – The X coordinate of the third point of the triangle
  • y3 (int) – The Y coordinate of the third point of the triangle
  • color (int) – The color of the triangle
hline(x, y, width, color)

Draw a Horizontal Line (HW Accelerated)

Parameters:
  • x (int) – The X coordinate of the beginning point of the line
  • y (int) – The Y coordinate of the beginning point of the line
  • width (int) – The width of the line
  • color (int) – The color of the line
line(x1, y1, x2, y2, color)

Draw a Line (HW Accelerated)

Parameters:
  • x1 (int) – The X coordinate of the beginning point of the line
  • y1 (int) – The Y coordinate of the beginning point of the line
  • x2 (int) – The X coordinate of the end point of the line
  • y2 (int) – The Y coordinate of the end point of the line
  • color (int) – The color of the line
rect(x, y, width, height, color)

Draw a rectangle (HW Accelerated)

Parameters:
  • x (int) – The X coordinate of the left side of the rectangle
  • y (int) – The Y coordinate of the top side of the rectangle
  • width (int) – The width of the rectangle
  • height (int) – The height of the rectangle
  • color (int) – The color of the rectangle
round_rect(x, y, width, height, radius, color)

Draw a rounded rectangle

Parameters:
  • x (int) – The X coordinate of the left side of the rectangle
  • y (int) – The Y coordinate of the top side of the rectangle
  • width (int) – The width of the rectangle
  • height (int) – The height of the rectangle
  • radius (int) – The radius of the corners
  • color (int) – The color of the rectangle
triangle(x1, y1, x2, y2, x3, y3, color)

Draw a Triangle (HW Accelerated)

Parameters:
  • x1 (int) – The X coordinate of the first point of the triangle
  • y1 (int) – The Y coordinate of the first point of the triangle
  • x2 (int) – The X coordinate of the second point of the triangle
  • y2 (int) – The Y coordinate of the second point of the triangle
  • x3 (int) – The X coordinate of the third point of the triangle
  • y3 (int) – The Y coordinate of the third point of the triangle
  • color (int) – The color of the triangle
vline(x, y, height, color)

Draw a Vertical Line (HW Accelerated)

Parameters:
  • x (int) – The X coordinate of the beginning point of the line
  • y (int) – The Y coordinate of the beginning point of the line
  • height (int) – The height of the line
  • color (int) – The color of the line
class adafruit_ra8875.ra8875.RA8875Display(spi, cs, rst=None, width=800, height=480, baudrate=6000000, polarity=0, phase=0)

Drawing Class for the Display. Contains all the basic drawing functionality as well as the text functions. Valid display sizes are currently 800x480 and 480x272.

Parameters:
  • spi (SPI) – The spi peripheral to use
  • cs (DigitalInOut) – The chip-select pin to use (sometimes labeled “SS”)
  • rst (DigitalInOut) – (optional) The reset pin if it exists (default=None)
  • width (int) – (optional) The width of the display in pixels (default=800)
  • height (int) – (optional) The height of the display in pixels (default=480)
  • baudrate (int) – (optional) The spi speed (default=6000000)
  • phase (int) – (optional) The spi phase (default=0)
  • polarity (int) – (optional) The spi polarity (default=0)
pixel(x, y, color)

Draw a pixel at the X and Y coordinates of the specified color

Parameters:
  • x (int) – The X coordinate to set the cursor
  • y (int) – The Y coordinate to set the cursor
  • color (int) – The color of the pixel
push_pixels(pixel_data)

Push a stream of pixel data to the screen.

Parameters:pixel_data (bytearray) – Raw pixel data to push
set_bgcolor(color)

Set the text background color

Parameters:color (int) – The color behind the text
set_color(color)

Set the foreground color for graphics/text

Parameters:color (int) – The of the text or graphics
set_window(x, y, width, height)

Set an Active Drawing Window, which can be used in conjuntion with push_pixels for faster drawing

Parameters:
  • x (int) – The X coordinate of the left side of the window
  • y (int) – The Y coordinate of the top side of the window
  • width (int) – The width of the window
  • height (int) – The height of the window
setxy(x, y)

Set the X and Y coordinates of the Graphic Cursor

Parameters:
  • x (int) – The X coordinate to set the cursor
  • y (int) – The Y coordinate to set the cursor
txt_color(fgcolor, bgcolor)

Set the text foreground and background colors

Parameters:
  • fgcolor (int) – Foreground Color - The color of the text
  • bgcolor (int) – Background Color - The color behind the text
txt_set_cursor(x, y)

Set the X and Y coordinates of the Text Cursor

Parameters:
  • x (int) – The X coordinate to set the cursor
  • y (int) – The Y coordinate to set the cursor
txt_size(scale)

Set the Text Size (0-3)

Parameters:scale (byte) – The the size to scale the Text to
txt_trans(color)

Set the text foreground color with a transparent background

Parameters:color (int) – The color of the text
txt_write(string)

Write text at the current cursor location using current settings

Parameters:string (str) – The text string to write
class adafruit_ra8875.ra8875.RA8875_Device(spi, cs, rst=None, width=800, height=480, baudrate=6000000, polarity=0, phase=0)

Base Class for the Display. Contains all the low level stuff. As well as the touch functions. Valid display sizes are currently 800x480 and 480x272.

brightness(level)

Configure the backlight brightness (0-255)

Parameters:level (byte) – The PWM Duty Cycle
init(start_on=True)

Send the Init Commands for the selected Display Size

Parameters:start_on (bool) – (optional) If the display should start in an On State (default=True)
pllinit()

Init the Controller PLL

reset()

Perform a hard reset

sleep(sleep)

Turn the display off with and set or remove the sleep state

Parameters:sleep (bool) – Should we enable sleep mode
soft_reset()

Perform a soft reset

touch_enable(touch_on)

Enable touch functionality

Parameters:touch_on (bool) – Enable/Disable the Touch Functionality
touch_init(tpin=None, enable=True)

Initialize the Touchscreen

Parameters:
  • tpin (DigitalInOut) – (Optional) The Touch Screen Interrupt Pin (default=None)
  • enable (bool) – Enable the Touch Functionality as well
touch_read()

Read the X and Y Coordinates of the current Touch Position

Returns:The coordinate of the detected touch
Return type:tuple[int, int]
touched()

Check if the Screen is currently being touched. If a touch interrupt was specified, this is checked first.

Returns:Is screen is currently being touched
Return type:bool
turn_on(display_on)

Turn the display on or off

Parameters:start_on (bool) – If the display should turn on or off
adafruit_ra8875.ra8875.color565(r, g=0, b=0)

Convert red, green and blue values (0-255) into a 16-bit 565 encoding.