Example that shows how to use the ewgui wrapper classes in combination with Segger's emwin library.
Dependencies: EALib ewgui mbed
main.cpp
00001 00002 /****************************************************************************** 00003 * Includes 00004 *****************************************************************************/ 00005 00006 #include "mbed.h" 00007 00008 #include "sdram.h" 00009 00010 #include "EwGuiImpl.h" 00011 #include "EwFrameWindow.h" 00012 #include "MyWindow.h" 00013 00014 00015 /****************************************************************************** 00016 * Typedefs and defines 00017 *****************************************************************************/ 00018 00019 00020 /****************************************************************************** 00021 * Local variables 00022 *****************************************************************************/ 00023 00024 static EwGuiImpl* gui = NULL; 00025 00026 /****************************************************************************** 00027 * Local functions 00028 *****************************************************************************/ 00029 00030 static void pollTouch() { 00031 if (gui == NULL) return; 00032 00033 gui->execTouch(); 00034 } 00035 00036 /****************************************************************************** 00037 * Main function 00038 *****************************************************************************/ 00039 00040 int main (void) { 00041 Ticker ticker; 00042 00043 // Frame buffer is put in SDRAM 00044 if (sdram_init() == 1) { 00045 printf("Failed to initialize SDRAM\n"); 00046 return 1; 00047 } 00048 00049 // instantiate and initialize GUI 00050 gui = new EwGuiImpl(); 00051 if (gui == NULL) { 00052 printf("Failed to instantiate EwGuiImpl\n"); 00053 return 1; 00054 } 00055 00056 // calibrate touch screen 00057 gui->calibrate(); 00058 00059 // register a callback that will check for touch events 00060 ticker.attach(&pollTouch, 0.10); 00061 00062 // showing how to enable skinning 00063 BUTTON_SetDefaultSkin (BUTTON_SKIN_FLEX); 00064 CHECKBOX_SetDefaultSkin (CHECKBOX_SKIN_FLEX); 00065 DROPDOWN_SetDefaultSkin (DROPDOWN_SKIN_FLEX); 00066 FRAMEWIN_SetDefaultSkin (FRAMEWIN_SKIN_FLEX); 00067 00068 // make sure the desktop has a color so that it is redrawn 00069 EwWindow::setDesktopColor(EW_BLACK); 00070 00071 // create a frame window 00072 EwFrameWindow frameWin(30, 30, gui->getDisplayWidth()-60, 00073 gui->getDisplayHeight()-60, "Window Title"); 00074 frameWin.setTitleHeight(20); 00075 00076 // create and associate a custom window with the frame window 00077 MyWindow myWindow(&frameWin); 00078 00079 // application loop running the UI and checking for touch events 00080 while(1) { 00081 00082 // In this example touch events are checked by interrupt 00083 // (pollTouch function), but we could also have done it 00084 // in this while loop 00085 //gui.execTouch(); 00086 gui->exec(); 00087 00088 } 00089 00090 }
Generated on Fri Jul 15 2022 19:49:24 by 1.7.2