Curtis Mattull
/
PANEL_GUI_hello_world
basic functional test of FT810 LCD via SPI
main.cpp@23:0045679060e3, 2016-10-02 (annotated)
- Committer:
- cpm219
- Date:
- Sun Oct 02 04:54:20 2016 +0000
- Revision:
- 23:0045679060e3
- Parent:
- 22:2bdc80e45f3b
latest
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
cpm219 | 23:0045679060e3 | 1 | /* Curtis Mattull |
cpm219 | 23:0045679060e3 | 2 | 10/1/16 |
cpm219 | 23:0045679060e3 | 3 | This simple program tests LCD SPI functionality |
cratliff | 5:e2e04cb5eada | 4 | */ |
cpm219 | 17:f98333612db8 | 5 | #include "mbed.h" |
cratliff | 0:aa55c6eb6867 | 6 | #include "FT_Platform.h" |
cpm219 | 17:f98333612db8 | 7 | |
cpm219 | 23:0045679060e3 | 8 | void screen1(uint32_t tracker, uint8_t tag); |
cpm219 | 23:0045679060e3 | 9 | void rotate_screen(uint8_t val); |
cpm219 | 22:2bdc80e45f3b | 10 | // create an LCD object |
cpm219 | 23:0045679060e3 | 11 | FT800 TFT( PTD6, PTD7, PTD5, PTD4, PTB19, PTA1); |
cpm219 | 23:0045679060e3 | 12 | // ( mosi, miso, sclk, ss, intr, pd ); |
cpm219 | 23:0045679060e3 | 13 | RawSerial terminal(USBTX, USBRX); // computer to mbed board |
cpm219 | 23:0045679060e3 | 14 | int main(void) |
cpm219 | 18:d1566d9b6ea1 | 15 | { |
cpm219 | 23:0045679060e3 | 16 | terminal.baud(9600); |
cpm219 | 23:0045679060e3 | 17 | printf("main entered\r\n"); |
cpm219 | 23:0045679060e3 | 18 | rotate_screen(1); |
cpm219 | 23:0045679060e3 | 19 | set_time(0); // Set RTC time to 0 |
cpm219 | 20:92b3e641b306 | 20 | |
cpm219 | 23:0045679060e3 | 21 | //draw screen |
cpm219 | 23:0045679060e3 | 22 | for(;;) |
cpm219 | 23:0045679060e3 | 23 | { |
cpm219 | 23:0045679060e3 | 24 | // screen1(0x0,0x0); |
cpm219 | 23:0045679060e3 | 25 | wait(1); |
cpm219 | 18:d1566d9b6ea1 | 26 | } |
cpm219 | 23:0045679060e3 | 27 | |
cpm219 | 18:d1566d9b6ea1 | 28 | return 0; |
cpm219 | 18:d1566d9b6ea1 | 29 | } |
cpm219 | 17:f98333612db8 | 30 | |
cpm219 | 17:f98333612db8 | 31 | |
cpm219 | 23:0045679060e3 | 32 | void rotate_screen(uint8_t val) |
cpm219 | 18:d1566d9b6ea1 | 33 | { |
cpm219 | 23:0045679060e3 | 34 | if (val == 0) |
cpm219 | 23:0045679060e3 | 35 | { |
cpm219 | 23:0045679060e3 | 36 | TFT.MemWrite(REG_ROTATE, 1); // rotate screen |
cpm219 | 23:0045679060e3 | 37 | TFT.Rotate(1); |
cpm219 | 23:0045679060e3 | 38 | TFT.Flush_Co_Buffer(); // Download the command list into fifo |
cpm219 | 23:0045679060e3 | 39 | TFT.WaitCmdfifo_empty(); // Wait till coprocessor completes the operation |
cpm219 | 17:f98333612db8 | 40 | } |
cpm219 | 17:f98333612db8 | 41 | } |
cpm219 | 17:f98333612db8 | 42 | |
montgojj | 4:a48fc7a3bda9 | 43 | |
cpm219 | 23:0045679060e3 | 44 | void screen1(uint32_t tracker, uint8_t tag) |
cpm219 | 17:f98333612db8 | 45 | { |
cpm219 | 23:0045679060e3 | 46 | printf("screen1 entered\r\n"); |
cpm219 | 22:2bdc80e45f3b | 47 | time_t seconds = time(NULL); |
cpm219 | 18:d1566d9b6ea1 | 48 | |
cpm219 | 17:f98333612db8 | 49 | //start new display list |
cpm219 | 17:f98333612db8 | 50 | TFT.DLstart(); // start a new display command list |
cpm219 | 17:f98333612db8 | 51 | TFT.DL(CLEAR_COLOR_RGB(255,255,255)); // set the clear color to white |
cpm219 | 17:f98333612db8 | 52 | TFT.DL(CLEAR(1,1,1)); // clear buffers -> color buffer,stencil buffer, tag buffer |
cpm219 | 18:d1566d9b6ea1 | 53 | |
cpm219 | 17:f98333612db8 | 54 | TFT.DL(TAG(0)); // assign TAG value 0 to everything else |
cpm219 | 18:d1566d9b6ea1 | 55 | |
cpm219 | 18:d1566d9b6ea1 | 56 | //title text |
cpm219 | 22:2bdc80e45f3b | 57 | TFT.DL(COLOR_RGB(0, 0, 0)); |
cpm219 | 23:0045679060e3 | 58 | TFT.Text((TFT.DispWidth/2), TFT.DispHeight/8, 28, OPT_CENTERX, "test\0"); // draw Text with font 31 |
cpm219 | 18:d1566d9b6ea1 | 59 | |
cpm219 | 22:2bdc80e45f3b | 60 | // time |
cpm219 | 23:0045679060e3 | 61 | TFT.Text((TFT.DispWidth/4), TFT.DispHeight*7/8, 28, OPT_CENTERX, "Run time [s]: \0"); // draw Text with font 31 |
cpm219 | 23:0045679060e3 | 62 | TFT.Number((TFT.DispWidth/2), (TFT.DispHeight*7/8),28,OPT_CENTERX, seconds); |
cpm219 | 22:2bdc80e45f3b | 63 | |
cpm219 | 17:f98333612db8 | 64 | //author text |
cpm219 | 18:d1566d9b6ea1 | 65 | TFT.DL(COLOR_RGB(0x00, 0x00, 0x00)); |
cpm219 | 23:0045679060e3 | 66 | TFT.Text((TFT.DispWidth*7/8)+9, (TFT.DispHeight*15/16), 28, OPT_CENTERX, "by Curtis Mattull\0"); // draw Text with font 31 |
cpm219 | 18:d1566d9b6ea1 | 67 | |
cpm219 | 17:f98333612db8 | 68 | //display the screen |
cpm219 | 17:f98333612db8 | 69 | TFT.DL(DISPLAY()); // display the image |
cpm219 | 17:f98333612db8 | 70 | TFT.Swap(); // swap the current display list |
cpm219 | 17:f98333612db8 | 71 | TFT.Flush_Co_Buffer(); // download the command list into fifo |
cpm219 | 17:f98333612db8 | 72 | TFT.WaitCmdfifo_empty(); // wait till coprocessor completes the operation |
cpm219 | 17:f98333612db8 | 73 | |
montgojj | 8:886908a6127c | 74 | } |