Andrew Reed / Mbed OS CITY1082-i2c_master_wifi_mqtt
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers TOUCH_Sample.c Source File

TOUCH_Sample.c

00001 /*********************************************************************
00002 *                SEGGER Microcontroller GmbH                         *
00003 *        Solutions for real time microcontroller applications        *
00004 **********************************************************************
00005 *                                                                    *
00006 *        (c) 1996 - 2018  SEGGER Microcontroller GmbH                *
00007 *                                                                    *
00008 *        Internet: www.segger.com    Support:  support@segger.com    *
00009 *                                                                    *
00010 **********************************************************************
00011 
00012 ** emWin V5.48 - Graphical user interface for embedded applications **
00013 All  Intellectual Property rights  in the Software belongs to  SEGGER.
00014 emWin is protected by  international copyright laws.  Knowledge of the
00015 source code may not be used to write a similar product.  This file may
00016 only be used in accordance with the following terms:
00017 
00018 The software  has been licensed to  Cypress Semiconductor Corporation,
00019 whose registered  office is situated  at 198 Champion Ct. San Jose, CA 
00020 95134 USA  solely for the  purposes of creating  libraries for Cypress
00021 PSoC3 and  PSoC5 processor-based devices,  sublicensed and distributed
00022 under  the  terms  and  conditions  of  the  Cypress  End User License
00023 Agreement.
00024 Full source code is available at: www.segger.com
00025 
00026 We appreciate your understanding and fairness.
00027 ----------------------------------------------------------------------
00028 Licensing information
00029 Licensor:                 SEGGER Microcontroller Systems LLC
00030 Licensed to:              Cypress Semiconductor Corp, 198 Champion Ct., San Jose, CA 95134, USA
00031 Licensed SEGGER software: emWin
00032 License number:           GUI-00319
00033 License model:            Services and License Agreement, signed June 10th, 2009
00034 Licensed platform:        Any Cypress platform (Initial targets are: PSoC3, PSoC5)
00035 ----------------------------------------------------------------------
00036 Support and Update Agreement (SUA)
00037 SUA period:               2009-06-12 - 2022-07-27
00038 Contact to extend SUA:    sales@segger.com
00039 ----------------------------------------------------------------------
00040 File        : TOUCH_Sample.c
00041 Purpose     : Shows how to access a touch panel without using buttons
00042 Requirements: WindowManager - ( )
00043               MemoryDevices - ( )
00044               AntiAliasing  - ( )
00045               VNC-Server    - ( )
00046               PNG-Library   - ( )
00047               TrueTypeFonts - ( )
00048 ---------------------------END-OF-HEADER------------------------------
00049 */
00050 
00051 #include "GUI.h"
00052 
00053 /*********************************************************************
00054 *
00055 *       Defines
00056 *
00057 **********************************************************************
00058 */
00059 //
00060 // Recommended memory to run the sample with adequate performance
00061 //
00062 #define RECOMMENDED_MEMORY (1024L * 10)
00063 
00064 /*********************************************************************
00065 *
00066 *       Public code
00067 *
00068 **********************************************************************
00069 */
00070 /*********************************************************************
00071 *
00072 *       MainTask
00073 */
00074 void MainTask(void) {
00075   GUI_PID_STATE TouchState;
00076   int           xPhys;
00077   int           yPhys;
00078 
00079   GUI_Init();
00080   //
00081   // Check if recommended memory for the sample is available
00082   //
00083   if (GUI_ALLOC_GetNumFreeBytes() < RECOMMENDED_MEMORY) {
00084     GUI_ErrorOut("Not enough memory available."); 
00085     return;
00086   }
00087   GUI_CURSOR_Show();
00088   GUI_CURSOR_Select(&GUI_CursorCrossL);
00089   GUI_SetBkColor(GUI_WHITE);
00090   GUI_SetColor(GUI_BLACK);
00091   GUI_Clear();
00092   GUI_DispString("Measurement of\nA/D converter values");
00093   while (1) {
00094     GUI_TOUCH_GetState(&TouchState);  // Get the touch position in pixel
00095     xPhys = GUI_TOUCH_GetxPhys();     // Get the A/D mesurement result in x
00096     yPhys = GUI_TOUCH_GetyPhys();     // Get the A/D mesurement result in y
00097     //
00098     // Display the measurement result
00099     //
00100     GUI_SetColor(GUI_BLUE);
00101     GUI_DispStringAt("Analog input:\n", 0, 20);
00102     GUI_GotoY(GUI_GetDispPosY() + 2);
00103     GUI_DispString("x:");
00104     GUI_DispDec(xPhys, 4);
00105     GUI_DispString(", y:");
00106     GUI_DispDec(yPhys, 4);
00107     //
00108     // Display the according position
00109     //
00110     GUI_SetColor(GUI_RED);
00111     GUI_GotoY(GUI_GetDispPosY() + 4);
00112     GUI_DispString("\nPosition:\n");
00113     GUI_GotoY(GUI_GetDispPosY() + 2);
00114     GUI_DispString("x:");
00115     GUI_DispDec(TouchState.x,4);
00116     GUI_DispString(", y:");
00117     GUI_DispDec(TouchState.y,4);
00118     //
00119     // Wait a while
00120     //
00121     GUI_Delay(100);
00122   };
00123 }
00124 
00125 /*************************** End of file ****************************/
00126