This commit is contained in:
ladyada
2013-11-22 16:26:44 -05:00
parent f567fd2f02
commit fca19994e1
4 changed files with 152 additions and 102 deletions
+44 -28
View File
@@ -1,7 +1,28 @@
/******************************************************************
This is an example for the Adafruit RA8875 Driver board for TFT displays
---------------> http://www.adafruit.com/products/1590
The RA8875 is a TFT driver for up to 800x480 dotclock'd displays
It is tested to work with displays in the Adafruit shop. Other displays
may need timing adjustments and are not guanteed to work.
Adafruit invests time and resources providing this open
source code, please support Adafruit and open-source hardware
by purchasing products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, check license.txt for more information.
All text above must be included in any redistribution.
******************************************************************/
#include <SPI.h>
#include "Adafruit_GFX.h"
#include "Adafruit_RA8875.h"
// Library only supports hardware SPI at this time
// Connect SCLK to UNO Digital #13 (Hardware SPI clock)
// Connect MISO to UNO Digital #12 (Hardware SPI MISO)
// Connect MOSI to UNO Digital #13 (Hardware SPI MOSI)
#define RA8875_INT 3
#define RA8875_CS 10
#define RA8875_RESET 9
@@ -15,60 +36,55 @@ void setup()
Serial.println("RA8875 start");
/* Initialise the display using 'RA8875_480x272' or 'RA8875_800x480' */
if (!tft.begin(RA8875_800x480)) {
if (!tft.begin(RA8875_480x272)) {
Serial.println("RA8875 Not Found!");
while (1);
}
Serial.println("Found RA8875");
/*
//RA8875_softReset();
for (uint8_t i=0; i<100; i++) {
Serial.print("$"); Serial.print(i, HEX);
Serial.print(": 0x"); Serial.println(readReg(i), HEX);
}
*/
tft.displayOn(true);
tft.GPIOX(true); // Enable TFT - display enable tied to GPIOX
tft.PWM1config(true, RA8875_PWM_CLK_DIV1024); // PWM output for backlight
tft.PWM1out(255);
// With hardware accelleration this is instant
tft.fillScreen(RA8875_WHITE);
// Play with PWM
for (uint8_t i=255; i!=0; i-=5 )
{
tft.PWM1out(i);
delay(1);
delay(10);
}
for (uint8_t i=0; i!=255; i+=5 )
{
tft.PWM1out(i);
delay(1);
delay(10);
}
tft.PWM1out(255);
tft.fillScreen(RA8875_RED);
delay(500);
tft.fillScreen(RA8875_YELLOW);
delay(500);
tft.fillScreen(RA8875_GREEN);
delay(500);
tft.fillScreen(RA8875_CYAN);
delay(500);
tft.fillScreen(RA8875_MAGENTA);
delay(500);
tft.fillScreen(RA8875_BLACK);
// Try some GFX acceleration!
tft.drawCircle(100, 100, 50, RA8875_BLACK);
tft.fillCircle(100, 100, 49, RA8875_GREEN);
tft.fillRect(11, 11, 398, 198, RA8875_BLUE);
tft.drawRect(10, 10, 400, 200, RA8875_GREEN);
tft.fillRoundRect(200, 10, 200, 100, 10, RA8875_RED);
tft.drawPixel(10,10,RA8875_BLACK);
tft.drawPixel(11,11,RA8875_BLACK);
tft.fillRoundRect(200, 10, 200, 100, 10, RA8875_RED);
tft.fillScreen(RA8875_GREEN);
delay(100);
tft.fillScreen(RA8875_RED);
delay(100);
tft.fillScreen(RA8875_GREEN);
delay(100);
tft.fillScreen(RA8875_RED);
delay(100);
tft.fillScreen(RA8875_GREEN);
delay(100);
tft.fillScreen(RA8875_BLACK);
tft.drawRect(10, 10, 400, 200, RA8875_GREEN);
tft.fillRect(11, 11, 398, 198, RA8875_BLUE);
tft.drawLine(10, 10, 200, 100, RA8875_RED);
tft.drawTriangle(200, 15, 250, 100, 150, 125, RA8875_BLACK);
tft.fillTriangle(200, 16, 249, 99, 151, 124, RA8875_YELLOW);
@@ -101,7 +117,7 @@ void loop()
tft.touchRead(&tx, &ty);
Serial.print(tx); Serial.print(", "); Serial.println(ty);
/* Draw a circle */
tft.fillCircle((uint16_t)(tx/xScale), (uint16_t)(ty/yScale), 10, RA8875_WHITE);
tft.fillCircle((uint16_t)(tx/xScale), (uint16_t)(ty/yScale), 4, RA8875_WHITE);
}
}
}