Skip to content

Instantly share code, notes, and snippets.

@matt448
Last active November 3, 2017 20:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matt448/8449600 to your computer and use it in GitHub Desktop.
Save matt448/8449600 to your computer and use it in GitHub Desktop.
This is a simple sketch I used to test the refresh rate of an Adafruit 2.2" TFT display on an Arduino Mega 2560. http://www.adafruit.com/products/1480
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9340.h"
#if defined(__SAM3X8E__)
#undef __FlashStringHelper::F(string_literal)
#define F(string_literal) string_literal
#endif
// These are the pins used for the Mega
// for Due/Uno/Leonardo use the hardware SPI pins (which are different)
#define _sclk 52
#define _miso 50
#define _mosi 51
#define _cs 53
#define _rst 9
#define _dc 8
Adafruit_ILI9340 tft = Adafruit_ILI9340(_cs, _dc, _rst);
void setup() {
tft.begin();
tft.setRotation(1);
tft.fillScreen(ILI9340_BLACK);
tft.fillRect(120, 70, 115, 70, ILI9340_RED);
tft.setTextColor(ILI9340_WHITE);
}
void loop(void) {
tft.setCursor(120, 70);
tft.setTextSize(10);
tft.print(millis()/1000);
delay(999);
tft.fillRect(120, 70, 115, 70, ILI9340_RED);
//tft.fillScreen(ILI9340_BLACK); //This is very slow
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment