Compare commits

..

No commits in common. "e2db4ee79068eda472a665bed61b4fa0fb44442f" and "c38d5764a8ba02402aba14dba77ccf1470efeca1" have entirely different histories.

6 changed files with 4 additions and 379 deletions

View File

@ -72,10 +72,8 @@ boolean Adafruit_RA8875::begin(enum RA8875sizes s) {
delay(100);
SPI.begin();
#ifdef __AVR__
SPI.setClockDivider(SPI_CLOCK_DIV128);
SPI.setDataMode(SPI_MODE0);
#endif
if (readReg(0) != 0x75) {
return false;
@ -83,9 +81,8 @@ boolean Adafruit_RA8875::begin(enum RA8875sizes s) {
initialize();
#ifdef __AVR__
SPI.setClockDivider(SPI_CLOCK_DIV4);
#endif
return true;
}
@ -989,61 +986,6 @@ void Adafruit_RA8875::curveHelper(int16_t xCenter, int16_t yCenter, int16_t long
waitPoll(RA8875_ELLIPSE, RA8875_ELLIPSE_STATUS);
}
void Adafruit_RA8875::setScrollWindow(int16_t x, int16_t y, int16_t w, int16_t h, uint8_t mode) {
// Horizontal Start point of Scroll Window
writeCommand(0x38);
writeData(x);
writeCommand(0x39);
writeData(x>>8);
// Vertical Start Point of Scroll Window
writeCommand(0x3a);
writeData(y);
writeCommand(0x3b);
writeData(y>>8);
// Horizontal End Point of Scroll Window
writeCommand(0x3c);
writeData(x+w);
writeCommand(0x3d);
writeData((x+w)>>8);
// Vertical End Point of Scroll Window
writeCommand(0x3e);
writeData(y+h);
writeCommand(0x3f);
writeData((y+h)>>8);
// Scroll function setting
writeCommand(0x52);
writeData(0x00);
}
void Adafruit_RA8875::scrollX(int16_t dist) {
writeCommand(0x24);
writeData(dist);
writeCommand(0x25);
writeData(dist>>8);
}
void Adafruit_RA8875::scrollY(int16_t dist) {
writeCommand(0x26);
writeData(dist);
writeCommand(0x27);
writeData(dist>>8);
}
void Adafruit_RA8875::scanDirection(boolean invertH, boolean invertV, boolean portrait) {
uint8_t r=readReg(RA8875_DPCR);
invertH == true ? r |= (1 << 3) : r &= ~(1 << 3);
invertV == true ? r |= (1 << 2) : r &= ~(1 << 2);
writeReg(RA8875_DPCR, r);
r=readReg(RA8875_FNCR1);
portrait == true ? r |= (1 << 4) : r &= ~(1 << 4);
writeReg(RA8875_FNCR1, r);
}
/************************* Mid Level ***********************************/
/**************************************************************************/

View File

@ -31,17 +31,12 @@
#include "WProgram.h"
#endif
#ifdef __AVR
#ifdef __AVR__
#include <avr/pgmspace.h>
#elif defined(ESP8266)
#include <pgmspace.h>
#endif
#include <Adafruit_GFX.h>
#ifndef _ADAFRUIT_RA8875_H
#define _ADAFRUIT_RA8875_H
// Sizes!
enum RA8875sizes { RA8875_480x272, RA8875_800x480 };
@ -52,7 +47,7 @@ typedef struct Point
int32_t y;
} tsPoint_t;
typedef struct //Matrix
typedef struct Matrix
{
int32_t An,
Bn,
@ -105,11 +100,6 @@ class Adafruit_RA8875 : public Adafruit_GFX {
void drawCurve(int16_t xCenter, int16_t yCenter, int16_t longAxis, int16_t shortAxis, uint8_t curvePart, uint16_t color);
void fillCurve(int16_t xCenter, int16_t yCenter, int16_t longAxis, int16_t shortAxis, uint8_t curvePart, uint16_t color);
/* Scroll */
void setScrollWindow(int16_t x, int16_t y, int16_t w, int16_t h, uint8_t mode);
void scrollX(int16_t dist);
void scrollY(int16_t dist);
/* Backlight */
void GPIOX(boolean on);
void PWM1config(boolean on, uint8_t clock);
@ -133,9 +123,6 @@ class Adafruit_RA8875 : public Adafruit_GFX {
uint16_t width(void);
uint16_t height(void);
void scanDirection(boolean invertH, boolean invertV, boolean portrait);
/* Play nice with Arduino's Print class */
virtual size_t write(uint8_t b) {
textWrite((const char *)&b, 1);
return 1;
@ -187,8 +174,7 @@ class Adafruit_RA8875 : public Adafruit_GFX {
#define RA8875_PWRR_SOFTRESET 0x01
#define RA8875_MRWC 0x02
#define RA8875_DPCR 0x20
#define RA8875_FNCR1 0x22
#define RA8875_GPIOX 0xC7
#define RA8875_PLLC1 0x88
@ -366,10 +352,3 @@ class Adafruit_RA8875 : public Adafruit_GFX {
#define RA8875_INTC2_DMA 0x08
#define RA8875_INTC2_TP 0x04
#define RA8875_INTC2_BTE 0x02
#define RA8875_SCROLL_BOTH 0x00
#define RA8875_SCROLL_LAYER1 0x40
#define RA8875_SCROLL_LAYER2 0x80
#define RA8875_SCROLL_BUFFER 0xC0
#endif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

View File

@ -1,232 +0,0 @@
#include <Adafruit_GFX.h> // Core graphics library
#include <SPI.h>
#include <Wire.h>
#include <SD.h>
#include "Adafruit_RA8875.h"
#include <Adafruit_STMPE610.h>
#define sd_cs 6 // uding ethernet shield sd
// 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 #11 (Hardware SPI MOSI)
#define RA8875_INT 3
#define RA8875_CS 10
#define RA8875_RESET 9
Adafruit_RA8875 tft = Adafruit_RA8875(RA8875_CS, RA8875_RESET);
void setup () {
Serial.begin(9600);
if (!SD.begin(sd_cs))
{
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");
Serial.println("RA8875 start");
/* Initialise the display using 'RA8875_480x272' or 'RA8875_800x480' */
if (!tft.begin(RA8875_800x480)) {
Serial.println("RA8875 Not Found!");
while (1);
}
Serial.println("Found RA8875");
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);
Serial.print("(");
Serial.print(tft.width());
Serial.print(", ");
Serial.print(tft.height());
Serial.println(")");
tft.graphicsMode(); // go back to graphics mode
tft.fillScreen(RA8875_BLACK);
tft.graphicsMode();
bmpDraw("parrot.bmp", 0, 0);
}
void loop()
{
}
// This function opens a Windows Bitmap (BMP) file and
// displays it at the given coordinates. It's sped up
// by reading many pixels worth of data at a time
// (rather than pixel by pixel). Increasing the buffer
// size takes more of the Arduino's precious RAM but
// makes loading a little faster. 20 pixels seems a
// good balance.
#define BUFFPIXEL 20
void bmpDraw(char *filename, int x, int y) {
File bmpFile;
int bmpWidth, bmpHeight; // W+H in pixels
uint8_t bmpDepth; // Bit depth (currently must be 24)
uint32_t bmpImageoffset; // Start of image data in file
uint32_t rowSize; // Not always = bmpWidth; may have padding
uint8_t sdbuffer[3*BUFFPIXEL]; // pixel in buffer (R+G+B per pixel)
uint16_t lcdbuffer[BUFFPIXEL]; // pixel out buffer (16-bit per pixel)
uint8_t buffidx = sizeof(sdbuffer); // Current position in sdbuffer
boolean goodBmp = false; // Set to true on valid header parse
boolean flip = true; // BMP is stored bottom-to-top
int w, h, row, col;
uint8_t r, g, b;
uint32_t pos = 0, startTime = millis();
uint8_t lcdidx = 0;
boolean first = true;
if((x >= tft.width()) || (y >= tft.height())) return;
Serial.println();
Serial.print(F("Loading image '"));
Serial.print(filename);
Serial.println('\'');
// Open requested file on SD card
if ((bmpFile = SD.open(filename)) == NULL) {
Serial.println(F("File not found"));
return;
}
// Parse BMP header
if(read16(bmpFile) == 0x4D42) { // BMP signature
Serial.println(F("File size: "));
Serial.println(read32(bmpFile));
(void)read32(bmpFile); // Read & ignore creator bytes
bmpImageoffset = read32(bmpFile); // Start of image data
Serial.print(F("Image Offset: "));
Serial.println(bmpImageoffset, DEC);
// Read DIB header
Serial.print(F("Header size: "));
Serial.println(read32(bmpFile));
bmpWidth = read32(bmpFile);
bmpHeight = read32(bmpFile);
if(read16(bmpFile) == 1) { // # planes -- must be '1'
bmpDepth = read16(bmpFile); // bits per pixel
Serial.print(F("Bit Depth: "));
Serial.println(bmpDepth);
if((bmpDepth == 24) && (read32(bmpFile) == 0)) { // 0 = uncompressed
goodBmp = true; // Supported BMP format -- proceed!
Serial.print(F("Image size: "));
Serial.print(bmpWidth);
Serial.print('x');
Serial.println(bmpHeight);
// BMP rows are padded (if needed) to 4-byte boundary
rowSize = (bmpWidth * 3 + 3) & ~3;
// If bmpHeight is negative, image is in top-down order.
// This is not canon but has been observed in the wild.
if(bmpHeight < 0) {
bmpHeight = -bmpHeight;
flip = false;
}
// Crop area to be loaded
w = bmpWidth;
h = bmpHeight;
if((x+w-1) >= tft.width()) w = tft.width() - x;
if((y+h-1) >= tft.height()) h = tft.height() - y;
// Set TFT address window to clipped image bounds
for (row=0; row<h; row++) { // For each scanline...
// Seek to start of scan line. It might seem labor-
// intensive to be doing this on every line, but this
// method covers a lot of gritty details like cropping
// and scanline padding. Also, the seek only takes
// place if the file position actually needs to change
// (avoids a lot of cluster math in SD library).
if(flip) // Bitmap is stored bottom-to-top order (normal BMP)
pos = bmpImageoffset + (bmpHeight - 1 - row) * rowSize;
else // Bitmap is stored top-to-bottom
pos = bmpImageoffset + row * rowSize;
if(bmpFile.position() != pos) { // Need seek?
bmpFile.seek(pos);
buffidx = sizeof(sdbuffer); // Force buffer reload
}
for (col=0; col<w; col++) { // For each column...
// Time to read more pixel data?
if (buffidx >= sizeof(sdbuffer)) { // Indeed
// Push LCD buffer to the display first
if(lcdidx > 0) {
tft.drawPixel(col, row, lcdbuffer[lcdidx]);
lcdidx = 0;
first = false;
}
bmpFile.read(sdbuffer, sizeof(sdbuffer));
buffidx = 0; // Set index to beginning
}
// Convert pixel from BMP to TFT format
b = sdbuffer[buffidx++];
g = sdbuffer[buffidx++];
r = sdbuffer[buffidx++];
lcdbuffer[lcdidx] = color565(r,g,b);
tft.drawPixel(col, row, lcdbuffer[lcdidx]);
} // end pixel
} // end scanline
// Write any remaining data to LCD
if(lcdidx > 0) {
tft.drawPixel(col, row, lcdbuffer[lcdidx]);
}
Serial.print(F("Loaded in "));
Serial.print(millis() - startTime);
Serial.println(" ms");
} // end goodBmp
}
}
bmpFile.close();
if(!goodBmp) Serial.println(F("BMP format not recognized."));
}
// These read 16- and 32-bit types from the SD card file.
// BMP data is stored little-endian, Arduino is little-endian too.
// May need to reverse subscript order if porting elsewhere.
uint16_t read16(File f) {
uint16_t result;
((uint8_t *)&result)[0] = f.read(); // LSB
((uint8_t *)&result)[1] = f.read(); // MSB
return result;
}
uint32_t read32(File f) {
uint32_t result;
((uint8_t *)&result)[0] = f.read(); // LSB
((uint8_t *)&result)[1] = f.read();
((uint8_t *)&result)[2] = f.read();
((uint8_t *)&result)[3] = f.read(); // MSB
return result;
}
uint16_t color565(uint8_t r, uint8_t g, uint8_t b) {
return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3);
}
byte decToBcd(byte val){
// Convert normal decimal numbers to binary coded decimal
return ( (val/10*16) + (val%10) );
}

View File

@ -1,55 +0,0 @@
#include <SPI.h>
#include <Wire.h>
#include <EEPROM.h>
#include "Adafruit_GFX.h"
#include "Adafruit_RA8875.h"
// LCD
// 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 #11 (Hardware SPI MOSI)
#define RA8875_INT 3
#define RA8875_CS 10
#define RA8875_RESET 9
#define NUMINPUTS 4
Adafruit_RA8875 tft = Adafruit_RA8875(RA8875_CS, RA8875_RESET);
void setup() {
Serial.begin(9600);
if (!tft.begin(RA8875_800x480)) {
Serial.println("LCD not found!");
while (1);
}
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);
tft.fillScreen(RA8875_BLACK);
tft.setScrollWindow(0,0,800,480,RA8875_SCROLL_BOTH);
tft.fillCircle(690, 370, 100, RA8875_WHITE);
}
void loop() {
static int Scroll=0;
static int Dir=1;
tft.scrollX(Scroll);
tft.scrollY(Scroll);
Scroll+=Dir;
if(Scroll >= 250) {
Dir=-1;;
} else if(Scroll <= 0) {
Dir=1;
}
delay(10);
}

View File

@ -1,9 +0,0 @@
name=Adafruit RA8875
version=1.0.1
author=Adafruit
maintainer=Adafruit <info@adafruit.com>
sentence=Adafruit's Arduino driver for the RA8875 TFT driver
paragraph=Adafruit's Arduino driver for the RA8875 TFT driver
category=Display
url=https://github.com/adafruit/Adafruit_RA8875
architectures=*