RT1050 GUI demo using emWin library

Committer:
alejandroRL
Date:
Thu Sep 20 19:16:34 2018 +0000
Revision:
0:dd702039127a
emWin GUI Demo for RT1050

Who changed what in which revision?

UserRevisionLine numberNew contents of line
alejandroRL 0:dd702039127a 1 /*********************************************************************
alejandroRL 0:dd702039127a 2 * SEGGER Microcontroller GmbH & Co. KG *
alejandroRL 0:dd702039127a 3 * Solutions for real time microcontroller applications *
alejandroRL 0:dd702039127a 4 **********************************************************************
alejandroRL 0:dd702039127a 5 * *
alejandroRL 0:dd702039127a 6 * (c) 1996 - 2016 SEGGER Microcontroller GmbH & Co. KG *
alejandroRL 0:dd702039127a 7 * *
alejandroRL 0:dd702039127a 8 * Internet: www.segger.com Support: support@segger.com *
alejandroRL 0:dd702039127a 9 * *
alejandroRL 0:dd702039127a 10 **********************************************************************
alejandroRL 0:dd702039127a 11
alejandroRL 0:dd702039127a 12 ** emWin V5.38 - Graphical user interface for embedded applications **
alejandroRL 0:dd702039127a 13 All Intellectual Property rights in the Software belongs to SEGGER.
alejandroRL 0:dd702039127a 14 emWin is protected by international copyright laws. Knowledge of the
alejandroRL 0:dd702039127a 15 source code may not be used to write a similar product. This file may
alejandroRL 0:dd702039127a 16 only be used in accordance with the following terms:
alejandroRL 0:dd702039127a 17
alejandroRL 0:dd702039127a 18 The software has been licensed to NXP Semiconductors USA, Inc. whose
alejandroRL 0:dd702039127a 19 registered office is situated at 411 E. Plumeria Drive, San Jose,
alejandroRL 0:dd702039127a 20 CA 95134, USA solely for the purposes of creating libraries for
alejandroRL 0:dd702039127a 21 NXPs M0, M3/M4 and ARM7/9 processor-based devices, sublicensed and
alejandroRL 0:dd702039127a 22 distributed under the terms and conditions of the NXP End User License
alejandroRL 0:dd702039127a 23 Agreement.
alejandroRL 0:dd702039127a 24 Full source code is available at: www.segger.com
alejandroRL 0:dd702039127a 25
alejandroRL 0:dd702039127a 26 We appreciate your understanding and fairness.
alejandroRL 0:dd702039127a 27 ----------------------------------------------------------------------
alejandroRL 0:dd702039127a 28 Licensing information
alejandroRL 0:dd702039127a 29
alejandroRL 0:dd702039127a 30 Licensor: SEGGER Microcontroller Systems LLC
alejandroRL 0:dd702039127a 31 Licensed to: NXP Semiconductors, 1109 McKay Dr, M/S 76, San Jose, CA 95131, USA
alejandroRL 0:dd702039127a 32 Licensed SEGGER software: emWin
alejandroRL 0:dd702039127a 33 License number: GUI-00186
alejandroRL 0:dd702039127a 34 License model: emWin License Agreement, dated August 20th 2011
alejandroRL 0:dd702039127a 35 Licensed product: -
alejandroRL 0:dd702039127a 36 Licensed platform: NXP's ARM 7/9, Cortex-M0,M3,M4
alejandroRL 0:dd702039127a 37 Licensed number of seats: -
alejandroRL 0:dd702039127a 38 ----------------------------------------------------------------------
alejandroRL 0:dd702039127a 39 File : GUITDRV_ADS7846.h
alejandroRL 0:dd702039127a 40 Purpose : Touch screen driver include
alejandroRL 0:dd702039127a 41 ----------------------------------------------------------------------
alejandroRL 0:dd702039127a 42
alejandroRL 0:dd702039127a 43 Notes
alejandroRL 0:dd702039127a 44 =====
alejandroRL 0:dd702039127a 45 (1) The driver needs some function pointer to be filled correctly to be able
alejandroRL 0:dd702039127a 46 to communicate with the external peripheral correctly. The correct assignment
alejandroRL 0:dd702039127a 47 of these function pointers is checked during driver configuration.
alejandroRL 0:dd702039127a 48
alejandroRL 0:dd702039127a 49 (2) The driver needs some configuration variables filled in to be able to calculate
alejandroRL 0:dd702039127a 50 the logical screen coordinates from the physical AD values.
alejandroRL 0:dd702039127a 51 A description of the typical paramaters that have to be known by the driver is
alejandroRL 0:dd702039127a 52 listed below:
alejandroRL 0:dd702039127a 53 - Orientation: Orientation of the touch screen if not the same as the physical orientation.
alejandroRL 0:dd702039127a 54 A or-combination of the defines GUI_SWAP_XY, GUI_MIRROR_X and GUI_MIRROR_Y
alejandroRL 0:dd702039127a 55 can be used.
alejandroRL 0:dd702039127a 56 - xLog0 : Logical pixel value of horizontal reference point 0. Typically 0.
alejandroRL 0:dd702039127a 57 - xLog1 : Logical pixel value of horizontal reference point 1. Typically horizontal screen resolution -1.
alejandroRL 0:dd702039127a 58 - xPhys0 : Physical AD value of horizontal reference point 0.
alejandroRL 0:dd702039127a 59 - xPhys1 : Physical AD value of horizontal reference point 1.
alejandroRL 0:dd702039127a 60 - yLog0 : Logical pixel value of vertical reference point 0. Typically 0.
alejandroRL 0:dd702039127a 61 - yLog1 : Logical pixel value of vertical reference point 1. Typically vertical screen resolution -1.
alejandroRL 0:dd702039127a 62 - yPhys0 : Physical AD value of vertical reference point 0.
alejandroRL 0:dd702039127a 63 - yPhys1 : Physical AD value of vertical reference point 1.
alejandroRL 0:dd702039127a 64
alejandroRL 0:dd702039127a 65 (3) If the PENIRQ line of the touch controller is connected to a port of the target hardware
alejandroRL 0:dd702039127a 66 a touch event can be detected by the driver. Upon polling the driver's exec routine the
alejandroRL 0:dd702039127a 67 driver can check if a touch event is ready to be sampled by checking the PENIRQ line.
alejandroRL 0:dd702039127a 68 Without PENIRQ line the driver will always try to sample a touch event even if no touch
alejandroRL 0:dd702039127a 69 happened which will consume time even if not necessary.
alejandroRL 0:dd702039127a 70 Without PENIRQ it is the responsibility of the user's pfGetResult() routine to return
alejandroRL 0:dd702039127a 71 0xFFFF if the measured AD value is out of bounds.
alejandroRL 0:dd702039127a 72 If both, the PENIRQ and the touch pressure recognition are enabled first the PENIRQ will
alejandroRL 0:dd702039127a 73 signal that there is a touch event. Afterwards the touch pressure measurement is used to
alejandroRL 0:dd702039127a 74 confirm that this was a valid touch and the touch had enough pressure to deliver good
alejandroRL 0:dd702039127a 75 measurements.
alejandroRL 0:dd702039127a 76
alejandroRL 0:dd702039127a 77 (4) The touch pressure measurement is activated by setting a value for PressureMin and
alejandroRL 0:dd702039127a 78 PressureMax .
alejandroRL 0:dd702039127a 79 To calculate the correct touch pressure the resistance of the X-plate has to be known.
alejandroRL 0:dd702039127a 80 This can be set via PlateResistanceX [Ohm].
alejandroRL 0:dd702039127a 81 A touch event that we have measured with a pressure within these thresholds is confirmed
alejandroRL 0:dd702039127a 82 as valid touch event with good measurment samples.
alejandroRL 0:dd702039127a 83 If both, the PENIRQ and the touch pressure recognition are enabled first the PENIRQ will
alejandroRL 0:dd702039127a 84 signal that there is a touch event. Afterwards the touch pressure measurement is used to
alejandroRL 0:dd702039127a 85 confirm that this was a valid touch and the touch had enough pressure to deliver good
alejandroRL 0:dd702039127a 86 measurements.
alejandroRL 0:dd702039127a 87 If no PENIRQ line is connected this measurement takes place everytime the touch event is
alejandroRL 0:dd702039127a 88 polled regardless if there is a touch event or not as the driver will only know for sure
alejandroRL 0:dd702039127a 89 after calculating the touch pressure.
alejandroRL 0:dd702039127a 90 Setting the value for PlateResistanceX to 0 is invalid. The driver will internally use a
alejandroRL 0:dd702039127a 91 value of 1 instead.
alejandroRL 0:dd702039127a 92 */
alejandroRL 0:dd702039127a 93
alejandroRL 0:dd702039127a 94 #ifndef GUITDRV_ADS7846_H /* Make sure we only include it once */
alejandroRL 0:dd702039127a 95 #define GUITDRV_ADS7846_H
alejandroRL 0:dd702039127a 96
alejandroRL 0:dd702039127a 97 #include "GUI_Type.h"
alejandroRL 0:dd702039127a 98
alejandroRL 0:dd702039127a 99 #if defined(__cplusplus)
alejandroRL 0:dd702039127a 100 extern "C" { /* Make sure we have C-declarations in C++ programs */
alejandroRL 0:dd702039127a 101 #endif
alejandroRL 0:dd702039127a 102
alejandroRL 0:dd702039127a 103 /*********************************************************************
alejandroRL 0:dd702039127a 104 *
alejandroRL 0:dd702039127a 105 * Types
alejandroRL 0:dd702039127a 106 *
alejandroRL 0:dd702039127a 107 **********************************************************************
alejandroRL 0:dd702039127a 108 */
alejandroRL 0:dd702039127a 109
alejandroRL 0:dd702039127a 110 typedef struct {
alejandroRL 0:dd702039127a 111 //
alejandroRL 0:dd702039127a 112 // Function pointer (1)
alejandroRL 0:dd702039127a 113 //
alejandroRL 0:dd702039127a 114 void (* pfSendCmd) (U8 Data); // Sends a 8-bit command to the peripheral
alejandroRL 0:dd702039127a 115 U16 (* pfGetResult) (void); // Retrieves the result of the AD conversion. 4 dummy bytes have to be shifted out to the left.
alejandroRL 0:dd702039127a 116 char (* pfGetBusy) (void); // Retrieves the status of the busy line. 0: Not busy; 1: Busy
alejandroRL 0:dd702039127a 117 void (* pfSetCS) (char OnOff); // Set chip select line. OnOff == 1 means peripheral selected
alejandroRL 0:dd702039127a 118 //
alejandroRL 0:dd702039127a 119 // Configuration (2)
alejandroRL 0:dd702039127a 120 //
alejandroRL 0:dd702039127a 121 unsigned Orientation;
alejandroRL 0:dd702039127a 122 int xLog0;
alejandroRL 0:dd702039127a 123 int xLog1;
alejandroRL 0:dd702039127a 124 int xPhys0;
alejandroRL 0:dd702039127a 125 int xPhys1;
alejandroRL 0:dd702039127a 126 int yLog0;
alejandroRL 0:dd702039127a 127 int yLog1;
alejandroRL 0:dd702039127a 128 int yPhys0;
alejandroRL 0:dd702039127a 129 int yPhys1;
alejandroRL 0:dd702039127a 130 //
alejandroRL 0:dd702039127a 131 // Optional, touch recognition via PENIRQ line (3)
alejandroRL 0:dd702039127a 132 //
alejandroRL 0:dd702039127a 133 char (* pfGetPENIRQ) (void); // Retrieves the status of the PENIRQ line to detect a touch event.
alejandroRL 0:dd702039127a 134 //
alejandroRL 0:dd702039127a 135 // Optional, touch recognition via touch pressure measurement (4)
alejandroRL 0:dd702039127a 136 //
alejandroRL 0:dd702039127a 137 int PressureMin; // Minimum pressure threshold. A measured pressure below this value means we do not have a valid touch event.
alejandroRL 0:dd702039127a 138 int PressureMax; // Maximum pressure threshold. A measured pressure above this value means we do not have a valid touch event.
alejandroRL 0:dd702039127a 139 int PlateResistanceX; // Resistance of the X-plate of the touch screen. This value is needed for calculation of the touch pressure.
alejandroRL 0:dd702039127a 140 } GUITDRV_ADS7846_CONFIG;
alejandroRL 0:dd702039127a 141
alejandroRL 0:dd702039127a 142 typedef struct {
alejandroRL 0:dd702039127a 143 int xPhys; // Last measured x value
alejandroRL 0:dd702039127a 144 int yPhys; // Last measured y value
alejandroRL 0:dd702039127a 145 int z1Phys; // Last measured z1 value
alejandroRL 0:dd702039127a 146 int z2Phys; // Last measured z2 value
alejandroRL 0:dd702039127a 147 int PENIRQ; // Last sampled PENIRQ state if PENIRQ callback has been set
alejandroRL 0:dd702039127a 148 int Pressure; // Last measured touch pressure if touch pressure measurement is enabled
alejandroRL 0:dd702039127a 149 } GUITDRV_ADS7846_LAST_VAL;
alejandroRL 0:dd702039127a 150
alejandroRL 0:dd702039127a 151 /*********************************************************************
alejandroRL 0:dd702039127a 152 *
alejandroRL 0:dd702039127a 153 * Prototypes
alejandroRL 0:dd702039127a 154 *
alejandroRL 0:dd702039127a 155 **********************************************************************
alejandroRL 0:dd702039127a 156 */
alejandroRL 0:dd702039127a 157
alejandroRL 0:dd702039127a 158 void GUITDRV_ADS7846_Config (GUITDRV_ADS7846_CONFIG * pConfig);
alejandroRL 0:dd702039127a 159 char GUITDRV_ADS7846_Exec (void);
alejandroRL 0:dd702039127a 160 void GUITDRV_ADS7846_GetLastVal(GUITDRV_ADS7846_LAST_VAL * p);
alejandroRL 0:dd702039127a 161
alejandroRL 0:dd702039127a 162 #if defined(__cplusplus)
alejandroRL 0:dd702039127a 163 } /* Make sure we have C-declarations in C++ programs */
alejandroRL 0:dd702039127a 164 #endif
alejandroRL 0:dd702039127a 165
alejandroRL 0:dd702039127a 166
alejandroRL 0:dd702039127a 167 #endif /* GUITDRV_ADS7846_H */
alejandroRL 0:dd702039127a 168
alejandroRL 0:dd702039127a 169 /*************************** End of file ****************************/