mirror of
https://github.com/YuzuZensai/MCUFRIEND_kbv.git
synced 2026-03-30 20:27:30 +00:00
Merge remote-tracking branch 'refs/remotes/origin/test_2560'
This commit is contained in:
@@ -89,7 +89,7 @@ void MCUFRIEND_kbv::reset(void)
|
|||||||
WriteCmdData(0xB0, 0x0000); //R61520 needs this to read ID
|
WriteCmdData(0xB0, 0x0000); //R61520 needs this to read ID
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCUFRIEND_kbv::WriteCmdData(uint16_t cmd, uint16_t dat)
|
static void writecmddata(uint16_t cmd, uint16_t dat)
|
||||||
{
|
{
|
||||||
CS_ACTIVE;
|
CS_ACTIVE;
|
||||||
WriteCmd(cmd);
|
WriteCmd(cmd);
|
||||||
@@ -97,13 +97,14 @@ void MCUFRIEND_kbv::WriteCmdData(uint16_t cmd, uint16_t dat)
|
|||||||
CS_IDLE;
|
CS_IDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MCUFRIEND_kbv::WriteCmdData(uint16_t cmd, uint16_t dat) { writecmddata(cmd, dat); }
|
||||||
|
|
||||||
static void WriteCmdParamN(uint16_t cmd, int8_t N, uint8_t * block)
|
static void WriteCmdParamN(uint16_t cmd, int8_t N, uint8_t * block)
|
||||||
{
|
{
|
||||||
CS_ACTIVE;
|
CS_ACTIVE;
|
||||||
WriteCmd(cmd);
|
WriteCmd(cmd);
|
||||||
while (N-- > 0) {
|
while (N-- > 0) {
|
||||||
uint8_t u8 = *block++;
|
uint8_t u8 = *block++;
|
||||||
CD_DATA;
|
|
||||||
write8(u8);
|
write8(u8);
|
||||||
if (N && is8347) {
|
if (N && is8347) {
|
||||||
cmd++;
|
cmd++;
|
||||||
@@ -148,7 +149,6 @@ uint16_t MCUFRIEND_kbv::readReg(uint16_t reg, int8_t index)
|
|||||||
CS_ACTIVE;
|
CS_ACTIVE;
|
||||||
WriteCmd(reg);
|
WriteCmd(reg);
|
||||||
setReadDir();
|
setReadDir();
|
||||||
CD_DATA;
|
|
||||||
delay(1); //1us should be adequate
|
delay(1); //1us should be adequate
|
||||||
// READ_16(ret);
|
// READ_16(ret);
|
||||||
do { ret = read16bits(); }while (--index >= 0); //need to test with SSD1963
|
do { ret = read16bits(); }while (--index >= 0); //need to test with SSD1963
|
||||||
@@ -277,7 +277,6 @@ int16_t MCUFRIEND_kbv::readGRAM(int16_t x, int16_t y, uint16_t * block, int16_t
|
|||||||
CS_ACTIVE;
|
CS_ACTIVE;
|
||||||
WriteCmd(_MR);
|
WriteCmd(_MR);
|
||||||
setReadDir();
|
setReadDir();
|
||||||
CD_DATA;
|
|
||||||
if (_lcd_capable & READ_NODUMMY) {
|
if (_lcd_capable & READ_NODUMMY) {
|
||||||
;
|
;
|
||||||
} else if ((_lcd_capable & MIPI_DCS_REV1) || _lcd_ID == 0x1289) {
|
} else if ((_lcd_capable & MIPI_DCS_REV1) || _lcd_ID == 0x1289) {
|
||||||
@@ -484,22 +483,11 @@ void MCUFRIEND_kbv::drawPixel(int16_t x, int16_t y, uint16_t color)
|
|||||||
// MCUFRIEND just plots at edge if you try to write outside of the box:
|
// MCUFRIEND just plots at edge if you try to write outside of the box:
|
||||||
if (x < 0 || y < 0 || x >= width() || y >= height())
|
if (x < 0 || y < 0 || x >= width() || y >= height())
|
||||||
return;
|
return;
|
||||||
#if defined(OFFSET_9327)
|
|
||||||
if (_lcd_ID == 0x9327) {
|
|
||||||
if (rotation == 2) y += OFFSET_9327;
|
|
||||||
if (rotation == 3) x += OFFSET_9327;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (_lcd_capable & MIPI_DCS_REV1) {
|
|
||||||
WriteCmdParam4(_MC, x >> 8, x, x >> 8, x);
|
|
||||||
WriteCmdParam4(_MP, y >> 8, y, y >> 8, y);
|
|
||||||
} else {
|
|
||||||
WriteCmdData(_MC, x);
|
|
||||||
WriteCmdData(_MP, y);
|
|
||||||
}
|
|
||||||
#if defined(SUPPORT_9488_555)
|
#if defined(SUPPORT_9488_555)
|
||||||
if (is555) color = color565_to_555(color);
|
if (is555) color = color565_to_555(color);
|
||||||
#endif
|
#endif
|
||||||
|
setAddrWindow(x, y, x, y);
|
||||||
|
// CS_ACTIVE; WriteCmd(_MW); write16(color); CS_IDLE; //-0.01s +98B
|
||||||
WriteCmdData(_MW, color);
|
WriteCmdData(_MW, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -519,11 +507,19 @@ void MCUFRIEND_kbv::setAddrWindow(int16_t x, int16_t y, int16_t x1, int16_t y1)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (_lcd_capable & MIPI_DCS_REV1) {
|
if (_lcd_capable & MIPI_DCS_REV1) {
|
||||||
|
#if 1
|
||||||
|
CS_ACTIVE; //-0.26s, +272B
|
||||||
|
WriteCmd(_MC); write8(x>>8); write8(x); write8(x1>>8); write8(x1);
|
||||||
|
WriteCmd(_MP); write8(y>>8); write8(y); write8(y1>>8); write8(y1);
|
||||||
|
CS_IDLE;
|
||||||
|
#else
|
||||||
WriteCmdParam4(_MC, x >> 8, x, x1 >> 8, x1);
|
WriteCmdParam4(_MC, x >> 8, x, x1 >> 8, x1);
|
||||||
WriteCmdParam4(_MP, y >> 8, y, y1 >> 8, y1);
|
WriteCmdParam4(_MP, y >> 8, y, y1 >> 8, y1);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
WriteCmdData(_MC, x);
|
WriteCmdData(_MC, x);
|
||||||
WriteCmdData(_MP, y);
|
WriteCmdData(_MP, y);
|
||||||
|
if (!(x == x1 && y == y1)) { //only need MC,MP for drawPixel
|
||||||
if (_lcd_capable & XSA_XEA_16BIT) {
|
if (_lcd_capable & XSA_XEA_16BIT) {
|
||||||
if (rotation & 1)
|
if (rotation & 1)
|
||||||
y1 = y = (y1 << 8) | y;
|
y1 = y = (y1 << 8) | y;
|
||||||
@@ -536,6 +532,7 @@ void MCUFRIEND_kbv::setAddrWindow(int16_t x, int16_t y, int16_t x1, int16_t y1)
|
|||||||
WriteCmdData(_EP, y1);
|
WriteCmdData(_EP, y1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MCUFRIEND_kbv::fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
|
void MCUFRIEND_kbv::fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
|
||||||
{
|
{
|
||||||
@@ -563,7 +560,6 @@ void MCUFRIEND_kbv::fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_
|
|||||||
if (end > height())
|
if (end > height())
|
||||||
end = height();
|
end = height();
|
||||||
h = end - y;
|
h = end - y;
|
||||||
|
|
||||||
setAddrWindow(x, y, x + w - 1, y + h - 1);
|
setAddrWindow(x, y, x + w - 1, y + h - 1);
|
||||||
CS_ACTIVE;
|
CS_ACTIVE;
|
||||||
WriteCmd(_MW);
|
WriteCmd(_MW);
|
||||||
@@ -573,7 +569,6 @@ void MCUFRIEND_kbv::fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_
|
|||||||
w = end;
|
w = end;
|
||||||
}
|
}
|
||||||
uint8_t hi = color >> 8, lo = color & 0xFF;
|
uint8_t hi = color >> 8, lo = color & 0xFF;
|
||||||
CD_DATA;
|
|
||||||
while (h-- > 0) {
|
while (h-- > 0) {
|
||||||
end = w;
|
end = w;
|
||||||
#if USING_16BIT_BUS
|
#if USING_16BIT_BUS
|
||||||
@@ -611,37 +606,25 @@ void MCUFRIEND_kbv::fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_
|
|||||||
setAddrWindow(0, 0, width() - 1, height() - 1);
|
setAddrWindow(0, 0, width() - 1, height() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCUFRIEND_kbv::pushColors(uint16_t * block, int16_t n, bool first)
|
static void pushColors_any(uint16_t cmd, uint8_t * block, int16_t n, bool first, uint8_t flags)
|
||||||
{
|
|
||||||
uint16_t color;
|
|
||||||
CS_ACTIVE;
|
|
||||||
if (first) {
|
|
||||||
WriteCmd(_MW);
|
|
||||||
}
|
|
||||||
CD_DATA;
|
|
||||||
while (n-- > 0) {
|
|
||||||
color = *block++;
|
|
||||||
#if defined(SUPPORT_9488_555)
|
|
||||||
if (is555) color = color565_to_555(color);
|
|
||||||
#endif
|
|
||||||
write16(color);
|
|
||||||
}
|
|
||||||
CS_IDLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MCUFRIEND_kbv::pushColors(uint8_t * block, int16_t n, bool first)
|
|
||||||
{
|
{
|
||||||
uint16_t color;
|
uint16_t color;
|
||||||
uint8_t h, l;
|
uint8_t h, l;
|
||||||
|
bool isconst = flags & 1;
|
||||||
|
bool isbigend = (flags & 2) != 0;
|
||||||
CS_ACTIVE;
|
CS_ACTIVE;
|
||||||
if (first) {
|
if (first) {
|
||||||
WriteCmd(_MW);
|
WriteCmd(cmd);
|
||||||
}
|
}
|
||||||
CD_DATA;
|
|
||||||
while (n-- > 0) {
|
while (n-- > 0) {
|
||||||
|
if (isconst) {
|
||||||
|
h = pgm_read_byte(block++);
|
||||||
|
l = pgm_read_byte(block++);
|
||||||
|
} else {
|
||||||
h = (*block++);
|
h = (*block++);
|
||||||
l = (*block++);
|
l = (*block++);
|
||||||
color = h << 8 | l;
|
}
|
||||||
|
color = (isbigend) ? (h << 8 | l) : (l << 8 | h);
|
||||||
#if defined(SUPPORT_9488_555)
|
#if defined(SUPPORT_9488_555)
|
||||||
if (is555) color = color565_to_555(color);
|
if (is555) color = color565_to_555(color);
|
||||||
#endif
|
#endif
|
||||||
@@ -650,25 +633,17 @@ void MCUFRIEND_kbv::pushColors(uint8_t * block, int16_t n, bool first)
|
|||||||
CS_IDLE;
|
CS_IDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCUFRIEND_kbv::pushColors(const uint8_t * block, int16_t n, bool first, bool bigend) //costs 28 bytes
|
void MCUFRIEND_kbv::pushColors(uint16_t * block, int16_t n, bool first)
|
||||||
{
|
{
|
||||||
uint16_t color;
|
pushColors_any(_MW, (uint8_t *)block, n, first, 0);
|
||||||
uint8_t h, l;
|
|
||||||
CS_ACTIVE;
|
|
||||||
if (first) {
|
|
||||||
WriteCmd(_MW);
|
|
||||||
}
|
}
|
||||||
CD_DATA;
|
void MCUFRIEND_kbv::pushColors(uint8_t * block, int16_t n, bool first)
|
||||||
while (n-- > 0) {
|
{
|
||||||
l = pgm_read_byte(block++);
|
pushColors_any(_MW, (uint8_t *)block, n, first, 0);
|
||||||
h = pgm_read_byte(block++);
|
|
||||||
color = (bigend) ? (l << 8 ) | h : (h << 8) | l;
|
|
||||||
#if defined(SUPPORT_9488_555)
|
|
||||||
if (is555) color = color565_to_555(color);
|
|
||||||
#endif
|
|
||||||
write16(color);
|
|
||||||
}
|
}
|
||||||
CS_IDLE;
|
void MCUFRIEND_kbv::pushColors(const uint8_t * block, int16_t n, bool first, bool bigend)
|
||||||
|
{
|
||||||
|
pushColors_any(_MW, (uint8_t *)block, n, first, bigend ? 3 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCUFRIEND_kbv::vertScroll(int16_t top, int16_t scrollines, int16_t offset)
|
void MCUFRIEND_kbv::vertScroll(int16_t top, int16_t scrollines, int16_t offset)
|
||||||
@@ -839,10 +814,7 @@ static void init_table16(const void *table, int16_t size)
|
|||||||
if (cmd == TFTLCD_DELAY)
|
if (cmd == TFTLCD_DELAY)
|
||||||
delay(d);
|
delay(d);
|
||||||
else {
|
else {
|
||||||
CS_ACTIVE;
|
writecmddata(cmd, d); //static function
|
||||||
WriteCmd(cmd);
|
|
||||||
WriteData(d);
|
|
||||||
CS_IDLE;
|
|
||||||
}
|
}
|
||||||
size -= 2 * sizeof(int16_t);
|
size -= 2 * sizeof(int16_t);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
//#define USE_SPECIAL //check for custom drivers
|
#define USE_SPECIAL //check for custom drivers
|
||||||
#if defined(USE_SPECIAL)
|
#if defined(USE_SPECIAL)
|
||||||
#include "mcufriend_special.h"
|
#include "mcufriend_special.h"
|
||||||
#if !defined(USE_SPECIAL_FAIL)
|
#if !defined(USE_SPECIAL_FAIL)
|
||||||
@@ -589,5 +589,5 @@ static void setReadDir()
|
|||||||
#define GPIO_INIT()
|
#define GPIO_INIT()
|
||||||
#endif
|
#endif
|
||||||
#define CTL_INIT() { GPIO_INIT(); RD_OUTPUT; WR_OUTPUT; CD_OUTPUT; CS_OUTPUT; RESET_OUTPUT; }
|
#define CTL_INIT() { GPIO_INIT(); RD_OUTPUT; WR_OUTPUT; CD_OUTPUT; CS_OUTPUT; RESET_OUTPUT; }
|
||||||
#define WriteCmd(x) { CD_COMMAND; write16(x); }
|
#define WriteCmd(x) { CD_COMMAND; write16(x); CD_DATA; }
|
||||||
#define WriteData(x) { CD_DATA; write16(x); }
|
#define WriteData(x) { write16(x); }
|
||||||
|
|||||||
@@ -4,10 +4,10 @@
|
|||||||
//#define USE_SSD1289_SHIELD_MEGA
|
//#define USE_SSD1289_SHIELD_MEGA
|
||||||
//#define USE_SSD1289_SHIELD_DUE
|
//#define USE_SSD1289_SHIELD_DUE
|
||||||
//#define USE_MEGA_8BIT_PROTOSHIELD
|
//#define USE_MEGA_8BIT_PROTOSHIELD
|
||||||
//#define USE_MEGA_8BIT_SHIELD
|
//#define USE_MEGA_8BIT_SHIELD // 4.7sec Mega2560 Shield
|
||||||
//#define USE_MEGA_16BIT_SHIELD //RD on PL6 (D43)
|
//#define USE_MEGA_16BIT_SHIELD // 2.14sec Mega2560 Shield
|
||||||
//#define USE_BLD_BST_MEGA32U4
|
//#define USE_BLD_BST_MEGA32U4
|
||||||
//#define USE_BLD_BST_MEGA2560
|
#define USE_BLD_BST_MEGA2560 // 12.23sec Uno Shield (17.38s C)
|
||||||
//#define USE_DUE_8BIT_PROTOSHIELD
|
//#define USE_DUE_8BIT_PROTOSHIELD
|
||||||
//#define USE_DUE_16BIT_SHIELD //RD on PA15 (D24)
|
//#define USE_DUE_16BIT_SHIELD //RD on PA15 (D24)
|
||||||
//#define USE_BOBCACHELOT_TEENSY
|
//#define USE_BOBCACHELOT_TEENSY
|
||||||
@@ -144,7 +144,7 @@
|
|||||||
#define EMASK 0x38
|
#define EMASK 0x38
|
||||||
#define GMASK 0x20
|
#define GMASK 0x20
|
||||||
#define HMASK 0x78
|
#define HMASK 0x78
|
||||||
static inline void write_8(uint8_t val)
|
static __attribute((always_inline)) void write_8(uint8_t val)
|
||||||
{
|
{
|
||||||
asm volatile("lds __tmp_reg__,0x0102" "\n\t"
|
asm volatile("lds __tmp_reg__,0x0102" "\n\t"
|
||||||
"BST %0,0" "\n\t" "BLD __tmp_reg__,5" "\n\t"
|
"BST %0,0" "\n\t" "BLD __tmp_reg__,5" "\n\t"
|
||||||
@@ -371,7 +371,7 @@ static inline void write_8(uint8_t val)
|
|||||||
#define CMASK (1<<6)
|
#define CMASK (1<<6)
|
||||||
#define DMASK ((1<<7)|(1<<4)|(3<<0))
|
#define DMASK ((1<<7)|(1<<4)|(3<<0))
|
||||||
#define EMASK (1<<6)
|
#define EMASK (1<<6)
|
||||||
static inline void write_8(uint8_t val)
|
static __attribute((always_inline)) void write_8(uint8_t val)
|
||||||
{
|
{
|
||||||
asm volatile("in __tmp_reg__,0x05" "\n\t"
|
asm volatile("in __tmp_reg__,0x05" "\n\t"
|
||||||
"BST %0,0" "\n\t" "BLD __tmp_reg__,4" "\n\t"
|
"BST %0,0" "\n\t" "BLD __tmp_reg__,4" "\n\t"
|
||||||
|
|||||||
Reference in New Issue
Block a user