Example that shows how to use emWin. This example is based on NXP's POS demo available at lpcware.com

Dependencies:   EALib ewgui mbed

Committer:
embeddedartists
Date:
Mon Apr 14 08:40:59 2014 +0000
Revision:
2:cbf00ac63f35
Parent:
0:2052561807c5
Updated to use latest ewgui

Who changed what in which revision?

UserRevisionLine numberNew contents of line
embeddedartists 0:2052561807c5 1 /*********************************************************************
embeddedartists 0:2052561807c5 2 * *
embeddedartists 0:2052561807c5 3 * SEGGER Microcontroller GmbH & Co. KG *
embeddedartists 0:2052561807c5 4 * Solutions for real time microcontroller applications *
embeddedartists 0:2052561807c5 5 * *
embeddedartists 0:2052561807c5 6 **********************************************************************
embeddedartists 0:2052561807c5 7 * *
embeddedartists 0:2052561807c5 8 * C-file generated by: *
embeddedartists 0:2052561807c5 9 * *
embeddedartists 0:2052561807c5 10 * GUI_Builder for emWin version 5.14 *
embeddedartists 0:2052561807c5 11 * Compiled Jan 12 2012, 10:28:50 *
embeddedartists 0:2052561807c5 12 * (c) 2011 Segger Microcontroller GmbH & Co. KG *
embeddedartists 0:2052561807c5 13 * *
embeddedartists 0:2052561807c5 14 **********************************************************************
embeddedartists 0:2052561807c5 15 * *
embeddedartists 0:2052561807c5 16 * Internet: www.segger.com Support: support@segger.com *
embeddedartists 0:2052561807c5 17 * *
embeddedartists 0:2052561807c5 18 **********************************************************************
embeddedartists 0:2052561807c5 19 */
embeddedartists 0:2052561807c5 20
embeddedartists 0:2052561807c5 21 // USER START (Optionally insert additional includes)
embeddedartists 0:2052561807c5 22 #include "DIALOG.h"
embeddedartists 0:2052561807c5 23 #include "BlueboardPOS.h"
embeddedartists 0:2052561807c5 24 #include <stdio.h>
embeddedartists 0:2052561807c5 25 // USER END
embeddedartists 0:2052561807c5 26
embeddedartists 0:2052561807c5 27
embeddedartists 0:2052561807c5 28
embeddedartists 0:2052561807c5 29 /*********************************************************************
embeddedartists 0:2052561807c5 30 *
embeddedartists 0:2052561807c5 31 * Defines
embeddedartists 0:2052561807c5 32 *
embeddedartists 0:2052561807c5 33 **********************************************************************
embeddedartists 0:2052561807c5 34 */
embeddedartists 0:2052561807c5 35
embeddedartists 0:2052561807c5 36 #define ID_FRAMEWIN_0 (GUI_ID_USER + 0x00)
embeddedartists 0:2052561807c5 37 #define ID_BUTTON_0 (GUI_ID_USER + 0x01)
embeddedartists 0:2052561807c5 38 #define ID_TEXT_0 (GUI_ID_USER + 0x02)
embeddedartists 0:2052561807c5 39
embeddedartists 0:2052561807c5 40 // USER START (Optionally insert additional defines)
embeddedartists 0:2052561807c5 41 // USER END
embeddedartists 0:2052561807c5 42
embeddedartists 0:2052561807c5 43 /*********************************************************************
embeddedartists 0:2052561807c5 44 *
embeddedartists 0:2052561807c5 45 * Static data
embeddedartists 0:2052561807c5 46 *
embeddedartists 0:2052561807c5 47 **********************************************************************
embeddedartists 0:2052561807c5 48 */
embeddedartists 0:2052561807c5 49
embeddedartists 0:2052561807c5 50 // USER START (Optionally insert additional static data)
embeddedartists 0:2052561807c5 51 // USER END
embeddedartists 0:2052561807c5 52
embeddedartists 0:2052561807c5 53 /*********************************************************************
embeddedartists 0:2052561807c5 54 *
embeddedartists 0:2052561807c5 55 * _aDialogCreate
embeddedartists 0:2052561807c5 56 */
embeddedartists 0:2052561807c5 57 static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
embeddedartists 0:2052561807c5 58 { FRAMEWIN_CreateIndirect, "SwipeCard", ID_FRAMEWIN_0, 100, 75, 400, 155, 0, 100, 0 },
embeddedartists 0:2052561807c5 59 { BUTTON_CreateIndirect, "CancelButton", ID_BUTTON_0, 160, 70, 80, 40, 0, 0, 0 },
embeddedartists 0:2052561807c5 60 { TEXT_CreateIndirect, "Text", ID_TEXT_0, 0, 15, 390, 50, 0, 100, 0 },
embeddedartists 0:2052561807c5 61 // USER START (Optionally insert additional widgets)
embeddedartists 0:2052561807c5 62 // USER END
embeddedartists 0:2052561807c5 63 };
embeddedartists 0:2052561807c5 64
embeddedartists 0:2052561807c5 65 /*********************************************************************
embeddedartists 0:2052561807c5 66 *
embeddedartists 0:2052561807c5 67 * Static code
embeddedartists 0:2052561807c5 68 *
embeddedartists 0:2052561807c5 69 **********************************************************************
embeddedartists 0:2052561807c5 70 */
embeddedartists 0:2052561807c5 71
embeddedartists 0:2052561807c5 72 // USER START (Optionally insert additional static code)
embeddedartists 0:2052561807c5 73 // USER END
embeddedartists 0:2052561807c5 74
embeddedartists 0:2052561807c5 75 /*********************************************************************
embeddedartists 0:2052561807c5 76 *
embeddedartists 0:2052561807c5 77 * _cbDialog
embeddedartists 0:2052561807c5 78 */
embeddedartists 0:2052561807c5 79 static void _cbDialog(WM_MESSAGE * pMsg) {
embeddedartists 0:2052561807c5 80 WM_HWIN hItem;
embeddedartists 0:2052561807c5 81 int Id, NCode;
embeddedartists 0:2052561807c5 82 // USER START (Optionally insert additional variables)
embeddedartists 0:2052561807c5 83 // USER END
embeddedartists 0:2052561807c5 84
embeddedartists 0:2052561807c5 85 switch (pMsg->MsgId) {
embeddedartists 0:2052561807c5 86 case WM_INIT_DIALOG:
embeddedartists 0:2052561807c5 87 //
embeddedartists 0:2052561807c5 88 // Initialization of 'SwipeCard'
embeddedartists 0:2052561807c5 89 //
embeddedartists 0:2052561807c5 90 hItem = pMsg->hWin;
embeddedartists 0:2052561807c5 91 FRAMEWIN_SetText(hItem, "");
embeddedartists 0:2052561807c5 92 //
embeddedartists 0:2052561807c5 93 // Initialization of 'CancelButton'
embeddedartists 0:2052561807c5 94 //
embeddedartists 0:2052561807c5 95 hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0);
embeddedartists 0:2052561807c5 96 BUTTON_SetText(hItem, "Cancel");
embeddedartists 0:2052561807c5 97 //
embeddedartists 0:2052561807c5 98 // Initialization of 'Text'
embeddedartists 0:2052561807c5 99 //
embeddedartists 0:2052561807c5 100 hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
embeddedartists 0:2052561807c5 101 TEXT_SetText(hItem, "Swipe Card ...");
embeddedartists 0:2052561807c5 102 TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
embeddedartists 0:2052561807c5 103 TEXT_SetFont(hItem, GUI_FONT_32B_ASCII);
embeddedartists 0:2052561807c5 104 // USER START (Optionally insert additional code for further widget initialization)
embeddedartists 0:2052561807c5 105 // USER END
embeddedartists 0:2052561807c5 106 break;
embeddedartists 0:2052561807c5 107 case WM_NOTIFY_PARENT:
embeddedartists 0:2052561807c5 108 Id = WM_GetId(pMsg->hWinSrc);
embeddedartists 0:2052561807c5 109 NCode = pMsg->Data.v;
embeddedartists 0:2052561807c5 110 switch(Id) {
embeddedartists 0:2052561807c5 111 case ID_BUTTON_0: // Notifications sent by 'CancelButton'
embeddedartists 0:2052561807c5 112 switch(NCode) {
embeddedartists 0:2052561807c5 113 case WM_NOTIFICATION_CLICKED:
embeddedartists 0:2052561807c5 114 // USER START (Optionally insert code for reacting on notification message)
embeddedartists 0:2052561807c5 115 // USER END
embeddedartists 0:2052561807c5 116 break;
embeddedartists 0:2052561807c5 117 case WM_NOTIFICATION_RELEASED:
embeddedartists 0:2052561807c5 118 // USER START (Optionally insert code for reacting on notification message)
embeddedartists 0:2052561807c5 119 RFID_Cancelled = 1;
embeddedartists 0:2052561807c5 120 FRAMEWIN_SetClientColor(hWinSwipeCard, GUI_LIGHTGRAY);
embeddedartists 0:2052561807c5 121 hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
embeddedartists 0:2052561807c5 122 TEXT_SetText(hItem, "Swipe Card ...");
embeddedartists 0:2052561807c5 123 hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0);
embeddedartists 0:2052561807c5 124 BUTTON_SetText(hItem, "Cancel");
embeddedartists 0:2052561807c5 125 ShowLastWindow();
embeddedartists 0:2052561807c5 126 // USER END
embeddedartists 0:2052561807c5 127 break;
embeddedartists 0:2052561807c5 128 // USER START (Optionally insert additional code for further notification handling)
embeddedartists 0:2052561807c5 129 // USER END
embeddedartists 0:2052561807c5 130 }
embeddedartists 0:2052561807c5 131 break;
embeddedartists 0:2052561807c5 132 // USER START (Optionally insert additional code for further Ids)
embeddedartists 0:2052561807c5 133 // USER END
embeddedartists 0:2052561807c5 134 }
embeddedartists 0:2052561807c5 135 break;
embeddedartists 0:2052561807c5 136 // USER START (Optionally insert additional message handling)
embeddedartists 0:2052561807c5 137 // USER END
embeddedartists 0:2052561807c5 138 default:
embeddedartists 0:2052561807c5 139 WM_DefaultProc(pMsg);
embeddedartists 0:2052561807c5 140 break;
embeddedartists 0:2052561807c5 141 }
embeddedartists 0:2052561807c5 142 }
embeddedartists 0:2052561807c5 143
embeddedartists 0:2052561807c5 144 /*********************************************************************
embeddedartists 0:2052561807c5 145 *
embeddedartists 0:2052561807c5 146 * Public code
embeddedartists 0:2052561807c5 147 *
embeddedartists 0:2052561807c5 148 **********************************************************************
embeddedartists 0:2052561807c5 149 */
embeddedartists 0:2052561807c5 150 /*********************************************************************
embeddedartists 0:2052561807c5 151 *
embeddedartists 0:2052561807c5 152 * CreateSwipeCard
embeddedartists 0:2052561807c5 153 */
embeddedartists 0:2052561807c5 154 WM_HWIN CreateSwipeCard(void);
embeddedartists 0:2052561807c5 155 WM_HWIN CreateSwipeCard(void) {
embeddedartists 0:2052561807c5 156 WM_HWIN hWin;
embeddedartists 0:2052561807c5 157
embeddedartists 0:2052561807c5 158 hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), &_cbDialog, WM_HBKWIN, 100, 75);
embeddedartists 0:2052561807c5 159 return hWin;
embeddedartists 0:2052561807c5 160 }
embeddedartists 0:2052561807c5 161
embeddedartists 0:2052561807c5 162 // USER START (Optionally insert additional public code)
embeddedartists 0:2052561807c5 163 void Callback(WM_MESSAGE * pMsg);
embeddedartists 0:2052561807c5 164 void Callback(WM_MESSAGE * pMsg)
embeddedartists 0:2052561807c5 165 {
embeddedartists 0:2052561807c5 166 WM_HWIN hItem;
embeddedartists 0:2052561807c5 167 char string[20];
embeddedartists 0:2052561807c5 168
embeddedartists 0:2052561807c5 169 switch (pMsg->MsgId) {
embeddedartists 0:2052561807c5 170 case WM_USER_RFID_Load_OK:
embeddedartists 0:2052561807c5 171 sprintf(string, "Credit: $%d.%02d", Credit/100, Credit%100);
embeddedartists 0:2052561807c5 172 FRAMEWIN_SetClientColor(hWinSwipeCard, GUI_GREEN);
embeddedartists 0:2052561807c5 173 TEXT_SetText(pMsg->hWin, string);
embeddedartists 0:2052561807c5 174 hItem = WM_GetDialogItem(hWinSwipeCard, ID_BUTTON_0);
embeddedartists 0:2052561807c5 175 BUTTON_SetText(hItem, "OK");
embeddedartists 0:2052561807c5 176 break;
embeddedartists 0:2052561807c5 177 case WM_USER_RFID_Store_OK:
embeddedartists 0:2052561807c5 178 FRAMEWIN_SetClientColor(hWinSwipeCard, GUI_GREEN);
embeddedartists 0:2052561807c5 179 TEXT_SetText(pMsg->hWin, "Checkout successful!");
embeddedartists 0:2052561807c5 180 hItem = WM_GetDialogItem(hWinSwipeCard, ID_BUTTON_0);
embeddedartists 0:2052561807c5 181 BUTTON_SetText(hItem, "OK");
embeddedartists 0:2052561807c5 182 break;
embeddedartists 0:2052561807c5 183 case WM_USER_RFID_Credit_Low:
embeddedartists 0:2052561807c5 184 FRAMEWIN_SetClientColor(hWinSwipeCard, GUI_RED);
embeddedartists 0:2052561807c5 185 TEXT_SetText(pMsg->hWin, "Insufficient credit!");
embeddedartists 0:2052561807c5 186 hItem = WM_GetDialogItem(hWinSwipeCard, ID_BUTTON_0);
embeddedartists 0:2052561807c5 187 BUTTON_SetText(hItem, "OK");
embeddedartists 0:2052561807c5 188 break;
embeddedartists 0:2052561807c5 189 case WM_USER_RFID_Error:
embeddedartists 0:2052561807c5 190 FRAMEWIN_SetClientColor(hWinSwipeCard, GUI_RED);
embeddedartists 0:2052561807c5 191 TEXT_SetText(pMsg->hWin, "Error!");
embeddedartists 0:2052561807c5 192 hItem = WM_GetDialogItem(hWinSwipeCard, ID_BUTTON_0);
embeddedartists 0:2052561807c5 193 BUTTON_SetText(hItem, "OK");
embeddedartists 0:2052561807c5 194 break;
embeddedartists 0:2052561807c5 195 case WM_USER_RFID_Reset_OK:
embeddedartists 0:2052561807c5 196 FRAMEWIN_SetClientColor(hWinSwipeCard, GUI_GREEN);
embeddedartists 0:2052561807c5 197 TEXT_SetText(pMsg->hWin, "Card initialized at $0");
embeddedartists 0:2052561807c5 198 hItem = WM_GetDialogItem(hWinSwipeCard, ID_BUTTON_0);
embeddedartists 0:2052561807c5 199 BUTTON_SetText(hItem, "OK");
embeddedartists 0:2052561807c5 200 break;
embeddedartists 0:2052561807c5 201 case WM_USER_RFID_Increment_OK:
embeddedartists 0:2052561807c5 202 FRAMEWIN_SetClientColor(hWinSwipeCard, GUI_GREEN);
embeddedartists 0:2052561807c5 203 TEXT_SetText(pMsg->hWin, "+$10");
embeddedartists 0:2052561807c5 204 hItem = WM_GetDialogItem(hWinSwipeCard, ID_BUTTON_0);
embeddedartists 0:2052561807c5 205 BUTTON_SetText(hItem, "OK");
embeddedartists 0:2052561807c5 206 break;
embeddedartists 0:2052561807c5 207 case WM_USER_RFID_Swipe:
embeddedartists 0:2052561807c5 208 FRAMEWIN_SetClientColor(hWinSwipeCard, GUI_LIGHTGRAY);
embeddedartists 0:2052561807c5 209 TEXT_SetText(pMsg->hWin, "Swipe Card ...");
embeddedartists 0:2052561807c5 210 hItem = WM_GetDialogItem(hWinSwipeCard, ID_BUTTON_0);
embeddedartists 0:2052561807c5 211 BUTTON_SetText(hItem, "Cancel");
embeddedartists 0:2052561807c5 212 break;
embeddedartists 0:2052561807c5 213 case WM_USER_RFID_INIT_ERR:
embeddedartists 0:2052561807c5 214 FRAMEWIN_SetClientColor(hWinSwipeCard, GUI_RED);
embeddedartists 0:2052561807c5 215 TEXT_SetText(pMsg->hWin, "Error initializing CLRC663!");
embeddedartists 0:2052561807c5 216 hItem = WM_GetDialogItem(hWinSwipeCard, ID_BUTTON_0);
embeddedartists 0:2052561807c5 217 BUTTON_SetText(hItem, "OK");
embeddedartists 0:2052561807c5 218 break;
embeddedartists 0:2052561807c5 219 default:
embeddedartists 0:2052561807c5 220 TEXT_Callback(pMsg);
embeddedartists 0:2052561807c5 221 }
embeddedartists 0:2052561807c5 222 }
embeddedartists 0:2052561807c5 223
embeddedartists 0:2052561807c5 224 WM_HWIN GetCallbackHandle(void);
embeddedartists 0:2052561807c5 225 WM_HWIN GetCallbackHandle(void)
embeddedartists 0:2052561807c5 226 {
embeddedartists 0:2052561807c5 227 WM_HWIN hItem;
embeddedartists 0:2052561807c5 228
embeddedartists 0:2052561807c5 229 hItem = WM_GetDialogItem(hWinSwipeCard, ID_TEXT_0);
embeddedartists 0:2052561807c5 230 WM_SetCallback(hItem, Callback);
embeddedartists 0:2052561807c5 231 return hItem;
embeddedartists 0:2052561807c5 232 }
embeddedartists 0:2052561807c5 233 // USER END
embeddedartists 0:2052561807c5 234
embeddedartists 0:2052561807c5 235 /*************************** End of file ****************************/