mikroSDK Reference Manual
tp.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2020 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 ****************************************************************************/
39 
48 #ifndef TP_H
49 #define TP_H
50 
51 #include <stdint.h>
52 #include <stddef.h>
53 
58 #define TP_N_TOUCHES_MAX 5
59 
64 typedef enum
65 {
74 } tp_err_t;
75 
80 typedef enum
81 {
95 } tp_event_t;
96 
101 typedef enum
102 {
110 } tp_touch_id_t;
111 
116 typedef enum
117 {
123 } tp_rotate_t;
124 
130 typedef uint16_t tp_coord_t;
131 
136 typedef struct
137 {
138  tp_coord_t coord_x;
139  tp_coord_t coord_y;
140  tp_event_t event;
141  tp_touch_id_t id;
144 
150 typedef struct
151 {
153  uint8_t n_touches;
156 
161 typedef tp_event_t ( * tp_press_det_t )( void * );
162 
167 typedef void ( * tp_press_coord_t )( void *, tp_touch_item_t * );
168 
173 typedef void ( * tp_gesture_t )( void *, tp_event_t * );
174 
179 typedef tp_err_t ( * tp_process_t )( void * );
180 
186  tp_touch_id_t );
187 
192 typedef void ( * tp_gesture_callback_t )( tp_event_t );
193 
198 typedef struct
199 {
200  tp_press_det_t tp_press_detect_f;
201  tp_press_coord_t tp_press_coordinates_f;
202  tp_gesture_t tp_gesture_f;
203  tp_process_t tp_process_f;
205 } tp_drv_t;
206 
211 typedef struct
212 {
213  uint16_t width;
214  uint16_t height;
215  tp_rotate_t start_pos;
217 } tp_cfg_t;
218 
223 typedef struct
224 {
225  // Touch panel interface.
226 
227  tp_drv_t * tp_drv;
228  void * tp_drv_ctx;
230  tp_press_callback_t press_callback_f;
231  tp_gesture_callback_t gesture_callback_f;
233  // Touch panel size and orientation.
234 
235  uint16_t width;
236  uint16_t height;
237  uint16_t coord_x_max;
238  uint16_t coord_y_max;
239  tp_rotate_t start_pos;
240  uint8_t curr_pos;
241  tp_rotate_t rotate;
243  // Touch panel current and previous data.
244 
246  tp_event_t gesture;
248  tp_touch_item_t touch_prev;
249  tp_event_t gesture_prev;
250  tp_touch_item_t touch_prev_mirr;
252  uint8_t release;
254 } tp_t;
255 
268 #ifdef __cplusplus
269 extern "C"{
270 #endif
271 
291 void
292 tp_cfg_setup( tp_cfg_t * cfg );
293 
345 tp_err_t
346 tp_init( tp_t * ctx, tp_cfg_t * cfg, tp_drv_t * drv, void * drv_ctx );
347 
371 void
373 
396 void
398 
417 void
418 tp_rotate( tp_t * ctx, tp_rotate_t rotate );
419 
440 tp_get_orientation( tp_t * ctx );
441 
462 void
463 tp_get_size( tp_t * ctx, uint16_t * width, uint16_t * height );
464 
488 tp_press_detect( tp_t * ctx );
489 
517 tp_err_t
518 tp_press_coordinates( tp_t * ctx, tp_touch_item_t * touch_item );
519 
542 void
543 tp_gesture( tp_t * ctx, tp_event_t * event );
544 
571 tp_err_t
572 tp_process( tp_t * ctx );
573 
574 #ifdef __cplusplus
575 }
576 #endif
577 #endif // TP_H
578  // tpgroup // apigroup
581 
582 // ------------------------------------------------------------------------ END
TP_ERR_N_TOUCHES
Definition: tp.h:70
tp_t
Touch Panel Context Object.
Definition: tp.h:222
TP_ROTATE_270
Definition: tp.h:120
TP_TOUCH_ID_1
Definition: tp.h:103
TP_EVENT_PRESS_UP
Definition: tp.h:82
TP_TOUCH_ID_3
Definition: tp.h:105
TP_ROTATE_0
Definition: tp.h:117
TP_EVENT_PRESS_NOT_DET
Definition: tp.h:84
tp_touch_id_t
tp_touch_id_t
Touch Point ID Definition.
Definition: tp.h:100
tp_press_detect
tp_event_t tp_press_detect(tp_t *ctx)
Touch Panel Pressure Detector Function.
TP_N_TOUCHES_MAX
#define TP_N_TOUCHES_MAX
Touch Panel Touch Limit.
Definition: tp.h:57
tp_gesture_callback_t
void(* tp_gesture_callback_t)(tp_event_t)
Touch Panel Gesture Callback Function.
Definition: tp.h:191
TP_EVENT_GEST_UP
Definition: tp.h:89
tp_gesture
void tp_gesture(tp_t *ctx, tp_event_t *event)
Touch Panel Gesture Check Function.
tp_press_coord_t
void(* tp_press_coord_t)(void *, tp_touch_item_t *)
Touch Panel Driver Interface Definition.
Definition: tp.h:166
TP_EVENT_GEST_LEFT
Definition: tp.h:87
tp_event_t
tp_event_t
Touch Panel Event Code Definition.
Definition: tp.h:79
TP_EVENT_GEST_ZOOM_IN
Definition: tp.h:91
TP_ERR_SIZE
Definition: tp.h:68
TP_TOUCH_ID_5
Definition: tp.h:107
TP_ERR_INIT_DRV
Definition: tp.h:66
TP_ERR_N_DATA
Definition: tp.h:71
tp_press_det_t
tp_event_t(* tp_press_det_t)(void *)
Touch Panel Driver Interface Definition.
Definition: tp.h:160
tp_touch_item_t
Touch Item Definition.
Definition: tp.h:149
TP_EVENT_PRESS_DET
Definition: tp.h:85
tp_gesture_t
void(* tp_gesture_t)(void *, tp_event_t *)
Touch Panel Driver Interface Definition.
Definition: tp.h:172
tp_gesture_callback_setup
void tp_gesture_callback_setup(tp_t *ctx, tp_gesture_callback_t cb)
Touch Panel Callback Setup Function.
TP_ROTATE_180
Definition: tp.h:119
TP_ERR_UNSUPPORTED_PIN
Definition: tp.h:67
tp_process_t
tp_err_t(* tp_process_t)(void *)
Touch Panel Driver Interface Definition.
Definition: tp.h:178
TP_OK
Definition: tp.h:65
tp_err_t
tp_err_t
Touch Panel Error Code Definition.
Definition: tp.h:63
TP_EVENT_GEST_DOWN
Definition: tp.h:90
tp_touch_coord_t
Touch Point Object Definition.
Definition: tp.h:135
tp_rotate_t
tp_rotate_t
Touch Panel Placement (Orientation) Definition.
Definition: tp.h:115
TP_ERR_PRESS_COORD
Definition: tp.h:69
TP_EVENT_GEST_ZOOM_OUT
Definition: tp.h:92
tp_rotate
void tp_rotate(tp_t *ctx, tp_rotate_t rotate)
Touch Panel Rotate Function.
tp_process
tp_err_t tp_process(tp_t *ctx)
Touch Panel Process Function.
TP_ROTATE_90
Definition: tp.h:118
tp_coord_t
uint16_t tp_coord_t
Touch Point Coordinates Data Type.
Definition: tp.h:129
tp_cfg_setup
void tp_cfg_setup(tp_cfg_t *cfg)
Touch Panel Configuration Function.
tp_init
tp_err_t tp_init(tp_t *ctx, tp_cfg_t *cfg, tp_drv_t *drv, void *drv_ctx)
Touch Panel Initialization Function.
tp_press_callback_t
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:184
TP_TOUCH_ID_4
Definition: tp.h:106
TP_EVENT_GEST_NONE
Definition: tp.h:86
tp_get_orientation
tp_rotate_t tp_get_orientation(tp_t *ctx)
Touch Panel Orientation Check Function.
tp_press_callback_setup
void tp_press_callback_setup(tp_t *ctx, tp_press_callback_t cb)
Touch Panel Callback Setup Function.
TP_EVENT_PRESS_MOVE
Definition: tp.h:83
tp_cfg_t
Touch Panel Size And Placement Configuration Object.
Definition: tp.h:210
TP_EVENT_PRESS_DOWN
Definition: tp.h:81
TP_EVENT_GEST_RIGHT
Definition: tp.h:88
TP_TOUCH_ID_0
Definition: tp.h:102
tp_get_size
void tp_get_size(tp_t *ctx, uint16_t *width, uint16_t *height)
Touch Panel Size Check Function.
tp_drv_t
Touch Panel Driver Interface Items.
Definition: tp.h:197
tp_press_coordinates
tp_err_t tp_press_coordinates(tp_t *ctx, tp_touch_item_t *touch_item)
Touch Panel Pressure Coordinates Check Function.
TP_TOUCH_ID_2
Definition: tp.h:104