t

Dependencies:   DMBasicGUI DMSupport mbed

Fork of lpc4088_displaymodule_hello_world by Embedded Artists

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

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