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

This program requires the emWin library. Instructions and more information.

Committer:
embeddedartists
Date:
Tue Jul 14 11:34:15 2015 +0000
Revision:
0:7f5765fcd048
First version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
embeddedartists 0:7f5765fcd048 1
embeddedartists 0:7f5765fcd048 2 /******************************************************************************
embeddedartists 0:7f5765fcd048 3 * Includes
embeddedartists 0:7f5765fcd048 4 *****************************************************************************/
embeddedartists 0:7f5765fcd048 5
embeddedartists 0:7f5765fcd048 6 #include "mbed.h"
embeddedartists 0:7f5765fcd048 7
embeddedartists 0:7f5765fcd048 8 #include "sdram.h"
embeddedartists 0:7f5765fcd048 9
embeddedartists 0:7f5765fcd048 10 #include "EwGuiImpl.h"
embeddedartists 0:7f5765fcd048 11 #include "EwFrameWindow.h"
embeddedartists 0:7f5765fcd048 12 #include "MyWindow.h"
embeddedartists 0:7f5765fcd048 13
embeddedartists 0:7f5765fcd048 14
embeddedartists 0:7f5765fcd048 15 /******************************************************************************
embeddedartists 0:7f5765fcd048 16 * Typedefs and defines
embeddedartists 0:7f5765fcd048 17 *****************************************************************************/
embeddedartists 0:7f5765fcd048 18
embeddedartists 0:7f5765fcd048 19
embeddedartists 0:7f5765fcd048 20 /******************************************************************************
embeddedartists 0:7f5765fcd048 21 * Local variables
embeddedartists 0:7f5765fcd048 22 *****************************************************************************/
embeddedartists 0:7f5765fcd048 23
embeddedartists 0:7f5765fcd048 24 static EwGuiImpl* gui = NULL;
embeddedartists 0:7f5765fcd048 25
embeddedartists 0:7f5765fcd048 26 /******************************************************************************
embeddedartists 0:7f5765fcd048 27 * Local functions
embeddedartists 0:7f5765fcd048 28 *****************************************************************************/
embeddedartists 0:7f5765fcd048 29
embeddedartists 0:7f5765fcd048 30 static void pollTouch() {
embeddedartists 0:7f5765fcd048 31 if (gui == NULL) return;
embeddedartists 0:7f5765fcd048 32
embeddedartists 0:7f5765fcd048 33 gui->execTouch();
embeddedartists 0:7f5765fcd048 34 }
embeddedartists 0:7f5765fcd048 35
embeddedartists 0:7f5765fcd048 36 /******************************************************************************
embeddedartists 0:7f5765fcd048 37 * Main function
embeddedartists 0:7f5765fcd048 38 *****************************************************************************/
embeddedartists 0:7f5765fcd048 39
embeddedartists 0:7f5765fcd048 40 int main (void) {
embeddedartists 0:7f5765fcd048 41 Ticker ticker;
embeddedartists 0:7f5765fcd048 42
embeddedartists 0:7f5765fcd048 43 // Frame buffer is put in SDRAM
embeddedartists 0:7f5765fcd048 44 if (sdram_init() == 1) {
embeddedartists 0:7f5765fcd048 45 printf("Failed to initialize SDRAM\n");
embeddedartists 0:7f5765fcd048 46 return 1;
embeddedartists 0:7f5765fcd048 47 }
embeddedartists 0:7f5765fcd048 48
embeddedartists 0:7f5765fcd048 49 // instantiate and initialize GUI
embeddedartists 0:7f5765fcd048 50 gui = new EwGuiImpl(EwGuiImpl::TFT_4_3);
embeddedartists 0:7f5765fcd048 51 //gui = new EwGuiImpl(EwGuiImpl::TFT_5);
embeddedartists 0:7f5765fcd048 52 if (gui == NULL) {
embeddedartists 0:7f5765fcd048 53 printf("Failed to instantiate EwGuiImpl\n");
embeddedartists 0:7f5765fcd048 54 return 1;
embeddedartists 0:7f5765fcd048 55 }
embeddedartists 0:7f5765fcd048 56
embeddedartists 0:7f5765fcd048 57 // calibrate touch screen
embeddedartists 0:7f5765fcd048 58 gui->calibrate();
embeddedartists 0:7f5765fcd048 59
embeddedartists 0:7f5765fcd048 60 // register a callback that will check for touch events
embeddedartists 0:7f5765fcd048 61 ticker.attach(&pollTouch, 0.10);
embeddedartists 0:7f5765fcd048 62
embeddedartists 0:7f5765fcd048 63 // showing how to enable skinning
embeddedartists 0:7f5765fcd048 64 BUTTON_SetDefaultSkin (BUTTON_SKIN_FLEX);
embeddedartists 0:7f5765fcd048 65 CHECKBOX_SetDefaultSkin (CHECKBOX_SKIN_FLEX);
embeddedartists 0:7f5765fcd048 66 DROPDOWN_SetDefaultSkin (DROPDOWN_SKIN_FLEX);
embeddedartists 0:7f5765fcd048 67 FRAMEWIN_SetDefaultSkin (FRAMEWIN_SKIN_FLEX);
embeddedartists 0:7f5765fcd048 68
embeddedartists 0:7f5765fcd048 69 // make sure the desktop has a color so that it is redrawn
embeddedartists 0:7f5765fcd048 70 EwWindow::setDesktopColor(EW_BLACK);
embeddedartists 0:7f5765fcd048 71
embeddedartists 0:7f5765fcd048 72 // create a frame window
embeddedartists 0:7f5765fcd048 73 EwFrameWindow frameWin(30, 30, gui->getDisplayWidth()-60,
embeddedartists 0:7f5765fcd048 74 gui->getDisplayHeight()-60, "Window Title");
embeddedartists 0:7f5765fcd048 75 frameWin.setTitleHeight(20);
embeddedartists 0:7f5765fcd048 76
embeddedartists 0:7f5765fcd048 77 // create and associate a custom window with the frame window
embeddedartists 0:7f5765fcd048 78 MyWindow myWindow(&frameWin);
embeddedartists 0:7f5765fcd048 79
embeddedartists 0:7f5765fcd048 80 // application loop running the UI and checking for touch events
embeddedartists 0:7f5765fcd048 81 while(1) {
embeddedartists 0:7f5765fcd048 82
embeddedartists 0:7f5765fcd048 83 // In this example touch events are checked by interrupt
embeddedartists 0:7f5765fcd048 84 // (pollTouch function), but we could also have done it
embeddedartists 0:7f5765fcd048 85 // in this while loop
embeddedartists 0:7f5765fcd048 86 //gui.execTouch();
embeddedartists 0:7f5765fcd048 87 gui->exec();
embeddedartists 0:7f5765fcd048 88
embeddedartists 0:7f5765fcd048 89 }
embeddedartists 0:7f5765fcd048 90
embeddedartists 0:7f5765fcd048 91 }
embeddedartists 0:7f5765fcd048 92