Example that shows how to use emWin. This example is based on NXP's POS demo available at lpcware.com
Dependencies: EALib ewgui mbed
Project_BlueboardPOS.cpp@0:2052561807c5, 2013-12-16 (annotated)
- Committer:
- embeddedartists
- Date:
- Mon Dec 16 10:58:05 2013 +0000
- Revision:
- 0:2052561807c5
First commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
embeddedartists | 0:2052561807c5 | 1 | /********************************************************************* |
embeddedartists | 0:2052561807c5 | 2 | * SEGGER MICROCONTROLLER GmbH & Co. KG * |
embeddedartists | 0:2052561807c5 | 3 | * Solutions for real time microcontroller applications * |
embeddedartists | 0:2052561807c5 | 4 | ********************************************************************** |
embeddedartists | 0:2052561807c5 | 5 | * * |
embeddedartists | 0:2052561807c5 | 6 | * (c) 2003-2012 SEGGER Microcontroller GmbH & Co KG * |
embeddedartists | 0:2052561807c5 | 7 | * * |
embeddedartists | 0:2052561807c5 | 8 | * Internet: www.segger.com Support: support@segger.com * |
embeddedartists | 0:2052561807c5 | 9 | * * |
embeddedartists | 0:2052561807c5 | 10 | ********************************************************************** |
embeddedartists | 0:2052561807c5 | 11 | |
embeddedartists | 0:2052561807c5 | 12 | ---------------------------------------------------------------------- |
embeddedartists | 0:2052561807c5 | 13 | File : Main.c |
embeddedartists | 0:2052561807c5 | 14 | Purpose : Calls hardware initialization and application. |
embeddedartists | 0:2052561807c5 | 15 | -------- END-OF-HEADER --------------------------------------------- |
embeddedartists | 0:2052561807c5 | 16 | */ |
embeddedartists | 0:2052561807c5 | 17 | #include <stdio.h> |
embeddedartists | 0:2052561807c5 | 18 | #ifndef _WINDOWS |
embeddedartists | 0:2052561807c5 | 19 | //AR #include "lpc_i2c.h" |
embeddedartists | 0:2052561807c5 | 20 | //AR #include "lpc_pinsel.h" |
embeddedartists | 0:2052561807c5 | 21 | //AR #include "CLRC663.h" |
embeddedartists | 0:2052561807c5 | 22 | #endif |
embeddedartists | 0:2052561807c5 | 23 | #include "emwin/DIALOG.h" |
embeddedartists | 0:2052561807c5 | 24 | #include "BlueboardPOS.h" |
embeddedartists | 0:2052561807c5 | 25 | #include <stdlib.h> |
embeddedartists | 0:2052561807c5 | 26 | |
embeddedartists | 0:2052561807c5 | 27 | #ifdef __CROSSWORKS_ARM |
embeddedartists | 0:2052561807c5 | 28 | extern void __low_level_init(); // hwconf.c |
embeddedartists | 0:2052561807c5 | 29 | #endif |
embeddedartists | 0:2052561807c5 | 30 | |
embeddedartists | 0:2052561807c5 | 31 | WM_HWIN hWinOrderEntry; /* Main dialog */ |
embeddedartists | 0:2052561807c5 | 32 | WM_HWIN hWinSwipeCard; /* Dialog display when user must swipe Mifare card */ |
embeddedartists | 0:2052561807c5 | 33 | WM_HWIN hWinLastWindow; /* Saves which windows was displayed last */ |
embeddedartists | 0:2052561807c5 | 34 | WM_HWIN hWinCurrentWindow; /* Current displayed window */ |
embeddedartists | 0:2052561807c5 | 35 | WM_HWIN hWinCallBack; /* Used for callback */ |
embeddedartists | 0:2052561807c5 | 36 | |
embeddedartists | 0:2052561807c5 | 37 | uint32_t Credit; /* Credit on card */ |
embeddedartists | 0:2052561807c5 | 38 | uint8_t RFID_Cancelled; /* Flag, set it user hit Cancel button of SwipeCard dialog before card was swiped */ |
embeddedartists | 0:2052561807c5 | 39 | |
embeddedartists | 0:2052561807c5 | 40 | void ShowWindow(WM_HWIN window) |
embeddedartists | 0:2052561807c5 | 41 | { |
embeddedartists | 0:2052561807c5 | 42 | hWinLastWindow = hWinCurrentWindow; |
embeddedartists | 0:2052561807c5 | 43 | hWinCurrentWindow = window; |
embeddedartists | 0:2052561807c5 | 44 | |
embeddedartists | 0:2052561807c5 | 45 | WM_HideWindow(hWinOrderEntry); |
embeddedartists | 0:2052561807c5 | 46 | WM_HideWindow(hWinSwipeCard); |
embeddedartists | 0:2052561807c5 | 47 | WM_ShowWindow(window); |
embeddedartists | 0:2052561807c5 | 48 | } |
embeddedartists | 0:2052561807c5 | 49 | |
embeddedartists | 0:2052561807c5 | 50 | void ShowLastWindow(void) |
embeddedartists | 0:2052561807c5 | 51 | { |
embeddedartists | 0:2052561807c5 | 52 | ShowWindow(hWinLastWindow); |
embeddedartists | 0:2052561807c5 | 53 | } |
embeddedartists | 0:2052561807c5 | 54 | |
embeddedartists | 0:2052561807c5 | 55 | void MainTask(void); // Defined in SEGGERDEMO.c |
embeddedartists | 0:2052561807c5 | 56 | void displayTotal(WM_HWIN hWin); |
embeddedartists | 0:2052561807c5 | 57 | WM_HWIN GetCallbackHandle(void); |
embeddedartists | 0:2052561807c5 | 58 | |
embeddedartists | 0:2052561807c5 | 59 | |
embeddedartists | 0:2052561807c5 | 60 | /********************************************************************* |
embeddedartists | 0:2052561807c5 | 61 | * |
embeddedartists | 0:2052561807c5 | 62 | * main() |
embeddedartists | 0:2052561807c5 | 63 | */ |
embeddedartists | 0:2052561807c5 | 64 | void MainTask(void); |
embeddedartists | 0:2052561807c5 | 65 | void MainTask(void) |
embeddedartists | 0:2052561807c5 | 66 | { |
embeddedartists | 0:2052561807c5 | 67 | uint32_t Buttons; |
embeddedartists | 0:2052561807c5 | 68 | uint32_t PrevButtons = 0; |
embeddedartists | 0:2052561807c5 | 69 | uint32_t IncVal = 1000; |
embeddedartists | 0:2052561807c5 | 70 | uint32_t InitVal = 0; |
embeddedartists | 0:2052561807c5 | 71 | |
embeddedartists | 0:2052561807c5 | 72 | GUI_Init(); |
embeddedartists | 0:2052561807c5 | 73 | |
embeddedartists | 0:2052561807c5 | 74 | /* Set skinning */ |
embeddedartists | 0:2052561807c5 | 75 | BUTTON_SetDefaultSkin (BUTTON_SKIN_FLEX); |
embeddedartists | 0:2052561807c5 | 76 | CHECKBOX_SetDefaultSkin (CHECKBOX_SKIN_FLEX); |
embeddedartists | 0:2052561807c5 | 77 | DROPDOWN_SetDefaultSkin (DROPDOWN_SKIN_FLEX); |
embeddedartists | 0:2052561807c5 | 78 | FRAMEWIN_SetDefaultSkin (FRAMEWIN_SKIN_FLEX); |
embeddedartists | 0:2052561807c5 | 79 | HEADER_SetDefaultSkin (HEADER_SKIN_FLEX); |
embeddedartists | 0:2052561807c5 | 80 | PROGBAR_SetDefaultSkin (PROGBAR_SKIN_FLEX); |
embeddedartists | 0:2052561807c5 | 81 | RADIO_SetDefaultSkin (RADIO_SKIN_FLEX); |
embeddedartists | 0:2052561807c5 | 82 | SCROLLBAR_SetDefaultSkin(SCROLLBAR_SKIN_FLEX); |
embeddedartists | 0:2052561807c5 | 83 | SLIDER_SetDefaultSkin (SLIDER_SKIN_FLEX); |
embeddedartists | 0:2052561807c5 | 84 | // |
embeddedartists | 0:2052561807c5 | 85 | // Set some further defaults |
embeddedartists | 0:2052561807c5 | 86 | // |
embeddedartists | 0:2052561807c5 | 87 | WIDGET_SetDefaultEffect(&WIDGET_Effect_3D); |
embeddedartists | 0:2052561807c5 | 88 | FRAMEWIN_SetDefaultFont(GUI_FONT_20_ASCII); |
embeddedartists | 0:2052561807c5 | 89 | FRAMEWIN_SetDefaultTextAlign(GUI_TA_HCENTER); |
embeddedartists | 0:2052561807c5 | 90 | |
embeddedartists | 0:2052561807c5 | 91 | /* Create windows */ |
embeddedartists | 0:2052561807c5 | 92 | hWinOrderEntry = CreateOrderEntry(); |
embeddedartists | 0:2052561807c5 | 93 | hWinSwipeCard = CreateSwipeCard(); |
embeddedartists | 0:2052561807c5 | 94 | WM_EnableMemdev(hWinOrderEntry); |
embeddedartists | 0:2052561807c5 | 95 | hWinCallBack = GetCallbackHandle(); |
embeddedartists | 0:2052561807c5 | 96 | |
embeddedartists | 0:2052561807c5 | 97 | ShowWindow(hWinOrderEntry); |
embeddedartists | 0:2052561807c5 | 98 | |
embeddedartists | 0:2052561807c5 | 99 | #if 0 // AR |
embeddedartists | 0:2052561807c5 | 100 | |
embeddedartists | 0:2052561807c5 | 101 | #ifndef _WINDOWS |
embeddedartists | 0:2052561807c5 | 102 | if(InitCLRC663()) |
embeddedartists | 0:2052561807c5 | 103 | { |
embeddedartists | 0:2052561807c5 | 104 | WM_SendMessageNoPara(hWinCallBack, WM_USER_RFID_INIT_ERR); |
embeddedartists | 0:2052561807c5 | 105 | ShowWindow(hWinSwipeCard); |
embeddedartists | 0:2052561807c5 | 106 | } |
embeddedartists | 0:2052561807c5 | 107 | #endif /* _WINDOWS */ |
embeddedartists | 0:2052561807c5 | 108 | while(1) { |
embeddedartists | 0:2052561807c5 | 109 | #ifndef _WINDOWS |
embeddedartists | 0:2052561807c5 | 110 | /* Check if any of the joystick buttons has been pressed */ |
embeddedartists | 0:2052561807c5 | 111 | Buttons = LPC_GPIO2->PIN; |
embeddedartists | 0:2052561807c5 | 112 | if(!(Buttons & (1<<22)) && (PrevButtons & (1<<22))) |
embeddedartists | 0:2052561807c5 | 113 | { |
embeddedartists | 0:2052561807c5 | 114 | if(!MifareExecute(InitCard_CMD, &InitVal)) |
embeddedartists | 0:2052561807c5 | 115 | { |
embeddedartists | 0:2052561807c5 | 116 | WM_SendMessageNoPara(hWinCallBack, WM_USER_RFID_Reset_OK); |
embeddedartists | 0:2052561807c5 | 117 | ShowWindow(hWinSwipeCard); |
embeddedartists | 0:2052561807c5 | 118 | GUI_Delay(500); |
embeddedartists | 0:2052561807c5 | 119 | WM_SendMessageNoPara(hWinCallBack, WM_USER_RFID_Swipe); |
embeddedartists | 0:2052561807c5 | 120 | ShowLastWindow(); |
embeddedartists | 0:2052561807c5 | 121 | } |
embeddedartists | 0:2052561807c5 | 122 | } |
embeddedartists | 0:2052561807c5 | 123 | if(!(Buttons & (1<<27)) && (PrevButtons & (1<<27))) |
embeddedartists | 0:2052561807c5 | 124 | { |
embeddedartists | 0:2052561807c5 | 125 | if(!MifareExecute(IncCredit_CMD, &IncVal)) |
embeddedartists | 0:2052561807c5 | 126 | { |
embeddedartists | 0:2052561807c5 | 127 | WM_SendMessageNoPara(hWinCallBack, WM_USER_RFID_Increment_OK); |
embeddedartists | 0:2052561807c5 | 128 | ShowWindow(hWinSwipeCard); |
embeddedartists | 0:2052561807c5 | 129 | GUI_Delay(500); |
embeddedartists | 0:2052561807c5 | 130 | WM_SendMessageNoPara(hWinCallBack, WM_USER_RFID_Swipe); |
embeddedartists | 0:2052561807c5 | 131 | ShowLastWindow(); |
embeddedartists | 0:2052561807c5 | 132 | } |
embeddedartists | 0:2052561807c5 | 133 | } |
embeddedartists | 0:2052561807c5 | 134 | |
embeddedartists | 0:2052561807c5 | 135 | PrevButtons = Buttons; |
embeddedartists | 0:2052561807c5 | 136 | #endif /* _WINDOWS */ |
embeddedartists | 0:2052561807c5 | 137 | GUI_Delay(10); |
embeddedartists | 0:2052561807c5 | 138 | } |
embeddedartists | 0:2052561807c5 | 139 | |
embeddedartists | 0:2052561807c5 | 140 | #endif // AR |
embeddedartists | 0:2052561807c5 | 141 | |
embeddedartists | 0:2052561807c5 | 142 | } |