mardi 15 avril 2014


 SainSmart 1.8 ST7735R TFT LCD Module with MicroSD LED 

   http://www.sainsmart.com

https://bitbucket.org/johnmccombs/arduino-libraries/src/64e60d1637398bb8a3c6cb9adb4c7e1fcc07a4bc/ST7735/?at=default 

 


 code  Arduino 


//#define sclk 13    // for MEGAs use pin 52
//#define mosi 11    // for MEGAs use pin 51
#define cs 10   // for MEGAs you probably want this to be pin 53
#define dc 9
#define rst 8  // you can also connect this to the Arduino reset
// couleur definitions
# define NOIR           0x0000
# define BLEU           0xF800 
# define ROUGE          0x001F
# define VERT           0x07E0
# define CYAN           0xFFE0 
# define MAGENTA        0xF81F
# define JAUNE          0x07FF 
# define BLANC          0xFFFF


#include <ST7735.h>
#include <SPI.h>
//ST7735 tft = ST7735(cs, dc, rst);
  ST7735 tft = ST7735(10, 9 ,  8 );
//........................
int x;
int y;
int xx;
int yy;
//.............................
void setup() {

 tft.initR(); // initialize a ST7735R chip
   tft.fillScreen(BLEU);
  tft.drawString(30,20, "PAPY_08", ROUGE ,2);
 delay(4000);
 tft.fillScreen(BLANC);
}
void loop(){
 spcercle();
 delay(4000);
  tft.fillScreen(BLANC);
 spRectangle();
 delay(4000);
  tft.fillScreen(BLANC);
  spligne();
 delay(4000);
  tft.fillScreen(BLANC);
    spligneverticale();
 delay(4000);
  tft.fillScreen(BLANC);
   splignehorizontale();
 delay(4000);
  tft.fillScreen(BLANC);
     spcourbe();
 delay(4000);
  tft.fillScreen(BLANC);
      sptriangle();
 delay(4000);
  tft.fillScreen(BLANC);
}
void spcercle(){
tft.drawString(10,15, "cercle",MAGENTA,2);
tft.drawCircle(70,90, 52,NOIR);//tracer le cercle
tft.fillCircle(70,90, 50,ROUGE);// remplir un Cercle
tft.drawHorizontalLine(70,90,52,NOIR);//Tracer une ligne horizontale
 tft.drawString(60,80, "X,Y   R",JAUNE,1);
}
 void spRectangle(){
 tft.drawString(10,15, "Rectangle",MAGENTA,2); 
tft.fillRect(20,50,70, 50,JAUNE);//remplir Rectangle
tft.drawRect(20,50 ,70,50,VERT);//Dessine un rectangle
tft.drawString(10,40, "X,Y",NOIR,1);
 tft.drawVerticalLine(95,50,50,BLEU);//Tracer une ligne verticale
  tft.drawHorizontalLine(20,130,70,CYAN);//Tracer une ligne horizontale
 tft.drawString(30,110, "Longueur ",MAGENTA,1); 
 tft.drawString(100,75, "Haut",MAGENTA,1); 
 }
void spligne(){
tft.drawString(10,15, "Ligne",MAGENTA,2);
tft.drawLine(20,140,100,40,ROUGE);//tracer une ligne
tft.drawString(10,150, "X,Y",NOIR,1);
tft.drawString(90,30, "X1,Y1",NOIR,1);

void spligneverticale(){
tft.drawString(2,15, "Ligne verticale",MAGENTA,1);
 tft.drawVerticalLine(20,40,70,BLEU);//Tracer une ligne verticale
 tft.drawString(30,50, "Hauteur",MAGENTA,1);
tft.drawString(10,30, "X,Y",NOIR,1);

void splignehorizontale(){
  tft.drawString(2,15, "Ligne horizontale",MAGENTA,1);
 tft.drawHorizontalLine(20,110,80,CYAN);//Tracer une ligne horizontale
 tft.drawString(40,130, "Longueur ",MAGENTA,1); 
tft.drawString(10,120, "X,Y",NOIR,1);
}  
void spcourbe(){
  tft.drawString(2,15, "Courbe",MAGENTA,1);
 x=1;
 y=50;
 xx=1;
 yy=50; 
for (x=1; x <= 120;  x++){
y= random(50, 150);
tft.drawPixel(x, y,NOIR);
tft.drawLine(x,y,xx,yy,ROUGE);//tracer une ligne
xx=x;
yy=y;
delay(10);
}
}
void sptriangle(){
tft.drawString(2,15, "Triangle",MAGENTA,1);
tft.drawVerticalLine(20,40,70,NOIR);//Tracer une ligne verticale
tft.drawHorizontalLine(20,110,80,NOIR);//Tracer une ligne horizontale
tft.drawLine(20,40,100,110,NOIR);//tracer une ligne
}

translate  google



 

 

Aucun commentaire:

Enregistrer un commentaire