z

 #include <Adafruit_GFX.h>


#include <Adafruit_ST7735.h>


#include <SPI.h>




#define TFT_CS     10


#define TFT_RST    8


#define TFT_DC     9




Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);




// Custom colors


#define SKY_BLUE   tft.color565(0, 102, 204)


#define GROUND_BR  tft.color565(153, 76, 0)


#define YELLOW     ST77XX_YELLOW


#define WHITE      ST77XX_WHITE


#define BLACK      ST77XX_BLACK




void setup() {


  tft.initR(INITR_BLACKTAB);


  tft.setRotation(1); // Landscape


  drawHorizon();


}




void loop() {


}




void drawHorizon() {




  tft.fillScreen(BLACK);




  int cx = 80;


  int cy = 64;




  // Sky


  tft.fillRect(0, 0, 160, cy, SKY_BLUE);




  // Ground


  tft.fillRect(0, cy, 160, 128, GROUND_BR);




  // Horizon line


  tft.drawFastHLine(0, cy, 160, WHITE);




  tft.setTextSize(1);


  tft.setTextColor(WHITE);




  // 🔥 Pitch lines + Numbers


  for (int i = -3; i <= 3; i++) {




    int y = cy - (i * 15);




    // Skip center (0 line already drawn)


    if (i != 0) {


      tft.drawFastHLine(cx - 20, y, 40, WHITE);


    }




    // Value calculate (30,20,10,...)


    int value = i * 10;

   

    String valStr;

    if (value > 0) {

    valStr = "+" + String(value);

    }

    else { 

    valStr = String(value);

    }


    // LEFT side numbers


    tft.setCursor(1, y - 3);


    tft.print(valStr);




    // RIGHT side numbers


    tft.setCursor(142, y - 3);


    tft.print(valStr);


  }




  // Center 0 label


  tft.setCursor(5, cy - 3);



  tft.setCursor(135, cy - 3);




  // Aircraft symbol


  tft.fillRect(cx - 30, cy - 2, 20, 4, YELLOW);


  tft.fillRect(cx + 10, cy - 2, 20, 4, YELLOW);


  tft.drawLine(cx - 10, cy, cx, cy + 8, YELLOW);


  tft.drawLine(cx, cy + 8, cx + 10, cy, YELLOW);




  // Center dot


  tft.fillCircle(cx, cy, 3, YELLOW);




  // Border circle


  tft.drawCircle(cx, cy, 60, WHITE);


}

Post a Comment

Previous Post Next Post

Contact Form