Template for creating new programs for the LPC4088 Display Module
Dependencies: DMBasicGUI DMSupport
Fork of lpc4088_displaymodule_hello_world by
main.cpp
00001 #include "mbed.h" 00002 #include "platform/mbed_thread.h" 00003 #include "DMBoard.h" 00004 #include "lpc_swim.h" 00005 #include "lpc_swim_font.h" 00006 00007 int main() 00008 { 00009 00010 DMBoard::BoardError err; 00011 DMBoard* board = &DMBoard::instance(); 00012 RtosLog* log = board->logger(); 00013 Display* disp = board->display(); 00014 00015 do { 00016 err = board->init(); 00017 if (err != DMBoard::Ok) { 00018 log->printf("Failed to initialize the board, got error %d\r\n", err); 00019 break; 00020 } 00021 00022 log->printf("\n\nHello World!\n\n"); 00023 00024 SWIM_WINDOW_T win; 00025 void* fb = disp->allocateFramebuffer(); 00026 if (fb == NULL) { 00027 log->printf("Failed to allocate memory for a frame buffer\r\n"); 00028 err = DMBoard::MemoryError; 00029 break; 00030 } 00031 00032 // Prepare fullscreen 00033 swim_window_open(&win, 00034 disp->width(), disp->height(), // full size 00035 (COLOR_T*)fb, 00036 0,0,disp->width()-1, disp->height()-1, // window position and size 00037 1, // border 00038 WHITE, BLUE, BLACK); // colors: pen, backgr, forgr 00039 swim_set_title(&win, "My Program", BLACK); 00040 00041 // Message 00042 swim_put_text_xy(&win, "Hello World!", 100, 100); 00043 00044 // Start display in default mode (16-bit) 00045 Display::DisplayError disperr = disp->powerUp(fb); 00046 if (disperr != Display::DisplayError_Ok) { 00047 log->printf("Failed to initialize the display, got error %d\r\n", disperr); 00048 break; 00049 } 00050 00051 } while(false); 00052 00053 if (err != DMBoard::Ok) { 00054 log->printf("\nTERMINATING\n"); 00055 thread_sleep_for(2000); // allow RtosLog to flush messages 00056 mbed_die(); 00057 } 00058 00059 while(true) { 00060 } 00061 }
Generated on Tue Jul 12 2022 21:29:53 by 1.7.2