Skip to content

Instantly share code, notes, and snippets.

@atc1441
Created September 11, 2019 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atc1441/f06adddffe689f2111135696cb3409ad to your computer and use it in GitHub Desktop.
Save atc1441/f06adddffe689f2111135696cb3409ad to your computer and use it in GitHub Desktop.
#include <Adafruit_GFX.h>
#include <Adafruit_ST7735.h>
#define TFT_CS 8
#define TFT_RST 7
#define TFT_DC 6
#define TFT_MOSI 2
#define TFT_SCLK 3
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
//Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);
void setup(void) {
pinMode(11, OUTPUT);
digitalWrite(11, LOW);
tft.initR(INITR_MINI160x80);
tft.fillScreen(ST77XX_BLACK);
tft.setRotation(1);
}
void loop() {
tft.fillScreen(ST77XX_BLACK);
for (int16_t x = 0; x < tft.width(); x += 6) {
tft.drawLine(0, 0, x, tft.height() - 1, ST77XX_RED);
}
for (int16_t y = 0; y < tft.height(); y += 6) {
tft.drawLine(0, 0, tft.width() - 1, y, ST77XX_RED);
}
tft.drawRect(0, 0, tft.width(), tft.height(), ST77XX_GREEN);
tft.setCursor(12, tft.height() / 2);
tft.setTextColor(ST77XX_BLUE);
tft.setTextSize(4);
tft.println("RED!");
delay(1000);
tft.fillScreen(ST77XX_BLACK);
for (int16_t x = 0; x < tft.width(); x += 6) {
tft.drawLine(tft.width() - 1, 0, x, tft.height() - 1, ST77XX_GREEN);
}
for (int16_t y = 0; y < tft.height(); y += 6) {
tft.drawLine(tft.width() - 1, 0, 0, y, ST77XX_GREEN);
}
tft.drawRect(0, 0, tft.width(), tft.height(), ST77XX_BLUE);
tft.setCursor(12, tft.height() / 2);
tft.setTextColor(ST77XX_RED);
tft.setTextSize(4);
tft.println("Green!");
delay(1000);
tft.fillScreen(ST77XX_BLACK);
for (int16_t x = 0; x < tft.width(); x += 6) {
tft.drawLine(0, tft.height() - 1, x, 0, ST77XX_BLUE);
}
for (int16_t y = 0; y < tft.height(); y += 6) {
tft.drawLine(0, tft.height() - 1, tft.width() - 1, y, ST77XX_BLUE);
}
tft.drawRect(0, 0, tft.width(), tft.height(), ST77XX_RED);
tft.setCursor(12, tft.height() / 2);
tft.setTextColor(ST77XX_GREEN);
tft.setTextSize(4);
tft.println("Blue!");
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment