![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
t
Dependencies: DMBasicGUI DMSupport mbed
Fork of lpc4088_displaymodule_hello_world by
main.cpp@0:8ef5f57e33dc, 2015-01-28 (annotated)
- Committer:
- embeddedartists
- Date:
- Wed Jan 28 15:16:25 2015 +0000
- Revision:
- 0:8ef5f57e33dc
- Child:
- 6:dee9a136b848
First version
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
embeddedartists | 0:8ef5f57e33dc | 1 | #include "mbed.h" |
embeddedartists | 0:8ef5f57e33dc | 2 | #include "DMBoard.h" |
embeddedartists | 0:8ef5f57e33dc | 3 | #include "lpc_swim.h" |
embeddedartists | 0:8ef5f57e33dc | 4 | #include "lpc_swim_font.h" |
embeddedartists | 0:8ef5f57e33dc | 5 | |
embeddedartists | 0:8ef5f57e33dc | 6 | int main() |
embeddedartists | 0:8ef5f57e33dc | 7 | { |
embeddedartists | 0:8ef5f57e33dc | 8 | DMBoard::BoardError err; |
embeddedartists | 0:8ef5f57e33dc | 9 | DMBoard* board = &DMBoard::instance(); |
embeddedartists | 0:8ef5f57e33dc | 10 | RtosLog* log = board->logger(); |
embeddedartists | 0:8ef5f57e33dc | 11 | Display* disp = board->display(); |
embeddedartists | 0:8ef5f57e33dc | 12 | |
embeddedartists | 0:8ef5f57e33dc | 13 | do { |
embeddedartists | 0:8ef5f57e33dc | 14 | err = board->init(); |
embeddedartists | 0:8ef5f57e33dc | 15 | if (err != DMBoard::Ok) { |
embeddedartists | 0:8ef5f57e33dc | 16 | log->printf("Failed to initialize the board, got error %d\r\n", err); |
embeddedartists | 0:8ef5f57e33dc | 17 | break; |
embeddedartists | 0:8ef5f57e33dc | 18 | } |
embeddedartists | 0:8ef5f57e33dc | 19 | |
embeddedartists | 0:8ef5f57e33dc | 20 | log->printf("\n\nHello World!\n\n"); |
embeddedartists | 0:8ef5f57e33dc | 21 | |
embeddedartists | 0:8ef5f57e33dc | 22 | SWIM_WINDOW_T win; |
embeddedartists | 0:8ef5f57e33dc | 23 | void* fb = disp->allocateFramebuffer(); |
embeddedartists | 0:8ef5f57e33dc | 24 | if (fb == NULL) { |
embeddedartists | 0:8ef5f57e33dc | 25 | log->printf("Failed to allocate memory for a frame buffer\r\n"); |
embeddedartists | 0:8ef5f57e33dc | 26 | err = DMBoard::MemoryError; |
embeddedartists | 0:8ef5f57e33dc | 27 | break; |
embeddedartists | 0:8ef5f57e33dc | 28 | } |
embeddedartists | 0:8ef5f57e33dc | 29 | |
embeddedartists | 0:8ef5f57e33dc | 30 | // Prepare fullscreen |
embeddedartists | 0:8ef5f57e33dc | 31 | swim_window_open(&win, |
embeddedartists | 0:8ef5f57e33dc | 32 | disp->width(), disp->height(), // full size |
embeddedartists | 0:8ef5f57e33dc | 33 | (COLOR_T*)fb, |
embeddedartists | 0:8ef5f57e33dc | 34 | 0,0,disp->width()-1, disp->height()-1, // window position and size |
embeddedartists | 0:8ef5f57e33dc | 35 | 1, // border |
embeddedartists | 0:8ef5f57e33dc | 36 | WHITE, BLUE, BLACK); // colors: pen, backgr, forgr |
embeddedartists | 0:8ef5f57e33dc | 37 | swim_set_title(&win, "My Program", BLACK); |
embeddedartists | 0:8ef5f57e33dc | 38 | |
embeddedartists | 0:8ef5f57e33dc | 39 | // Message |
embeddedartists | 0:8ef5f57e33dc | 40 | swim_put_text_xy(&win, "Hello World!", 100, 100); |
embeddedartists | 0:8ef5f57e33dc | 41 | |
embeddedartists | 0:8ef5f57e33dc | 42 | // Start display in default mode (16-bit) |
embeddedartists | 0:8ef5f57e33dc | 43 | Display::DisplayError disperr = disp->powerUp(fb); |
embeddedartists | 0:8ef5f57e33dc | 44 | if (disperr != Display::DisplayError_Ok) { |
embeddedartists | 0:8ef5f57e33dc | 45 | log->printf("Failed to initialize the display, got error %d\r\n", disperr); |
embeddedartists | 0:8ef5f57e33dc | 46 | break; |
embeddedartists | 0:8ef5f57e33dc | 47 | } |
embeddedartists | 0:8ef5f57e33dc | 48 | } while(false); |
embeddedartists | 0:8ef5f57e33dc | 49 | |
embeddedartists | 0:8ef5f57e33dc | 50 | if (err != DMBoard::Ok) { |
embeddedartists | 0:8ef5f57e33dc | 51 | log->printf("\nTERMINATING\n"); |
embeddedartists | 0:8ef5f57e33dc | 52 | wait_ms(2000); // allow RtosLog to flush messages |
embeddedartists | 0:8ef5f57e33dc | 53 | mbed_die(); |
embeddedartists | 0:8ef5f57e33dc | 54 | } |
embeddedartists | 0:8ef5f57e33dc | 55 | |
embeddedartists | 0:8ef5f57e33dc | 56 | while(true) { |
embeddedartists | 0:8ef5f57e33dc | 57 | } |
embeddedartists | 0:8ef5f57e33dc | 58 | } |