Graphics4D
Introduction
The Graphics4D Library is provided by 4D Systems for use with gen4-RP2350-XX product series. This library provides users access to the graphics and touch features of 4D Systems' RP2350 display modules.
Note however that some functionalities might not be supported by a certain product types, depending on its specifications. For instance, non-touch variants have no access to all touch-related functions. For more information on the specifications of a product, refer to its datasheet.
It is recommended to use Workshop5 IDE to get the most out of the library functions.
Note
Workshop5 is a Windows-only application.
Library Setup
When using Workshop5, the library is automatically included in the code.
The library can be included to projects using the header file Graphics4D.h
Additionally, Workshop5 generates a project specific header file GeneratedConsts.h
which includes constants and useful functions.
By including the Graphics4D library, the main user code gains access to gfx
, img
and touch
functions.
Initializing the Library
Before using library functions to draw to the screen or detect touch for touch variants. The gfx
, img
and touch
needs to initialized.
For gfx
and touch
, this can be done by simply using the following functions as shown:
These two are responsible for basic graphical library features and touch handling.
For img
, you'll need to prepare a handle and prepare the graphical resources available in flash memory or microSD card.
Where GRAPHICS_GCX
can be a string indicating the graphics file to load from microSD or a pointer to a flash memory region containing the graphical resources. Note that the library only supports the graphical resources generated by Workshop5 IDE based on the user interface.
Workshop5 automatically generates the graphics file depending on project contents and define GRAPHICS_GCX
in GeneratedConsts.h
. The handle hndl
is also declared in this file. Additionally, Workshop5 also generates a utility function SetupMedia
that handles loading the graphical resources as well as providing useful parameters of the Workshop5 widgets added to the project.
A typical project will contain the code as shown:
#include "Graphics4D.h"
#include "GeneratedConsts.h"
int main() {
// this is required for programming without manually entering bootloader
stdio_init_all(); // must also enable usb stdio in CMakeLists
// otherwise, manually put the board to bootloader mode
gfx.Initialize();
gfx.ScreenMode(PROJECT_ORIENTATION);
gfx.Contrast(8);
// touch.Initialize(); // uncomment when using touch
// Uncomment when using widgets
// SetupMedia(); // autogenerated helper function used to load graphical widgets
// put your setup code here, to run once:
while (true) {
// put your main code here, to run repeatedly:
}
}
Basic Graphics Functions
The following functions are included in gfx
. These are basic draw functions including simple shapes.
Initialize
Initializes the graphics library and prepares the display for drawing.
Syntax: gfx.Initialize();
Argument | Type | Description |
---|---|---|
None | - | - |
Return: bool
- Returns true
if initialization is successful; otherwise, false
.
DrawWidget
Draws a widget at specified coordinates.
Syntax: gfx.DrawWidget(num, f, x, y, gciArray);
Argument | Type | Description |
---|---|---|
num | int | Widget ID number |
f | int | Frame number or additional identifier |
x | int | Horizontal position for widget |
y | int | Vertical position for widget |
gciArray | const uint8_t* | Pointer to widget graphics data |
Return: None (void)
Example
SetFramebuffer
Sets the framebuffer for direct access to the display buffer.
Syntax: gfx.SetFramebuffer(buffer);
Argument | Type | Description |
---|---|---|
buffer | uint16_t* | Pointer to the framebuffer memory |
Return: None (void)
Reset
Resets the display to its initial state.
Syntax: gfx.Reset();
Argument | Type | Description |
---|---|---|
None | - | - |
Return: None (void)
SetBacklightLevel
Sets the backlight level of the display.
Syntax: gfx.SetBacklightLevel(level);
Argument | Type | Description |
---|---|---|
level | uint16_t | Backlight intensity level |
Return: None (void)
Contrast
Adjusts the display contrast.
Syntax: gfx.Contrast(level);
Argument | Type | Description |
---|---|---|
level | uint8_t | Contrast level (0-255) |
Return: None (void)
GetWidth
Returns the width of the display in pixels.
Syntax: gfx.GetWidth();
Argument | Type | Description |
---|---|---|
None | - | - |
Return: uint
- Width of the display in pixels.
GetHeight
Returns the height of the display in pixels.
Syntax: gfx.GetHeight();
Argument | Type | Description |
---|---|---|
None | - | - |
Return: uint
- Height of the display in pixels.
ScreenMode
Sets the screen orientation mode.
Syntax: gfx.ScreenMode(orientation);
Argument | Type | Description |
---|---|---|
orientation | uint8_t | Screen orientation setting |
Return: None (void)
SetAddressWindow
Defines a rectangular area for subsequent drawing operations.
Syntax: gfx.SetAddressWindow(x_start, y_start, x_end, y_end);
Argument | Type | Description |
---|---|---|
x_start | uint16_t | Starting x-coordinate of the rectangle |
y_start | uint16_t | Starting y-coordinate of the rectangle |
x_end | uint16_t | Ending x-coordinate of the rectangle |
y_end | uint16_t | Ending y-coordinate of the rectangle |
Return: None (void)
Example
SendFrameBuffer
Sends a defined portion of the framebuffer to the display.
Syntax: gfx.SendFrameBuffer(x1, y1, x2, y2);
Argument | Type | Description |
---|---|---|
x1 | uint | Horizontal starting position of the framebuffer area |
y1 | uint | Vertical starting position of the framebuffer area |
x2 | uint | Horizontal ending position of the framebuffer area |
y2 | uint | Vertical ending position of the framebuffer area |
Return: None (void)
Example
GetFrameBuffer
Retrieves the pointer to the current framebuffer.
Syntax: gfx.GetFrameBuffer();
Argument | Type | Description |
---|---|---|
None | - | - |
Return: uint16_t*
- Pointer to the framebuffer.
BlendColor
Blends two colors based on a specified alpha value.
Syntax: gfx.BlendColor(base_color, new_color, alpha);
Argument | Type | Description |
---|---|---|
base_color | uint16_t | The base color to blend |
new_color | uint16_t | The color to blend with the base |
alpha | uint8_t | Alpha value for blending (0-255) |
Return: uint16_t
- The resulting color after blending.
Example
Cls
Clears the screen, optionally updating the framebuffer.
Syntax: gfx.Cls(draw_fb);
Argument | Type | Description |
---|---|---|
draw_fb | bool | Specifies whether to update the framebuffer |
Return: None (void)
RectangleFilled
Draws a solid rectangle with a specified color.
Syntax: gfx.RectangleFilled(x1, y1, x2, y2, color, draw_fb);
Argument | Type | Description |
---|---|---|
x1 | int | Horizontal position of the first endpoint |
y1 | int | Vertical position of the first endpoint |
x2 | int | Horizontal position of the second endpoint |
y2 | int | Vertical position of the second endpoint |
color | uint16_t | Color of the rectangle |
draw_fb | bool | Specifies whether to update the framebuffer |
Return: None (void)
Example
RectangleFilled (with color array)
Draws a solid rectangle using an array of colors.
Syntax: gfx.RectangleFilled(x1, y1, x2, y2, colors, draw_fb);
Argument | Type | Description |
---|---|---|
x1 | int | Horizontal position of the first endpoint |
y1 | int | Vertical position of the first endpoint |
x2 | int | Horizontal position of the second endpoint |
y2 | int | Vertical position of the second endpoint |
colors | const uint16_t* | Array of colors for filling the rectangle |
draw_fb | bool | Specifies whether to update the framebuffer |
Return: None (void)
Example
RectangleFilled (with buffer)
Draws a solid rectangle using a buffer.
Syntax: gfx.RectangleFilled(x1, y1, x2, y2, buffer, draw_fb);
Argument | Type | Description |
---|---|---|
x1 | int | Horizontal position of the first endpoint |
y1 | int | Vertical position of the first endpoint |
x2 | int | Horizontal position of the second endpoint |
y2 | int | Vertical position of the second endpoint |
buffer | const uint8_t* | Buffer of color data for the rectangle |
draw_fb | bool | Specifies whether to update the framebuffer |
Return: None (void)
Example
RectangleFilledWithAlpha
Draws a solid rectangle with alpha transparency.
Syntax: gfx.RectangleFilledWithAlpha(x1, y1, x2, y2, buffer, draw_fb);
Argument | Type | Description |
---|---|---|
x1 | int | Horizontal position of the first endpoint |
y1 | int | Vertical position of the first endpoint |
x2 | int | Horizontal position of the second endpoint |
y2 | int | Vertical position of the second endpoint |
buffer | const uint8_t* | Buffer with color and alpha data |
draw_fb | bool | Specifies whether to update the framebuffer |
Return: None (void)
Example
Hline
Draws a horizontal line at a specified vertical position.
Syntax: gfx.Hline(y, x1, x2, color, draw_fb);
Argument | Type | Description |
---|---|---|
y | int | Vertical position for the line |
x1 | int | Starting horizontal position for the line |
x2 | int | Ending horizontal position for the line |
color | uint16_t | Color of the line |
draw_fb | bool | Specifies whether to update the framebuffer |
Return: None (void)
Vline
Draws a vertical line at a specified horizontal position.
Syntax: gfx.Vline(x, y1, y2, color, draw_fb);
Argument | Type | Description |
---|---|---|
x | int | Horizontal position for the line |
y1 | int | Starting vertical position for the line |
y2 | int | Ending vertical position for the line |
color | uint16_t | Color of the line |
draw_fb | bool | Specifies whether to update the framebuffer |
Return: None (void)
PutPixel
Sets a pixel at the specified coordinates with the given color.
Syntax: gfx.PutPixel(int x, int y, uint16_t color, bool draw_fb = true);
Argument | Type | Description |
---|---|---|
x | int | X-coordinate of the pixel |
y | int | Y-coordinate of the pixel |
color | uint16_t | Color of the pixel |
draw_fb | bool | Whether to draw to framebuffer |
Return: void
Line
Draws a line between two points with the specified color.
Syntax: gfx.Line(int x1, int y1, int x2, int y2, uint16_t color, bool draw_fb = true);
Argument | Type | Description |
---|---|---|
x1 | int | X-coordinate of the starting point |
y1 | int | Y-coordinate of the starting point |
x2 | int | X-coordinate of the endpoint |
y2 | int | Y-coordinate of the endpoint |
color | uint16_t | Color of the line |
draw_fb | bool | Whether to draw to framebuffer |
Return: void
Ellipse
Draws an ellipse centered at the specified coordinates with the given radii and color.
Syntax: gfx.Ellipse(int x, int y, uint x_rad, uint y_rad, uint16_t color, bool draw_fb = true);
Argument | Type | Description |
---|---|---|
x | int | X-coordinate of the ellipse center |
y | int | Y-coordinate of the ellipse center |
x_rad | uint | Horizontal radius of the ellipse |
y_rad | uint | Vertical radius of the ellipse |
color | uint16_t | Color of the ellipse |
draw_fb | bool | Whether to draw to framebuffer |
Return: void
EllipseFilled
Draws a filled ellipse centered at the specified coordinates with the given radii and color.
Syntax: gfx.EllipseFilled(int x, int y, uint x_rad, uint y_rad, uint16_t color, bool draw_fb = true);
Argument | Type | Description |
---|---|---|
x | int | X-coordinate of the ellipse center |
y | int | Y-coordinate of the ellipse center |
x_rad | uint | Horizontal radius of the ellipse |
y_rad | uint | Vertical radius of the ellipse |
color | uint16_t | Color of the filled ellipse |
draw_fb | bool | Whether to draw to framebuffer |
Return: void
Example
Circle
Draws a circle centered at the specified coordinates with the given radius and color.
Syntax: gfx.Circle(int x, int y, uint radius, uint16_t color, bool draw_fb = true);
Argument | Type | Description |
---|---|---|
x | int | X-coordinate of the circle center |
y | int | Y-coordinate of the circle center |
radius | uint | Radius of the circle |
color | uint16_t | Color of the circle |
draw_fb | bool | Whether to draw to framebuffer |
Return: void
Arc
Draws an arc centered at the specified coordinates with the given radius and start angle.
Syntax: gfx.Arc(int x, int y, uint radius, int sa, uint16_t color, bool draw_fb = true);
Argument | Type | Description |
---|---|---|
x | int | X-coordinate of the arc center |
y | int | Y-coordinate of the arc center |
radius | uint | Radius of the arc |
sa | int | Start angle of the arc |
color | uint16_t | Color of the arc |
draw_fb | bool | Whether to draw to framebuffer |
Return: void
Example
ArcFilled
Draws a filled arc centered at the specified coordinates with the given radius, start angle, and end angle.
Syntax: gfx.ArcFilled(int x, int y, uint radius, int sa, int ea, uint16_t color, bool draw_fb = true);
Argument | Type | Description |
---|---|---|
x | int | X-coordinate of the arc center |
y | int | Y-coordinate of the arc center |
radius | uint | Radius of the arc |
sa | int | Start angle of the arc |
ea | int | End angle of the arc |
color | uint16_t | Color of the filled arc |
draw_fb | bool | Whether to draw to framebuffer |
Return: void
Example
CircleFilled
Draws a filled circle centered at the specified coordinates with the given radius and color.
Syntax: gfx.CircleFilled(int x, int y, uint radius, uint16_t color, bool draw_fb = true);
Argument | Type | Description |
---|---|---|
x | int | X-coordinate of the circle center |
y | int | Y-coordinate of the circle center |
radius | uint | Radius of the filled circle |
color | uint16_t | Color of the filled circle |
draw_fb | bool | Whether to draw to framebuffer |
Return: void
Triangle
Draws a triangle using the specified vertices and color.
Syntax: gfx.Triangle(int x1, int y1, int x2, int y2, int x3, int y3, uint16_t color, bool draw_fb = true);
Argument | Type | Description |
---|---|---|
x1 | int | X-coordinate of vertex 1 |
y1 | int | Y-coordinate of vertex 1 |
x2 | int | X-coordinate of vertex 2 |
y2 | int | Y-coordinate of vertex 2 |
x3 | int | X-coordinate of vertex 3 |
y3 | int | Y-coordinate of vertex 3 |
color | uint16_t | Color of the triangle |
draw_fb | bool | Whether to draw to framebuffer |
Return: void
Example
TriangleFilled
Draws a filled triangle using the specified vertices and color.
Syntax: gfx.TriangleFilled(int x1, int y1, int x2, int y2, int x3, int y3, uint16_t color, bool draw_fb = true);
Argument | Type | Description |
---|---|---|
x1 | int | X-coordinate of vertex 1 |
y1 | int | Y-coordinate of vertex 1 |
x2 | int | X-coordinate of vertex 2 |
y2 | int | Y-coordinate of vertex 2 |
x3 | int | X-coordinate of vertex 3 |
y3 | int | Y-coordinate of vertex 3 |
color | uint16_t | Color of the filled triangle |
draw_fb | bool | Whether to draw to framebuffer |
Return: void
Example
Polyline
Draws a polyline defined by a series of vertices with the specified color.
Syntax: gfx.Polyline(uint len, const int *vx, const int *vy, uint16_t color, bool draw_fb = true);
Argument | Type | Description |
---|---|---|
len | uint | Number of vertices in the polyline |
vx | const int* | Array of X-coordinates of the vertices |
vy | const int* | Array of Y-coordinates of the vertices |
color | uint16_t | Color of the polyline |
draw_fb | bool | Whether to draw to framebuffer |
Return: void
Example
Polygon
Draws a polygon defined by a series of vertices with the specified color.
Syntax: gfx.Polygon(uint len, const int *vx, const int *vy, uint16_t color, bool draw_fb = true);
Argument | Type | Description |
---|---|---|
len | uint | Number of vertices in the polygon |
vx | const int* | Array of X-coordinates of the vertices |
vy | const int* | Array of Y-coordinates of the vertices |
color | uint16_t | Color of the polygon |
draw_fb | bool | Whether to draw to framebuffer |
Return: void
Example
PolygonFilled
Draws a filled polygon defined by a series of vertices with the specified color.
Syntax: gfx.PolygonFilled(uint len, const int *vx, const int *vy, uint16_t color, bool draw_fb = true);
Argument | Type | Description |
---|---|---|
len | uint | Number of vertices in the polygon |
vx | const int* | Array of X-coordinates of the vertices |
vy | const int* | Array of Y-coordinates of the vertices |
color | uint16_t | Color of the filled polygon |
draw_fb | bool | Whether to draw to framebuffer |
Return: void
Example
SetBackgroundColor
Sets the background color of the display.
Syntax: gfx.SetBackgroundColor(uint16_t color);
Argument | Type | Description |
---|---|---|
color | uint16_t | Color to set as the background |
Return: uint16_t
- Previous background color.
Example
ClipWindow
Defines a clipping window for rendering.
Syntax: gfx.ClipWindow(int x1, int y1, int x2, int y2);
Argument | Type | Description |
---|---|---|
x1 | int | X-coordinate of the top-left corner |
y1 | int | Y-coordinate of the top-left corner |
x2 | int | X-coordinate of the bottom-right corner |
y2 | int | Y-coordinate of the bottom-right corner |
Return: bool
- true
if the clipping window was set successfully, false
otherwise.
SetFont
Sets the font for text rendering.
Syntax: gfx.SetFont(const uint8_t *f);
Argument | Type | Description |
---|---|---|
f | const uint8_t* | Pointer to the font data |
Return: const uint8_t*
- Pointer to the previous font.
Example
SetFontForeground (TextArea4D)
Sets the foreground color for text in a specified area.
Syntax: gfx.SetFontForeground(TextArea4D area, uint16_t color);
Argument | Type | Description |
---|---|---|
area | TextArea4D | Area for which to set the color |
color | uint16_t | Foreground color |
Return: uint16_t
- Previous foreground color.
Example
SetFontBackground (TextArea4D)
Sets the background color for text in a specified area.
Syntax: gfx.SetFontBackground(TextArea4D area, uint16_t color, bool transparent = false);
Argument | Type | Description |
---|---|---|
area | TextArea4D | Area for which to set the color |
color | uint16_t | Background color |
transparent | bool | Whether the background is transparent |
Return: uint16_t
- Previous background color.
Example
SetFontForeground
Sets the foreground color for text rendering.
Syntax: gfx.SetFontForeground(uint16_t color);
Argument | Type | Description |
---|---|---|
color | uint16_t | Foreground color |
Return: uint16_t
- Previous foreground color.
SetFontBackground
Sets the background color for text rendering.
Syntax: gfx.SetFontBackground(uint16_t color, bool transparent = false);
Argument | Type | Description |
---|---|---|
color | uint16_t | Background color |
transparent | bool | Whether the background is transparent |
Return: uint16_t
- Previous background color.
Example
MoveTo
Moves the current drawing position to the specified coordinates.
Syntax: gfx.MoveTo(int x, int y);
Argument | Type | Description |
---|---|---|
x | int | X-coordinate of the new position |
y | int | Y-coordinate of the new position |
Return: bool
- true
if the move was successful, false
otherwise.
MoveRel
Moves the current drawing position relative to its current position.
Syntax: gfx.MoveRel(int x_offset, int y_offset);
Argument | Type | Description |
---|---|---|
x_offset | int | X-offset to move from current position |
y_offset | int | Y-offset to move from current position |
Return: bool
- true
if the move was successful, false
otherwise.
Example
Prints a string at the current position.
Syntax: gfx.print(const char *str, bool draw_fb = true);
Argument | Type | Description |
---|---|---|
str | const char* | String to print |
draw_fb | bool | Whether to draw to framebuffer |
Return: size_t
- Number of characters printed.
Example
printf
Prints a formatted string at the current position.
Syntax: gfx.printf(const char *format, ...);
Argument | Type | Description |
---|---|---|
format | const char* | Format string |
... | ... | Additional arguments as needed |
Return: size_t
- Number of characters printed.
Example
CreateTextArea
Creates a text area for rendering text.
Syntax: gfx.CreateTextArea(int x1, int y1, int x2, int y2, uint16_t fg_color, uint16_t bg_color);
Argument | Type | Description |
---|---|---|
x1 | int | X-coordinate of the top-left corner |
y1 | int | Y-coordinate of the top-left corner |
x2 | int | X-coordinate of the bottom-right corner |
y2 | int | Y-coordinate of the bottom-right corner |
fg_color | uint16_t | Foreground color |
bg_color | uint16_t | Background color |
Return: TextArea4D
- The created text area.
Example
print (TextArea4D)
Prints a string in the specified text area.
Syntax: gfx.print(TextArea4D area, const char *str, bool draw_fb = true);
Argument | Type | Description |
---|---|---|
area | TextArea4D | The text area to print into |
str | const char* | String to print |
draw_fb | bool | Whether to draw to framebuffer |
Return: size_t
- Number of characters printed.
Example
printf (TextArea4D)
Prints a formatted string in the specified text area.
Syntax: gfx.printf(TextArea4D area, const char *format, ...);
Argument | Type | Description |
---|---|---|
area | TextArea4D | The text area to print into |
format | const char* | Format string |
... | ... | Additional arguments as needed |
Return: size_t
- Number of characters printed.
Example
Image Control Functions
The following functions are included in img
. These allows displaying of widgets generated by Workshop5 into to flash memory or as a file in the microSD.
LoadImageControl (Pointer)
Loads an image control from a pointer to image data.
Syntax: img.LoadImageControl(const uint8_t *ptr);
Argument | Type | Description |
---|---|---|
ptr | const uint8_t* | Pointer to the image data |
Return: ImageControl4D
- Handle to the loaded image control.
Example
LoadImageControl (Filename)
Loads an image control from a specified file.
Syntax: img.LoadImageControl(const char *filename);
Argument | Type | Description |
---|---|---|
filename | const char* | Path to the image file |
Return: ImageControl4D
- Handle to the loaded image control.
Example
GetCount
Retrieves the number of images in the image control.
Syntax: img.GetCount(ImageControl4D hndl);
Argument | Type | Description |
---|---|---|
hndl | ImageControl4D | Handle to the image control |
Return: uint
- Number of images in the control.
Example
GetFile
Retrieves a pointer to the file associated with the image control.
Syntax: img.GetFile(ImageControl4D hndl);
Argument | Type | Description |
---|---|---|
hndl | ImageControl4D | Handle to the image control |
Return: FIL*
- Pointer to the file associated with the image control.
Example
GetInfo
Retrieves media information for a specified image.
Syntax: img.GetInfo(ImageControl4D hndl, uint index);
Argument | Type | Description |
---|---|---|
hndl | ImageControl4D | Handle to the image control |
index | uint | Index of the image |
Return: MediaInfo4D
- Information about the specified image.
Example
SetProperties
Sets properties for a specified image in the image control.
Syntax: img.SetProperties(ImageControl4D hndl, uint index, const uint16_t *properties);
Argument | Type | Description |
---|---|---|
hndl | ImageControl4D | Handle to the image control |
index | uint | Index of the image |
properties | const uint16_t* | Pointer to an array of properties |
Return: void
Example
SetValue
Sets a value for a specified property of an image.
Syntax: img.SetValue(ImageControl4D hndl, uint index, uint16_t value);
Argument | Type | Description |
---|---|---|
hndl | ImageControl4D | Handle to the image control |
index | uint | Index of the image |
value | uint16_t | Value to set for the property |
Return: uint16_t
- The new value of the property.
Example
GetValue
Gets a value for a specified property of an image.
Syntax: img.GetValue(ImageControl4D hndl, uint index);
Argument | Type | Description |
---|---|---|
hndl | ImageControl4D | Handle to the image control |
index | uint | Index of the image |
Return: uint16_t
- The value of the specified property.
Example
SetPosition
Sets the position of a specified image in the image control.
Syntax: img.SetPosition(ImageControl4D hndl, uint index, int16_t x, int16_t y);
Argument | Type | Description |
---|---|---|
hndl | ImageControl4D | Handle to the image control |
index | uint | Index of the image |
x | int16_t | X-coordinate of the position |
y | int16_t | Y-coordinate of the position |
Return: void
Example
GetFrames
Gets the number of frames for a specified image.
Syntax: img.GetFrames(ImageControl4D hndl, uint index);
Argument | Type | Description |
---|---|---|
hndl | ImageControl4D | Handle to the image control |
index | uint | Index of the image |
Return: uint16_t
- The number of frames for the specified image.
Example
Show
Displays a specified image from the image control.
Syntax: img.Show(ImageControl4D hndl, uint index, bool draw_fb = true);
Argument | Type | Description |
---|---|---|
hndl | ImageControl4D | Handle to the image control |
index | uint | Index of the image |
draw_fb | bool | Whether to draw to framebuffer |
Return: void
Clear
Clears a specified image in the image control with a given color.
Syntax: img.Clear(ImageControl4D hndl, uint index, uint16_t color, bool draw_fb = true);
Argument | Type | Description |
---|---|---|
hndl | ImageControl4D | Handle to the image control |
index | uint | Index of the image |
color | uint16_t | Color to clear the image with |
draw_fb | bool | Whether to draw to framebuffer |
Return: void
Touch Handling Functions
The following functions are included for touch support.
Initialize
Initializes the touch object.
Syntax: touch.Initialize();
Argument | Type | Description |
---|---|---|
None | - | - |
Return: bool
- true
if initialization was successful, false
otherwise.
SetHandler
Sets a callback function to handle touch events.
Syntax: touch.SetHandler(TouchHandler user_cb = NULL);
Argument | Type | Description |
---|---|---|
user_cb | TouchHandler | Callback function for touch events |
Return: void
Example
Calibrate
Calibrates the touch screen.
Syntax: touch.Calibrate();
Argument | Type | Description |
---|---|---|
None | - | - |
Return: bool
- true
if calibration was successful, false
otherwise.
GetStatus
Retrieves the status of the touch object.
Syntax: touch.GetStatus();
Argument | Type | Description |
---|---|---|
None | - | - |
Return: int8_t
- Status of the touch object.
GetID
Retrieves the ID of the currently active touch point.
Syntax: touch.GetID();
Argument | Type | Description |
---|---|---|
None | - | - |
Return: int16_t
- ID of the active touch point.
GetX
Retrieves the X-coordinate of the currently active touch point.
Syntax: touch.GetX();
Argument | Type | Description |
---|---|---|
None | - | - |
Return: int16_t
- X-coordinate of the active touch point.
GetY
Retrieves the Y-coordinate of the currently active touch point.
Syntax: touch.GetY();
Argument | Type | Description |
---|---|---|
None | - | - |
Return: int16_t
- Y-coordinate of the active touch point.
GetWeight
Retrieves the weight of the currently active touch point.
Syntax: touch.GetWeight();
Argument | Type | Description |
---|---|---|
None | - | - |
Return: int16_t
- Weight of the active touch point.
GetArea
Retrieves the area of the currently active touch point.
Syntax: touch.GetArea();
Argument | Type | Description |
---|---|---|
None | - | - |
Return: int16_t
- Area of the active touch point.