Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: app_emwin1 app_emwin2_pos lpc4088_ebb_gui_emwin
emwin_port.cpp
00001 00002 #include <stdio.h> 00003 #include "mbed.h" 00004 #include "GUI.h" 00005 #include "GUIDRV_Lin.h" 00006 #include "EwGui.h" 00007 00008 /********************************************************************* 00009 * 00010 * Defines 00011 * 00012 ********************************************************************** 00013 */ 00014 00015 00016 /********************************************************************* 00017 * 00018 * Static data 00019 * 00020 ********************************************************************** 00021 */ 00022 00023 static EwGui* ewGui = 0; 00024 static Timer ewGuiTimer; 00025 static uint32_t ewGuiMsTime = 0; 00026 00027 /********************************************************************* 00028 * 00029 * Public code 00030 * 00031 ********************************************************************** 00032 */ 00033 00034 void ew_registerGuiHandle(EwGui* gui) { 00035 ewGui = gui; 00036 } 00037 00038 /********************************************************************* 00039 * 00040 * GUI_X_Config 00041 * 00042 * Purpose: 00043 * Called during the initialization process in order to set up the 00044 * available memory for the GUI. 00045 */ 00046 void GUI_X_Config(void) { 00047 00048 if (!ewGui) return; 00049 00050 // 00051 // Assign memory to emWin 00052 // 00053 00054 GUI_ALLOC_AssignMemory(ewGui->getMemoryBlockAddress(), 00055 ewGui->getMemoryBlockSize()); 00056 // GUI_ALLOC_SetAvBlockSize(0x80); 00057 } 00058 00059 /********************************************************************* 00060 * 00061 * LCD_X_Config 00062 * 00063 * Purpose: 00064 * Called during the initialization process in order to set up the 00065 * display driver configuration. 00066 */ 00067 void LCD_X_Config(void) { 00068 00069 if (!ewGui) return; 00070 00071 GUI_DEVICE_CreateAndLink(&GUIDRV_Lin_16_API, GUICC_M565, 0, 0); 00072 00073 // 00074 // Display driver configuration, required for Lin-driver 00075 // 00076 LCD_SetPosEx(0, 0, 0); 00077 if (LCD_GetSwapXYEx(0)) { 00078 LCD_SetSizeEx (0, ewGui->getDisplayHeight(), ewGui->getDisplayWidth()); 00079 LCD_SetVSizeEx (0, ewGui->getDisplayHeight(), ewGui->getDisplayWidth()); 00080 } else { 00081 LCD_SetSizeEx (0, ewGui->getDisplayWidth(), ewGui->getDisplayHeight()); 00082 LCD_SetVSizeEx (0, ewGui->getDisplayWidth(), ewGui->getDisplayHeight()); 00083 } 00084 LCD_SetVRAMAddrEx(0, (void*)0); 00085 } 00086 00087 /********************************************************************* 00088 * 00089 * LCD_X_DisplayDriver 00090 * 00091 * Purpose: 00092 * This function is called by the display driver for several purposes. 00093 * To support the according task the routine needs to be adapted to 00094 * the display controller. Please note that the commands marked with 00095 * 'optional' are not cogently required and should only be adapted if 00096 * the display controller supports these features. 00097 * 00098 * Parameter: 00099 * LayerIndex - Index of layer to be configured 00100 * Cmd - Please refer to the details in the switch statement below 00101 * pData - Pointer to a LCD_X_DATA structure 00102 * 00103 * Return Value: 00104 * < -1 - Error 00105 * -1 - Command not handled 00106 * 0 - Ok 00107 */ 00108 int LCD_X_DisplayDriver(unsigned LayerIndex, unsigned Cmd, void * pData) { 00109 // LCD_X_SETORG_INFO * pSetOrg; 00110 int r; 00111 U32 TouchOrientation; 00112 00113 if (!ewGui) return -1; 00114 00115 switch (Cmd) { 00116 // 00117 // Required 00118 // 00119 case LCD_X_INITCONTROLLER: 00120 // 00121 // Called during the initialization process in order to set up the 00122 // display controller and put it into operation. If the display 00123 // controller is not initialized by any external routine this needs 00124 // to be adapted by the customer... 00125 // 00126 // ... 00127 00128 // 00129 // Set display size and video-RAM address 00130 // 00131 // LCD_SetSizeEx (800, 480, 0); 00132 // LCD_SetVSizeEx(800, 480, 0); 00133 LCD_SetVRAMAddrEx(0, (void*)ewGui->getFrameBufferAddress()); 00134 00135 TouchOrientation = (GUI_MIRROR_X * LCD_GetMirrorXEx(0)) | 00136 (GUI_MIRROR_Y * LCD_GetMirrorYEx(0)) | 00137 (GUI_SWAP_XY * LCD_GetSwapXYEx (0)) ; 00138 GUI_TOUCH_SetOrientation(TouchOrientation); 00139 00140 return 0; 00141 case LCD_X_SETORG: 00142 // 00143 // Required for setting the display origin which is passed in the 'xPos' and 'yPos' element of p 00144 // 00145 00146 // pSetOrg = (LCD_X_SETORG_INFO *)pData; 00147 // LPC_LCD->UPBASE = VRAM_ADDR_PHYS + 00148 // (pSetOrg->yPos * YSIZE_PHYS * /*PIXEL_WIDTH*/ 2); // Needs to be set, before LCDC is enabled 00149 00150 return 0; 00151 default: 00152 r = -1; 00153 00154 } 00155 00156 return r; 00157 } 00158 00159 00160 00161 /********************************************************************* 00162 * 00163 * Timing: 00164 * GUI_X_GetTime() 00165 * GUI_X_Delay(int) 00166 00167 Some timing dependent routines require a GetTime 00168 and delay function. Default time unit (tick), normally is 00169 1 ms. 00170 */ 00171 00172 int GUI_X_GetTime(void) { 00173 ewGuiMsTime += ewGuiTimer.read_ms(); 00174 ewGuiTimer.reset(); 00175 return ewGuiMsTime; 00176 } 00177 00178 void GUI_X_Delay(int ms) { 00179 wait_ms(ms); 00180 } 00181 00182 /********************************************************************* 00183 * 00184 * GUI_X_Init() 00185 * 00186 * Note: 00187 * GUI_X_Init() is called from GUI_Init is a possibility to init 00188 * some hardware which needs to be up and running before the GUI. 00189 * If not required, leave this routine blank. 00190 */ 00191 void GUI_X_Init(void) { 00192 ewGuiTimer.start(); 00193 } 00194 00195 00196 /********************************************************************* 00197 * 00198 * GUI_X_ExecIdle 00199 * 00200 * Note: 00201 * Called if WM is in idle state 00202 */ 00203 00204 void GUI_X_ExecIdle(void) {} 00205 00206 /********************************************************************* 00207 * 00208 * Multitasking: 00209 * 00210 * GUI_X_InitOS() 00211 * GUI_X_GetTaskId() 00212 * GUI_X_Lock() 00213 * GUI_X_Unlock() 00214 * 00215 * Note: 00216 * The following routines are required only if emWin is used in a 00217 * true multi task environment, which means you have more than one 00218 * thread using the emWin API. 00219 * In this case the 00220 * #define GUI_OS 1 00221 * needs to be in GUIConf.h 00222 */ 00223 00224 00225 //static OS_RSEMA RSema; 00226 00227 void GUI_X_InitOS(void) { /*OS_CreateRSema(&RSema);*/ } 00228 void GUI_X_Unlock(void) { /*OS_Unuse(&RSema);*/ } 00229 void GUI_X_Lock(void) { /*OS_Use(&RSema);*/ } 00230 U32 GUI_X_GetTaskId(void) { return 0; /*(U32)OS_GetTaskID();*/ } 00231 00232 /********************************************************************* 00233 * 00234 * Logging: OS dependent 00235 00236 Note: 00237 Logging is used in higher debug levels only. The typical target 00238 build does not use logging and does therefor not require any of 00239 the logging routines below. For a release build without logging 00240 the routines below may be eliminated to save some space. 00241 (If the linker is not function aware and eliminates unreferenced 00242 functions automatically) 00243 00244 */ 00245 00246 void GUI_X_Log (const char *s) { GUI_USE_PARA(s); } 00247 void GUI_X_Warn (const char *s) { GUI_USE_PARA(s); } 00248 void GUI_X_ErrorOut(const char *s) { GUI_USE_PARA(s); } 00249 00250 00251 /********************************************************************* 00252 * 00253 * GUI_TOUCH_X_ActivateX() 00254 * 00255 * Function decription: 00256 * Called from GUI, if touch support is enabled. 00257 * Switches on voltage on X-axis, 00258 * prepares measurement for Y-axis. 00259 * Voltage on Y-axis is switched off. 00260 */ 00261 void GUI_TOUCH_X_ActivateX(void) { 00262 } 00263 00264 /********************************************************************* 00265 * 00266 * GUI_TOUCH_X_ActivateY() 00267 * 00268 * Function decription: 00269 * Called from GUI, if touch support is enabled. 00270 * Switches on voltage on Y-axis, 00271 * prepares measurement for X-axis. 00272 * Voltage on X-axis is switched off. 00273 */ 00274 void GUI_TOUCH_X_ActivateY(void) { 00275 } 00276 00277 /********************************************************************* 00278 * 00279 * GUI_TOUCH_X_MeasureX() 00280 * 00281 * Function decription: 00282 * Called from GUI, if touch support is enabled. 00283 * Measures voltage of X-axis. 00284 */ 00285 int GUI_TOUCH_X_MeasureX(void) { 00286 if (!ewGui) return 0; 00287 00288 return ewGui->getTouchX(); 00289 } 00290 00291 /********************************************************************* 00292 * 00293 * GUI_TOUCH_X_MeasureY() 00294 * 00295 * Function decription: 00296 * Called from GUI, if touch support is enabled. 00297 * Measures voltage of Y-axis. 00298 */ 00299 int GUI_TOUCH_X_MeasureY(void) { 00300 if (!ewGui) return 0; 00301 00302 return ewGui->getTouchY(); 00303 } 00304 00305 /*************************** End of file ****************************/ 00306 00307 00308
Generated on Tue Jul 12 2022 19:57:49 by
