Utilisation de la librairie modifiée pour afficher un Hello world sur l'écran de l'arduino esplora

Dependencies:   ST7735_TFT mbed

Fork of SPI18TFT by Jonne Valola

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/

Files at this revision

API Documentation at this revision

Comitter:
alex_asi_elec
Date:
Fri Dec 06 21:39:48 2013 +0000
Parent:
0:309c546f048d
Child:
2:761b496d208e
Commit message:
fonctionne sur l'?cran

Changed in this revision

ST7735_TFT.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/ST7735_TFT.lib	Sun Dec 11 21:14:33 2011 +0000
+++ b/ST7735_TFT.lib	Fri Dec 06 21:39:48 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/smultron1977/code/ST7735_TFT/#967235e6fd48
+http://mbed.org/users/smultron1977/code/ST7735_TFT/#b9c08958fef9
--- a/main.cpp	Sun Dec 11 21:14:33 2011 +0000
+++ b/main.cpp	Fri Dec 06 21:39:48 2013 +0000
@@ -8,51 +8,15 @@
  #include "Arial24x23.h"
  #include "Arial28x28.h"
 
- #define NUMBER_OF_STARS 300
- #define SCREEN_WIDTH 128
- #define SCREEN_HEIGHT 160
+ #define SCREEN_WIDTH 160
+ #define SCREEN_HEIGHT 128
  
- /*star struct*/
-typedef struct 
-{
-  float xpos, ypos;
-  short zpos, speed;
-  unsigned int color;
-} STAR;
-
-static STAR stars[NUMBER_OF_STARS];
 
 
-void init_star(STAR* star, int i)
-{
-  /* randomly init stars, generate them around the center of the screen */
-  
-  star->xpos =  -10.0 + (20.0 * (rand()/(RAND_MAX+1.0)));
-  star->ypos =  -10.0 + (20.0 * (rand()/(RAND_MAX+1.0)));
-  
-  star->xpos *= 3072.0; /*change viewpoint */
-  star->ypos *= 3072.0;
-
-  star->zpos =  i;
-  star->speed =  2 + (int)(2.0 * (rand()/(RAND_MAX+1.0)));
-
-  star->color = i*Cyan >> 2; /*the closer to the viewer the brighter*/
-}
-
-
-void init()
-{
-  int i;
-
-  for (i = 0; i < NUMBER_OF_STARS; i++)
-    {
-      init_star(stars + i, i + 1);
-    }
-}
  
   
  // the TFT is connected to SPI pin 5-7, CS is p8, RS is p11, reset is p15 
- ST7735_TFT TFT(p5, p6, p7, p8, p11, p15,"TFT"); // mosi, miso, sclk, cs, rs, reset
+ ST7735_TFT TFT(p11, p12, p13, p14, p16, p17,"TFT"); // mosi, miso, sclk, cs, rs, reset
  
  Serial pc(USBTX, USBRX); // tx, rx
  Timer t;
@@ -60,15 +24,8 @@
 extern unsigned char p1[];  // the mbed logo
  
  int main() {
-    
-    unsigned int centerx, centery;
-    int i, j, tempx, tempy;  
-    init();
-    TFT.set_orientation(1);
-    centerx = TFT.width() >> 1;
-    centery = TFT.height() >> 1; 
-    
-     
+    TFT.set_orientation(3);
+   
     TFT.claim(stdout);      // send stdout to the TFT display 
     //TFT.claim(stderr);      // send stderr to the TFT display
 
@@ -77,50 +34,10 @@
     
     TFT.cls();
     TFT.set_font((unsigned char*) Arial24x23);  // select the font
-        
-    t.start();
-
-    ////// demo start
-    
-    for ( j = 0 ; j < 10000; j++ ) 
-    {
-     
-      /* move and draw stars */
-       
-      for (i = 0; i < NUMBER_OF_STARS; i++)
-    {
-      tempx = (stars[i].xpos / stars[i].zpos) + centerx;
-      tempy = (stars[i].ypos / stars[i].zpos) + centery;
-      TFT.pixel(tempx,tempy,Black);
-      
-        
-      stars[i].zpos -= stars[i].speed;
-      
-      if (stars[i].zpos <= 0)
-        {
-          init_star(stars + i, i + 1);
-        }
-
-      //compute 3D position
-      tempx = (stars[i].xpos / stars[i].zpos) + centerx;
-      tempy = (stars[i].ypos / stars[i].zpos) + centery;
-
-      if (tempx < 0 || tempx > TFT.width() - 1 || tempy < 0 || tempy > TFT.height() - 1) //check if a star leaves the screen
-        {
-          init_star(stars + i, i + 1);
-          continue;
-        }
-      
-      TFT.pixel(tempx,tempy,stars[i].color);
-        
-    }
-     TFT.Bitmap(centerx-60,centery-19,120,38,p1);
-    }
-    
-    ///// demo stop
-
-    t.stop();
+   
     TFT.locate(0,10);
     TFT.set_font((unsigned char*) Arial12x12);  // select the font
-    printf("Time %f s\n", t.read());
+    printf(" Hello world!");
+    TFT.circle(70, 70, 30, Red);
+    TFT.fillrect(20, 100, 100, 130, Blue);
   }
\ No newline at end of file