Wrapper classes for the emwin library

Dependents:   app_emwin1 app_emwin2_pos lpc4088_ebb_gui_emwin

Committer:
embeddedartists
Date:
Mon Apr 14 08:38:33 2014 +0000
Revision:
1:0b16165ada7c
Parent:
0:316c181e9b65
Initialize uninitialized touchState in EwGui

Who changed what in which revision?

UserRevisionLine numberNew contents of line
embeddedartists 0:316c181e9b65 1
embeddedartists 0:316c181e9b65 2 #include <stdio.h>
embeddedartists 0:316c181e9b65 3 #include "mbed.h"
embeddedartists 0:316c181e9b65 4 #include "GUI.h"
embeddedartists 0:316c181e9b65 5 #include "GUIDRV_Lin.h"
embeddedartists 0:316c181e9b65 6 #include "EwGui.h"
embeddedartists 0:316c181e9b65 7
embeddedartists 0:316c181e9b65 8 /*********************************************************************
embeddedartists 0:316c181e9b65 9 *
embeddedartists 0:316c181e9b65 10 * Defines
embeddedartists 0:316c181e9b65 11 *
embeddedartists 0:316c181e9b65 12 **********************************************************************
embeddedartists 0:316c181e9b65 13 */
embeddedartists 0:316c181e9b65 14
embeddedartists 0:316c181e9b65 15
embeddedartists 0:316c181e9b65 16 /*********************************************************************
embeddedartists 0:316c181e9b65 17 *
embeddedartists 0:316c181e9b65 18 * Static data
embeddedartists 0:316c181e9b65 19 *
embeddedartists 0:316c181e9b65 20 **********************************************************************
embeddedartists 0:316c181e9b65 21 */
embeddedartists 0:316c181e9b65 22
embeddedartists 0:316c181e9b65 23 static EwGui* ewGui = 0;
embeddedartists 0:316c181e9b65 24 static Timer ewGuiTimer;
embeddedartists 0:316c181e9b65 25 static uint32_t ewGuiMsTime = 0;
embeddedartists 0:316c181e9b65 26
embeddedartists 0:316c181e9b65 27 /*********************************************************************
embeddedartists 0:316c181e9b65 28 *
embeddedartists 0:316c181e9b65 29 * Public code
embeddedartists 0:316c181e9b65 30 *
embeddedartists 0:316c181e9b65 31 **********************************************************************
embeddedartists 0:316c181e9b65 32 */
embeddedartists 0:316c181e9b65 33
embeddedartists 0:316c181e9b65 34 void ew_registerGuiHandle(EwGui* gui) {
embeddedartists 0:316c181e9b65 35 ewGui = gui;
embeddedartists 0:316c181e9b65 36 }
embeddedartists 0:316c181e9b65 37
embeddedartists 0:316c181e9b65 38 /*********************************************************************
embeddedartists 0:316c181e9b65 39 *
embeddedartists 0:316c181e9b65 40 * GUI_X_Config
embeddedartists 0:316c181e9b65 41 *
embeddedartists 0:316c181e9b65 42 * Purpose:
embeddedartists 0:316c181e9b65 43 * Called during the initialization process in order to set up the
embeddedartists 0:316c181e9b65 44 * available memory for the GUI.
embeddedartists 0:316c181e9b65 45 */
embeddedartists 0:316c181e9b65 46 void GUI_X_Config(void) {
embeddedartists 0:316c181e9b65 47
embeddedartists 0:316c181e9b65 48 if (!ewGui) return;
embeddedartists 0:316c181e9b65 49
embeddedartists 0:316c181e9b65 50 //
embeddedartists 0:316c181e9b65 51 // Assign memory to emWin
embeddedartists 0:316c181e9b65 52 //
embeddedartists 0:316c181e9b65 53
embeddedartists 0:316c181e9b65 54 GUI_ALLOC_AssignMemory(ewGui->getMemoryBlockAddress(),
embeddedartists 0:316c181e9b65 55 ewGui->getMemoryBlockSize());
embeddedartists 0:316c181e9b65 56 // GUI_ALLOC_SetAvBlockSize(0x80);
embeddedartists 0:316c181e9b65 57 }
embeddedartists 0:316c181e9b65 58
embeddedartists 0:316c181e9b65 59 /*********************************************************************
embeddedartists 0:316c181e9b65 60 *
embeddedartists 0:316c181e9b65 61 * LCD_X_Config
embeddedartists 0:316c181e9b65 62 *
embeddedartists 0:316c181e9b65 63 * Purpose:
embeddedartists 0:316c181e9b65 64 * Called during the initialization process in order to set up the
embeddedartists 0:316c181e9b65 65 * display driver configuration.
embeddedartists 0:316c181e9b65 66 */
embeddedartists 0:316c181e9b65 67 void LCD_X_Config(void) {
embeddedartists 0:316c181e9b65 68
embeddedartists 0:316c181e9b65 69 if (!ewGui) return;
embeddedartists 0:316c181e9b65 70
embeddedartists 0:316c181e9b65 71 GUI_DEVICE_CreateAndLink(&GUIDRV_Lin_16_API, GUICC_M565, 0, 0);
embeddedartists 0:316c181e9b65 72
embeddedartists 0:316c181e9b65 73 //
embeddedartists 0:316c181e9b65 74 // Display driver configuration, required for Lin-driver
embeddedartists 0:316c181e9b65 75 //
embeddedartists 0:316c181e9b65 76 LCD_SetPosEx(0, 0, 0);
embeddedartists 0:316c181e9b65 77 if (LCD_GetSwapXYEx(0)) {
embeddedartists 0:316c181e9b65 78 LCD_SetSizeEx (0, ewGui->getDisplayHeight(), ewGui->getDisplayWidth());
embeddedartists 0:316c181e9b65 79 LCD_SetVSizeEx (0, ewGui->getDisplayHeight(), ewGui->getDisplayWidth());
embeddedartists 0:316c181e9b65 80 } else {
embeddedartists 0:316c181e9b65 81 LCD_SetSizeEx (0, ewGui->getDisplayWidth(), ewGui->getDisplayHeight());
embeddedartists 0:316c181e9b65 82 LCD_SetVSizeEx (0, ewGui->getDisplayWidth(), ewGui->getDisplayHeight());
embeddedartists 0:316c181e9b65 83 }
embeddedartists 0:316c181e9b65 84 LCD_SetVRAMAddrEx(0, (void*)0);
embeddedartists 0:316c181e9b65 85 }
embeddedartists 0:316c181e9b65 86
embeddedartists 0:316c181e9b65 87 /*********************************************************************
embeddedartists 0:316c181e9b65 88 *
embeddedartists 0:316c181e9b65 89 * LCD_X_DisplayDriver
embeddedartists 0:316c181e9b65 90 *
embeddedartists 0:316c181e9b65 91 * Purpose:
embeddedartists 0:316c181e9b65 92 * This function is called by the display driver for several purposes.
embeddedartists 0:316c181e9b65 93 * To support the according task the routine needs to be adapted to
embeddedartists 0:316c181e9b65 94 * the display controller. Please note that the commands marked with
embeddedartists 0:316c181e9b65 95 * 'optional' are not cogently required and should only be adapted if
embeddedartists 0:316c181e9b65 96 * the display controller supports these features.
embeddedartists 0:316c181e9b65 97 *
embeddedartists 0:316c181e9b65 98 * Parameter:
embeddedartists 0:316c181e9b65 99 * LayerIndex - Index of layer to be configured
embeddedartists 0:316c181e9b65 100 * Cmd - Please refer to the details in the switch statement below
embeddedartists 0:316c181e9b65 101 * pData - Pointer to a LCD_X_DATA structure
embeddedartists 0:316c181e9b65 102 *
embeddedartists 0:316c181e9b65 103 * Return Value:
embeddedartists 0:316c181e9b65 104 * < -1 - Error
embeddedartists 0:316c181e9b65 105 * -1 - Command not handled
embeddedartists 0:316c181e9b65 106 * 0 - Ok
embeddedartists 0:316c181e9b65 107 */
embeddedartists 0:316c181e9b65 108 int LCD_X_DisplayDriver(unsigned LayerIndex, unsigned Cmd, void * pData) {
embeddedartists 0:316c181e9b65 109 // LCD_X_SETORG_INFO * pSetOrg;
embeddedartists 0:316c181e9b65 110 int r;
embeddedartists 0:316c181e9b65 111 U32 TouchOrientation;
embeddedartists 0:316c181e9b65 112
embeddedartists 0:316c181e9b65 113 if (!ewGui) return -1;
embeddedartists 0:316c181e9b65 114
embeddedartists 0:316c181e9b65 115 switch (Cmd) {
embeddedartists 0:316c181e9b65 116 //
embeddedartists 0:316c181e9b65 117 // Required
embeddedartists 0:316c181e9b65 118 //
embeddedartists 0:316c181e9b65 119 case LCD_X_INITCONTROLLER:
embeddedartists 0:316c181e9b65 120 //
embeddedartists 0:316c181e9b65 121 // Called during the initialization process in order to set up the
embeddedartists 0:316c181e9b65 122 // display controller and put it into operation. If the display
embeddedartists 0:316c181e9b65 123 // controller is not initialized by any external routine this needs
embeddedartists 0:316c181e9b65 124 // to be adapted by the customer...
embeddedartists 0:316c181e9b65 125 //
embeddedartists 0:316c181e9b65 126 // ...
embeddedartists 0:316c181e9b65 127
embeddedartists 0:316c181e9b65 128 //
embeddedartists 0:316c181e9b65 129 // Set display size and video-RAM address
embeddedartists 0:316c181e9b65 130 //
embeddedartists 0:316c181e9b65 131 // LCD_SetSizeEx (800, 480, 0);
embeddedartists 0:316c181e9b65 132 // LCD_SetVSizeEx(800, 480, 0);
embeddedartists 0:316c181e9b65 133 LCD_SetVRAMAddrEx(0, (void*)ewGui->getFrameBufferAddress());
embeddedartists 0:316c181e9b65 134
embeddedartists 0:316c181e9b65 135 TouchOrientation = (GUI_MIRROR_X * LCD_GetMirrorXEx(0)) |
embeddedartists 0:316c181e9b65 136 (GUI_MIRROR_Y * LCD_GetMirrorYEx(0)) |
embeddedartists 0:316c181e9b65 137 (GUI_SWAP_XY * LCD_GetSwapXYEx (0)) ;
embeddedartists 0:316c181e9b65 138 GUI_TOUCH_SetOrientation(TouchOrientation);
embeddedartists 0:316c181e9b65 139
embeddedartists 0:316c181e9b65 140 return 0;
embeddedartists 0:316c181e9b65 141 case LCD_X_SETORG:
embeddedartists 0:316c181e9b65 142 //
embeddedartists 0:316c181e9b65 143 // Required for setting the display origin which is passed in the 'xPos' and 'yPos' element of p
embeddedartists 0:316c181e9b65 144 //
embeddedartists 0:316c181e9b65 145
embeddedartists 0:316c181e9b65 146 // pSetOrg = (LCD_X_SETORG_INFO *)pData;
embeddedartists 0:316c181e9b65 147 // LPC_LCD->UPBASE = VRAM_ADDR_PHYS +
embeddedartists 0:316c181e9b65 148 // (pSetOrg->yPos * YSIZE_PHYS * /*PIXEL_WIDTH*/ 2); // Needs to be set, before LCDC is enabled
embeddedartists 0:316c181e9b65 149
embeddedartists 0:316c181e9b65 150 return 0;
embeddedartists 0:316c181e9b65 151 default:
embeddedartists 0:316c181e9b65 152 r = -1;
embeddedartists 0:316c181e9b65 153
embeddedartists 0:316c181e9b65 154 }
embeddedartists 0:316c181e9b65 155
embeddedartists 0:316c181e9b65 156 return r;
embeddedartists 0:316c181e9b65 157 }
embeddedartists 0:316c181e9b65 158
embeddedartists 0:316c181e9b65 159
embeddedartists 0:316c181e9b65 160
embeddedartists 0:316c181e9b65 161 /*********************************************************************
embeddedartists 0:316c181e9b65 162 *
embeddedartists 0:316c181e9b65 163 * Timing:
embeddedartists 0:316c181e9b65 164 * GUI_X_GetTime()
embeddedartists 0:316c181e9b65 165 * GUI_X_Delay(int)
embeddedartists 0:316c181e9b65 166
embeddedartists 0:316c181e9b65 167 Some timing dependent routines require a GetTime
embeddedartists 0:316c181e9b65 168 and delay function. Default time unit (tick), normally is
embeddedartists 0:316c181e9b65 169 1 ms.
embeddedartists 0:316c181e9b65 170 */
embeddedartists 0:316c181e9b65 171
embeddedartists 0:316c181e9b65 172 int GUI_X_GetTime(void) {
embeddedartists 0:316c181e9b65 173 ewGuiMsTime += ewGuiTimer.read_ms();
embeddedartists 0:316c181e9b65 174 ewGuiTimer.reset();
embeddedartists 0:316c181e9b65 175 return ewGuiMsTime;
embeddedartists 0:316c181e9b65 176 }
embeddedartists 0:316c181e9b65 177
embeddedartists 0:316c181e9b65 178 void GUI_X_Delay(int ms) {
embeddedartists 0:316c181e9b65 179 wait_ms(ms);
embeddedartists 0:316c181e9b65 180 }
embeddedartists 0:316c181e9b65 181
embeddedartists 0:316c181e9b65 182 /*********************************************************************
embeddedartists 0:316c181e9b65 183 *
embeddedartists 0:316c181e9b65 184 * GUI_X_Init()
embeddedartists 0:316c181e9b65 185 *
embeddedartists 0:316c181e9b65 186 * Note:
embeddedartists 0:316c181e9b65 187 * GUI_X_Init() is called from GUI_Init is a possibility to init
embeddedartists 0:316c181e9b65 188 * some hardware which needs to be up and running before the GUI.
embeddedartists 0:316c181e9b65 189 * If not required, leave this routine blank.
embeddedartists 0:316c181e9b65 190 */
embeddedartists 0:316c181e9b65 191 void GUI_X_Init(void) {
embeddedartists 0:316c181e9b65 192 ewGuiTimer.start();
embeddedartists 0:316c181e9b65 193 }
embeddedartists 0:316c181e9b65 194
embeddedartists 0:316c181e9b65 195
embeddedartists 0:316c181e9b65 196 /*********************************************************************
embeddedartists 0:316c181e9b65 197 *
embeddedartists 0:316c181e9b65 198 * GUI_X_ExecIdle
embeddedartists 0:316c181e9b65 199 *
embeddedartists 0:316c181e9b65 200 * Note:
embeddedartists 0:316c181e9b65 201 * Called if WM is in idle state
embeddedartists 0:316c181e9b65 202 */
embeddedartists 0:316c181e9b65 203
embeddedartists 0:316c181e9b65 204 void GUI_X_ExecIdle(void) {}
embeddedartists 0:316c181e9b65 205
embeddedartists 0:316c181e9b65 206 /*********************************************************************
embeddedartists 0:316c181e9b65 207 *
embeddedartists 0:316c181e9b65 208 * Multitasking:
embeddedartists 0:316c181e9b65 209 *
embeddedartists 0:316c181e9b65 210 * GUI_X_InitOS()
embeddedartists 0:316c181e9b65 211 * GUI_X_GetTaskId()
embeddedartists 0:316c181e9b65 212 * GUI_X_Lock()
embeddedartists 0:316c181e9b65 213 * GUI_X_Unlock()
embeddedartists 0:316c181e9b65 214 *
embeddedartists 0:316c181e9b65 215 * Note:
embeddedartists 0:316c181e9b65 216 * The following routines are required only if emWin is used in a
embeddedartists 0:316c181e9b65 217 * true multi task environment, which means you have more than one
embeddedartists 0:316c181e9b65 218 * thread using the emWin API.
embeddedartists 0:316c181e9b65 219 * In this case the
embeddedartists 0:316c181e9b65 220 * #define GUI_OS 1
embeddedartists 0:316c181e9b65 221 * needs to be in GUIConf.h
embeddedartists 0:316c181e9b65 222 */
embeddedartists 0:316c181e9b65 223
embeddedartists 0:316c181e9b65 224
embeddedartists 0:316c181e9b65 225 //static OS_RSEMA RSema;
embeddedartists 0:316c181e9b65 226
embeddedartists 0:316c181e9b65 227 void GUI_X_InitOS(void) { /*OS_CreateRSema(&RSema);*/ }
embeddedartists 0:316c181e9b65 228 void GUI_X_Unlock(void) { /*OS_Unuse(&RSema);*/ }
embeddedartists 0:316c181e9b65 229 void GUI_X_Lock(void) { /*OS_Use(&RSema);*/ }
embeddedartists 0:316c181e9b65 230 U32 GUI_X_GetTaskId(void) { return 0; /*(U32)OS_GetTaskID();*/ }
embeddedartists 0:316c181e9b65 231
embeddedartists 0:316c181e9b65 232 /*********************************************************************
embeddedartists 0:316c181e9b65 233 *
embeddedartists 0:316c181e9b65 234 * Logging: OS dependent
embeddedartists 0:316c181e9b65 235
embeddedartists 0:316c181e9b65 236 Note:
embeddedartists 0:316c181e9b65 237 Logging is used in higher debug levels only. The typical target
embeddedartists 0:316c181e9b65 238 build does not use logging and does therefor not require any of
embeddedartists 0:316c181e9b65 239 the logging routines below. For a release build without logging
embeddedartists 0:316c181e9b65 240 the routines below may be eliminated to save some space.
embeddedartists 0:316c181e9b65 241 (If the linker is not function aware and eliminates unreferenced
embeddedartists 0:316c181e9b65 242 functions automatically)
embeddedartists 0:316c181e9b65 243
embeddedartists 0:316c181e9b65 244 */
embeddedartists 0:316c181e9b65 245
embeddedartists 0:316c181e9b65 246 void GUI_X_Log (const char *s) { GUI_USE_PARA(s); }
embeddedartists 0:316c181e9b65 247 void GUI_X_Warn (const char *s) { GUI_USE_PARA(s); }
embeddedartists 0:316c181e9b65 248 void GUI_X_ErrorOut(const char *s) { GUI_USE_PARA(s); }
embeddedartists 0:316c181e9b65 249
embeddedartists 0:316c181e9b65 250
embeddedartists 0:316c181e9b65 251 /*********************************************************************
embeddedartists 0:316c181e9b65 252 *
embeddedartists 0:316c181e9b65 253 * GUI_TOUCH_X_ActivateX()
embeddedartists 0:316c181e9b65 254 *
embeddedartists 0:316c181e9b65 255 * Function decription:
embeddedartists 0:316c181e9b65 256 * Called from GUI, if touch support is enabled.
embeddedartists 0:316c181e9b65 257 * Switches on voltage on X-axis,
embeddedartists 0:316c181e9b65 258 * prepares measurement for Y-axis.
embeddedartists 0:316c181e9b65 259 * Voltage on Y-axis is switched off.
embeddedartists 0:316c181e9b65 260 */
embeddedartists 0:316c181e9b65 261 void GUI_TOUCH_X_ActivateX(void) {
embeddedartists 0:316c181e9b65 262 }
embeddedartists 0:316c181e9b65 263
embeddedartists 0:316c181e9b65 264 /*********************************************************************
embeddedartists 0:316c181e9b65 265 *
embeddedartists 0:316c181e9b65 266 * GUI_TOUCH_X_ActivateY()
embeddedartists 0:316c181e9b65 267 *
embeddedartists 0:316c181e9b65 268 * Function decription:
embeddedartists 0:316c181e9b65 269 * Called from GUI, if touch support is enabled.
embeddedartists 0:316c181e9b65 270 * Switches on voltage on Y-axis,
embeddedartists 0:316c181e9b65 271 * prepares measurement for X-axis.
embeddedartists 0:316c181e9b65 272 * Voltage on X-axis is switched off.
embeddedartists 0:316c181e9b65 273 */
embeddedartists 0:316c181e9b65 274 void GUI_TOUCH_X_ActivateY(void) {
embeddedartists 0:316c181e9b65 275 }
embeddedartists 0:316c181e9b65 276
embeddedartists 0:316c181e9b65 277 /*********************************************************************
embeddedartists 0:316c181e9b65 278 *
embeddedartists 0:316c181e9b65 279 * GUI_TOUCH_X_MeasureX()
embeddedartists 0:316c181e9b65 280 *
embeddedartists 0:316c181e9b65 281 * Function decription:
embeddedartists 0:316c181e9b65 282 * Called from GUI, if touch support is enabled.
embeddedartists 0:316c181e9b65 283 * Measures voltage of X-axis.
embeddedartists 0:316c181e9b65 284 */
embeddedartists 0:316c181e9b65 285 int GUI_TOUCH_X_MeasureX(void) {
embeddedartists 0:316c181e9b65 286 if (!ewGui) return 0;
embeddedartists 0:316c181e9b65 287
embeddedartists 0:316c181e9b65 288 return ewGui->getTouchX();
embeddedartists 0:316c181e9b65 289 }
embeddedartists 0:316c181e9b65 290
embeddedartists 0:316c181e9b65 291 /*********************************************************************
embeddedartists 0:316c181e9b65 292 *
embeddedartists 0:316c181e9b65 293 * GUI_TOUCH_X_MeasureY()
embeddedartists 0:316c181e9b65 294 *
embeddedartists 0:316c181e9b65 295 * Function decription:
embeddedartists 0:316c181e9b65 296 * Called from GUI, if touch support is enabled.
embeddedartists 0:316c181e9b65 297 * Measures voltage of Y-axis.
embeddedartists 0:316c181e9b65 298 */
embeddedartists 0:316c181e9b65 299 int GUI_TOUCH_X_MeasureY(void) {
embeddedartists 0:316c181e9b65 300 if (!ewGui) return 0;
embeddedartists 0:316c181e9b65 301
embeddedartists 0:316c181e9b65 302 return ewGui->getTouchY();
embeddedartists 0:316c181e9b65 303 }
embeddedartists 0:316c181e9b65 304
embeddedartists 0:316c181e9b65 305 /*************************** End of file ****************************/
embeddedartists 0:316c181e9b65 306
embeddedartists 0:316c181e9b65 307
embeddedartists 0:316c181e9b65 308