A simple Hello World program, to demonstrate the current problem with the dm_board_config.h file - if it is in its normal place, the root directory, the project will not build, while if I copy it to the DMSupport subdirectory, the project builds OK.
Dependencies: DMBasicGUI DMSupport
main.cpp@0:4d73151d9b87, 2018-10-04 (annotated)
- Committer:
- jmitc91516
- Date:
- Thu Oct 04 08:33:31 2018 +0000
- Revision:
- 0:4d73151d9b87
Demonstrates the current problem with dm_board_config.h - the project will not build with this file in its normal place, the root directory, but builds OK if I copy it to the DMSupport subdirectory.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jmitc91516 | 0:4d73151d9b87 | 1 | #include "mbed.h" |
jmitc91516 | 0:4d73151d9b87 | 2 | #include "DMBoard.h" |
jmitc91516 | 0:4d73151d9b87 | 3 | #include "lpc_swim.h" |
jmitc91516 | 0:4d73151d9b87 | 4 | #include "lpc_swim_font.h" |
jmitc91516 | 0:4d73151d9b87 | 5 | |
jmitc91516 | 0:4d73151d9b87 | 6 | int main() |
jmitc91516 | 0:4d73151d9b87 | 7 | { |
jmitc91516 | 0:4d73151d9b87 | 8 | DMBoard::BoardError err; |
jmitc91516 | 0:4d73151d9b87 | 9 | DMBoard* board = &DMBoard::instance(); |
jmitc91516 | 0:4d73151d9b87 | 10 | RtosLog* log = board->logger(); |
jmitc91516 | 0:4d73151d9b87 | 11 | Display* disp = board->display(); |
jmitc91516 | 0:4d73151d9b87 | 12 | |
jmitc91516 | 0:4d73151d9b87 | 13 | do { |
jmitc91516 | 0:4d73151d9b87 | 14 | err = board->init(); |
jmitc91516 | 0:4d73151d9b87 | 15 | if (err != DMBoard::Ok) { |
jmitc91516 | 0:4d73151d9b87 | 16 | log->printf("Failed to initialize the board, got error %d\r\n", err); |
jmitc91516 | 0:4d73151d9b87 | 17 | break; |
jmitc91516 | 0:4d73151d9b87 | 18 | } |
jmitc91516 | 0:4d73151d9b87 | 19 | |
jmitc91516 | 0:4d73151d9b87 | 20 | log->printf("\n\nHello World!\n\n"); |
jmitc91516 | 0:4d73151d9b87 | 21 | |
jmitc91516 | 0:4d73151d9b87 | 22 | SWIM_WINDOW_T win; |
jmitc91516 | 0:4d73151d9b87 | 23 | void* fb = disp->allocateFramebuffer(); |
jmitc91516 | 0:4d73151d9b87 | 24 | if (fb == NULL) { |
jmitc91516 | 0:4d73151d9b87 | 25 | log->printf("Failed to allocate memory for a frame buffer\r\n"); |
jmitc91516 | 0:4d73151d9b87 | 26 | err = DMBoard::MemoryError; |
jmitc91516 | 0:4d73151d9b87 | 27 | break; |
jmitc91516 | 0:4d73151d9b87 | 28 | } |
jmitc91516 | 0:4d73151d9b87 | 29 | |
jmitc91516 | 0:4d73151d9b87 | 30 | // Prepare fullscreen |
jmitc91516 | 0:4d73151d9b87 | 31 | swim_window_open(&win, |
jmitc91516 | 0:4d73151d9b87 | 32 | disp->width(), disp->height(), // full size |
jmitc91516 | 0:4d73151d9b87 | 33 | (COLOR_T*)fb, |
jmitc91516 | 0:4d73151d9b87 | 34 | 0,0,disp->width()-1, disp->height()-1, // window position and size |
jmitc91516 | 0:4d73151d9b87 | 35 | 1, // border |
jmitc91516 | 0:4d73151d9b87 | 36 | WHITE, BLUE, BLACK); // colors: pen, backgr, forgr |
jmitc91516 | 0:4d73151d9b87 | 37 | swim_set_title(&win, "My Program", BLACK); |
jmitc91516 | 0:4d73151d9b87 | 38 | |
jmitc91516 | 0:4d73151d9b87 | 39 | // Message |
jmitc91516 | 0:4d73151d9b87 | 40 | swim_put_text_xy(&win, "Hello World!", 100, 100); |
jmitc91516 | 0:4d73151d9b87 | 41 | |
jmitc91516 | 0:4d73151d9b87 | 42 | // Start display in default mode (16-bit) |
jmitc91516 | 0:4d73151d9b87 | 43 | Display::DisplayError disperr = disp->powerUp(fb); |
jmitc91516 | 0:4d73151d9b87 | 44 | if (disperr != Display::DisplayError_Ok) { |
jmitc91516 | 0:4d73151d9b87 | 45 | log->printf("Failed to initialize the display, got error %d\r\n", disperr); |
jmitc91516 | 0:4d73151d9b87 | 46 | break; |
jmitc91516 | 0:4d73151d9b87 | 47 | } |
jmitc91516 | 0:4d73151d9b87 | 48 | } while(false); |
jmitc91516 | 0:4d73151d9b87 | 49 | |
jmitc91516 | 0:4d73151d9b87 | 50 | if (err != DMBoard::Ok) { |
jmitc91516 | 0:4d73151d9b87 | 51 | log->printf("\nTERMINATING\n"); |
jmitc91516 | 0:4d73151d9b87 | 52 | wait_ms(2000); // allow RtosLog to flush messages |
jmitc91516 | 0:4d73151d9b87 | 53 | mbed_die(); |
jmitc91516 | 0:4d73151d9b87 | 54 | } |
jmitc91516 | 0:4d73151d9b87 | 55 | |
jmitc91516 | 0:4d73151d9b87 | 56 | while(true) { |
jmitc91516 | 0:4d73151d9b87 | 57 | } |
jmitc91516 | 0:4d73151d9b87 | 58 | } |