Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //bem10jfx.blogspot.com.br
- #include <Adafruit_GFX.h> // Biblioteca
- #include <Adafruit_ST7735.h> // Adafruit
- // Definindo os pinos do display
- #define TFT_CS 10 // CS
- #define TFT_RST 8 // Reset//referente ao loop();eviatar
- #define TFT_DC 9 // DC
- Adafruit_ST7735 tft = Adafruit_ST7735(10, 9, 8);
- int BIND_WIDTH = 128; //pixels
- int BIND_HEIGHT = 160;//pixels
- int int_Lx = tft.width() / 2; //binda da tela dividada
- int int_Ly = tft.height() / 2;
- int engate_velX = 1; //velocidades orizontal
- int engate_velY = 2 ; // velocidade vertical
- int vlx=0;
- int RADIAL = 5; // Raio do círculo
- void setup() {
- tft.initR(INITR_BLACKTAB); // Initializaçao....
- //display black
- tft.fillScreen(ST7735_BLACK);
- tft.drawCircle(int_Lx, int_Ly, RADIAL, ST7735_BLUE);
- programa();}
- void loop() {}; //evitar
- void programa(){
- int_Lx += engate_velX; //valores com diferencia de potencial :D
- int_Ly += engate_velY;
- // Verificar limites da tela
- // se a localizaçao do objeto x + o radial do cirle for o maior que o limite de pixel e se a
- // localizaçao for menor ou igual o liminite minimo da tela
- if (int_Lx + RADIAL > BIND_WIDTH || int_Lx - RADIAL < 0) {
- engate_velX = -engate_velX; // utilize o valor atual diminuindo ou almentando dependendo da direçao e do limite
- legacy(); //imprime uma bolha com cor diferente na nos limites do layout
- }
- if (int_Ly + RADIAL > BIND_HEIGHT || int_Ly - RADIAL < 0) {
- engate_velY = -engate_velY; // heigth
- legacy();//imprime uma bolha com cor diferente na nos limites do layout
- }
- // sobrepor mesma cor do backgraund
- tft.drawCircle(int_Lx - engate_velX, int_Ly - engate_velY, RADIAL, ST7735_BLACK);
- legacy();
- delay(120);
- loop2();//passa pra oloop 2 e o loop2 manda devolta pra o programa sem utilizar oreset do void loop();
- }
- void loop2(){
- programa();
- delay(20);
- };
- void legacy(){
- if(vlx==0){ // criar
- tft.drawCircle(int_Lx, int_Ly, RADIAL, ST7735_BLUE);
- vlx=vlx+1;
- }else if(vlx==1){
- tft.drawCircle(int_Lx, int_Ly, RADIAL, ST7735_RED);
- vlx=2;
- }else if(vlx==2){ // criar
- tft.drawCircle(int_Lx, int_Ly, RADIAL, ST7735_YELLOW);
- vlx=3;
- }else if(vlx==3){ // criar
- tft.drawCircle(int_Lx, int_Ly, RADIAL, ST7735_WHITE);
- vlx=0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment