The Touch module provides access to the touch controller, and executes a callback if a certain region is touched
typedef void(* TOUCH_CALLBACK) (void *touchArea, TOUCH_ACTION triggeredAction) |
Prototype for Event Listeners (called for every occurring, hooked action)
- Note
- You should NOT execute long running things in this callback nor should you update the gui. But you can call gui_screen_navigate() for instance.
- Parameters
-
touchArea | The pointer to the TOUCH_AREA_STRUCT in which the event occurred |
triggeredAction | The Action which occurred |
Definition at line 67 of file touch.h.
Enum to describe the hooked actions for which you want to receive events for. You can OR-combine them.
- See also
- touch_register_area
Enumerator |
---|
NONE |
Do not receive any events.
|
PEN_DOWN |
Receive an event when the pen goes down inside the region.
|
PEN_UP |
Receive an event when the pen goes up inside the region.
|
PEN_ENTER |
Receive an event when the pen enters the region (pen was down before)
|
PEN_LEAVE |
Receive an event when the pen leaves the region (pen was inside region before)
|
PEN_MOVE |
Receive an event when the pen moves inside the region (pen is down)
|
Definition at line 52 of file touch.h.
Receive an event when the pen moves inside the region (pen is down)
Receive an event when the pen goes down inside the region.
Receive an event when the pen goes up inside the region.
Receive an event when the pen enters the region (pen was down before)
Do not receive any events.
Receive an event when the pen leaves the region (pen was inside region before)
Enum to describe the current Touch State.
- See also
- touch_add_raw_event
Enumerator |
---|
TOUCH_UP |
The display is currently not touched.
|
TOUCH_DOWN |
The display is currently touched at some point.
|
Definition at line 43 of file touch.h.
The display is currently not touched.
The display is currently touched at some point.
bool touch_add_raw_event |
( |
uint16_t |
x, |
|
|
uint16_t |
y, |
|
|
TOUCH_STATE |
state |
|
) |
| |
Processes a native touch event. Call this function when the pen goes down (TOUCH_DOWN), when it moves (TOUCH_DOWN) and also when it goes up again (TOUCH_UP)! It's safe to call this function from an (SPI)-Interrupt.
- Parameters
-
x | The x-Coordinate of the touch event |
y | The y-Coordinate of the touch event |
state | Whether the pen is up or down |
- Returns
- True on success
Definition at line 72 of file touch.c.
108 if (
areas[z] != NULL && touchX >=
areas[z]->x1 && touchX <=
areas[z]->x2 && touchY >=
areas[z]->y1 && touchY <=
areas[z]->y2) {
118 if (
areas[z] != NULL) {
120 if (touchX >=
areas[z]->x1 && touchX <=
areas[z]->x2 && touchY >=
areas[z]->y1 && touchY <=
areas[z]->y2) {
121 if (
areas[z]->flags == 0) {
128 }
else if (
areas[z]->flags) {
142 if (touchX >=
areas[z]->x1 && touchX <=
areas[z]->x2 && touchY >=
areas[z]->y1 && touchY <=
areas[z]->y2) {
151 if (
areas[z] != NULL && touchX >=
areas[z]->x1 && touchX <=
areas[z]->x2 && touchY >=
areas[z]->y1 && touchY <=
areas[z]->y2) {
Receive an event when the pen moves inside the region (pen is down)
Receive an event when the pen goes down inside the region.
Receive an event when the pen goes up inside the region.
uint16_t y
The Y-Coordinate of the point.
uint8_t flags
For internal use, don't change, don't initialize.
uint16_t x
The X-Coordinate of the point.
The display is currently touched at some point.
volatile POINT_STRUCT pos
volatile TOUCH_STATE oldState
TOUCH_CALLBACK callback
Callback which is executed when an event occurred in this Area.
Receive an event when the pen enters the region (pen was down before)
volatile bool calibration
TOUCH_AREA_STRUCT * areas[NUM_AREAS]
Receive an event when the pen leaves the region (pen was inside region before)
Gets the last touched point
- Returns
- The Coordinates of the last touched points
Definition at line 211 of file touch.c.
volatile POINT_STRUCT pos
bool touch_have_empty |
( |
unsigned char |
num | ) |
|
Checks whether or not we have memory to manage and track additional num
TOUCH_AREA_STRUCTs
- Parameters
-
num | The number of touch areas you would like to allocate |
- Returns
- True if there's enough memory to allocate num TOUCH_AREAs
Definition at line 165 of file touch.c.
168 for (
unsigned char i = 0; i <
NUM_AREAS; i++) {
169 if (
areas[i] == NULL) {
TOUCH_AREA_STRUCT * areas[NUM_AREAS]
Initializes the Touch Controller. Call this method before using any touch_* functions
- Returns
- true on success
Definition at line 61 of file touch.c.
Registers a new touch Area. You will receive events for this area from now on.
- Parameters
-
- Returns
- True if everything was successful and the corresponding Touch Area will be monitored from now on
Definition at line 181 of file touch.c.
184 for (
unsigned char i = 0; i <
NUM_AREAS; i++) {
185 if (
areas[i] == NULL) {
uint8_t flags
For internal use, don't change, don't initialize.
TOUCH_AREA_STRUCT * areas[NUM_AREAS]
void touch_set_calibration_values |
( |
int |
xs, |
|
|
int |
dx, |
|
|
int |
ys, |
|
|
int |
dy |
|
) |
| |
Set's the new calibration values
- Parameters
-
xs | x offset (to calibration point 1) |
dx | x difference (between calibration point 1 and 2) |
ys | y offset (to calibration point 1) |
dy | y difference (between calibration point 1 and 2) |
Definition at line 51 of file touch.c.
void touch_set_value_convert_mode |
( |
bool |
use_calibration | ) |
|
Set's the new value convert mode. Per default use_calibration is false.
- Parameters
-
use_calibration | whether or not the current platform needs display calibration |
Definition at line 66 of file touch.c.
Unregisters a touch area. You will no longer receive events for this area
- Parameters
-
Definition at line 195 of file touch.c.
202 for (
unsigned char i = 0; i <
NUM_AREAS; i++) {
203 if (
areas[i] == area) {
TOUCH_AREA_STRUCT * areas[NUM_AREAS]