|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
The GT911 polling task: reads contacts, maps them into the panel's coordinates, crops them to the UI's area and publishes snapshots and events. More...
#include "touch.h"#include <stdatomic.h>#include <string.h>#include "board.h"#include "esp_check.h"#include "esp_log.h"#include "esp_timer.h"#include "freertos/FreeRTOS.h"#include "freertos/queue.h"#include "freertos/semphr.h"#include "freertos/task.h"#include "gfx_turn.h"#include "gt911.h"#include "touch_inject.h"#include "touch_merge.h"Data Structures | |
| struct | touch_state_t |
| struct | queued_t |
Functions | |
| static uint32_t | now_ms (void) |
| static void | publish (const touch_point_t *pts, int count) |
Run the tracker over pts and queue its events, numbered. | |
| static void | crop_and_publish (touch_point_t *pts, int count) |
| Publish only the contacts inside the UI's area: the UI draws BOARD_UI_H_RES x BOARD_UI_V_RES of the panel. | |
| static void | touch_task (void *arg) |
| esp_err_t | touch_init (const touch_config_t *cfg) |
| Reset the controller, probe it and start the polling task. | |
| esp_err_t | touch_deinit (void) |
| Stop the task and release the controller. | |
| int | touch_snapshot (touch_point_t *out, int max) |
| bool | touch_pressed (touch_point_t *out) |
| bool | touch_wait_event (touch_event_t *out, uint32_t *seq, uint32_t timeout_ms) |
| uint32_t | touch_published (void) |
| void | touch_flush_events (void) |
| uint16_t | touch_i2c_address (void) |
| uint32_t | touch_age_ms (void) |
Variables | |
| static const char * | TAG = "touch" |
| static touch_state_t | s_touch |
The GT911 polling task: reads contacts, maps them into the panel's coordinates, crops them to the UI's area and publishes snapshots and events.
Screen rotation 180° turns the glass's contacts with the picture: the task reads the one flag the display's flush sets once a turned frame is on the glass (gfx_turn_shown()), once per report.
SPDX-License-Identifier: MIT
|
static |
Publish only the contacts inside the UI's area: the UI draws BOARD_UI_H_RES x BOARD_UI_V_RES of the panel.
| pts | Contacts in panel pixels, each source already mapped with its own map; cropped in place. |
| count | How many. |
| uint32_t touch_age_ms | ( | void | ) |
Milliseconds since the controller last answered a read, or UINT32_MAX when touch never came up.
"Answered" means the I2C (Inter-Integrated Circuit) transaction succeeded, not that a finger was down. An untouched panel is healthy and reports an age near zero, so this separates "nobody is touching it" from "the controller stopped answering", which the event stream cannot.
An application that can act on input, and only on input, treats a large age as a fault rather than as quiet.
| esp_err_t touch_deinit | ( | void | ) |
Stop the task and release the controller.
| void touch_flush_events | ( | void | ) |
Drop any queued events (useful after a screen change).
| uint16_t touch_i2c_address | ( | void | ) |
I2C address the controller answered on, or 0 before init.
| esp_err_t touch_init | ( | const touch_config_t * | cfg | ) |
Reset the controller, probe it and start the polling task.
| cfg | The set-up; NULL takes TOUCH_CONFIG_DEFAULT(). |
| bool touch_pressed | ( | touch_point_t * | out | ) |
True when at least one finger is down; fills out if given.
| uint32_t touch_published | ( | void | ) |
The number of the last event the driver offered to its queue, stored after the offer. Read before draining the queue: an event up to it that the drain did not deliver was dropped, which a loss at the end of the stream, with no later event to show the gap, needs.
| int touch_snapshot | ( | touch_point_t * | out, |
| int | max ) |
Copy the current contact set. Returns the number of active contacts, which may exceed max (only max of them are written).
| bool touch_wait_event | ( | touch_event_t * | out, |
| uint32_t * | seq, | ||
| uint32_t | timeout_ms ) |
Pop the next input event. timeout_ms of 0 polls, UINT32_MAX blocks. Returns false when nothing arrived in time.
seq, when not NULL, receives the event's number. The driver numbers every event it offers to its queue, from 1 and in order, whether or not the queue kept it, so a number skipped is an event the queue dropped because nobody collected it. touch_loss.h turns the numbers into losses.