mikroSDK Reference Manual
tp.h
Go to the documentation of this file.
1/****************************************************************************
2**
3** Copyright (C) 2024 MikroElektronika d.o.o.
4** Contact: https://www.mikroe.com/contact
5**
6** This file is part of the mikroSDK package
7**
8** Commercial License Usage
9**
10** Licensees holding valid commercial NECTO compilers AI licenses may use this
11** file in accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The MikroElektronika Company.
14** For licensing terms and conditions see
15** https://www.mikroe.com/legal/software-license-agreement.
16** For further information use the contact form at
17** https://www.mikroe.com/contact.
18**
19**
20** GNU Lesser General Public License Usage
21**
22** Alternatively, this file may be used for
23** non-commercial projects under the terms of the GNU Lesser
24** General Public License version 3 as published by the Free Software
25** Foundation: https://www.gnu.org/licenses/lgpl-3.0.html.
26**
27** The above copyright notice and this permission notice shall be
28** included in all copies or substantial portions of the Software.
29**
30** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
31** OF MERCHANTABILITY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
32** TO THE WARRANTIES FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
33** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
34** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
35** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
36** OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37**
38****************************************************************************/
47#ifndef _TP_H_
48#define _TP_H_
49
50#include <stdint.h>
51#include <stddef.h>
52
64
76
81typedef enum {
84
95
101typedef uint16_t tp_coord_t;
102
107typedef struct {
108 tp_coord_t coord_x;
109 tp_coord_t coord_y;
110 tp_event_t event;
111 tp_touch_id_t id;
113
118typedef tp_event_t ( * tp_press_det_t )( void * );
119
124typedef void ( * tp_press_coord_t )( void *, tp_touch_coord_t * );
125
130typedef tp_err_t ( * tp_process_t )( void * );
131
137
142typedef struct {
143 tp_press_det_t tp_press_detect_f;
144 tp_press_coord_t tp_press_coordinates_f;
145 tp_process_t tp_process_f;
146} tp_drv_t;
147
152typedef struct {
153 uint16_t width;
154 uint16_t height;
155 tp_rotate_t start_pos;
156} tp_cfg_t;
157
162typedef struct {
163 // Touch panel interface.
164 tp_drv_t *tp_drv;
165 void *tp_drv_ctx;
167 tp_press_callback_t press_callback_f;
169 // Touch panel size and orientation.
170 uint16_t width;
171 uint16_t height;
172 uint16_t coord_x_max;
173 uint16_t coord_y_max;
174 tp_rotate_t start_pos;
175 uint8_t curr_pos;
176 tp_rotate_t rotate;
178 // Touch panel current and previous data.
182 uint8_t release;
183} tp_t;
184
197#ifdef __cplusplus
198extern "C"{
199#endif
200
220void tp_cfg_setup( tp_cfg_t *cfg );
221
259tp_err_t tp_init( tp_t *ctx, tp_cfg_t *cfg, tp_drv_t *drv, void *drv_ctx );
260
284
303void tp_rotate( tp_t *ctx, tp_rotate_t rotate );
304
325
346void tp_get_size( tp_t *ctx, uint16_t *width, uint16_t *height );
347
371
399
424tp_err_t tp_process( tp_t *ctx );
425
426#ifdef __cplusplus
427}
428#endif
429#endif // _TP_H_
430
431 // tpgroup
432 // apigroup
433
434// ------------------------------------------------------------------------ END
void tp_rotate(tp_t *ctx, tp_rotate_t rotate)
Touch Panel Rotate Function.
tp_err_t tp_init(tp_t *ctx, tp_cfg_t *cfg, tp_drv_t *drv, void *drv_ctx)
Touch Panel Initialization Function.
tp_event_t tp_press_detect(tp_t *ctx)
Touch Panel Pressure Detector Function.
void tp_get_size(tp_t *ctx, uint16_t *width, uint16_t *height)
Touch Panel Size Check Function.
tp_err_t tp_press_coordinates(tp_t *ctx, tp_touch_coord_t *touch_item)
Touch Panel Pressure Coordinates Check Function.
void tp_cfg_setup(tp_cfg_t *cfg)
Touch Panel Configuration Function.
tp_rotate_t tp_get_orientation(tp_t *ctx)
Touch Panel Orientation Check Function.
void tp_press_callback_setup(tp_t *ctx, tp_press_callback_t cb)
Touch Panel Callback Setup Function.
tp_err_t tp_process(tp_t *ctx)
Touch Panel Process Function.
Touch Panel Size And Placement Configuration Object.
Definition tp.h:212
Touch Panel Driver Interface Items.
Definition tp.h:199
Touch Panel Context Object.
Definition tp.h:224
tp_touch_coord_t touch
Definition tp.h:179
tp_touch_coord_t touch_prev
Definition tp.h:180
tp_touch_coord_t touch_prev_mirr
Definition tp.h:181
Touch Point Object Definition.
Definition tp.h:137
uint16_t tp_coord_t
Touch Point Coordinates Data Type.
Definition tp.h:130
tp_event_t
Touch Panel Event Code Definition.
Definition tp.h:81
tp_err_t
Touch Panel Error Code Definition.
Definition tp.h:65
tp_rotate_t
Touch Panel Placement (Orientation) Definition.
Definition tp.h:117
tp_touch_id_t
Touch Point ID Definition.
Definition tp.h:102
@ TP_TOUCH_ID_0
Definition tp.h:103
tp_event_t(* tp_press_det_t)(void *)
Touch Panel Driver Interface Definition.
Definition tp.h:118
tp_err_t(* tp_process_t)(void *)
Touch Panel Driver Interface Definition.
Definition tp.h:130
uint16_t tp_coord_t
Touch Point Coordinates Data Type.
Definition tp.h:101
tp_event_t
Touch Panel Event Code Definition.
Definition tp.h:69
@ TP_EVENT_PRESS_NOT_DET
Definition tp.h:73
@ TP_EVENT_PRESS_DOWN
Definition tp.h:70
@ TP_EVENT_PRESS_MOVE
Definition tp.h:72
@ TP_EVENT_PRESS_DET
Definition tp.h:74
@ TP_EVENT_PRESS_UP
Definition tp.h:71
tp_err_t
Touch Panel Error Code Definition.
Definition tp.h:57
@ TP_ERR_INIT_DRV
Definition tp.h:59
@ TP_ERR_UNSUPPORTED_PIN
Definition tp.h:60
@ TP_ERR_SIZE
Definition tp.h:61
@ TP_ERR_PRESS_COORD
Definition tp.h:62
@ TP_OK
Definition tp.h:58
void(* tp_press_coord_t)(void *, tp_touch_coord_t *)
Touch Panel Driver Interface Definition.
Definition tp.h:124
void(* tp_press_callback_t)(tp_event_t, tp_coord_t, tp_coord_t, tp_touch_id_t)
Touch Panel Touch Callback Function.
Definition tp.h:136
tp_rotate_t
Touch Panel Placement (Orientation) Definition.
Definition tp.h:89
@ TP_ROTATE_270
Definition tp.h:93
@ TP_ROTATE_180
Definition tp.h:92
@ TP_ROTATE_90
Definition tp.h:91
@ TP_ROTATE_0
Definition tp.h:90
tp_touch_id_t
Touch Point ID Definition.
Definition tp.h:81