Utilisation de la librairie modifiée pour afficher un Hello world sur l'écran de l'arduino esplora
Fork of SPI18TFT by
This program is a little hello world for the arduino esplora's screen.
/!\ do't forget to include !!My!! ST7735 llibary /!\ link: http://mbed.org/users/alex_asi_elec/code/ST7735_TFT/
main.cpp@2:761b496d208e, 2013-12-06 (annotated)
- Committer:
- alex_asi_elec
- Date:
- Fri Dec 06 21:44:17 2013 +0000
- Revision:
- 2:761b496d208e
- Parent:
- 1:a7ccea14bb0d
Fonctionne sur ecran d'arduino
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
smultron1977 | 0:309c546f048d | 1 | #include "stdio.h" |
smultron1977 | 0:309c546f048d | 2 | #include "stdlib.h" |
smultron1977 | 0:309c546f048d | 3 | #include "math.h" |
smultron1977 | 0:309c546f048d | 4 | #include "mbed.h" |
smultron1977 | 0:309c546f048d | 5 | #include "ST7735_TFT.h" |
smultron1977 | 0:309c546f048d | 6 | #include "string" |
smultron1977 | 0:309c546f048d | 7 | #include "Arial12x12.h" |
smultron1977 | 0:309c546f048d | 8 | #include "Arial24x23.h" |
smultron1977 | 0:309c546f048d | 9 | #include "Arial28x28.h" |
smultron1977 | 0:309c546f048d | 10 | |
alex_asi_elec | 1:a7ccea14bb0d | 11 | #define SCREEN_WIDTH 160 |
alex_asi_elec | 1:a7ccea14bb0d | 12 | #define SCREEN_HEIGHT 128 |
smultron1977 | 0:309c546f048d | 13 | |
smultron1977 | 0:309c546f048d | 14 | |
smultron1977 | 0:309c546f048d | 15 | |
smultron1977 | 0:309c546f048d | 16 | |
smultron1977 | 0:309c546f048d | 17 | |
smultron1977 | 0:309c546f048d | 18 | // the TFT is connected to SPI pin 5-7, CS is p8, RS is p11, reset is p15 |
alex_asi_elec | 1:a7ccea14bb0d | 19 | ST7735_TFT TFT(p11, p12, p13, p14, p16, p17,"TFT"); // mosi, miso, sclk, cs, rs, reset |
smultron1977 | 0:309c546f048d | 20 | |
smultron1977 | 0:309c546f048d | 21 | Serial pc(USBTX, USBRX); // tx, rx |
smultron1977 | 0:309c546f048d | 22 | Timer t; |
smultron1977 | 0:309c546f048d | 23 | |
smultron1977 | 0:309c546f048d | 24 | extern unsigned char p1[]; // the mbed logo |
smultron1977 | 0:309c546f048d | 25 | |
smultron1977 | 0:309c546f048d | 26 | int main() { |
alex_asi_elec | 1:a7ccea14bb0d | 27 | TFT.set_orientation(3); |
alex_asi_elec | 1:a7ccea14bb0d | 28 | |
smultron1977 | 0:309c546f048d | 29 | TFT.claim(stdout); // send stdout to the TFT display |
smultron1977 | 0:309c546f048d | 30 | //TFT.claim(stderr); // send stderr to the TFT display |
smultron1977 | 0:309c546f048d | 31 | |
smultron1977 | 0:309c546f048d | 32 | TFT.background(Black); // set background to black |
smultron1977 | 0:309c546f048d | 33 | TFT.foreground(White); // set chars to white |
smultron1977 | 0:309c546f048d | 34 | |
smultron1977 | 0:309c546f048d | 35 | TFT.cls(); |
smultron1977 | 0:309c546f048d | 36 | TFT.set_font((unsigned char*) Arial24x23); // select the font |
alex_asi_elec | 1:a7ccea14bb0d | 37 | |
smultron1977 | 0:309c546f048d | 38 | TFT.locate(0,10); |
smultron1977 | 0:309c546f048d | 39 | TFT.set_font((unsigned char*) Arial12x12); // select the font |
alex_asi_elec | 1:a7ccea14bb0d | 40 | printf(" Hello world!"); |
alex_asi_elec | 1:a7ccea14bb0d | 41 | TFT.circle(70, 70, 30, Red); |
alex_asi_elec | 1:a7ccea14bb0d | 42 | TFT.fillrect(20, 100, 100, 130, Blue); |
smultron1977 | 0:309c546f048d | 43 | } |