Example that shows how to use emWin. This example is based on NXP's POS demo available at lpcware.com
Dependencies: EALib ewgui mbed
main.cpp@2:cbf00ac63f35, 2014-04-14 (annotated)
- Committer:
- embeddedartists
- Date:
- Mon Apr 14 08:40:59 2014 +0000
- Revision:
- 2:cbf00ac63f35
- Parent:
- 0:2052561807c5
Updated to use latest ewgui
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
embeddedartists | 0:2052561807c5 | 1 | |
embeddedartists | 0:2052561807c5 | 2 | /****************************************************************************** |
embeddedartists | 0:2052561807c5 | 3 | * Includes |
embeddedartists | 0:2052561807c5 | 4 | *****************************************************************************/ |
embeddedartists | 0:2052561807c5 | 5 | |
embeddedartists | 0:2052561807c5 | 6 | #include "mbed.h" |
embeddedartists | 0:2052561807c5 | 7 | |
embeddedartists | 0:2052561807c5 | 8 | #include "sdram.h" |
embeddedartists | 0:2052561807c5 | 9 | |
embeddedartists | 0:2052561807c5 | 10 | #include "EwGuiImpl.h" |
embeddedartists | 0:2052561807c5 | 11 | |
embeddedartists | 0:2052561807c5 | 12 | |
embeddedartists | 0:2052561807c5 | 13 | |
embeddedartists | 0:2052561807c5 | 14 | /****************************************************************************** |
embeddedartists | 0:2052561807c5 | 15 | * Typedefs and defines |
embeddedartists | 0:2052561807c5 | 16 | *****************************************************************************/ |
embeddedartists | 0:2052561807c5 | 17 | |
embeddedartists | 0:2052561807c5 | 18 | |
embeddedartists | 0:2052561807c5 | 19 | /****************************************************************************** |
embeddedartists | 0:2052561807c5 | 20 | * Local variables |
embeddedartists | 0:2052561807c5 | 21 | *****************************************************************************/ |
embeddedartists | 0:2052561807c5 | 22 | |
embeddedartists | 0:2052561807c5 | 23 | |
embeddedartists | 0:2052561807c5 | 24 | /****************************************************************************** |
embeddedartists | 0:2052561807c5 | 25 | * Local functions |
embeddedartists | 0:2052561807c5 | 26 | *****************************************************************************/ |
embeddedartists | 0:2052561807c5 | 27 | |
embeddedartists | 0:2052561807c5 | 28 | static EwGuiImpl* gui = NULL; |
embeddedartists | 0:2052561807c5 | 29 | |
embeddedartists | 0:2052561807c5 | 30 | static void pollTouch() { |
embeddedartists | 0:2052561807c5 | 31 | if (gui == NULL) return; |
embeddedartists | 0:2052561807c5 | 32 | |
embeddedartists | 0:2052561807c5 | 33 | gui->execTouch(); |
embeddedartists | 0:2052561807c5 | 34 | } |
embeddedartists | 0:2052561807c5 | 35 | |
embeddedartists | 0:2052561807c5 | 36 | /****************************************************************************** |
embeddedartists | 0:2052561807c5 | 37 | * Main function |
embeddedartists | 0:2052561807c5 | 38 | *****************************************************************************/ |
embeddedartists | 0:2052561807c5 | 39 | |
embeddedartists | 0:2052561807c5 | 40 | int main (void) { |
embeddedartists | 0:2052561807c5 | 41 | |
embeddedartists | 0:2052561807c5 | 42 | Ticker ticker; |
embeddedartists | 0:2052561807c5 | 43 | |
embeddedartists | 0:2052561807c5 | 44 | // Frame buffer is put in SDRAM |
embeddedartists | 0:2052561807c5 | 45 | if (sdram_init() == 1) { |
embeddedartists | 0:2052561807c5 | 46 | printf("Failed to initialize SDRAM\n"); |
embeddedartists | 0:2052561807c5 | 47 | return 1; |
embeddedartists | 0:2052561807c5 | 48 | } |
embeddedartists | 0:2052561807c5 | 49 | |
embeddedartists | 0:2052561807c5 | 50 | |
embeddedartists | 0:2052561807c5 | 51 | // instantiate and initialize GUI |
embeddedartists | 0:2052561807c5 | 52 | gui = new EwGuiImpl(); |
embeddedartists | 0:2052561807c5 | 53 | |
embeddedartists | 0:2052561807c5 | 54 | // calibrate touch screen |
embeddedartists | 0:2052561807c5 | 55 | gui->calibrate(); |
embeddedartists | 0:2052561807c5 | 56 | |
embeddedartists | 0:2052561807c5 | 57 | ticker.attach(&pollTouch, 0.05); |
embeddedartists | 0:2052561807c5 | 58 | |
embeddedartists | 0:2052561807c5 | 59 | |
embeddedartists | 0:2052561807c5 | 60 | MainTask(); |
embeddedartists | 0:2052561807c5 | 61 | |
embeddedartists | 0:2052561807c5 | 62 | // application loop running the UI and checking for touch events |
embeddedartists | 0:2052561807c5 | 63 | while(1) { |
embeddedartists | 0:2052561807c5 | 64 | gui->exec(); |
embeddedartists | 0:2052561807c5 | 65 | //gui.execTouch(); |
embeddedartists | 0:2052561807c5 | 66 | } |
embeddedartists | 0:2052561807c5 | 67 | |
embeddedartists | 0:2052561807c5 | 68 | |
embeddedartists | 0:2052561807c5 | 69 | } |