Graphical demo for the LPC4088 Experiment Base Board with one of the Display Expansion Kits. This program displays how to use the emWin library from Segger.

Dependencies:   EALib ewgui mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

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(EwGuiImpl::TFT_4_3);
00051     //gui = new EwGuiImpl(EwGuiImpl::TFT_5);
00052     if (gui == NULL) {
00053         printf("Failed to instantiate EwGuiImpl\n");
00054         return 1;
00055     }
00056 
00057     // calibrate touch screen
00058     gui->calibrate();
00059 
00060     // register a callback that will check for touch events
00061     ticker.attach(&pollTouch, 0.10);
00062 
00063     // showing how to enable skinning
00064     BUTTON_SetDefaultSkin   (BUTTON_SKIN_FLEX);
00065     CHECKBOX_SetDefaultSkin (CHECKBOX_SKIN_FLEX);
00066     DROPDOWN_SetDefaultSkin (DROPDOWN_SKIN_FLEX);
00067     FRAMEWIN_SetDefaultSkin (FRAMEWIN_SKIN_FLEX);
00068 
00069     // make sure the desktop has a color so that it is redrawn
00070     EwWindow::setDesktopColor(EW_BLACK);
00071 
00072     // create a frame window
00073     EwFrameWindow frameWin(30, 30, gui->getDisplayWidth()-60,
00074             gui->getDisplayHeight()-60, "Window Title");
00075     frameWin.setTitleHeight(20);
00076 
00077     // create and associate a custom window with the frame window
00078     MyWindow myWindow(&frameWin);
00079 
00080     // application loop running the UI and checking for touch events
00081     while(1) {
00082 
00083         // In this example touch events are checked by interrupt
00084         // (pollTouch function), but we could also have done it
00085         // in this while loop
00086         //gui.execTouch();
00087         gui->exec();
00088 
00089     }
00090 
00091 }
00092