mirror of
https://github.com/adafruit/TFTLCD-Library.git
synced 2026-09-13 10:03:41 +00:00
Compare commits
26
Commits
Due
..
nondma_samd51
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3e1da13313 | ||
|
|
8ad1ede59f | ||
|
|
d73bbf1866 | ||
|
|
9535fbf889 | ||
|
|
97a82854c8 | ||
|
|
ecf4cf17b0 | ||
|
|
6c236e25fa | ||
|
|
40266af7ab | ||
|
|
6c41da9750 | ||
|
|
9323b5cdb5 | ||
|
|
87479c7442 | ||
|
|
7a983dcbc5 | ||
|
|
7d70af32ff | ||
|
|
d9b13dbda0 | ||
|
|
318bb8356e | ||
|
|
162103b583 | ||
|
|
879c387a08 | ||
|
|
f775b97d86 | ||
|
|
286f81f96e | ||
|
|
391f1a503f | ||
|
|
7fc3d6fb0a | ||
|
|
6bc43d3e67 | ||
|
|
b9d06458f5 | ||
|
|
1cf75baa9b | ||
|
|
4ccd1148b0 | ||
|
|
c596e1aa7f |
@@ -0,0 +1,46 @@
|
||||
Thank you for opening an issue on an Adafruit Arduino library repository. To
|
||||
improve the speed of resolution please review the following guidelines and
|
||||
common troubleshooting steps below before creating the issue:
|
||||
|
||||
- **Do not use GitHub issues for troubleshooting projects and issues.** Instead use
|
||||
the forums at http://forums.adafruit.com to ask questions and troubleshoot why
|
||||
something isn't working as expected. In many cases the problem is a common issue
|
||||
that you will more quickly receive help from the forum community. GitHub issues
|
||||
are meant for known defects in the code. If you don't know if there is a defect
|
||||
in the code then start with troubleshooting on the forum first.
|
||||
|
||||
- **If following a tutorial or guide be sure you didn't miss a step.** Carefully
|
||||
check all of the steps and commands to run have been followed. Consult the
|
||||
forum if you're unsure or have questions about steps in a guide/tutorial.
|
||||
|
||||
- **For Arduino projects check these very common issues to ensure they don't apply**:
|
||||
|
||||
- For uploading sketches or communicating with the board make sure you're using
|
||||
a **USB data cable** and **not** a **USB charge-only cable**. It is sometimes
|
||||
very hard to tell the difference between a data and charge cable! Try using the
|
||||
cable with other devices or swapping to another cable to confirm it is not
|
||||
the problem.
|
||||
|
||||
- **Be sure you are supplying adequate power to the board.** Check the specs of
|
||||
your board and plug in an external power supply. In many cases just
|
||||
plugging a board into your computer is not enough to power it and other
|
||||
peripherals.
|
||||
|
||||
- **Double check all soldering joints and connections.** Flakey connections
|
||||
cause many mysterious problems. See the [guide to excellent soldering](https://learn.adafruit.com/adafruit-guide-excellent-soldering/tools) for examples of good solder joints.
|
||||
|
||||
- **Ensure you are using an official Arduino or Adafruit board.** We can't
|
||||
guarantee a clone board will have the same functionality and work as expected
|
||||
with this code and don't support them.
|
||||
|
||||
If you're sure this issue is a defect in the code and checked the steps above
|
||||
please fill in the following fields to provide enough troubleshooting information.
|
||||
You may delete the guideline and text above to just leave the following details:
|
||||
|
||||
- Arduino board: **INSERT ARDUINO BOARD NAME/TYPE HERE**
|
||||
|
||||
- Arduino IDE version (found in Arduino -> About Arduino menu): **INSERT ARDUINO
|
||||
VERSION HERE**
|
||||
|
||||
- List the steps to reproduce the problem below (if possible attach a sketch or
|
||||
copy the sketch code in too): **LIST REPRO STEPS BELOW**
|
||||
@@ -0,0 +1,26 @@
|
||||
Thank you for creating a pull request to contribute to Adafruit's GitHub code!
|
||||
Before you open the request please review the following guidelines and tips to
|
||||
help it be more easily integrated:
|
||||
|
||||
- **Describe the scope of your change--i.e. what the change does and what parts
|
||||
of the code were modified.** This will help us understand any risks of integrating
|
||||
the code.
|
||||
|
||||
- **Describe any known limitations with your change.** For example if the change
|
||||
doesn't apply to a supported platform of the library please mention it.
|
||||
|
||||
- **Please run any tests or examples that can exercise your modified code.** We
|
||||
strive to not break users of the code and running tests/examples helps with this
|
||||
process.
|
||||
|
||||
Thank you again for contributing! We will try to test and integrate the change
|
||||
as soon as we can, but be aware we have many GitHub repositories to manage and
|
||||
can't immediately respond to every request. There is no need to bump or check in
|
||||
on a pull request (it will clutter the discussion of the request).
|
||||
|
||||
Also don't be worried if the request is closed or not integrated--sometimes the
|
||||
priorities of Adafruit's GitHub code (education, ease of use) might not match the
|
||||
priorities of the pull request. Don't fret, the open source community thrives on
|
||||
forks and GitHub makes it easy to keep your changes in a forked repo.
|
||||
|
||||
After reviewing the guidelines above you can delete this text from the pull request.
|
||||
+273
-72
@@ -18,75 +18,20 @@
|
||||
#include "Adafruit_TFTLCD.h"
|
||||
#include "pin_magic.h"
|
||||
|
||||
//#define TFTWIDTH 320
|
||||
//#define TFTHEIGHT 480
|
||||
|
||||
#define TFTWIDTH 240
|
||||
#define TFTHEIGHT 320
|
||||
|
||||
// LCD controller chip identifiers
|
||||
#define ID_932X 0
|
||||
#define ID_7575 1
|
||||
#define ID_9341 2
|
||||
#define ID_HX8357D 3
|
||||
#define ID_UNKNOWN 0xFF
|
||||
|
||||
// Register names from Peter Barrett's Microtouch code
|
||||
#define ILI932X_START_OSC 0x00
|
||||
#define ILI932X_DRIV_OUT_CTRL 0x01
|
||||
#define ILI932X_DRIV_WAV_CTRL 0x02
|
||||
#define ILI932X_ENTRY_MOD 0x03
|
||||
#define ILI932X_RESIZE_CTRL 0x04
|
||||
#define ILI932X_DISP_CTRL1 0x07
|
||||
#define ILI932X_DISP_CTRL2 0x08
|
||||
#define ILI932X_DISP_CTRL3 0x09
|
||||
#define ILI932X_DISP_CTRL4 0x0A
|
||||
#define ILI932X_RGB_DISP_IF_CTRL1 0x0C
|
||||
#define ILI932X_FRM_MARKER_POS 0x0D
|
||||
#define ILI932X_RGB_DISP_IF_CTRL2 0x0F
|
||||
#define ILI932X_POW_CTRL1 0x10
|
||||
#define ILI932X_POW_CTRL2 0x11
|
||||
#define ILI932X_POW_CTRL3 0x12
|
||||
#define ILI932X_POW_CTRL4 0x13
|
||||
#define ILI932X_GRAM_HOR_AD 0x20
|
||||
#define ILI932X_GRAM_VER_AD 0x21
|
||||
#define ILI932X_RW_GRAM 0x22
|
||||
#define ILI932X_POW_CTRL7 0x29
|
||||
#define ILI932X_FRM_RATE_COL_CTRL 0x2B
|
||||
#define ILI932X_GAMMA_CTRL1 0x30
|
||||
#define ILI932X_GAMMA_CTRL2 0x31
|
||||
#define ILI932X_GAMMA_CTRL3 0x32
|
||||
#define ILI932X_GAMMA_CTRL4 0x35
|
||||
#define ILI932X_GAMMA_CTRL5 0x36
|
||||
#define ILI932X_GAMMA_CTRL6 0x37
|
||||
#define ILI932X_GAMMA_CTRL7 0x38
|
||||
#define ILI932X_GAMMA_CTRL8 0x39
|
||||
#define ILI932X_GAMMA_CTRL9 0x3C
|
||||
#define ILI932X_GAMMA_CTRL10 0x3D
|
||||
#define ILI932X_HOR_START_AD 0x50
|
||||
#define ILI932X_HOR_END_AD 0x51
|
||||
#define ILI932X_VER_START_AD 0x52
|
||||
#define ILI932X_VER_END_AD 0x53
|
||||
#define ILI932X_GATE_SCAN_CTRL1 0x60
|
||||
#define ILI932X_GATE_SCAN_CTRL2 0x61
|
||||
#define ILI932X_GATE_SCAN_CTRL3 0x6A
|
||||
#define ILI932X_PART_IMG1_DISP_POS 0x80
|
||||
#define ILI932X_PART_IMG1_START_AD 0x81
|
||||
#define ILI932X_PART_IMG1_END_AD 0x82
|
||||
#define ILI932X_PART_IMG2_DISP_POS 0x83
|
||||
#define ILI932X_PART_IMG2_START_AD 0x84
|
||||
#define ILI932X_PART_IMG2_END_AD 0x85
|
||||
#define ILI932X_PANEL_IF_CTRL1 0x90
|
||||
#define ILI932X_PANEL_IF_CTRL2 0x92
|
||||
#define ILI932X_PANEL_IF_CTRL3 0x93
|
||||
#define ILI932X_PANEL_IF_CTRL4 0x95
|
||||
#define ILI932X_PANEL_IF_CTRL5 0x97
|
||||
#define ILI932X_PANEL_IF_CTRL6 0x98
|
||||
|
||||
#define HX8347G_COLADDRSTART_HI 0x02
|
||||
#define HX8347G_COLADDRSTART_LO 0x03
|
||||
#define HX8347G_COLADDREND_HI 0x04
|
||||
#define HX8347G_COLADDREND_LO 0x05
|
||||
#define HX8347G_ROWADDRSTART_HI 0x06
|
||||
#define HX8347G_ROWADDRSTART_LO 0x07
|
||||
#define HX8347G_ROWADDREND_HI 0x08
|
||||
#define HX8347G_ROWADDREND_LO 0x09
|
||||
#define HX8347G_MEMACCESS 0x16
|
||||
#include "registers.h"
|
||||
|
||||
// Constructor for breakout board (configurable LCD control lines).
|
||||
// Can still use this w/shield, but parameters are ignored.
|
||||
@@ -129,6 +74,12 @@ Adafruit_TFTLCD::Adafruit_TFTLCD(
|
||||
wrPort->PIO_SODR |= wrPinSet;
|
||||
rdPort->PIO_SODR |= rdPinSet;
|
||||
#endif
|
||||
#if defined(ADAFRUIT_PYPORTAL)
|
||||
write_port = (volatile uint8_t *)&(PORT->Group[0].OUT.reg) + 2;
|
||||
read_port = (volatile uint8_t *)&(PORT->Group[0].IN.reg) + 2;
|
||||
dir_port = (volatile uint8_t *)&(PORT->Group[0].DIR.reg) + 2;
|
||||
#endif
|
||||
|
||||
pinMode(cs, OUTPUT); // Enable outputs
|
||||
pinMode(cd, OUTPUT);
|
||||
pinMode(wr, OUTPUT);
|
||||
@@ -227,6 +178,28 @@ static const uint8_t HX8347G_regValues[] PROGMEM = {
|
||||
0x09 , 0x3F
|
||||
};
|
||||
|
||||
static const uint8_t HX8357D_regValues[] PROGMEM = {
|
||||
HX8357_SWRESET, 0,
|
||||
HX8357D_SETC, 3, 0xFF, 0x83, 0x57,
|
||||
TFTLCD_DELAY, 250,
|
||||
HX8357_SETRGB, 4, 0x00, 0x00, 0x06, 0x06,
|
||||
HX8357D_SETCOM, 1, 0x25, // -1.52V
|
||||
HX8357_SETOSC, 1, 0x68, // Normal mode 70Hz, Idle mode 55 Hz
|
||||
HX8357_SETPANEL, 1, 0x05, // BGR, Gate direction swapped
|
||||
HX8357_SETPWR1, 6, 0x00, 0x15, 0x1C, 0x1C, 0x83, 0xAA,
|
||||
HX8357D_SETSTBA, 6, 0x50, 0x50, 0x01, 0x3C, 0x1E, 0x08,
|
||||
// MEME GAMMA HERE
|
||||
HX8357D_SETCYC, 7, 0x02, 0x40, 0x00, 0x2A, 0x2A, 0x0D, 0x78,
|
||||
HX8357_COLMOD, 1, 0x55,
|
||||
HX8357_MADCTL, 1, 0xC0,
|
||||
HX8357_TEON, 1, 0x00,
|
||||
HX8357_TEARLINE, 2, 0x00, 0x02,
|
||||
HX8357_SLPOUT, 0,
|
||||
TFTLCD_DELAY, 150,
|
||||
HX8357_DISPON, 0,
|
||||
TFTLCD_DELAY, 50,
|
||||
};
|
||||
|
||||
static const uint16_t ILI932x_regValues[] PROGMEM = {
|
||||
ILI932X_START_OSC , 0x0001, // Start oscillator
|
||||
TFTLCD_DELAY , 50, // 50 millisecond delay
|
||||
@@ -286,6 +259,8 @@ void Adafruit_TFTLCD::begin(uint16_t id) {
|
||||
|
||||
reset();
|
||||
|
||||
delay(200);
|
||||
|
||||
if((id == 0x9325) || (id == 0x9328)) {
|
||||
|
||||
uint16_t a, d;
|
||||
@@ -300,6 +275,60 @@ void Adafruit_TFTLCD::begin(uint16_t id) {
|
||||
setRotation(rotation);
|
||||
setAddrWindow(0, 0, TFTWIDTH-1, TFTHEIGHT-1);
|
||||
|
||||
} else if (id == 0x9341) {
|
||||
|
||||
uint16_t a, d;
|
||||
driver = ID_9341;
|
||||
CS_ACTIVE;
|
||||
writeRegister8(ILI9341_SOFTRESET, 0);
|
||||
delay(50);
|
||||
writeRegister8(ILI9341_DISPLAYOFF, 0);
|
||||
|
||||
writeRegister8(ILI9341_POWERCONTROL1, 0x23);
|
||||
writeRegister8(ILI9341_POWERCONTROL2, 0x10);
|
||||
writeRegister16(ILI9341_VCOMCONTROL1, 0x2B2B);
|
||||
writeRegister8(ILI9341_VCOMCONTROL2, 0xC0);
|
||||
writeRegister8(ILI9341_MEMCONTROL, ILI9341_MADCTL_MY | ILI9341_MADCTL_BGR);
|
||||
writeRegister8(ILI9341_PIXELFORMAT, 0x55);
|
||||
writeRegister16(ILI9341_FRAMECONTROL, 0x001B);
|
||||
|
||||
writeRegister8(ILI9341_ENTRYMODE, 0x07);
|
||||
/* writeRegister32(ILI9341_DISPLAYFUNC, 0x0A822700);*/
|
||||
|
||||
writeRegister8(ILI9341_SLEEPOUT, 0);
|
||||
delay(150);
|
||||
writeRegister8(ILI9341_DISPLAYON, 0);
|
||||
delay(500);
|
||||
setAddrWindow(0, 0, TFTWIDTH-1, TFTHEIGHT-1);
|
||||
return;
|
||||
|
||||
} else if (id == 0x8357) {
|
||||
// HX8357D
|
||||
driver = ID_HX8357D;
|
||||
CS_ACTIVE;
|
||||
while(i < sizeof(HX8357D_regValues)) {
|
||||
uint8_t r = pgm_read_byte(&HX8357D_regValues[i++]);
|
||||
uint8_t len = pgm_read_byte(&HX8357D_regValues[i++]);
|
||||
if(r == TFTLCD_DELAY) {
|
||||
delay(len);
|
||||
} else {
|
||||
//Serial.print("Register $"); Serial.print(r, HEX);
|
||||
//Serial.print(" datalen "); Serial.println(len);
|
||||
|
||||
CS_ACTIVE;
|
||||
CD_COMMAND;
|
||||
write8(r);
|
||||
CD_DATA;
|
||||
for (uint8_t d=0; d<len; d++) {
|
||||
uint8_t x = pgm_read_byte(&HX8357D_regValues[i++]);
|
||||
write8(x);
|
||||
}
|
||||
CS_IDLE;
|
||||
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
} else if(id == 0x7575) {
|
||||
|
||||
uint8_t a, d;
|
||||
@@ -351,7 +380,6 @@ void Adafruit_TFTLCD::reset(void) {
|
||||
// Relevant to rect/screen fills and H/V lines. Input coordinates are
|
||||
// assumed pre-sorted (e.g. x2 >= x1).
|
||||
void Adafruit_TFTLCD::setAddrWindow(int x1, int y1, int x2, int y2) {
|
||||
|
||||
CS_ACTIVE;
|
||||
if(driver == ID_932X) {
|
||||
|
||||
@@ -411,6 +439,18 @@ void Adafruit_TFTLCD::setAddrWindow(int x1, int y1, int x2, int y2) {
|
||||
writeRegisterPair(HX8347G_COLADDREND_HI , HX8347G_COLADDREND_LO , x2);
|
||||
writeRegisterPair(HX8347G_ROWADDREND_HI , HX8347G_ROWADDREND_LO , y2);
|
||||
|
||||
} else if ((driver == ID_9341) || (driver == ID_HX8357D)){
|
||||
uint32_t t;
|
||||
|
||||
t = x1;
|
||||
t <<= 16;
|
||||
t |= x2;
|
||||
writeRegister32(ILI9341_COLADDRSET, t); // HX8357D uses same registers!
|
||||
t = y1;
|
||||
t <<= 16;
|
||||
t |= y2;
|
||||
writeRegister32(ILI9341_PAGEADDRSET, t); // HX8357D uses same registers!
|
||||
|
||||
}
|
||||
CS_IDLE;
|
||||
}
|
||||
@@ -438,8 +478,16 @@ void Adafruit_TFTLCD::flood(uint16_t color, uint32_t len) {
|
||||
|
||||
CS_ACTIVE;
|
||||
CD_COMMAND;
|
||||
if(driver == ID_932X) write8(0x00); // High byte of GRAM register...
|
||||
write8(0x22); // Write data to GRAM
|
||||
if (driver == ID_9341) {
|
||||
write8(0x2C);
|
||||
} else if (driver == ID_932X) {
|
||||
write8(0x00); // High byte of GRAM register...
|
||||
write8(0x22); // Write data to GRAM
|
||||
} else if (driver == ID_HX8357D) {
|
||||
write8(HX8357_RAMWR);
|
||||
} else {
|
||||
write8(0x22); // Write data to GRAM
|
||||
}
|
||||
|
||||
// Write first pixel normally, decrement counter by 1
|
||||
CD_DATA;
|
||||
@@ -579,9 +627,8 @@ void Adafruit_TFTLCD::fillScreen(uint16_t color) {
|
||||
writeRegister16(0x0020, x);
|
||||
writeRegister16(0x0021, y);
|
||||
|
||||
} else if(driver == ID_7575) {
|
||||
|
||||
// For the 7575, there is no settable address pointer, instead the
|
||||
} else if ((driver == ID_9341) || (driver == ID_7575) || (driver == ID_HX8357D)) {
|
||||
// For these, there is no settable address pointer, instead the
|
||||
// address window must be set for each drawing operation. However,
|
||||
// this display takes rotation into account for the parameters, no
|
||||
// need to do extra rotation math here.
|
||||
@@ -635,7 +682,15 @@ void Adafruit_TFTLCD::drawPixel(int16_t x, int16_t y, uint16_t color) {
|
||||
hi = color >> 8; lo = color;
|
||||
CD_COMMAND; write8(0x22); CD_DATA; write8(hi); write8(lo);
|
||||
|
||||
} else if ((driver == ID_9341) || (driver == ID_HX8357D)) {
|
||||
setAddrWindow(x, y, _width-1, _height-1);
|
||||
CS_ACTIVE;
|
||||
CD_COMMAND;
|
||||
write8(0x2C);
|
||||
CD_DATA;
|
||||
write8(color >> 8); write8(color);
|
||||
}
|
||||
|
||||
CS_IDLE;
|
||||
}
|
||||
|
||||
@@ -650,7 +705,11 @@ void Adafruit_TFTLCD::pushColors(uint16_t *data, uint8_t len, boolean first) {
|
||||
if(first == true) { // Issue GRAM write command only on first call
|
||||
CD_COMMAND;
|
||||
if(driver == ID_932X) write8(0x00);
|
||||
write8(0x22);
|
||||
if ((driver == ID_9341) || (driver == ID_HX8357D)){
|
||||
write8(0x2C);
|
||||
} else {
|
||||
write8(0x22);
|
||||
}
|
||||
}
|
||||
CD_DATA;
|
||||
while(len--) {
|
||||
@@ -683,7 +742,8 @@ void Adafruit_TFTLCD::setRotation(uint8_t x) {
|
||||
// For 932X, init default full-screen address window:
|
||||
setAddrWindow(0, 0, _width - 1, _height - 1); // CS_IDLE happens here
|
||||
|
||||
} if(driver == ID_7575) {
|
||||
}
|
||||
if(driver == ID_7575) {
|
||||
|
||||
uint8_t t;
|
||||
switch(rotation) {
|
||||
@@ -697,9 +757,53 @@ void Adafruit_TFTLCD::setRotation(uint8_t x) {
|
||||
// drawPixel() cheats by setting only the top left...by default,
|
||||
// the lower right is always reset to the corner.
|
||||
setLR(); // CS_IDLE happens here
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (driver == ID_9341) {
|
||||
// MEME, HX8357D uses same registers as 9341 but different values
|
||||
uint16_t t;
|
||||
|
||||
switch (rotation) {
|
||||
case 2:
|
||||
t = ILI9341_MADCTL_MX | ILI9341_MADCTL_BGR;
|
||||
break;
|
||||
case 3:
|
||||
t = ILI9341_MADCTL_MV | ILI9341_MADCTL_BGR;
|
||||
break;
|
||||
case 0:
|
||||
t = ILI9341_MADCTL_MY | ILI9341_MADCTL_BGR;
|
||||
break;
|
||||
case 1:
|
||||
t = ILI9341_MADCTL_MX | ILI9341_MADCTL_MY | ILI9341_MADCTL_MV | ILI9341_MADCTL_BGR;
|
||||
break;
|
||||
}
|
||||
writeRegister8(ILI9341_MADCTL, t ); // MADCTL
|
||||
// For 9341, init default full-screen address window:
|
||||
setAddrWindow(0, 0, _width - 1, _height - 1); // CS_IDLE happens here
|
||||
}
|
||||
|
||||
if (driver == ID_HX8357D) {
|
||||
// MEME, HX8357D uses same registers as 9341 but different values
|
||||
uint16_t t;
|
||||
|
||||
switch (rotation) {
|
||||
case 2:
|
||||
t = HX8357B_MADCTL_RGB;
|
||||
break;
|
||||
case 3:
|
||||
t = HX8357B_MADCTL_MX | HX8357B_MADCTL_MV | HX8357B_MADCTL_RGB;
|
||||
break;
|
||||
case 0:
|
||||
t = HX8357B_MADCTL_MX | HX8357B_MADCTL_MY | HX8357B_MADCTL_RGB;
|
||||
break;
|
||||
case 1:
|
||||
t = HX8357B_MADCTL_MY | HX8357B_MADCTL_MV | HX8357B_MADCTL_RGB;
|
||||
break;
|
||||
}
|
||||
writeRegister8(ILI9341_MADCTL, t ); // MADCTL
|
||||
// For 8357, init default full-screen address window:
|
||||
setAddrWindow(0, 0, _width - 1, _height - 1); // CS_IDLE happens here
|
||||
}}
|
||||
|
||||
#ifdef read8isFunctionalized
|
||||
#define read8(x) x=read8fn()
|
||||
@@ -774,9 +878,42 @@ uint16_t Adafruit_TFTLCD::readPixel(int16_t x, int16_t y) {
|
||||
|
||||
// Ditto with the read/write port directions, as above.
|
||||
uint16_t Adafruit_TFTLCD::readID(void) {
|
||||
uint16_t id;
|
||||
|
||||
// retry a bunch!
|
||||
for (int i = 0; i<5; i++) {
|
||||
id = readReg(0xD3);
|
||||
if (id == 0x9341) {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t hi, lo;
|
||||
|
||||
/*
|
||||
for (uint8_t i=0; i<128; i++) {
|
||||
Serial.print("$"); Serial.print(i, HEX);
|
||||
Serial.print(" = 0x"); Serial.println(readReg(i), HEX);
|
||||
}
|
||||
*/
|
||||
|
||||
if (readReg(0x04) == 0x8000) { // eh close enough
|
||||
// setc!
|
||||
/*
|
||||
Serial.println("!");
|
||||
for (uint8_t i=0; i<254; i++) {
|
||||
Serial.print("$"); Serial.print(i, HEX);
|
||||
Serial.print(" = 0x"); Serial.println(readReg(i), HEX);
|
||||
}
|
||||
*/
|
||||
writeRegister24(HX8357D_SETC, 0xFF8357);
|
||||
delay(300);
|
||||
//Serial.println(readReg(0xD0), HEX);
|
||||
if (readReg(0xD0) == 0x990000) {
|
||||
return 0x8357;
|
||||
}
|
||||
}
|
||||
|
||||
CS_ACTIVE;
|
||||
CD_COMMAND;
|
||||
write8(0x00);
|
||||
@@ -788,7 +925,38 @@ uint16_t Adafruit_TFTLCD::readID(void) {
|
||||
setWriteDir(); // Restore LCD data port(s) to WRITE configuration
|
||||
CS_IDLE;
|
||||
|
||||
return (hi << 8) | lo;
|
||||
id = hi; id <<= 8; id |= lo;
|
||||
return id;
|
||||
}
|
||||
|
||||
uint32_t Adafruit_TFTLCD::readReg(uint8_t r) {
|
||||
uint32_t id;
|
||||
uint8_t x;
|
||||
|
||||
// try reading register #4
|
||||
CS_ACTIVE;
|
||||
CD_COMMAND;
|
||||
write8(r);
|
||||
setReadDir(); // Set up LCD data port(s) for READ operations
|
||||
CD_DATA;
|
||||
delayMicroseconds(50);
|
||||
read8(x);
|
||||
id = x; // Do not merge or otherwise simplify
|
||||
id <<= 8; // these lines. It's an unfortunate
|
||||
read8(x);
|
||||
id |= x; // shenanigans that are going on.
|
||||
id <<= 8; // these lines. It's an unfortunate
|
||||
read8(x);
|
||||
id |= x; // shenanigans that are going on.
|
||||
id <<= 8; // these lines. It's an unfortunate
|
||||
read8(x);
|
||||
id |= x; // shenanigans that are going on.
|
||||
CS_IDLE;
|
||||
setWriteDir(); // Restore LCD data port(s) to WRITE configuration
|
||||
|
||||
//Serial.print("Read $"); Serial.print(r, HEX);
|
||||
//Serial.print(":\t0x"); Serial.println(id, HEX);
|
||||
return id;
|
||||
}
|
||||
|
||||
// Pass 8-bit (each) R,G,B, get back 16-bit packed color
|
||||
@@ -843,3 +1011,36 @@ void Adafruit_TFTLCD::writeRegisterPair(uint8_t aH, uint8_t aL, uint16_t d) {
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void Adafruit_TFTLCD::writeRegister24(uint8_t r, uint32_t d) {
|
||||
CS_ACTIVE;
|
||||
CD_COMMAND;
|
||||
write8(r);
|
||||
CD_DATA;
|
||||
delayMicroseconds(10);
|
||||
write8(d >> 16);
|
||||
delayMicroseconds(10);
|
||||
write8(d >> 8);
|
||||
delayMicroseconds(10);
|
||||
write8(d);
|
||||
CS_IDLE;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Adafruit_TFTLCD::writeRegister32(uint8_t r, uint32_t d) {
|
||||
CS_ACTIVE;
|
||||
CD_COMMAND;
|
||||
write8(r);
|
||||
CD_DATA;
|
||||
delayMicroseconds(10);
|
||||
write8(d >> 24);
|
||||
delayMicroseconds(10);
|
||||
write8(d >> 16);
|
||||
delayMicroseconds(10);
|
||||
write8(d >> 8);
|
||||
delayMicroseconds(10);
|
||||
write8(d);
|
||||
CS_IDLE;
|
||||
|
||||
}
|
||||
|
||||
+18
-13
@@ -6,6 +6,12 @@
|
||||
#ifndef _ADAFRUIT_TFTLCD_H_
|
||||
#define _ADAFRUIT_TFTLCD_H_
|
||||
|
||||
#if defined(__AVR__)
|
||||
typedef volatile uint8_t RwReg;
|
||||
#elif defined(__arm__)
|
||||
typedef volatile uint32_t RwReg;
|
||||
#endif
|
||||
|
||||
#if ARDUINO >= 100
|
||||
#include "Arduino.h"
|
||||
#else
|
||||
@@ -16,7 +22,8 @@
|
||||
|
||||
// **** IF USING THE LCD BREAKOUT BOARD, COMMENT OUT THIS NEXT LINE. ****
|
||||
// **** IF USING THE LCD SHIELD, LEAVE THE LINE ENABLED: ****
|
||||
//#define USE_ADAFRUIT_SHIELD_PINOUT
|
||||
|
||||
//#define USE_ADAFRUIT_SHIELD_PINOUT 1
|
||||
|
||||
class Adafruit_TFTLCD : public Adafruit_GFX {
|
||||
|
||||
@@ -42,6 +49,7 @@ class Adafruit_TFTLCD : public Adafruit_GFX {
|
||||
uint16_t color565(uint8_t r, uint8_t g, uint8_t b),
|
||||
readPixel(int16_t x, int16_t y),
|
||||
readID(void);
|
||||
uint32_t readReg(uint8_t r);
|
||||
|
||||
private:
|
||||
|
||||
@@ -63,6 +71,8 @@ class Adafruit_TFTLCD : public Adafruit_GFX {
|
||||
#ifndef writeRegister16
|
||||
writeRegister16(uint16_t a, uint16_t d),
|
||||
#endif
|
||||
writeRegister24(uint8_t a, uint32_t d),
|
||||
writeRegister32(uint8_t a, uint32_t d),
|
||||
#ifndef writeRegisterPair
|
||||
writeRegisterPair(uint8_t aH, uint8_t aL, uint16_t d),
|
||||
#endif
|
||||
@@ -77,19 +87,14 @@ class Adafruit_TFTLCD : public Adafruit_GFX {
|
||||
|
||||
#ifndef USE_ADAFRUIT_SHIELD_PINOUT
|
||||
|
||||
#ifdef __AVR__
|
||||
volatile uint8_t *csPort , *cdPort , *wrPort , *rdPort;
|
||||
uint8_t csPinSet , cdPinSet , wrPinSet , rdPinSet ,
|
||||
csPinUnset, cdPinUnset, wrPinUnset, rdPinUnset,
|
||||
_reset;
|
||||
volatile RwReg *csPort , *cdPort , *wrPort , *rdPort;
|
||||
RwReg csPinSet , cdPinSet , wrPinSet , rdPinSet ,
|
||||
csPinUnset, cdPinUnset, wrPinUnset, rdPinUnset,
|
||||
_reset;
|
||||
|
||||
#if defined(ADAFRUIT_PYPORTAL)
|
||||
volatile uint8_t *write_port, *read_port, *dir_port;
|
||||
#endif
|
||||
#if defined(__SAM3X8E__)
|
||||
Pio *csPort , *cdPort , *wrPort , *rdPort;
|
||||
uint32_t csPinSet , cdPinSet , wrPinSet , rdPinSet ,
|
||||
csPinUnset, cdPinUnset, wrPinUnset, rdPinUnset,
|
||||
_reset;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@@ -53,6 +53,8 @@ void setup(void) {
|
||||
Serial.println(F("Using Adafruit 2.8\" TFT Breakout Board Pinout"));
|
||||
#endif
|
||||
|
||||
Serial.print("TFT size is "); Serial.print(tft.width()); Serial.print("x"); Serial.println(tft.height());
|
||||
|
||||
tft.reset();
|
||||
|
||||
uint16_t identifier = tft.readID();
|
||||
@@ -63,6 +65,10 @@ void setup(void) {
|
||||
Serial.println(F("Found ILI9328 LCD driver"));
|
||||
} else if(identifier == 0x7575) {
|
||||
Serial.println(F("Found HX8347G LCD driver"));
|
||||
} else if(identifier == 0x9341) {
|
||||
Serial.println(F("Found ILI9341 LCD driver"));
|
||||
} else if(identifier == 0x8357) {
|
||||
Serial.println(F("Found HX8357D LCD driver"));
|
||||
} else {
|
||||
Serial.print(F("Unknown LCD driver chip: "));
|
||||
Serial.println(identifier, HEX);
|
||||
@@ -377,4 +383,3 @@ unsigned long testFilledRoundRects() {
|
||||
|
||||
return micros() - start;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,385 @@
|
||||
// IMPORTANT: Adafruit_TFTLCD LIBRARY MUST BE SPECIFICALLY
|
||||
// CONFIGURED FOR EITHER THE TFT SHIELD OR THE BREAKOUT BOARD.
|
||||
// SEE RELEVANT COMMENTS IN Adafruit_TFTLCD.h FOR SETUP.
|
||||
|
||||
#include <Adafruit_GFX.h> // Core graphics library
|
||||
#include <Adafruit_TFTLCD.h> // Hardware-specific library
|
||||
|
||||
// The control pins for the LCD can be assigned to any digital or
|
||||
// analog pins...but we'll use the analog pins as this allows us to
|
||||
// double up the pins with the touch screen (see the TFT paint example).
|
||||
#define TFT_CS A3 // Chip Select goes to Analog 3
|
||||
#define TFT_CD A2 // Command/Data goes to Analog 2
|
||||
#define TFT_WR A1 // LCD Write goes to Analog 1
|
||||
#define TFT_RD A0 // LCD Read goes to Analog 0
|
||||
|
||||
#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin
|
||||
|
||||
// When using the BREAKOUT BOARD only, use these 8 data lines to the LCD:
|
||||
// For the Arduino Uno, Duemilanove, Diecimila, etc.:
|
||||
// D0 connects to digital pin 8 (Notice these are
|
||||
// D1 connects to digital pin 9 NOT in order!)
|
||||
// D2 connects to digital pin 2
|
||||
// D3 connects to digital pin 3
|
||||
// D4 connects to digital pin 4
|
||||
// D5 connects to digital pin 5
|
||||
// D6 connects to digital pin 6
|
||||
// D7 connects to digital pin 7
|
||||
// For the Arduino Mega, use digital pins 22 through 29
|
||||
// (on the 2-row header at the end of the board).
|
||||
|
||||
// Assign human-readable names to some common 16-bit color values:
|
||||
#define BLACK 0x0000
|
||||
#define BLUE 0x001F
|
||||
#define RED 0xF800
|
||||
#define GREEN 0x07E0
|
||||
#define CYAN 0x07FF
|
||||
#define MAGENTA 0xF81F
|
||||
#define YELLOW 0xFFE0
|
||||
#define WHITE 0xFFFF
|
||||
|
||||
Adafruit_TFTLCD tft(TFT_CS, TFT_CD, TFT_WR, TFT_RD, TFT_RESET);
|
||||
// If using the shield, all control and data lines are fixed, and
|
||||
// a simpler declaration can optionally be used:
|
||||
// Adafruit_TFTLCD tft;
|
||||
|
||||
void setup(void) {
|
||||
Serial.begin(9600);
|
||||
Serial.println(F("TFT LCD test"));
|
||||
|
||||
#ifdef USE_ADAFRUIT_SHIELD_PINOUT
|
||||
Serial.println(F("Using Adafruit 2.8\" TFT Arduino Shield Pinout"));
|
||||
#else
|
||||
Serial.println(F("Using Adafruit 2.8\" TFT Breakout Board Pinout"));
|
||||
#endif
|
||||
|
||||
Serial.print("TFT size is "); Serial.print(tft.width()); Serial.print("x"); Serial.println(tft.height());
|
||||
|
||||
tft.reset();
|
||||
|
||||
uint16_t identifier = tft.readID();
|
||||
|
||||
if(identifier == 0x9325) {
|
||||
Serial.println(F("Found ILI9325 LCD driver"));
|
||||
} else if(identifier == 0x9328) {
|
||||
Serial.println(F("Found ILI9328 LCD driver"));
|
||||
} else if(identifier == 0x7575) {
|
||||
Serial.println(F("Found HX8347G LCD driver"));
|
||||
} else if(identifier == 0x9341) {
|
||||
Serial.println(F("Found ILI9341 LCD driver"));
|
||||
} else if(identifier == 0x8357) {
|
||||
Serial.println(F("Found HX8357D LCD driver"));
|
||||
} else {
|
||||
Serial.print(F("Unknown LCD driver chip: "));
|
||||
Serial.println(identifier, HEX);
|
||||
Serial.println(F("If using the Adafruit 2.8\" TFT Arduino shield, the line:"));
|
||||
Serial.println(F(" #define USE_ADAFRUIT_SHIELD_PINOUT"));
|
||||
Serial.println(F("should appear in the library header (Adafruit_TFT.h)."));
|
||||
Serial.println(F("If using the breakout board, it should NOT be #defined!"));
|
||||
Serial.println(F("Also if using the breakout, double-check that all wiring"));
|
||||
Serial.println(F("matches the tutorial."));
|
||||
return;
|
||||
}
|
||||
|
||||
tft.begin(identifier);
|
||||
|
||||
Serial.println(F("Benchmark Time (microseconds)"));
|
||||
|
||||
Serial.print(F("Screen fill "));
|
||||
Serial.println(testFillScreen());
|
||||
delay(500);
|
||||
|
||||
Serial.print(F("Text "));
|
||||
Serial.println(testText());
|
||||
delay(3000);
|
||||
|
||||
Serial.print(F("Lines "));
|
||||
Serial.println(testLines(CYAN));
|
||||
delay(500);
|
||||
|
||||
Serial.print(F("Horiz/Vert Lines "));
|
||||
Serial.println(testFastLines(RED, BLUE));
|
||||
delay(500);
|
||||
|
||||
Serial.print(F("Rectangles (outline) "));
|
||||
Serial.println(testRects(GREEN));
|
||||
delay(500);
|
||||
|
||||
Serial.print(F("Rectangles (filled) "));
|
||||
Serial.println(testFilledRects(YELLOW, MAGENTA));
|
||||
delay(500);
|
||||
|
||||
Serial.print(F("Circles (filled) "));
|
||||
Serial.println(testFilledCircles(10, MAGENTA));
|
||||
|
||||
Serial.print(F("Circles (outline) "));
|
||||
Serial.println(testCircles(10, WHITE));
|
||||
delay(500);
|
||||
|
||||
Serial.print(F("Triangles (outline) "));
|
||||
Serial.println(testTriangles());
|
||||
delay(500);
|
||||
|
||||
Serial.print(F("Triangles (filled) "));
|
||||
Serial.println(testFilledTriangles());
|
||||
delay(500);
|
||||
|
||||
Serial.print(F("Rounded rects (outline) "));
|
||||
Serial.println(testRoundRects());
|
||||
delay(500);
|
||||
|
||||
Serial.print(F("Rounded rects (filled) "));
|
||||
Serial.println(testFilledRoundRects());
|
||||
delay(500);
|
||||
|
||||
Serial.println(F("Done!"));
|
||||
}
|
||||
|
||||
void loop(void) {
|
||||
for(uint8_t rotation=0; rotation<4; rotation++) {
|
||||
tft.setRotation(rotation);
|
||||
testText();
|
||||
delay(2000);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned long testFillScreen() {
|
||||
unsigned long start = micros();
|
||||
tft.fillScreen(BLACK);
|
||||
tft.fillScreen(RED);
|
||||
tft.fillScreen(GREEN);
|
||||
tft.fillScreen(BLUE);
|
||||
tft.fillScreen(BLACK);
|
||||
return micros() - start;
|
||||
}
|
||||
|
||||
unsigned long testText() {
|
||||
tft.fillScreen(BLACK);
|
||||
unsigned long start = micros();
|
||||
tft.setCursor(0, 0);
|
||||
tft.setTextColor(WHITE); tft.setTextSize(1);
|
||||
tft.println("Hello World!");
|
||||
tft.setTextColor(YELLOW); tft.setTextSize(2);
|
||||
tft.println(1234.56);
|
||||
tft.setTextColor(RED); tft.setTextSize(3);
|
||||
tft.println(0xDEADBEEF, HEX);
|
||||
tft.println();
|
||||
tft.setTextColor(GREEN);
|
||||
tft.setTextSize(5);
|
||||
tft.println("Groop");
|
||||
tft.setTextSize(2);
|
||||
tft.println("I implore thee,");
|
||||
tft.setTextSize(1);
|
||||
tft.println("my foonting turlingdromes.");
|
||||
tft.println("And hooptiously drangle me");
|
||||
tft.println("with crinkly bindlewurdles,");
|
||||
tft.println("Or I will rend thee");
|
||||
tft.println("in the gobberwarts");
|
||||
tft.println("with my blurglecruncheon,");
|
||||
tft.println("see if I don't!");
|
||||
return micros() - start;
|
||||
}
|
||||
|
||||
unsigned long testLines(uint16_t color) {
|
||||
unsigned long start, t;
|
||||
int x1, y1, x2, y2,
|
||||
w = tft.width(),
|
||||
h = tft.height();
|
||||
|
||||
tft.fillScreen(BLACK);
|
||||
|
||||
x1 = y1 = 0;
|
||||
y2 = h - 1;
|
||||
start = micros();
|
||||
for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
|
||||
x2 = w - 1;
|
||||
for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
|
||||
t = micros() - start; // fillScreen doesn't count against timing
|
||||
|
||||
tft.fillScreen(BLACK);
|
||||
|
||||
x1 = w - 1;
|
||||
y1 = 0;
|
||||
y2 = h - 1;
|
||||
start = micros();
|
||||
for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
|
||||
x2 = 0;
|
||||
for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
|
||||
t += micros() - start;
|
||||
|
||||
tft.fillScreen(BLACK);
|
||||
|
||||
x1 = 0;
|
||||
y1 = h - 1;
|
||||
y2 = 0;
|
||||
start = micros();
|
||||
for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
|
||||
x2 = w - 1;
|
||||
for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
|
||||
t += micros() - start;
|
||||
|
||||
tft.fillScreen(BLACK);
|
||||
|
||||
x1 = w - 1;
|
||||
y1 = h - 1;
|
||||
y2 = 0;
|
||||
start = micros();
|
||||
for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
|
||||
x2 = 0;
|
||||
for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
|
||||
|
||||
return micros() - start;
|
||||
}
|
||||
|
||||
unsigned long testFastLines(uint16_t color1, uint16_t color2) {
|
||||
unsigned long start;
|
||||
int x, y, w = tft.width(), h = tft.height();
|
||||
|
||||
tft.fillScreen(BLACK);
|
||||
start = micros();
|
||||
for(y=0; y<h; y+=5) tft.drawFastHLine(0, y, w, color1);
|
||||
for(x=0; x<w; x+=5) tft.drawFastVLine(x, 0, h, color2);
|
||||
|
||||
return micros() - start;
|
||||
}
|
||||
|
||||
unsigned long testRects(uint16_t color) {
|
||||
unsigned long start;
|
||||
int n, i, i2,
|
||||
cx = tft.width() / 2,
|
||||
cy = tft.height() / 2;
|
||||
|
||||
tft.fillScreen(BLACK);
|
||||
n = min(tft.width(), tft.height());
|
||||
start = micros();
|
||||
for(i=2; i<n; i+=6) {
|
||||
i2 = i / 2;
|
||||
tft.drawRect(cx-i2, cy-i2, i, i, color);
|
||||
}
|
||||
|
||||
return micros() - start;
|
||||
}
|
||||
|
||||
unsigned long testFilledRects(uint16_t color1, uint16_t color2) {
|
||||
unsigned long start, t = 0;
|
||||
int n, i, i2,
|
||||
cx = tft.width() / 2 - 1,
|
||||
cy = tft.height() / 2 - 1;
|
||||
|
||||
tft.fillScreen(BLACK);
|
||||
n = min(tft.width(), tft.height());
|
||||
for(i=n; i>0; i-=6) {
|
||||
i2 = i / 2;
|
||||
start = micros();
|
||||
tft.fillRect(cx-i2, cy-i2, i, i, color1);
|
||||
t += micros() - start;
|
||||
// Outlines are not included in timing results
|
||||
tft.drawRect(cx-i2, cy-i2, i, i, color2);
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
unsigned long testFilledCircles(uint8_t radius, uint16_t color) {
|
||||
unsigned long start;
|
||||
int x, y, w = tft.width(), h = tft.height(), r2 = radius * 2;
|
||||
|
||||
tft.fillScreen(BLACK);
|
||||
start = micros();
|
||||
for(x=radius; x<w; x+=r2) {
|
||||
for(y=radius; y<h; y+=r2) {
|
||||
tft.fillCircle(x, y, radius, color);
|
||||
}
|
||||
}
|
||||
|
||||
return micros() - start;
|
||||
}
|
||||
|
||||
unsigned long testCircles(uint8_t radius, uint16_t color) {
|
||||
unsigned long start;
|
||||
int x, y, r2 = radius * 2,
|
||||
w = tft.width() + radius,
|
||||
h = tft.height() + radius;
|
||||
|
||||
// Screen is not cleared for this one -- this is
|
||||
// intentional and does not affect the reported time.
|
||||
start = micros();
|
||||
for(x=0; x<w; x+=r2) {
|
||||
for(y=0; y<h; y+=r2) {
|
||||
tft.drawCircle(x, y, radius, color);
|
||||
}
|
||||
}
|
||||
|
||||
return micros() - start;
|
||||
}
|
||||
|
||||
unsigned long testTriangles() {
|
||||
unsigned long start;
|
||||
int n, i, cx = tft.width() / 2 - 1,
|
||||
cy = tft.height() / 2 - 1;
|
||||
|
||||
tft.fillScreen(BLACK);
|
||||
n = min(cx, cy);
|
||||
start = micros();
|
||||
for(i=0; i<n; i+=5) {
|
||||
tft.drawTriangle(
|
||||
cx , cy - i, // peak
|
||||
cx - i, cy + i, // bottom left
|
||||
cx + i, cy + i, // bottom right
|
||||
tft.color565(0, 0, i));
|
||||
}
|
||||
|
||||
return micros() - start;
|
||||
}
|
||||
|
||||
unsigned long testFilledTriangles() {
|
||||
unsigned long start, t = 0;
|
||||
int i, cx = tft.width() / 2 - 1,
|
||||
cy = tft.height() / 2 - 1;
|
||||
|
||||
tft.fillScreen(BLACK);
|
||||
start = micros();
|
||||
for(i=min(cx,cy); i>10; i-=5) {
|
||||
start = micros();
|
||||
tft.fillTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,
|
||||
tft.color565(0, i, i));
|
||||
t += micros() - start;
|
||||
tft.drawTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,
|
||||
tft.color565(i, i, 0));
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
unsigned long testRoundRects() {
|
||||
unsigned long start;
|
||||
int w, i, i2,
|
||||
cx = tft.width() / 2 - 1,
|
||||
cy = tft.height() / 2 - 1;
|
||||
|
||||
tft.fillScreen(BLACK);
|
||||
w = min(tft.width(), tft.height());
|
||||
start = micros();
|
||||
for(i=0; i<w; i+=6) {
|
||||
i2 = i / 2;
|
||||
tft.drawRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(i, 0, 0));
|
||||
}
|
||||
|
||||
return micros() - start;
|
||||
}
|
||||
|
||||
unsigned long testFilledRoundRects() {
|
||||
unsigned long start;
|
||||
int i, i2,
|
||||
cx = tft.width() / 2 - 1,
|
||||
cy = tft.height() / 2 - 1;
|
||||
|
||||
tft.fillScreen(BLACK);
|
||||
start = micros();
|
||||
for(i=min(tft.width(), tft.height()); i>20; i-=6) {
|
||||
i2 = i / 2;
|
||||
tft.fillRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(0, i, 0));
|
||||
}
|
||||
|
||||
return micros() - start;
|
||||
}
|
||||
Executable → Regular
+4
@@ -63,6 +63,10 @@ void setup(void) {
|
||||
Serial.println(F("Found ILI9328 LCD driver"));
|
||||
} else if(identifier == 0x7575) {
|
||||
Serial.println(F("Found HX8347G LCD driver"));
|
||||
} else if(identifier == 0x9341) {
|
||||
Serial.println(F("Found ILI9341 LCD driver"));
|
||||
} else if(identifier == 0x8357) {
|
||||
Serial.println(F("Found HX8357D LCD driver"));
|
||||
} else {
|
||||
Serial.print(F("Unknown LCD driver chip: "));
|
||||
Serial.println(identifier, HEX);
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
// BMP-loading example specifically for the TFTLCD breakout board.
|
||||
// If using the Arduino shield, use the tftbmp_shield.pde sketch instead!
|
||||
// If using an Arduino Mega, make sure the SD library is configured for
|
||||
// 'soft' SPI in the file Sd2Card.h.
|
||||
// If using an Arduino Mega make sure to use its hardware SPI pins, OR make
|
||||
// sure the SD library is configured for 'soft' SPI in the file Sd2Card.h.
|
||||
|
||||
#include <Adafruit_GFX.h> // Core graphics library
|
||||
#include <Adafruit_TFTLCD.h> // Hardware-specific library
|
||||
#include <SD.h>
|
||||
#include <SPI.h>
|
||||
|
||||
// The control pins for the LCD can be assigned to any digital or
|
||||
// analog pins...but we'll use the analog pins as this allows us to
|
||||
@@ -53,6 +54,10 @@ void setup()
|
||||
Serial.println(F("Found ILI9328 LCD driver"));
|
||||
} else if(identifier == 0x7575) {
|
||||
Serial.println(F("Found HX8347G LCD driver"));
|
||||
} else if(identifier == 0x9341) {
|
||||
Serial.println(F("Found ILI9341 LCD driver"));
|
||||
} else if(identifier == 0x8357) {
|
||||
Serial.println(F("Found HX8357D LCD driver"));
|
||||
} else {
|
||||
Serial.print(F("Unknown LCD driver chip: "));
|
||||
Serial.println(identifier, HEX);
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// BMP-loading example specifically for the TFTLCD Arduino shield.
|
||||
// If using the breakout board, use the tftbmp.pde sketch instead!
|
||||
// If using an Arduino Mega, make sure the SD library is configured for
|
||||
// 'soft' SPI in the file Sd2Card.h.
|
||||
// If using an Arduino Mega and your sheild does not use the ICSP header for
|
||||
// SPI, make sure the SD library is configured for 'soft' SPI in the file Sd2Card.h.
|
||||
// If in doubt, update the library to use 'soft' SPI.
|
||||
|
||||
#include <Adafruit_GFX.h> // Core graphics library
|
||||
#include <Adafruit_TFTLCD.h> // Hardware-specific library
|
||||
@@ -29,6 +30,8 @@ void setup()
|
||||
Serial.println(F("Found ILI9328 LCD driver"));
|
||||
} else if(identifier == 0x7575) {
|
||||
Serial.println(F("Found HX8347G LCD driver"));
|
||||
} else if(identifier == 0x9341) {
|
||||
Serial.println(F("Found ILI9341 LCD driver"));
|
||||
} else {
|
||||
Serial.print(F("Unknown LCD driver chip: "));
|
||||
Serial.println(identifier, HEX);
|
||||
|
||||
@@ -97,9 +97,19 @@ void setup(void) {
|
||||
Serial.println(F("Found ILI9328 LCD driver"));
|
||||
} else if(identifier == 0x7575) {
|
||||
Serial.println(F("Found HX8347G LCD driver"));
|
||||
} else if(identifier == 0x9341) {
|
||||
Serial.println(F("Found ILI9341 LCD driver"));
|
||||
} else if(identifier == 0x8357) {
|
||||
Serial.println(F("Found HX8357D LCD driver"));
|
||||
} else {
|
||||
Serial.print(F("Unknown LCD driver chip: "));
|
||||
Serial.println(identifier, HEX);
|
||||
Serial.println(F("If using the Adafruit 2.8\" TFT Arduino shield, the line:"));
|
||||
Serial.println(F(" #define USE_ADAFRUIT_SHIELD_PINOUT"));
|
||||
Serial.println(F("should appear in the library header (Adafruit_TFT.h)."));
|
||||
Serial.println(F("If using the breakout board, it should NOT be #defined!"));
|
||||
Serial.println(F("Also if using the breakout, double-check that all wiring"));
|
||||
Serial.println(F("matches the tutorial."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -127,7 +137,7 @@ void setup(void) {
|
||||
void loop()
|
||||
{
|
||||
digitalWrite(13, HIGH);
|
||||
Point p = ts.getPoint();
|
||||
TSPoint p = ts.getPoint();
|
||||
digitalWrite(13, LOW);
|
||||
|
||||
// if sharing pins, you'll need to fix the directions of the touchscreen pins
|
||||
|
||||
@@ -0,0 +1,264 @@
|
||||
|
||||
#ifndef FONT5X7_H
|
||||
#define FONT5X7_H
|
||||
|
||||
// standard ascii 5x7 font
|
||||
|
||||
static unsigned char font[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x3E, 0x5B, 0x4F, 0x5B, 0x3E,
|
||||
0x3E, 0x6B, 0x4F, 0x6B, 0x3E,
|
||||
0x1C, 0x3E, 0x7C, 0x3E, 0x1C,
|
||||
0x18, 0x3C, 0x7E, 0x3C, 0x18,
|
||||
0x1C, 0x57, 0x7D, 0x57, 0x1C,
|
||||
0x1C, 0x5E, 0x7F, 0x5E, 0x1C,
|
||||
0x00, 0x18, 0x3C, 0x18, 0x00,
|
||||
0xFF, 0xE7, 0xC3, 0xE7, 0xFF,
|
||||
0x00, 0x18, 0x24, 0x18, 0x00,
|
||||
0xFF, 0xE7, 0xDB, 0xE7, 0xFF,
|
||||
0x30, 0x48, 0x3A, 0x06, 0x0E,
|
||||
0x26, 0x29, 0x79, 0x29, 0x26,
|
||||
0x40, 0x7F, 0x05, 0x05, 0x07,
|
||||
0x40, 0x7F, 0x05, 0x25, 0x3F,
|
||||
0x5A, 0x3C, 0xE7, 0x3C, 0x5A,
|
||||
0x7F, 0x3E, 0x1C, 0x1C, 0x08,
|
||||
0x08, 0x1C, 0x1C, 0x3E, 0x7F,
|
||||
0x14, 0x22, 0x7F, 0x22, 0x14,
|
||||
0x5F, 0x5F, 0x00, 0x5F, 0x5F,
|
||||
0x06, 0x09, 0x7F, 0x01, 0x7F,
|
||||
0x00, 0x66, 0x89, 0x95, 0x6A,
|
||||
0x60, 0x60, 0x60, 0x60, 0x60,
|
||||
0x94, 0xA2, 0xFF, 0xA2, 0x94,
|
||||
0x08, 0x04, 0x7E, 0x04, 0x08,
|
||||
0x10, 0x20, 0x7E, 0x20, 0x10,
|
||||
0x08, 0x08, 0x2A, 0x1C, 0x08,
|
||||
0x08, 0x1C, 0x2A, 0x08, 0x08,
|
||||
0x1E, 0x10, 0x10, 0x10, 0x10,
|
||||
0x0C, 0x1E, 0x0C, 0x1E, 0x0C,
|
||||
0x30, 0x38, 0x3E, 0x38, 0x30,
|
||||
0x06, 0x0E, 0x3E, 0x0E, 0x06,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x5F, 0x00, 0x00,
|
||||
0x00, 0x07, 0x00, 0x07, 0x00,
|
||||
0x14, 0x7F, 0x14, 0x7F, 0x14,
|
||||
0x24, 0x2A, 0x7F, 0x2A, 0x12,
|
||||
0x23, 0x13, 0x08, 0x64, 0x62,
|
||||
0x36, 0x49, 0x56, 0x20, 0x50,
|
||||
0x00, 0x08, 0x07, 0x03, 0x00,
|
||||
0x00, 0x1C, 0x22, 0x41, 0x00,
|
||||
0x00, 0x41, 0x22, 0x1C, 0x00,
|
||||
0x2A, 0x1C, 0x7F, 0x1C, 0x2A,
|
||||
0x08, 0x08, 0x3E, 0x08, 0x08,
|
||||
0x00, 0x80, 0x70, 0x30, 0x00,
|
||||
0x08, 0x08, 0x08, 0x08, 0x08,
|
||||
0x00, 0x00, 0x60, 0x60, 0x00,
|
||||
0x20, 0x10, 0x08, 0x04, 0x02,
|
||||
0x3E, 0x51, 0x49, 0x45, 0x3E,
|
||||
0x00, 0x42, 0x7F, 0x40, 0x00,
|
||||
0x72, 0x49, 0x49, 0x49, 0x46,
|
||||
0x21, 0x41, 0x49, 0x4D, 0x33,
|
||||
0x18, 0x14, 0x12, 0x7F, 0x10,
|
||||
0x27, 0x45, 0x45, 0x45, 0x39,
|
||||
0x3C, 0x4A, 0x49, 0x49, 0x31,
|
||||
0x41, 0x21, 0x11, 0x09, 0x07,
|
||||
0x36, 0x49, 0x49, 0x49, 0x36,
|
||||
0x46, 0x49, 0x49, 0x29, 0x1E,
|
||||
0x00, 0x00, 0x14, 0x00, 0x00,
|
||||
0x00, 0x40, 0x34, 0x00, 0x00,
|
||||
0x00, 0x08, 0x14, 0x22, 0x41,
|
||||
0x14, 0x14, 0x14, 0x14, 0x14,
|
||||
0x00, 0x41, 0x22, 0x14, 0x08,
|
||||
0x02, 0x01, 0x59, 0x09, 0x06,
|
||||
0x3E, 0x41, 0x5D, 0x59, 0x4E,
|
||||
0x7C, 0x12, 0x11, 0x12, 0x7C,
|
||||
0x7F, 0x49, 0x49, 0x49, 0x36,
|
||||
0x3E, 0x41, 0x41, 0x41, 0x22,
|
||||
0x7F, 0x41, 0x41, 0x41, 0x3E,
|
||||
0x7F, 0x49, 0x49, 0x49, 0x41,
|
||||
0x7F, 0x09, 0x09, 0x09, 0x01,
|
||||
0x3E, 0x41, 0x41, 0x51, 0x73,
|
||||
0x7F, 0x08, 0x08, 0x08, 0x7F,
|
||||
0x00, 0x41, 0x7F, 0x41, 0x00,
|
||||
0x20, 0x40, 0x41, 0x3F, 0x01,
|
||||
0x7F, 0x08, 0x14, 0x22, 0x41,
|
||||
0x7F, 0x40, 0x40, 0x40, 0x40,
|
||||
0x7F, 0x02, 0x1C, 0x02, 0x7F,
|
||||
0x7F, 0x04, 0x08, 0x10, 0x7F,
|
||||
0x3E, 0x41, 0x41, 0x41, 0x3E,
|
||||
0x7F, 0x09, 0x09, 0x09, 0x06,
|
||||
0x3E, 0x41, 0x51, 0x21, 0x5E,
|
||||
0x7F, 0x09, 0x19, 0x29, 0x46,
|
||||
0x26, 0x49, 0x49, 0x49, 0x32,
|
||||
0x03, 0x01, 0x7F, 0x01, 0x03,
|
||||
0x3F, 0x40, 0x40, 0x40, 0x3F,
|
||||
0x1F, 0x20, 0x40, 0x20, 0x1F,
|
||||
0x3F, 0x40, 0x38, 0x40, 0x3F,
|
||||
0x63, 0x14, 0x08, 0x14, 0x63,
|
||||
0x03, 0x04, 0x78, 0x04, 0x03,
|
||||
0x61, 0x59, 0x49, 0x4D, 0x43,
|
||||
0x00, 0x7F, 0x41, 0x41, 0x41,
|
||||
0x02, 0x04, 0x08, 0x10, 0x20,
|
||||
0x00, 0x41, 0x41, 0x41, 0x7F,
|
||||
0x04, 0x02, 0x01, 0x02, 0x04,
|
||||
0x40, 0x40, 0x40, 0x40, 0x40,
|
||||
0x00, 0x03, 0x07, 0x08, 0x00,
|
||||
0x20, 0x54, 0x54, 0x78, 0x40,
|
||||
0x7F, 0x28, 0x44, 0x44, 0x38,
|
||||
0x38, 0x44, 0x44, 0x44, 0x28,
|
||||
0x38, 0x44, 0x44, 0x28, 0x7F,
|
||||
0x38, 0x54, 0x54, 0x54, 0x18,
|
||||
0x00, 0x08, 0x7E, 0x09, 0x02,
|
||||
0x18, 0xA4, 0xA4, 0x9C, 0x78,
|
||||
0x7F, 0x08, 0x04, 0x04, 0x78,
|
||||
0x00, 0x44, 0x7D, 0x40, 0x00,
|
||||
0x20, 0x40, 0x40, 0x3D, 0x00,
|
||||
0x7F, 0x10, 0x28, 0x44, 0x00,
|
||||
0x00, 0x41, 0x7F, 0x40, 0x00,
|
||||
0x7C, 0x04, 0x78, 0x04, 0x78,
|
||||
0x7C, 0x08, 0x04, 0x04, 0x78,
|
||||
0x38, 0x44, 0x44, 0x44, 0x38,
|
||||
0xFC, 0x18, 0x24, 0x24, 0x18,
|
||||
0x18, 0x24, 0x24, 0x18, 0xFC,
|
||||
0x7C, 0x08, 0x04, 0x04, 0x08,
|
||||
0x48, 0x54, 0x54, 0x54, 0x24,
|
||||
0x04, 0x04, 0x3F, 0x44, 0x24,
|
||||
0x3C, 0x40, 0x40, 0x20, 0x7C,
|
||||
0x1C, 0x20, 0x40, 0x20, 0x1C,
|
||||
0x3C, 0x40, 0x30, 0x40, 0x3C,
|
||||
0x44, 0x28, 0x10, 0x28, 0x44,
|
||||
0x4C, 0x90, 0x90, 0x90, 0x7C,
|
||||
0x44, 0x64, 0x54, 0x4C, 0x44,
|
||||
0x00, 0x08, 0x36, 0x41, 0x00,
|
||||
0x00, 0x00, 0x77, 0x00, 0x00,
|
||||
0x00, 0x41, 0x36, 0x08, 0x00,
|
||||
0x02, 0x01, 0x02, 0x04, 0x02,
|
||||
0x3C, 0x26, 0x23, 0x26, 0x3C,
|
||||
0x1E, 0xA1, 0xA1, 0x61, 0x12,
|
||||
0x3A, 0x40, 0x40, 0x20, 0x7A,
|
||||
0x38, 0x54, 0x54, 0x55, 0x59,
|
||||
0x21, 0x55, 0x55, 0x79, 0x41,
|
||||
0x21, 0x54, 0x54, 0x78, 0x41,
|
||||
0x21, 0x55, 0x54, 0x78, 0x40,
|
||||
0x20, 0x54, 0x55, 0x79, 0x40,
|
||||
0x0C, 0x1E, 0x52, 0x72, 0x12,
|
||||
0x39, 0x55, 0x55, 0x55, 0x59,
|
||||
0x39, 0x54, 0x54, 0x54, 0x59,
|
||||
0x39, 0x55, 0x54, 0x54, 0x58,
|
||||
0x00, 0x00, 0x45, 0x7C, 0x41,
|
||||
0x00, 0x02, 0x45, 0x7D, 0x42,
|
||||
0x00, 0x01, 0x45, 0x7C, 0x40,
|
||||
0xF0, 0x29, 0x24, 0x29, 0xF0,
|
||||
0xF0, 0x28, 0x25, 0x28, 0xF0,
|
||||
0x7C, 0x54, 0x55, 0x45, 0x00,
|
||||
0x20, 0x54, 0x54, 0x7C, 0x54,
|
||||
0x7C, 0x0A, 0x09, 0x7F, 0x49,
|
||||
0x32, 0x49, 0x49, 0x49, 0x32,
|
||||
0x32, 0x48, 0x48, 0x48, 0x32,
|
||||
0x32, 0x4A, 0x48, 0x48, 0x30,
|
||||
0x3A, 0x41, 0x41, 0x21, 0x7A,
|
||||
0x3A, 0x42, 0x40, 0x20, 0x78,
|
||||
0x00, 0x9D, 0xA0, 0xA0, 0x7D,
|
||||
0x39, 0x44, 0x44, 0x44, 0x39,
|
||||
0x3D, 0x40, 0x40, 0x40, 0x3D,
|
||||
0x3C, 0x24, 0xFF, 0x24, 0x24,
|
||||
0x48, 0x7E, 0x49, 0x43, 0x66,
|
||||
0x2B, 0x2F, 0xFC, 0x2F, 0x2B,
|
||||
0xFF, 0x09, 0x29, 0xF6, 0x20,
|
||||
0xC0, 0x88, 0x7E, 0x09, 0x03,
|
||||
0x20, 0x54, 0x54, 0x79, 0x41,
|
||||
0x00, 0x00, 0x44, 0x7D, 0x41,
|
||||
0x30, 0x48, 0x48, 0x4A, 0x32,
|
||||
0x38, 0x40, 0x40, 0x22, 0x7A,
|
||||
0x00, 0x7A, 0x0A, 0x0A, 0x72,
|
||||
0x7D, 0x0D, 0x19, 0x31, 0x7D,
|
||||
0x26, 0x29, 0x29, 0x2F, 0x28,
|
||||
0x26, 0x29, 0x29, 0x29, 0x26,
|
||||
0x30, 0x48, 0x4D, 0x40, 0x20,
|
||||
0x38, 0x08, 0x08, 0x08, 0x08,
|
||||
0x08, 0x08, 0x08, 0x08, 0x38,
|
||||
0x2F, 0x10, 0xC8, 0xAC, 0xBA,
|
||||
0x2F, 0x10, 0x28, 0x34, 0xFA,
|
||||
0x00, 0x00, 0x7B, 0x00, 0x00,
|
||||
0x08, 0x14, 0x2A, 0x14, 0x22,
|
||||
0x22, 0x14, 0x2A, 0x14, 0x08,
|
||||
0xAA, 0x00, 0x55, 0x00, 0xAA,
|
||||
0xAA, 0x55, 0xAA, 0x55, 0xAA,
|
||||
0x00, 0x00, 0x00, 0xFF, 0x00,
|
||||
0x10, 0x10, 0x10, 0xFF, 0x00,
|
||||
0x14, 0x14, 0x14, 0xFF, 0x00,
|
||||
0x10, 0x10, 0xFF, 0x00, 0xFF,
|
||||
0x10, 0x10, 0xF0, 0x10, 0xF0,
|
||||
0x14, 0x14, 0x14, 0xFC, 0x00,
|
||||
0x14, 0x14, 0xF7, 0x00, 0xFF,
|
||||
0x00, 0x00, 0xFF, 0x00, 0xFF,
|
||||
0x14, 0x14, 0xF4, 0x04, 0xFC,
|
||||
0x14, 0x14, 0x17, 0x10, 0x1F,
|
||||
0x10, 0x10, 0x1F, 0x10, 0x1F,
|
||||
0x14, 0x14, 0x14, 0x1F, 0x00,
|
||||
0x10, 0x10, 0x10, 0xF0, 0x00,
|
||||
0x00, 0x00, 0x00, 0x1F, 0x10,
|
||||
0x10, 0x10, 0x10, 0x1F, 0x10,
|
||||
0x10, 0x10, 0x10, 0xF0, 0x10,
|
||||
0x00, 0x00, 0x00, 0xFF, 0x10,
|
||||
0x10, 0x10, 0x10, 0x10, 0x10,
|
||||
0x10, 0x10, 0x10, 0xFF, 0x10,
|
||||
0x00, 0x00, 0x00, 0xFF, 0x14,
|
||||
0x00, 0x00, 0xFF, 0x00, 0xFF,
|
||||
0x00, 0x00, 0x1F, 0x10, 0x17,
|
||||
0x00, 0x00, 0xFC, 0x04, 0xF4,
|
||||
0x14, 0x14, 0x17, 0x10, 0x17,
|
||||
0x14, 0x14, 0xF4, 0x04, 0xF4,
|
||||
0x00, 0x00, 0xFF, 0x00, 0xF7,
|
||||
0x14, 0x14, 0x14, 0x14, 0x14,
|
||||
0x14, 0x14, 0xF7, 0x00, 0xF7,
|
||||
0x14, 0x14, 0x14, 0x17, 0x14,
|
||||
0x10, 0x10, 0x1F, 0x10, 0x1F,
|
||||
0x14, 0x14, 0x14, 0xF4, 0x14,
|
||||
0x10, 0x10, 0xF0, 0x10, 0xF0,
|
||||
0x00, 0x00, 0x1F, 0x10, 0x1F,
|
||||
0x00, 0x00, 0x00, 0x1F, 0x14,
|
||||
0x00, 0x00, 0x00, 0xFC, 0x14,
|
||||
0x00, 0x00, 0xF0, 0x10, 0xF0,
|
||||
0x10, 0x10, 0xFF, 0x10, 0xFF,
|
||||
0x14, 0x14, 0x14, 0xFF, 0x14,
|
||||
0x10, 0x10, 0x10, 0x1F, 0x00,
|
||||
0x00, 0x00, 0x00, 0xF0, 0x10,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
|
||||
0xFF, 0xFF, 0xFF, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0xFF, 0xFF,
|
||||
0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
|
||||
0x38, 0x44, 0x44, 0x38, 0x44,
|
||||
0x7C, 0x2A, 0x2A, 0x3E, 0x14,
|
||||
0x7E, 0x02, 0x02, 0x06, 0x06,
|
||||
0x02, 0x7E, 0x02, 0x7E, 0x02,
|
||||
0x63, 0x55, 0x49, 0x41, 0x63,
|
||||
0x38, 0x44, 0x44, 0x3C, 0x04,
|
||||
0x40, 0x7E, 0x20, 0x1E, 0x20,
|
||||
0x06, 0x02, 0x7E, 0x02, 0x02,
|
||||
0x99, 0xA5, 0xE7, 0xA5, 0x99,
|
||||
0x1C, 0x2A, 0x49, 0x2A, 0x1C,
|
||||
0x4C, 0x72, 0x01, 0x72, 0x4C,
|
||||
0x30, 0x4A, 0x4D, 0x4D, 0x30,
|
||||
0x30, 0x48, 0x78, 0x48, 0x30,
|
||||
0xBC, 0x62, 0x5A, 0x46, 0x3D,
|
||||
0x3E, 0x49, 0x49, 0x49, 0x00,
|
||||
0x7E, 0x01, 0x01, 0x01, 0x7E,
|
||||
0x2A, 0x2A, 0x2A, 0x2A, 0x2A,
|
||||
0x44, 0x44, 0x5F, 0x44, 0x44,
|
||||
0x40, 0x51, 0x4A, 0x44, 0x40,
|
||||
0x40, 0x44, 0x4A, 0x51, 0x40,
|
||||
0x00, 0x00, 0xFF, 0x01, 0x03,
|
||||
0xE0, 0x80, 0xFF, 0x00, 0x00,
|
||||
0x08, 0x08, 0x6B, 0x6B, 0x08,
|
||||
0x36, 0x12, 0x36, 0x24, 0x36,
|
||||
0x06, 0x0F, 0x09, 0x0F, 0x06,
|
||||
0x00, 0x00, 0x18, 0x18, 0x00,
|
||||
0x00, 0x00, 0x10, 0x10, 0x00,
|
||||
0x30, 0x40, 0xFF, 0x01, 0x01,
|
||||
0x00, 0x1F, 0x01, 0x01, 0x1E,
|
||||
0x00, 0x19, 0x1D, 0x17, 0x12,
|
||||
0x00, 0x3C, 0x3C, 0x3C, 0x3C,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
#endif
|
||||
@@ -103,7 +103,7 @@ void setup(void) {
|
||||
void loop()
|
||||
{
|
||||
digitalWrite(13, HIGH);
|
||||
Point p = ts.getPoint();
|
||||
TSPoint p = ts.getPoint();
|
||||
digitalWrite(13, LOW);
|
||||
|
||||
// if sharing pins, you'll need to fix the directions of the touchscreen pins
|
||||
|
||||
+19
@@ -345,6 +345,25 @@
|
||||
#endif
|
||||
|
||||
|
||||
#elif defined(ADAFRUIT_PYPORTAL)
|
||||
#define RD_ACTIVE *rdPort &= rdPinUnset
|
||||
#define RD_IDLE *rdPort |= rdPinSet
|
||||
#define WR_ACTIVE *wrPort &= wrPinUnset
|
||||
#define WR_IDLE *wrPort |= wrPinSet
|
||||
#define CD_COMMAND *cdPort &= cdPinUnset
|
||||
#define CD_DATA *cdPort |= cdPinSet
|
||||
#define CS_ACTIVE *csPort &= csPinUnset
|
||||
#define CS_IDLE *csPort |= csPinSet
|
||||
|
||||
#define write8inline(d) { *write_port = d; WR_STROBE; }
|
||||
#define read8inline(result) { \
|
||||
RD_ACTIVE; \
|
||||
delayMicroseconds(1); \
|
||||
result = *read_port; \
|
||||
RD_IDLE;}
|
||||
#define setWriteDirInline() { *dir_port = 0xFF; }
|
||||
#define setReadDirInline() { *dir_port = 0x00; }
|
||||
|
||||
#else
|
||||
|
||||
#error "Board type unsupported / not recognized"
|
||||
|
||||
+172
@@ -0,0 +1,172 @@
|
||||
// Register names from Peter Barrett's Microtouch code
|
||||
#define ILI932X_START_OSC 0x00
|
||||
#define ILI932X_DRIV_OUT_CTRL 0x01
|
||||
#define ILI932X_DRIV_WAV_CTRL 0x02
|
||||
#define ILI932X_ENTRY_MOD 0x03
|
||||
#define ILI932X_RESIZE_CTRL 0x04
|
||||
#define ILI932X_DISP_CTRL1 0x07
|
||||
#define ILI932X_DISP_CTRL2 0x08
|
||||
#define ILI932X_DISP_CTRL3 0x09
|
||||
#define ILI932X_DISP_CTRL4 0x0A
|
||||
#define ILI932X_RGB_DISP_IF_CTRL1 0x0C
|
||||
#define ILI932X_FRM_MARKER_POS 0x0D
|
||||
#define ILI932X_RGB_DISP_IF_CTRL2 0x0F
|
||||
#define ILI932X_POW_CTRL1 0x10
|
||||
#define ILI932X_POW_CTRL2 0x11
|
||||
#define ILI932X_POW_CTRL3 0x12
|
||||
#define ILI932X_POW_CTRL4 0x13
|
||||
#define ILI932X_GRAM_HOR_AD 0x20
|
||||
#define ILI932X_GRAM_VER_AD 0x21
|
||||
#define ILI932X_RW_GRAM 0x22
|
||||
#define ILI932X_POW_CTRL7 0x29
|
||||
#define ILI932X_FRM_RATE_COL_CTRL 0x2B
|
||||
#define ILI932X_GAMMA_CTRL1 0x30
|
||||
#define ILI932X_GAMMA_CTRL2 0x31
|
||||
#define ILI932X_GAMMA_CTRL3 0x32
|
||||
#define ILI932X_GAMMA_CTRL4 0x35
|
||||
#define ILI932X_GAMMA_CTRL5 0x36
|
||||
#define ILI932X_GAMMA_CTRL6 0x37
|
||||
#define ILI932X_GAMMA_CTRL7 0x38
|
||||
#define ILI932X_GAMMA_CTRL8 0x39
|
||||
#define ILI932X_GAMMA_CTRL9 0x3C
|
||||
#define ILI932X_GAMMA_CTRL10 0x3D
|
||||
#define ILI932X_HOR_START_AD 0x50
|
||||
#define ILI932X_HOR_END_AD 0x51
|
||||
#define ILI932X_VER_START_AD 0x52
|
||||
#define ILI932X_VER_END_AD 0x53
|
||||
#define ILI932X_GATE_SCAN_CTRL1 0x60
|
||||
#define ILI932X_GATE_SCAN_CTRL2 0x61
|
||||
#define ILI932X_GATE_SCAN_CTRL3 0x6A
|
||||
#define ILI932X_PART_IMG1_DISP_POS 0x80
|
||||
#define ILI932X_PART_IMG1_START_AD 0x81
|
||||
#define ILI932X_PART_IMG1_END_AD 0x82
|
||||
#define ILI932X_PART_IMG2_DISP_POS 0x83
|
||||
#define ILI932X_PART_IMG2_START_AD 0x84
|
||||
#define ILI932X_PART_IMG2_END_AD 0x85
|
||||
#define ILI932X_PANEL_IF_CTRL1 0x90
|
||||
#define ILI932X_PANEL_IF_CTRL2 0x92
|
||||
#define ILI932X_PANEL_IF_CTRL3 0x93
|
||||
#define ILI932X_PANEL_IF_CTRL4 0x95
|
||||
#define ILI932X_PANEL_IF_CTRL5 0x97
|
||||
#define ILI932X_PANEL_IF_CTRL6 0x98
|
||||
|
||||
#define HX8347G_COLADDRSTART_HI 0x02
|
||||
#define HX8347G_COLADDRSTART_LO 0x03
|
||||
#define HX8347G_COLADDREND_HI 0x04
|
||||
#define HX8347G_COLADDREND_LO 0x05
|
||||
#define HX8347G_ROWADDRSTART_HI 0x06
|
||||
#define HX8347G_ROWADDRSTART_LO 0x07
|
||||
#define HX8347G_ROWADDREND_HI 0x08
|
||||
#define HX8347G_ROWADDREND_LO 0x09
|
||||
#define HX8347G_MEMACCESS 0x16
|
||||
|
||||
|
||||
|
||||
#define ILI9341_SOFTRESET 0x01
|
||||
#define ILI9341_SLEEPIN 0x10
|
||||
#define ILI9341_SLEEPOUT 0x11
|
||||
#define ILI9341_NORMALDISP 0x13
|
||||
#define ILI9341_INVERTOFF 0x20
|
||||
#define ILI9341_INVERTON 0x21
|
||||
#define ILI9341_GAMMASET 0x26
|
||||
#define ILI9341_DISPLAYOFF 0x28
|
||||
#define ILI9341_DISPLAYON 0x29
|
||||
#define ILI9341_COLADDRSET 0x2A
|
||||
#define ILI9341_PAGEADDRSET 0x2B
|
||||
#define ILI9341_MEMORYWRITE 0x2C
|
||||
#define ILI9341_PIXELFORMAT 0x3A
|
||||
#define ILI9341_FRAMECONTROL 0xB1
|
||||
#define ILI9341_DISPLAYFUNC 0xB6
|
||||
#define ILI9341_ENTRYMODE 0xB7
|
||||
#define ILI9341_POWERCONTROL1 0xC0
|
||||
#define ILI9341_POWERCONTROL2 0xC1
|
||||
#define ILI9341_VCOMCONTROL1 0xC5
|
||||
#define ILI9341_VCOMCONTROL2 0xC7
|
||||
#define ILI9341_MEMCONTROL 0x36
|
||||
#define ILI9341_MADCTL 0x36
|
||||
|
||||
#define ILI9341_MADCTL_MY 0x80
|
||||
#define ILI9341_MADCTL_MX 0x40
|
||||
#define ILI9341_MADCTL_MV 0x20
|
||||
#define ILI9341_MADCTL_ML 0x10
|
||||
#define ILI9341_MADCTL_RGB 0x00
|
||||
#define ILI9341_MADCTL_BGR 0x08
|
||||
#define ILI9341_MADCTL_MH 0x04
|
||||
|
||||
|
||||
|
||||
#define HX8357_NOP 0x00
|
||||
#define HX8357_SWRESET 0x01
|
||||
#define HX8357_RDDID 0x04
|
||||
#define HX8357_RDDST 0x09
|
||||
|
||||
#define HX8357B_RDPOWMODE 0x0A
|
||||
#define HX8357B_RDMADCTL 0x0B
|
||||
#define HX8357B_RDCOLMOD 0x0C
|
||||
#define HX8357B_RDDIM 0x0D
|
||||
#define HX8357B_RDDSDR 0x0F
|
||||
|
||||
#define HX8357_SLPIN 0x10
|
||||
#define HX8357_SLPOUT 0x11
|
||||
#define HX8357B_PTLON 0x12
|
||||
#define HX8357B_NORON 0x13
|
||||
|
||||
#define HX8357_INVOFF 0x20
|
||||
#define HX8357_INVON 0x21
|
||||
#define HX8357_DISPOFF 0x28
|
||||
#define HX8357_DISPON 0x29
|
||||
|
||||
#define HX8357_CASET 0x2A
|
||||
#define HX8357_PASET 0x2B
|
||||
#define HX8357_RAMWR 0x2C
|
||||
#define HX8357_RAMRD 0x2E
|
||||
|
||||
#define HX8357B_PTLAR 0x30
|
||||
#define HX8357_TEON 0x35
|
||||
#define HX8357_TEARLINE 0x44
|
||||
#define HX8357_MADCTL 0x36
|
||||
#define HX8357_COLMOD 0x3A
|
||||
|
||||
#define HX8357_SETOSC 0xB0
|
||||
#define HX8357_SETPWR1 0xB1
|
||||
#define HX8357B_SETDISPLAY 0xB2
|
||||
#define HX8357_SETRGB 0xB3
|
||||
#define HX8357D_SETCOM 0xB6
|
||||
|
||||
#define HX8357B_SETDISPMODE 0xB4
|
||||
#define HX8357D_SETCYC 0xB4
|
||||
#define HX8357B_SETOTP 0xB7
|
||||
#define HX8357D_SETC 0xB9
|
||||
|
||||
#define HX8357B_SET_PANEL_DRIVING 0xC0
|
||||
#define HX8357D_SETSTBA 0xC0
|
||||
#define HX8357B_SETDGC 0xC1
|
||||
#define HX8357B_SETID 0xC3
|
||||
#define HX8357B_SETDDB 0xC4
|
||||
#define HX8357B_SETDISPLAYFRAME 0xC5
|
||||
#define HX8357B_GAMMASET 0xC8
|
||||
#define HX8357B_SETCABC 0xC9
|
||||
#define HX8357_SETPANEL 0xCC
|
||||
|
||||
|
||||
#define HX8357B_SETPOWER 0xD0
|
||||
#define HX8357B_SETVCOM 0xD1
|
||||
#define HX8357B_SETPWRNORMAL 0xD2
|
||||
|
||||
#define HX8357B_RDID1 0xDA
|
||||
#define HX8357B_RDID2 0xDB
|
||||
#define HX8357B_RDID3 0xDC
|
||||
#define HX8357B_RDID4 0xDD
|
||||
|
||||
#define HX8357D_SETGAMMA 0xE0
|
||||
|
||||
#define HX8357B_SETGAMMA 0xC8
|
||||
#define HX8357B_SETPANELRELATED 0xE9
|
||||
|
||||
#define HX8357B_MADCTL_MY 0x80
|
||||
#define HX8357B_MADCTL_MX 0x40
|
||||
#define HX8357B_MADCTL_MV 0x20
|
||||
#define HX8357B_MADCTL_ML 0x10
|
||||
#define HX8357B_MADCTL_RGB 0x00
|
||||
#define HX8357B_MADCTL_BGR 0x08
|
||||
#define HX8357B_MADCTL_MH 0x04
|
||||
Reference in New Issue
Block a user