Add support for scroll functions
This commit is contained in:
parent
7396fc17c8
commit
ca13033791
|
|
@ -989,6 +989,50 @@ void Adafruit_RA8875::curveHelper(int16_t xCenter, int16_t yCenter, int16_t long
|
||||||
waitPoll(RA8875_ELLIPSE, RA8875_ELLIPSE_STATUS);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
/************************* Mid Level ***********************************/
|
/************************* Mid Level ***********************************/
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,11 @@ class Adafruit_RA8875 : public Adafruit_GFX {
|
||||||
void fillEllipse(int16_t xCenter, int16_t yCenter, int16_t longAxis, int16_t shortAxis, uint16_t color);
|
void fillEllipse(int16_t xCenter, int16_t yCenter, int16_t longAxis, int16_t shortAxis, uint16_t color);
|
||||||
void drawCurve(int16_t xCenter, int16_t yCenter, int16_t longAxis, int16_t shortAxis, uint8_t curvePart, uint16_t color);
|
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);
|
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 */
|
/* Backlight */
|
||||||
void GPIOX(boolean on);
|
void GPIOX(boolean on);
|
||||||
|
|
@ -359,4 +364,9 @@ class Adafruit_RA8875 : public Adafruit_GFX {
|
||||||
#define RA8875_INTC2_TP 0x04
|
#define RA8875_INTC2_TP 0x04
|
||||||
#define RA8875_INTC2_BTE 0x02
|
#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
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,55 @@
|
||||||
|
#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);
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Reference in New Issue