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

« Back to documentation index

Show/hide line numbers VSCREEN_MultiPage.c Source File

VSCREEN_MultiPage.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        : MainTask.c
00041 Purpose     : Main program, called from after main after initialisation
00042 Requirements: WindowManager - (x)
00043               MemoryDevices - (x)
00044               AntiAliasing  - ( )
00045               VNC-Server    - ( )
00046               PNG-Library   - ( )
00047               TrueTypeFonts - ( )
00048 ---------------------------END-OF-HEADER------------------------------
00049 */
00050 
00051 #include <stddef.h>
00052 #include "GUI.h"
00053 #include "DIALOG.h"
00054 #include "Main.h"
00055 #include "LCDConf.h"
00056 
00057 /*********************************************************************
00058 *
00059 *       Dialog IDs
00060 */
00061 #define ID_BUTTON_SETUP          1
00062 #define ID_BUTTON_CALIBRATION    2
00063 #define ID_BUTTON_ABOUT          3
00064 
00065 //
00066 // Recommended memory to run the sample with adequate performance
00067 //
00068 #define RECOMMENDED_MEMORY (1024L * 20)
00069 
00070 /*********************************************************************
00071 *
00072 *       Static data
00073 *
00074 **********************************************************************
00075 */
00076 /*********************************************************************
00077 *
00078 *       Dialog resource
00079 *
00080 * This table conatins the info required to create the dialog.
00081 * It has been created manually, but could also be created by a GUI-builder.
00082 */
00083 static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
00084   { FRAMEWIN_CreateIndirect, "Main Screen", 0,                       0,   0, 320, 240, 0},
00085   { BUTTON_CreateIndirect,   "Setup",       ID_BUTTON_SETUP,       230,  80,  60,  20 },
00086   { BUTTON_CreateIndirect,   "Calibration", ID_BUTTON_CALIBRATION, 230, 110,  60,  20 },
00087   { BUTTON_CreateIndirect,   "About",       ID_BUTTON_ABOUT,       230, 140,  60,  20 },
00088 };
00089 
00090 /*********************************************************************
00091 *
00092 *       Static code
00093 *
00094 **********************************************************************
00095 */
00096 /*********************************************************************
00097 *
00098 *       _cbCallback
00099 */
00100 static void _cbCallback(WM_MESSAGE * pMsg) {
00101   WM_HWIN hDlg;
00102   WM_HWIN hWinSrc;
00103   int Id;
00104   int NCode;
00105 
00106   hWinSrc = pMsg->hWinSrc;
00107   hDlg = pMsg->hWin;
00108   switch (pMsg->MsgId) {
00109   case WM_PAINT:
00110     GUI_SetColor(GUI_BLACK);
00111     GUI_DrawBitmap(&bmLogoBitmap, 30, 80);
00112     GUI_SetFont(&GUI_Font24B_ASCII);
00113     GUI_SetFont(&GUI_Font16B_ASCII);
00114     GUI_DispStringHCenterAt("www.segger.com", 30 + bmLogoBitmap.XSize / 2, 80 + bmLogoBitmap.YSize);
00115     GUI_DispStringHCenterAt("Virtual screen sample", 160, 20);
00116     break;
00117   case WM_INIT_DIALOG:
00118     FRAMEWIN_SetFont(hDlg, &GUI_Font24B_ASCII);
00119     FRAMEWIN_SetTextAlign(hDlg, GUI_TA_HCENTER);
00120     break;
00121   case WM_NOTIFY_PARENT:
00122     Id    = WM_GetId(hWinSrc);      /* Id of widget */
00123     NCode = pMsg->Data.v;           /* Notification code */
00124     switch (NCode) {
00125     case WM_NOTIFICATION_RELEASED:
00126       switch (Id) {
00127       case ID_BUTTON_SETUP:
00128         ExecSetup();
00129         break;
00130       case ID_BUTTON_CALIBRATION:
00131         ExecCalibration();
00132         break;
00133       case ID_BUTTON_ABOUT:
00134         ExecAbout();
00135         break;
00136       }
00137       break;
00138     }
00139     break;
00140   default:
00141     WM_DefaultProc(pMsg);
00142   }
00143 }
00144 
00145 /*********************************************************************
00146 *
00147 *       Public code
00148 *
00149 **********************************************************************
00150 */
00151 /*********************************************************************
00152 *
00153 *       MainTask
00154 */
00155 void MainTask(void);
00156 void MainTask(void) {
00157   int XSize;
00158   int YSize;
00159 
00160   #if GUI_SUPPORT_MEMDEV
00161     WM_SetCreateFlags(WM_CF_MEMDEV);
00162   #endif
00163   GUI_Init();
00164   //
00165   // Check if recommended memory for the sample is available
00166   //
00167   if (GUI_ALLOC_GetNumFreeBytes() < RECOMMENDED_MEMORY) {
00168     GUI_ErrorOut("Not enough memory available."); 
00169     return;
00170   }
00171   XSize = LCD_GetXSize();
00172   YSize = LCD_GetYSize();
00173   GUI_DrawBitmap(&bmLogoBitmap, (XSize - bmLogoBitmap.XSize) / 2, (YSize - bmLogoBitmap.YSize) / 3);
00174   GUI_SetFont(&GUI_Font24B_ASCII);
00175   GUI_DispStringHCenterAt("www.segger.com", XSize / 2, (YSize - bmLogoBitmap.YSize) / 3 + bmLogoBitmap.YSize + 10);
00176   GUI_Delay(1000);
00177   WM_SetDesktopColor(GUI_BLACK); /* Not required since desktop is not visible */
00178   GUI_ExecDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), &_cbCallback, 0, 0, 0);
00179 }
00180 
00181 /*************************** End of file ****************************/
00182