eGUI alias D4D  Release 3.0
Reference Manual
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
d4dtch_resistive_mqx.c
Go to the documentation of this file.
1 /**************************************************************************
2 *
3 * Copyright 2014 by Petr Gargulak. eGUI Community.
4 * Copyright 2009-2013 by Petr Gargulak. Freescale Semiconductor, Inc.
5 *
6 ***************************************************************************
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License Version 3
9 * or later (the "LGPL").
10 *
11 * As a special exception, the copyright holders of the eGUI project give you
12 * permission to link the eGUI sources with independent modules to produce an
13 * executable, regardless of the license terms of these independent modules,
14 * and to copy and distribute the resulting executable under terms of your
15 * choice, provided that you also meet, for each linked independent module,
16 * the terms and conditions of the license of that module.
17 * An independent module is a module which is not derived from or based
18 * on this library.
19 * If you modify the eGUI sources, you may extend this exception
20 * to your version of the eGUI sources, but you are not obligated
21 * to do so. If you do not wish to do so, delete this
22 * exception statement from your version.
23 *
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
27 *
28 * You should have received a copy of the GNU General Public License
29 * and the GNU Lesser General Public License along with this program.
30 * If not, see <http://www.gnu.org/licenses/>.
31 *
32 ***************************************************************************/
45 #include "d4d.h"
48 
49 #define d4dtch_resistive_mqx_ID 1
50 
51 #if (D4D_MK_STR(D4D_LLD_TCH) == d4dtch_resistive_mqx_ID)
52 
53 #include <mqx.h>
54 #include <fio.h>
55 #include <tchres.h>
57 
58 /******************************************************************************
59 * Macros
60 ******************************************************************************/
61 
62 /**************************************************************/
67 static unsigned char D4DTCH_Init_Tchres_Mqx(void);
68 static unsigned char D4DTCH_DeInit_Tchres_Mqx(void);
69 static D4D_TOUCHSCREEN_LIMITS* D4DTCH_GetRawLimits_Tchres_Mqx(void);
70 static unsigned char D4DTCH_GetPositionRaw_Tchres_Mqx (unsigned short *TouchPositionX,
71  unsigned short *TouchPositionY);
72 
73 /**************************************************************/
78 const D4DTCH_FUNCTIONS d4dtch_resistive_mqx =
79 {
80  D4DTCH_Init_Tchres_Mqx,
81  D4DTCH_GetPositionRaw_Tchres_Mqx,
82  D4DTCH_GetRawLimits_Tchres_Mqx,
83  D4DTCH_DeInit_Tchres_Mqx
84 };
85 
86 /**************************************************************/
91 static FILE_PTR tchscr_dev;
92 
93 /**************************************************************/
98 static unsigned char D4DTCH_Init_Tchres_Mqx(void)
99 {
100  tchscr_dev = fopen("tchscr:", NULL);
101  if( tchscr_dev == NULL )
102  return 0;
103  else
104  return 1;
105 }
106 
107 /**************************************************************/
112 static unsigned char D4DTCH_DeInit_Tchres_Mqx(void)
113 {
114  if( tchscr_dev )
115  {
116  fclose( tchscr_dev );
117  tchscr_dev = NULL;
118  }
119  return 1;
120 }
121 
122 /**************************************************************/
127 static D4D_TOUCHSCREEN_LIMITS* D4DTCH_GetRawLimits_Tchres_Mqx(void)
128 {
129  static D4D_TOUCHSCREEN_LIMITS touchscreen_limits;
130  TCHRES_ADC_LIMITS_STRUCT limit_struct;
131 
132  if( tchscr_dev )
133  {
134  _io_ioctl(tchscr_dev, IO_IOCTL_TCHSCR_GET_RAW_LIMITS, &limit_struct);
135 
136 // *(&touchscreen_limits) = *(D4D_TOUCHSCREEN_LIMITS *)(&limit_struct);
137 
138  touchscreen_limits.rawDataScale = (unsigned short)limit_struct.FULL_SCALE;
139  touchscreen_limits.touchMinX = (unsigned short)limit_struct.X_TOUCH_MIN;
140  touchscreen_limits.touchMinY = (unsigned short)limit_struct.Y_TOUCH_MIN;
141  touchscreen_limits.touchOffMaxX = (unsigned short)limit_struct.X_TOUCH_MAX;
142  touchscreen_limits.touchOffMaxY = (unsigned short)limit_struct.Y_TOUCH_MAX;
143 
144  return( &touchscreen_limits );
145  }
146  return( NULL );
147 }
148 
149 //
150 //-----------------------------------------------------------------------------
151 // FUNCTION: LCD_GetTouchScreenPositionRaw
152 // SCOPE: Global
153 // DESCRIPTION: Reads touch screen and returns raw uncompensated X, Y
154 // coordinates if screen touched
155 // PARAMETERS: unsigned int *TouchPositionX Pointer to X coordinate
156 // unsigned int *TouchPositionY Pointer to Y ccordinate
157 // RETURNS: 0 no screen touch
158 // 1 screen touch,
159 //-----------------------------------------------------------------------------
160 //
161 static unsigned char D4DTCH_GetPositionRaw_Tchres_Mqx (unsigned short *TouchPositionX,
162  unsigned short *TouchPositionY)
163 {
164  TCHRES_POSITION_STRUCT position;
165 
166  if( tchscr_dev == NULL )
167  {
168  return 0;
169  }
170  if (ioctl(tchscr_dev, IO_IOCTL_TCHSCR_GET_POSITION_RAW, &position ) == TCHRES_OK)
171  {
172  *TouchPositionX = (unsigned short)position.X;
173  *TouchPositionY = (unsigned short)position.Y;
174  return 1;
175  }
176  else
177  {
178  return 0;
179  }
180 }
181 
182 #endif
unsigned short touchOffMaxX
Maximal valid raw value of axis X.
Definition: d4d_lldapi.h:110
D4D low level touch screen interface API structure.
Definition: d4d_lldapi.h:195
D4D Driver main header file.
unsigned short touchMinX
Minimal valid raw value of axis X.
Definition: d4d_lldapi.h:108
D4D Driver private header file.
unsigned short touchMinY
Minimal valid raw value of axis Y.
Definition: d4d_lldapi.h:109
D4D driver - resistive touch screen driver function header file.
D4D low level touch screen limitation structure.
Definition: d4d_lldapi.h:105
#define NULL
Type definition of null pointer.
Definition: d4d_types.h:184
unsigned short rawDataScale
The scale mask of ADC convertor.
Definition: d4d_lldapi.h:107
unsigned short touchOffMaxY
Maximal valid raw value of axis Y.
Definition: d4d_lldapi.h:111
D4D driver - resistive touch screen driver function header file.