adafruit_ra8875.ra8875
¶
A Driver Library for the RA8875
- Author(s): Melissa LeBlanc-Williams
Implementation Notes¶
Hardware:
- RA8875 Driver Board for 40-pin TFT Touch Displays - 800x480: https://www.adafruit.com/product/1590
Software and Dependencies:
- Adafruit CircuitPython firmware for the supported boards: https://github.com/adafruit/circuitpython/releases
- Adafruit’s Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
-
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:
-
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:
-
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:
-
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:
-
fill_rect
(x, y, width, height, color)¶ Draw a filled rectangle (HW Accelerated)
Parameters:
-
fill_round_rect
(x, y, width, height, radius, color)¶ Draw a filled rounded rectangle
Parameters:
-
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:
-
line
(x1, y1, x2, y2, color)¶ Draw a Line (HW Accelerated)
Parameters:
-
rect
(x, y, width, height, color)¶ Draw a rectangle (HW Accelerated)
Parameters:
-
round_rect
(x, y, width, height, radius, color)¶ Draw a rounded rectangle
Parameters:
-
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
-
-
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:
-
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:
-
setxy
(x, y)¶ Set the X and Y coordinates of the Graphic Cursor
Parameters:
-
txt_color
(fgcolor, bgcolor)¶ Set the text foreground and background colors
Parameters:
-
txt_set_cursor
(x, y)¶ Set the X and Y coordinates of the Text Cursor
Parameters:
-
txt_size
(scale)¶ Set the Text Size (0-3)
Parameters: scale (byte) – The the size to scale the Text to
-
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]
-
-
adafruit_ra8875.ra8875.
color565
(r, g=0, b=0)¶ Convert red, green and blue values (0-255) into a 16-bit 565 encoding.