yay!
This commit is contained in:
parent
f567fd2f02
commit
fca19994e1
|
|
@ -5,12 +5,19 @@
|
|||
@license BSD license, all text above and below must be included in
|
||||
any redistribution
|
||||
|
||||
Designed specifically to work with the Adafruit RA8875 Breakout
|
||||
----> https://www.adafruit.com/products/
|
||||
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
products from Adafruit!
|
||||
This is the library 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.
|
||||
|
||||
@section HISTORY
|
||||
|
||||
|
|
@ -135,7 +142,7 @@ void Adafruit_RA8875::initialize(void) {
|
|||
/* Set the correct values for the display being used */
|
||||
if (_size == RA8875_480x272)
|
||||
{
|
||||
pixclk = RA8875_PCSR_PDATL | RA8875_PCSR_8CLK;
|
||||
pixclk = RA8875_PCSR_PDATL | RA8875_PCSR_4CLK;
|
||||
hsync_nondisp = 10;
|
||||
hsync_start = 8;
|
||||
hsync_pw = 48;
|
||||
|
|
@ -335,6 +342,8 @@ void Adafruit_RA8875::textEnlarge(uint8_t scale)
|
|||
temp |= scale << 2;
|
||||
temp |= scale;
|
||||
writeData(temp);
|
||||
|
||||
_textScale = scale;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
|
|
@ -345,12 +354,14 @@ void Adafruit_RA8875::textEnlarge(uint8_t scale)
|
|||
@args len[in] The size of the buffer in bytes
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_RA8875::textWrite(uint8_t* buffer, uint16_t len)
|
||||
void Adafruit_RA8875::textWrite(char* buffer, uint16_t len)
|
||||
{
|
||||
if (len == 0) len = strlen(buffer);
|
||||
writeCommand(RA8875_MRWC);
|
||||
for (uint16_t i=0;i<len;i++)
|
||||
{
|
||||
writeData(buffer[i]);
|
||||
if (_textScale > 1) delay(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -368,6 +379,23 @@ void Adafruit_RA8875::graphicsMode(void) {
|
|||
writeData(temp);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
Waits for screen to finish by polling the status!
|
||||
*/
|
||||
/**************************************************************************/
|
||||
boolean Adafruit_RA8875::waitPoll(uint8_t regname, uint8_t waitflag) {
|
||||
/* Wait for the command to finish */
|
||||
while (1)
|
||||
{
|
||||
uint8_t temp = readReg(regname);
|
||||
if (!(temp & waitflag))
|
||||
return true;
|
||||
}
|
||||
return false; // MEMEFIX: yeah i know, unreached! - add timeout?
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
Sets the current X/Y position on the display before drawing
|
||||
|
|
@ -485,13 +513,7 @@ void Adafruit_RA8875::drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, u
|
|||
writeData(0x80);
|
||||
|
||||
/* Wait for the command to finish */
|
||||
bool finished = false;
|
||||
while (!finished)
|
||||
{
|
||||
uint8_t temp = readReg(RA8875_DCR);
|
||||
if (!(temp & RA8875_DCR_LINESQUTRI_STATUS))
|
||||
finished = true;
|
||||
}
|
||||
waitPoll(RA8875_DCR, RA8875_DCR_LINESQUTRI_STATUS);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
|
|
@ -741,13 +763,7 @@ void Adafruit_RA8875::circleHelper(int16_t x0, int16_t y0, int16_t r, uint16_t c
|
|||
}
|
||||
|
||||
/* Wait for the command to finish */
|
||||
bool finished = false;
|
||||
while (!finished)
|
||||
{
|
||||
uint8_t temp = readReg(RA8875_DCR);
|
||||
if (!(temp & RA8875_DCR_CIRCLE_STATUS))
|
||||
finished = true;
|
||||
}
|
||||
waitPoll(RA8875_DCR, RA8875_DCR_CIRCLE_STATUS);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
|
|
@ -801,13 +817,7 @@ void Adafruit_RA8875::rectHelper(int16_t x, int16_t y, int16_t w, int16_t h, uin
|
|||
}
|
||||
|
||||
/* Wait for the command to finish */
|
||||
bool finished = false;
|
||||
while (!finished)
|
||||
{
|
||||
uint8_t temp = readReg(RA8875_DCR);
|
||||
if (!(temp & RA8875_DCR_LINESQUTRI_STATUS))
|
||||
finished = true;
|
||||
}
|
||||
waitPoll(RA8875_DCR, RA8875_DCR_LINESQUTRI_STATUS);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
|
|
@ -867,13 +877,7 @@ void Adafruit_RA8875::triangleHelper(int16_t x0, int16_t y0, int16_t x1, int16_t
|
|||
}
|
||||
|
||||
/* Wait for the command to finish */
|
||||
bool finished = false;
|
||||
while (!finished)
|
||||
{
|
||||
uint8_t temp = readReg(RA8875_DCR);
|
||||
if (!(temp & RA8875_DCR_LINESQUTRI_STATUS))
|
||||
finished = true;
|
||||
}
|
||||
waitPoll(RA8875_DCR, RA8875_DCR_LINESQUTRI_STATUS);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
|
|
@ -923,13 +927,7 @@ void Adafruit_RA8875::ellipseHelper(int16_t xCenter, int16_t yCenter, int16_t lo
|
|||
}
|
||||
|
||||
/* Wait for the command to finish */
|
||||
bool finished = false;
|
||||
while (!finished)
|
||||
{
|
||||
uint8_t temp = readReg(0xA0);
|
||||
if (!(temp & 0x80))
|
||||
finished = true;
|
||||
}
|
||||
waitPoll(RA8875_ELLIPSE, RA8875_ELLIPSE_STATUS);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
|
|
@ -979,13 +977,7 @@ void Adafruit_RA8875::curveHelper(int16_t xCenter, int16_t yCenter, int16_t long
|
|||
}
|
||||
|
||||
/* Wait for the command to finish */
|
||||
bool finished = false;
|
||||
while (!finished)
|
||||
{
|
||||
uint8_t temp = readReg(0xA0);
|
||||
if (!(temp & 0x80))
|
||||
finished = true;
|
||||
}
|
||||
waitPoll(RA8875_ELLIPSE, RA8875_ELLIPSE_STATUS);
|
||||
}
|
||||
|
||||
/************************* Mid Level ***********************************/
|
||||
|
|
|
|||
|
|
@ -1,22 +1,29 @@
|
|||
/**************************************************************************/
|
||||
/*!
|
||||
@file Adafruit_RA8875.h
|
||||
@file Adafruit_RA8875.cpp
|
||||
@author Limor Friend/Ladyada, K.Townsend/KTOWN for Adafruit Industries
|
||||
@license BSD license, all text above and below must be included in
|
||||
any redistribution
|
||||
|
||||
Designed specifically to work with the Adafruit RA8875 Breakout
|
||||
----> https://www.adafruit.com/products/
|
||||
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
products from Adafruit!
|
||||
This is the library 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.
|
||||
|
||||
@section HISTORY
|
||||
|
||||
v1.0 - First release
|
||||
*/
|
||||
/**************************************************************************/
|
||||
|
||||
#if ARDUINO >= 100
|
||||
#include "Arduino.h"
|
||||
#include "Print.h"
|
||||
|
|
@ -66,7 +73,7 @@ class Adafruit_RA8875 : public Adafruit_GFX {
|
|||
void textColor(uint16_t foreColor, uint16_t bgColor);
|
||||
void textTransparent(uint16_t foreColor);
|
||||
void textEnlarge(uint8_t scale);
|
||||
void textWrite(uint8_t* buffer, uint16_t len);
|
||||
void textWrite(char* buffer, uint16_t len=0);
|
||||
|
||||
/* Graphics functions */
|
||||
void graphicsMode(void);
|
||||
|
|
@ -112,7 +119,7 @@ class Adafruit_RA8875 : public Adafruit_GFX {
|
|||
uint8_t readData(void);
|
||||
void writeCommand(uint8_t d);
|
||||
uint8_t readStatus(void);
|
||||
|
||||
boolean waitPoll(uint8_t r, uint8_t f);
|
||||
uint16_t width(void);
|
||||
uint16_t height(void);
|
||||
|
||||
|
|
@ -129,6 +136,7 @@ class Adafruit_RA8875 : public Adafruit_GFX {
|
|||
|
||||
uint8_t _cs, _rst;
|
||||
uint16_t _width, _height;
|
||||
uint8_t _textScale;
|
||||
enum RA8875sizes _size;
|
||||
};
|
||||
|
||||
|
|
@ -240,6 +248,10 @@ class Adafruit_RA8875 : public Adafruit_GFX {
|
|||
#define RA8875_DCR_DRAWTRIANGLE 0x01
|
||||
#define RA8875_DCR_DRAWSQUARE 0x10
|
||||
|
||||
|
||||
#define RA8875_ELLIPSE 0xA0
|
||||
#define RA8875_ELLIPSE_STATUS 0x80
|
||||
|
||||
#define RA8875_MWCR0 0x40
|
||||
#define RA8875_MWCR0_GFXMODE 0x00
|
||||
#define RA8875_MWCR0_TXTMODE 0x80
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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,7 +36,7 @@ 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);
|
||||
}
|
||||
|
|
@ -29,32 +50,41 @@ void setup()
|
|||
/* Switch to text mode */
|
||||
tft.textMode();
|
||||
|
||||
/* If necessary, enlarge the font */
|
||||
// tft.textEnlarge(0);
|
||||
|
||||
|
||||
/* Set a solid for + bg color ... */
|
||||
// tft.textColor(RA8875_WHITE, RA8875_RED);
|
||||
|
||||
/* ... or a fore color plus a transparent background */
|
||||
tft.textTransparent(RA8875_WHITE);
|
||||
|
||||
|
||||
/* Set the cursor location (in pixels) */
|
||||
tft.textSetCursor(10, 10);
|
||||
|
||||
/* Render some text! */
|
||||
uint8_t string[15] = "Hello, World! ";
|
||||
tft.textWrite(string, 15);
|
||||
tft.textWrite(string, 15);
|
||||
tft.textWrite(string, 15);
|
||||
tft.textWrite(string, 15);
|
||||
tft.textWrite(string, 15);
|
||||
tft.textWrite(string, 15);
|
||||
char string[15] = "Hello, World! ";
|
||||
tft.textTransparent(RA8875_WHITE);
|
||||
tft.textWrite(string);
|
||||
tft.textColor(RA8875_WHITE, RA8875_RED);
|
||||
tft.textWrite(string);
|
||||
tft.textTransparent(RA8875_CYAN);
|
||||
tft.textWrite(string);
|
||||
tft.textTransparent(RA8875_GREEN);
|
||||
tft.textWrite(string);
|
||||
tft.textColor(RA8875_YELLOW, RA8875_CYAN);
|
||||
tft.textWrite(string);
|
||||
tft.textColor(RA8875_BLACK, RA8875_MAGENTA);
|
||||
tft.textWrite(string);
|
||||
|
||||
/* Change the cursor location and color ... */
|
||||
tft.textSetCursor(100, 100);
|
||||
tft.textTransparent(RA8875_RED);
|
||||
/* If necessary, enlarge the font */
|
||||
tft.textEnlarge(1);
|
||||
/* ... and render some more text! */
|
||||
tft.textWrite(string, 15);
|
||||
tft.textWrite(string, 15);
|
||||
tft.textWrite(string);
|
||||
tft.textSetCursor(100, 150);
|
||||
tft.textEnlarge(2);
|
||||
tft.textWrite(string);
|
||||
}
|
||||
|
||||
void loop()
|
||||
|
|
|
|||
Loading…
Reference in New Issue