EmbeddedArtists AB
/
app_lcdboard_demo_picture
Example for the LPC4088 QSB Base Board
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 /****************************************************************************** 00002 * Includes 00003 *****************************************************************************/ 00004 00005 #include "mbed.h" 00006 00007 #include "LcdController.h" 00008 #include "EaLcdBoard.h" 00009 #include "sdram.h" 00010 00011 #include "PictureDemo.h" 00012 00013 00014 /****************************************************************************** 00015 * Typedefs and defines 00016 *****************************************************************************/ 00017 00018 #define RESET_FLAG \ 00019 do { \ 00020 if (abortTest) { \ 00021 abortTest = false; \ 00022 wait(0.04); \ 00023 } \ 00024 } while(false) 00025 00026 /****************************************************************************** 00027 * Local variables 00028 *****************************************************************************/ 00029 00030 static InterruptIn buttonInterrupt(P2_10); 00031 static DigitalOut led(LED1); 00032 00033 /****************************************************************************** 00034 * Global variables 00035 *****************************************************************************/ 00036 00037 EaLcdBoard lcdBoard(P0_27, P0_28); 00038 bool abortTest = false; 00039 00040 /****************************************************************************** 00041 * Interrupt functions 00042 *****************************************************************************/ 00043 00044 void trigger() { 00045 abortTest = true; 00046 } 00047 00048 /****************************************************************************** 00049 * Main 00050 *****************************************************************************/ 00051 00052 int main (void) { 00053 00054 EaLcdBoard::Result result; 00055 LcdController::Config lcdCfg; 00056 uint32_t frameBuf1; 00057 00058 printf("EA LCD Board Picture Demo\n"); 00059 00060 // Listen for button presses 00061 buttonInterrupt.mode(PullUp); 00062 buttonInterrupt.fall(&trigger); 00063 00064 do { 00065 // framebuffer is put in SDRAM 00066 if (sdram_init() == 1) { 00067 printf("Failed to initialize SDRAM\n"); 00068 break; 00069 } 00070 00071 result = lcdBoard.open(NULL, NULL); 00072 if (result != EaLcdBoard::Ok) { 00073 printf("Failed to open display: %d\n", result); 00074 break; 00075 } 00076 00077 result = lcdBoard.getLcdConfig(&lcdCfg); 00078 if (result != EaLcdBoard::Ok) { 00079 printf("Failed to get LCD configuration: %d\n", result); 00080 break; 00081 } 00082 00083 // Prepare 3 consequtive framebuffers (2 will be used for background buffers) 00084 frameBuf1 = (uint32_t)malloc(lcdCfg.width*lcdCfg.height*2 *3); 00085 if (frameBuf1 == NULL) { 00086 printf("Failed to allocate memory for the frame buffer\n"); 00087 break; 00088 } 00089 memset((void*)frameBuf1, 0x0, lcdCfg.width*lcdCfg.height*2 *3); 00090 00091 result = lcdBoard.setFrameBuffer(frameBuf1); 00092 if (result != EaLcdBoard::Ok) { 00093 printf("Failed to activate frameBuffer: %d\n", result); 00094 break; 00095 } 00096 00097 PictureDemo pictureDemo((uint8_t *)frameBuf1, lcdCfg.width, lcdCfg.height); 00098 while (1) { 00099 00100 //Display Picture 1 for two seconds 00101 pictureDemo.run(1, 2000); 00102 RESET_FLAG; 00103 00104 //Display Picture 2 for three seconds 00105 pictureDemo.run(2, 3000); 00106 RESET_FLAG; 00107 } 00108 } while(0); 00109 00110 // Blink to indicate error 00111 while (1) { 00112 led = 0; 00113 wait(0.2); 00114 led = 1; 00115 wait(0.2); 00116 } 00117 }
Generated on Fri Jul 15 2022 02:20:39 by 1.7.2