Graphical demo for the LPC4088 Experiment Base Board with one of the Display Expansion Kits. This program displays how to write text in different fonts.
TextDemo.cpp@0:5e5e9ec91fc8, 2015-06-25 (annotated)
- Committer:
- embeddedartists
- Date:
- Thu Jun 25 10:30:15 2015 +0000
- Revision:
- 0:5e5e9ec91fc8
First version
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
embeddedartists | 0:5e5e9ec91fc8 | 1 | /****************************************************************************** |
embeddedartists | 0:5e5e9ec91fc8 | 2 | * Includes |
embeddedartists | 0:5e5e9ec91fc8 | 3 | *****************************************************************************/ |
embeddedartists | 0:5e5e9ec91fc8 | 4 | |
embeddedartists | 0:5e5e9ec91fc8 | 5 | #include "mbed.h" |
embeddedartists | 0:5e5e9ec91fc8 | 6 | |
embeddedartists | 0:5e5e9ec91fc8 | 7 | #include "LcdController.h" |
embeddedartists | 0:5e5e9ec91fc8 | 8 | #include "EaLcdBoard.h" |
embeddedartists | 0:5e5e9ec91fc8 | 9 | #include "TextDemo.h" |
embeddedartists | 0:5e5e9ec91fc8 | 10 | #include "lpc_winfreesystem14x16.h" |
embeddedartists | 0:5e5e9ec91fc8 | 11 | #include "lpc_rom8x8.h" |
embeddedartists | 0:5e5e9ec91fc8 | 12 | #include "lpc_rom8x16.h" |
embeddedartists | 0:5e5e9ec91fc8 | 13 | #include "lpc_x5x7.h" |
embeddedartists | 0:5e5e9ec91fc8 | 14 | #include "lpc_x6x13.h" |
embeddedartists | 0:5e5e9ec91fc8 | 15 | #include "lpc_helvr10.h" |
embeddedartists | 0:5e5e9ec91fc8 | 16 | |
embeddedartists | 0:5e5e9ec91fc8 | 17 | /****************************************************************************** |
embeddedartists | 0:5e5e9ec91fc8 | 18 | * Typedefs and defines |
embeddedartists | 0:5e5e9ec91fc8 | 19 | *****************************************************************************/ |
embeddedartists | 0:5e5e9ec91fc8 | 20 | |
embeddedartists | 0:5e5e9ec91fc8 | 21 | #define NUM_TO_TEST (sizeof(BKGCOLORS)/sizeof(BKGCOLORS[0])) |
embeddedartists | 0:5e5e9ec91fc8 | 22 | |
embeddedartists | 0:5e5e9ec91fc8 | 23 | /****************************************************************************** |
embeddedartists | 0:5e5e9ec91fc8 | 24 | * Local variables |
embeddedartists | 0:5e5e9ec91fc8 | 25 | *****************************************************************************/ |
embeddedartists | 0:5e5e9ec91fc8 | 26 | |
embeddedartists | 0:5e5e9ec91fc8 | 27 | static const COLOR_T BKGCOLORS[] = { BLUE, RED, GREEN, YELLOW, CYAN, MAGENTA, LIGHTGRAY }; |
embeddedartists | 0:5e5e9ec91fc8 | 28 | static const COLOR_T PENCOLORS[] = { WHITE, WHITE, BLACK, BLACK, BLACK, WHITE, RED }; |
embeddedartists | 0:5e5e9ec91fc8 | 29 | |
embeddedartists | 0:5e5e9ec91fc8 | 30 | /****************************************************************************** |
embeddedartists | 0:5e5e9ec91fc8 | 31 | * Public functions |
embeddedartists | 0:5e5e9ec91fc8 | 32 | *****************************************************************************/ |
embeddedartists | 0:5e5e9ec91fc8 | 33 | TextDemo::TextDemo(uint8_t *pFrameBuf, uint16_t dispWidth, uint16_t dispHeight) |
embeddedartists | 0:5e5e9ec91fc8 | 34 | { |
embeddedartists | 0:5e5e9ec91fc8 | 35 | swim_window_open(&this->_win, |
embeddedartists | 0:5e5e9ec91fc8 | 36 | dispWidth, dispHeight, // full screen |
embeddedartists | 0:5e5e9ec91fc8 | 37 | (COLOR_T*)pFrameBuf, |
embeddedartists | 0:5e5e9ec91fc8 | 38 | 0,0,dispWidth-1,dispHeight-1, // window position and size |
embeddedartists | 0:5e5e9ec91fc8 | 39 | 0, // border |
embeddedartists | 0:5e5e9ec91fc8 | 40 | WHITE, BLUE, BLACK); // colors: pen, backgr, forgr |
embeddedartists | 0:5e5e9ec91fc8 | 41 | } |
embeddedartists | 0:5e5e9ec91fc8 | 42 | |
embeddedartists | 0:5e5e9ec91fc8 | 43 | void TextDemo::run(EaLcdBoardGPIO& lcdBoard, uint32_t loops, uint32_t delayMs) |
embeddedartists | 0:5e5e9ec91fc8 | 44 | { |
embeddedartists | 0:5e5e9ec91fc8 | 45 | printf("TextDemo, %d loops, %dms delay\n", loops, delayMs); |
embeddedartists | 0:5e5e9ec91fc8 | 46 | |
embeddedartists | 0:5e5e9ec91fc8 | 47 | //update framebuffer |
embeddedartists | 0:5e5e9ec91fc8 | 48 | lcdBoard.setFrameBuffer((uint32_t)this->_win.fb); |
embeddedartists | 0:5e5e9ec91fc8 | 49 | |
embeddedartists | 0:5e5e9ec91fc8 | 50 | // Draw strings with the different fonts in different color combinations |
embeddedartists | 0:5e5e9ec91fc8 | 51 | for (int i = 0; i < NUM_TO_TEST; i++) { |
embeddedartists | 0:5e5e9ec91fc8 | 52 | swim_set_bkg_color(&this->_win, BKGCOLORS[i]); |
embeddedartists | 0:5e5e9ec91fc8 | 53 | swim_set_pen_color(&this->_win, PENCOLORS[i]); |
embeddedartists | 0:5e5e9ec91fc8 | 54 | swim_clear_screen(&this->_win, this->_win.bkg); |
embeddedartists | 0:5e5e9ec91fc8 | 55 | |
embeddedartists | 0:5e5e9ec91fc8 | 56 | int incr = 30; |
embeddedartists | 0:5e5e9ec91fc8 | 57 | int y = incr; |
embeddedartists | 0:5e5e9ec91fc8 | 58 | swim_put_text_xy(&this->_win, "Default Font 0123456789 abcdefghijklmnopqrstuvwxyz", 20, y); |
embeddedartists | 0:5e5e9ec91fc8 | 59 | y += incr; |
embeddedartists | 0:5e5e9ec91fc8 | 60 | |
embeddedartists | 0:5e5e9ec91fc8 | 61 | wait_ms(1000); |
embeddedartists | 0:5e5e9ec91fc8 | 62 | swim_set_font(&this->_win, (FONT_T*)&font_winfreesys14x16); |
embeddedartists | 0:5e5e9ec91fc8 | 63 | swim_put_text_xy(&this->_win, "font_winfreesys14x16 0123456789 abcdefghijklmnopqrstuvwxyz", 20, y); |
embeddedartists | 0:5e5e9ec91fc8 | 64 | y += incr; |
embeddedartists | 0:5e5e9ec91fc8 | 65 | |
embeddedartists | 0:5e5e9ec91fc8 | 66 | wait_ms(1000); |
embeddedartists | 0:5e5e9ec91fc8 | 67 | swim_set_font(&this->_win, (FONT_T*)&font_rom8x8); |
embeddedartists | 0:5e5e9ec91fc8 | 68 | swim_put_text_xy(&this->_win, "font_rom8x8 0123456789 abcdefghijklmnopqrstuvwxyz", 20, y); |
embeddedartists | 0:5e5e9ec91fc8 | 69 | y += incr; |
embeddedartists | 0:5e5e9ec91fc8 | 70 | |
embeddedartists | 0:5e5e9ec91fc8 | 71 | wait_ms(1000); |
embeddedartists | 0:5e5e9ec91fc8 | 72 | swim_set_font(&this->_win, (FONT_T*)&font_rom8x16); |
embeddedartists | 0:5e5e9ec91fc8 | 73 | swim_put_text_xy(&this->_win, "font_rom8x16 0123456789 abcdefghijklmnopqrstuvwxyz", 20, y); |
embeddedartists | 0:5e5e9ec91fc8 | 74 | y += incr; |
embeddedartists | 0:5e5e9ec91fc8 | 75 | |
embeddedartists | 0:5e5e9ec91fc8 | 76 | wait_ms(1000); |
embeddedartists | 0:5e5e9ec91fc8 | 77 | swim_set_font(&this->_win, (FONT_T*)&font_x5x7); |
embeddedartists | 0:5e5e9ec91fc8 | 78 | swim_put_text_xy(&this->_win, "font_x5x7 0123456789 abcdefghijklmnopqrstuvwxyz", 20, y); |
embeddedartists | 0:5e5e9ec91fc8 | 79 | y += incr; |
embeddedartists | 0:5e5e9ec91fc8 | 80 | |
embeddedartists | 0:5e5e9ec91fc8 | 81 | wait_ms(1000); |
embeddedartists | 0:5e5e9ec91fc8 | 82 | swim_set_font(&this->_win, (FONT_T*)&font_x6x13); |
embeddedartists | 0:5e5e9ec91fc8 | 83 | swim_put_text_xy(&this->_win, "font_x6x13 0123456789 abcdefghijklmnopqrstuvwxyz", 20, y); |
embeddedartists | 0:5e5e9ec91fc8 | 84 | y += incr; |
embeddedartists | 0:5e5e9ec91fc8 | 85 | |
embeddedartists | 0:5e5e9ec91fc8 | 86 | wait_ms(1000); |
embeddedartists | 0:5e5e9ec91fc8 | 87 | swim_set_font(&this->_win, (FONT_T*)&font_helvr10); |
embeddedartists | 0:5e5e9ec91fc8 | 88 | swim_put_text_xy(&this->_win, "font_helvr10 0123456789 abcdefghijklmnopqrstuvwxyz", 20, y); |
embeddedartists | 0:5e5e9ec91fc8 | 89 | y += incr; |
embeddedartists | 0:5e5e9ec91fc8 | 90 | |
embeddedartists | 0:5e5e9ec91fc8 | 91 | wait_ms(2500); |
embeddedartists | 0:5e5e9ec91fc8 | 92 | } |
embeddedartists | 0:5e5e9ec91fc8 | 93 | memset((void*)(this->_win.fb), 0, this->_win.xpsize * this->_win.ypsize * sizeof(COLOR_T)); |
embeddedartists | 0:5e5e9ec91fc8 | 94 | } |