Lab4
Dependencies: SeeedStudioTFTv2 TFT_fonts mbed
Fork of Seeed_TFT_Touch_Shield by
main.cpp@0:407dafce805d, 2013-10-29 (annotated)
- Committer:
- neilt6
- Date:
- Tue Oct 29 04:24:55 2013 +0000
- Revision:
- 0:407dafce805d
- Child:
- 1:b2794eb7c940
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
neilt6 | 0:407dafce805d | 1 | #include "mbed.h" |
neilt6 | 0:407dafce805d | 2 | #include "SeeedStudioTFTv2.h" |
neilt6 | 0:407dafce805d | 3 | #include "Arial12x12.h" |
neilt6 | 0:407dafce805d | 4 | #include "Arial24x23.h" |
neilt6 | 0:407dafce805d | 5 | #include "Arial28x28.h" |
neilt6 | 0:407dafce805d | 6 | #include "font_big.h" |
neilt6 | 0:407dafce805d | 7 | |
neilt6 | 0:407dafce805d | 8 | SeeedStudioTFTv2 TFT(PTB3, PTB1, PTB2, PTB0, PTD2, PTD3, PTD1, PTA5, PTC8, PTC9, PTA4); |
neilt6 | 0:407dafce805d | 9 | |
neilt6 | 0:407dafce805d | 10 | int main() |
neilt6 | 0:407dafce805d | 11 | { |
neilt6 | 0:407dafce805d | 12 | //Configure the display driver |
neilt6 | 0:407dafce805d | 13 | TFT.background(Black); |
neilt6 | 0:407dafce805d | 14 | TFT.foreground(White); |
neilt6 | 0:407dafce805d | 15 | TFT.cls(); |
neilt6 | 0:407dafce805d | 16 | |
neilt6 | 0:407dafce805d | 17 | //Print a welcome message |
neilt6 | 0:407dafce805d | 18 | TFT.set_font((unsigned char*) Arial12x12); |
neilt6 | 0:407dafce805d | 19 | TFT.locate(0,0); |
neilt6 | 0:407dafce805d | 20 | TFT.printf("Hello Mbed"); |
neilt6 | 0:407dafce805d | 21 | |
neilt6 | 0:407dafce805d | 22 | //Wait for 5 seconds |
neilt6 | 0:407dafce805d | 23 | wait(5.0); |
neilt6 | 0:407dafce805d | 24 | |
neilt6 | 0:407dafce805d | 25 | //Draw some graphics |
neilt6 | 0:407dafce805d | 26 | TFT.cls(); |
neilt6 | 0:407dafce805d | 27 | TFT.set_font((unsigned char*) Arial24x23); |
neilt6 | 0:407dafce805d | 28 | TFT.locate(100,100); |
neilt6 | 0:407dafce805d | 29 | TFT.printf("Graphic"); |
neilt6 | 0:407dafce805d | 30 | |
neilt6 | 0:407dafce805d | 31 | TFT.line(0,0,100,0,Green); |
neilt6 | 0:407dafce805d | 32 | TFT.line(0,0,0,200,Green); |
neilt6 | 0:407dafce805d | 33 | TFT.line(0,0,100,200,Green); |
neilt6 | 0:407dafce805d | 34 | |
neilt6 | 0:407dafce805d | 35 | TFT.rect(100,50,150,100,Red); |
neilt6 | 0:407dafce805d | 36 | TFT.fillrect(180,25,220,70,Blue); |
neilt6 | 0:407dafce805d | 37 | |
neilt6 | 0:407dafce805d | 38 | TFT.circle(80,150,33,White); |
neilt6 | 0:407dafce805d | 39 | TFT.fillcircle(160,190,20,Yellow); |
neilt6 | 0:407dafce805d | 40 | |
neilt6 | 0:407dafce805d | 41 | double s; |
neilt6 | 0:407dafce805d | 42 | for (int i = 0; i < 320; i++) { |
neilt6 | 0:407dafce805d | 43 | s = 20 * sin((long double)i / 10); |
neilt6 | 0:407dafce805d | 44 | TFT.pixel(i, 100 + (int)s, Red); |
neilt6 | 0:407dafce805d | 45 | } |
neilt6 | 0:407dafce805d | 46 | |
neilt6 | 0:407dafce805d | 47 | //Wait for 5 seconds |
neilt6 | 0:407dafce805d | 48 | wait(5.0); |
neilt6 | 0:407dafce805d | 49 | |
neilt6 | 0:407dafce805d | 50 | //Multiple fonts |
neilt6 | 0:407dafce805d | 51 | TFT.foreground(White); |
neilt6 | 0:407dafce805d | 52 | TFT.background(Blue); |
neilt6 | 0:407dafce805d | 53 | TFT.cls(); |
neilt6 | 0:407dafce805d | 54 | TFT.set_font((unsigned char*) Arial24x23); |
neilt6 | 0:407dafce805d | 55 | TFT.locate(0,0); |
neilt6 | 0:407dafce805d | 56 | TFT.printf("Different Fonts :"); |
neilt6 | 0:407dafce805d | 57 | TFT.set_font((unsigned char*) Neu42x35); |
neilt6 | 0:407dafce805d | 58 | TFT.locate(0,30); |
neilt6 | 0:407dafce805d | 59 | TFT.printf("Hello Mbed 1"); |
neilt6 | 0:407dafce805d | 60 | TFT.set_font((unsigned char*) Arial24x23); |
neilt6 | 0:407dafce805d | 61 | TFT.locate(20,80); |
neilt6 | 0:407dafce805d | 62 | TFT.printf("Hello Mbed 2"); |
neilt6 | 0:407dafce805d | 63 | TFT.set_font((unsigned char*) Arial12x12); |
neilt6 | 0:407dafce805d | 64 | TFT.locate(35,120); |
neilt6 | 0:407dafce805d | 65 | TFT.printf("Hello Mbed 3"); |
neilt6 | 0:407dafce805d | 66 | } |