This commit is contained in:
2026-02-12 01:27:25 -08:00
parent 0e91b56966
commit bf3aca0d38
322 changed files with 297928 additions and 93 deletions

View File

@@ -0,0 +1,115 @@
/*
* start rewrite from:
* https://github.com/ananevilya/Arduino-AXS15231B-Library.git
*/
#include "Arduino_AXS15231B.h"
Arduino_AXS15231B::Arduino_AXS15231B(
Arduino_DataBus *bus, int8_t rst, uint8_t r,
bool ips, int16_t w, int16_t h,
uint8_t col_offset1, uint8_t row_offset1, uint8_t col_offset2, uint8_t row_offset2,
const uint8_t *init_operations, size_t init_operations_len)
: Arduino_TFT(bus, rst, r, ips, w, h, col_offset1, row_offset1, col_offset2, row_offset2),
_init_operations(init_operations), _init_operations_len(init_operations_len)
{
}
bool Arduino_AXS15231B::begin(int32_t speed)
{
if (speed == GFX_NOT_DEFINED)
{
speed = 32000000UL; // AXS15231B Maximum supported speed
}
return Arduino_TFT::begin(speed);
}
void Arduino_AXS15231B::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
if ((x != _currentX) || (w != _currentW))
{
_currentX = x;
_currentW = w;
x += _xStart;
_bus->writeC8D16D16(AXS15231B_CASET, x, x + w - 1);
}
if ((y != _currentY) || (h != _currentH))
{
_currentY = y;
_currentH = h;
y += _yStart;
_bus->writeC8D16D16(AXS15231B_RASET, y, y + h - 1);
}
_bus->writeCommand(AXS15231B_RAMWR); // write to RAM
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_AXS15231B::setRotation(uint8_t r)
{
Arduino_TFT::setRotation(r);
switch (_rotation)
{
case 1:
r = AXS15231B_MADCTL_MX | AXS15231B_MADCTL_MV | AXS15231B_MADCTL_RGB;
break;
case 2:
r = AXS15231B_MADCTL_MX | AXS15231B_MADCTL_MY | AXS15231B_MADCTL_RGB;
break;
case 3:
r = AXS15231B_MADCTL_MY | AXS15231B_MADCTL_MV | AXS15231B_MADCTL_RGB;
break;
default: // case 0:
r = AXS15231B_MADCTL_RGB;
break;
}
_bus->beginWrite();
_bus->writeC8D8(AXS15231B_MADCTL, r);
_bus->endWrite();
}
void Arduino_AXS15231B::invertDisplay(bool i)
{
_bus->sendCommand((_ips ^ i) ? AXS15231B_INVON : AXS15231B_INVOFF);
}
void Arduino_AXS15231B::displayOn(void)
{
_bus->sendCommand(AXS15231B_SLPOUT);
delay(AXS15231B_SLPOUT_DELAY);
}
void Arduino_AXS15231B::displayOff(void)
{
_bus->sendCommand(AXS15231B_SLPIN);
delay(AXS15231B_SLPIN_DELAY);
}
void Arduino_AXS15231B::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(AXS15231B_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(AXS15231B_RST_DELAY);
}
else
{
// Software Rest
_bus->sendCommand(AXS15231B_SWRESET);
delay(AXS15231B_RST_DELAY);
}
_bus->batchOperation(_init_operations, _init_operations_len);
invertDisplay(false);
}

View File

@@ -0,0 +1,814 @@
/*
* start rewrite from:
* https://github.com/ananevilya/Arduino-AXS15231B-Library.git
*/
#pragma once
#include "../Arduino_GFX.h"
#include "../Arduino_TFT.h"
#define AXS15231B_TFTWIDTH 360
#define AXS15231B_TFTHEIGHT 640
#define AXS15231B_RST_DELAY 200 ///< delay ms wait for reset finish
#define AXS15231B_SLPIN_DELAY 200 ///< delay ms wait for sleep in finish
#define AXS15231B_SLPOUT_DELAY 200 ///< delay ms wait for sleep out finish
#define AXS15231B_SWRESET 0x01
#define AXS15231B_SLPIN 0x10
#define AXS15231B_SLPOUT 0x11
#define AXS15231B_INVOFF 0x20
#define AXS15231B_INVON 0x21
#define AXS15231B_DISPOFF 0x28
#define AXS15231B_DISPON 0x29
#define AXS15231B_CASET 0x2A
#define AXS15231B_RASET 0x2B
#define AXS15231B_RAMWR 0x2C
#define AXS15231B_PTLAR 0x30
#define AXS15231B_COLMOD 0x3A
#define AXS15231B_MADCTL 0x36
#define AXS15231B_MADCTL_MY 0x80
#define AXS15231B_MADCTL_MX 0x40
#define AXS15231B_MADCTL_MV 0x20
#define AXS15231B_MADCTL_ML 0x10
#define AXS15231B_MADCTL_RGB 0x00
static const uint8_t axs15231b_180640_init_operations[] = {
BEGIN_WRITE,
WRITE_C8_BYTES, 0xBB, 8,
0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x5A, 0xA5,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xA0, 17,
0xC0, 0x10, 0x00, 0x02, 0x00,
0x00, 0x04, 0x3F, 0x20, 0x05,
0x3F, 0x3F, 0x00, 0x00, 0x00,
0x00, 0x00,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xA2, 31,
0x30, 0x3C, 0x24, 0x14, 0xD0,
0x20, 0xFF, 0xE0, 0x40, 0x19,
0x80, 0x80, 0x80, 0x20, 0xf9,
0x10, 0x02, 0xff, 0xff, 0xF0,
0x90, 0x01, 0x32, 0xA0, 0x91,
0xE0, 0x20, 0x7F, 0xFF, 0x00,
0x5A,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xD0, 30,
0xE0, 0x40, 0x51, 0x24, 0x08,
0x05, 0x10, 0x01, 0x20, 0x15,
0xC2, 0x42, 0x22, 0x22, 0xAA,
0x03, 0x10, 0x12, 0x60, 0x14,
0x1E, 0x51, 0x15, 0x00, 0x8A,
0x20, 0x00, 0x03, 0x3A, 0x12,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xA3, 22,
0xA0, 0x06, 0xAA, 0x00, 0x08,
0x02, 0x0A, 0x04, 0x04, 0x04,
0x04, 0x04, 0x04, 0x04, 0x04,
0x04, 0x04, 0x04, 0x04, 0x00,
0x55, 0x55,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xC1, 30,
0x31, 0x04, 0x02, 0x02, 0x71,
0x05, 0x24, 0x55, 0x02, 0x00,
0x41, 0x00, 0x53, 0xFF, 0xFF,
0xFF, 0x4F, 0x52, 0x00, 0x4F,
0x52, 0x00, 0x45, 0x3B, 0x0B,
0x02, 0x0d, 0x00, 0xFF, 0x40,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xC3, 11,
0x00, 0x00, 0x00, 0x50, 0x03,
0x00, 0x00, 0x00, 0x01, 0x80,
0x01,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xC4, 29,
0x00, 0x24, 0x33, 0x80, 0x00,
0xea, 0x64, 0x32, 0xC8, 0x64,
0xC8, 0x32, 0x90, 0x90, 0x11,
0x06, 0xDC, 0xFA, 0x00, 0x00,
0x80, 0xFE, 0x10, 0x10, 0x00,
0x0A, 0x0A, 0x44, 0x50,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xC5, 23,
0x18, 0x00, 0x00, 0x03, 0xFE,
0x3A, 0x4A, 0x20, 0x30, 0x10,
0x88, 0xDE, 0x0D, 0x08, 0x0F,
0x0F, 0x01, 0x3A, 0x4A, 0x20,
0x10, 0x10, 0x00,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xC6, 20,
0x05, 0x0A, 0x05, 0x0A, 0x00,
0xE0, 0x2E, 0x0B, 0x12, 0x22,
0x12, 0x22, 0x01, 0x03, 0x00,
0x3F, 0x6A, 0x18, 0xC8, 0x22,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xC7, 20,
0x50, 0x32, 0x28, 0x00, 0xa2,
0x80, 0x8f, 0x00, 0x80, 0xff,
0x07, 0x11, 0x9c, 0x67, 0xff,
0x24, 0x0c, 0x0d, 0x0e, 0x0f,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xC9, 4,
0x33, 0x44, 0x44, 0x01,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xCF, 27,
0x2C, 0x1E, 0x88, 0x58, 0x13,
0x18, 0x56, 0x18, 0x1E, 0x68,
0x88, 0x00, 0x65, 0x09, 0x22,
0xC4, 0x0C, 0x77, 0x22, 0x44,
0xAA, 0x55, 0x08, 0x08, 0x12,
0xA0, 0x08,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xD5, 30,
0x40, 0x8E, 0x8D, 0x01, 0x35,
0x04, 0x92, 0x74, 0x04, 0x92,
0x74, 0x04, 0x08, 0x6A, 0x04,
0x46, 0x03, 0x03, 0x03, 0x03,
0x82, 0x01, 0x03, 0x00, 0xE0,
0x51, 0xA1, 0x00, 0x00, 0x00,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xD6, 30,
0x10, 0x32, 0x54, 0x76, 0x98,
0xBA, 0xDC, 0xFE, 0x93, 0x00,
0x01, 0x83, 0x07, 0x07, 0x00,
0x07, 0x07, 0x00, 0x03, 0x03,
0x03, 0x03, 0x03, 0x03, 0x00,
0x84, 0x00, 0x20, 0x01, 0x00,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xD7, 19,
0x03, 0x01, 0x0b, 0x09, 0x0f,
0x0d, 0x1E, 0x1F, 0x18, 0x1d,
0x1f, 0x19, 0x40, 0x8E, 0x04,
0x00, 0x20, 0xA0, 0x1F,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xD8, 12,
0x02, 0x00, 0x0a, 0x08, 0x0e,
0x0c, 0x1E, 0x1F, 0x18, 0x1d,
0x1f, 0x19,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xD9, 12,
0x1F, 0x1F, 0x1F, 0x1F, 0x1F,
0x1F, 0x1F, 0x1F, 0x1F, 0x1F,
0x1F, 0x1F,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xDD, 12,
0x1F, 0x1F, 0x1F, 0x1F, 0x1F,
0x1F, 0x1F, 0x1F, 0x1F, 0x1F,
0x1F, 0x1F,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xDF, 8,
0x44, 0x73, 0x4B, 0x69, 0x00,
0x0A, 0x02, 0x90,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xE0, 17,
0x3B, 0x28, 0x10, 0x16, 0x0c,
0x06, 0x11, 0x28, 0x5c, 0x21,
0x0D, 0x35, 0x13, 0x2C, 0x33,
0x28, 0x0D,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xE1, 17,
0x37, 0x28, 0x10, 0x16, 0x0b,
0x06, 0x11, 0x28, 0x5C, 0x21,
0x0D, 0x35, 0x14, 0x2C, 0x33,
0x28, 0x0F,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xE2, 17,
0x3B, 0x07, 0x12, 0x18, 0x0E,
0x0D, 0x17, 0x35, 0x44, 0x32,
0x0C, 0x14, 0x14, 0x36, 0x3A,
0x2F, 0x0D,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xE3, 17,
0x37, 0x07, 0x12, 0x18, 0x0E,
0x0D, 0x17, 0x35, 0x44, 0x32,
0x0C, 0x14, 0x14, 0x36, 0x32,
0x2F, 0x0F,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xE4, 17,
0x3B, 0x07, 0x12, 0x18, 0x0E,
0x0D, 0x17, 0x39, 0x44, 0x2E,
0x0C, 0x14, 0x14, 0x36, 0x3A,
0x2F, 0x0D,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xE5, 17,
0x37, 0x07, 0x12, 0x18, 0x0E,
0x0D, 0x17, 0x39, 0x44, 0x2E,
0x0C, 0x14, 0x14, 0x36, 0x3A,
0x2F, 0x0F,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xA4, 16,
0x85, 0x85, 0x95, 0x82, 0xAF,
0xAA, 0xAA, 0x80, 0x10, 0x30,
0x40, 0x40, 0x20, 0xFF, 0x60,
0x30,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xA4, 4,
0x85, 0x85, 0x95, 0x85,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xBB, 8,
0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_D8, 0x11, 0x00,
END_WRITE,
DELAY, AXS15231B_SLPOUT_DELAY,
BEGIN_WRITE,
WRITE_C8_D8, 0x29, 0x00,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_D8, 0x22, 0x00, // All Pixels off
END_WRITE,
DELAY, 100,
BEGIN_WRITE,
WRITE_C8_BYTES, 0x2C, 4,
0x00, 0x00, 0x00, 0x00,
END_WRITE};
static const uint8_t axs15231b_320480_type1_init_operations[] = {
BEGIN_WRITE,
WRITE_C8_BYTES, 0xA0, 17,
0xC0, 0x10, 0x00, 0x02, 0x00,
0x00, 0x04, 0x3F, 0x20, 0x05,
0x3F, 0x3F, 0x00, 0x00, 0x00,
0x00, 0x00,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xA2, 31,
0x30, 0x3C, 0x24, 0x14, 0xD0,
0x20, 0xFF, 0xE0, 0x40, 0x19,
0x80, 0x80, 0x80, 0x20, 0xf9,
0x10, 0x02, 0xff, 0xff, 0xF0,
0x90, 0x01, 0x32, 0xA0, 0x91,
0xE0, 0x20, 0x7F, 0xFF, 0x00,
0x5A,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xD0, 30,
0xE0, 0x40, 0x51, 0x24, 0x08,
0x05, 0x10, 0x01, 0x20, 0x15,
0xC2, 0x42, 0x22, 0x22, 0xAA,
0x03, 0x10, 0x12, 0x60, 0x14,
0x1E, 0x51, 0x15, 0x00, 0x8A,
0x20, 0x00, 0x03, 0x3A, 0x12,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xA3, 22,
0xA0, 0x06, 0xAA, 0x00, 0x08,
0x02, 0x0A, 0x04, 0x04, 0x04,
0x04, 0x04, 0x04, 0x04, 0x04,
0x04, 0x04, 0x04, 0x04, 0x00,
0x55, 0x55,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xC1, 30,
0x31, 0x04, 0x02, 0x02, 0x71,
0x05, 0x24, 0x55, 0x02, 0x00,
0x41, 0x00, 0x53, 0xFF, 0xFF,
0xFF, 0x4F, 0x52, 0x00, 0x4F,
0x52, 0x00, 0x45, 0x3B, 0x0B,
0x02, 0x0d, 0x00, 0xFF, 0x40,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xC3, 11,
0x00, 0x00, 0x00, 0x50, 0x03,
0x00, 0x00, 0x00, 0x01, 0x80,
0x01,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xC4, 29,
0x00, 0x24, 0x33, 0x80, 0x00,
0xea, 0x64, 0x32, 0xC8, 0x64,
0xC8, 0x32, 0x90, 0x90, 0x11,
0x06, 0xDC, 0xFA, 0x00, 0x00,
0x80, 0xFE, 0x10, 0x10, 0x00,
0x0A, 0x0A, 0x44, 0x50,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xC5, 23,
0x18, 0x00, 0x00, 0x03, 0xFE,
0x3A, 0x4A, 0x20, 0x30, 0x10,
0x88, 0xDE, 0x0D, 0x08, 0x0F,
0x0F, 0x01, 0x3A, 0x4A, 0x20,
0x10, 0x10, 0x00,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xC6, 20,
0x05, 0x0A, 0x05, 0x0A, 0x00,
0xE0, 0x2E, 0x0B, 0x12, 0x22,
0x12, 0x22, 0x01, 0x03, 0x00,
0x3F, 0x6A, 0x18, 0xC8, 0x22,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xC7, 20,
0x50, 0x32, 0x28, 0x00, 0xa2,
0x80, 0x8f, 0x00, 0x80, 0xff,
0x07, 0x11, 0x9c, 0x67, 0xff,
0x24, 0x0c, 0x0d, 0x0e, 0x0f,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xC9, 4,
0x33, 0x44, 0x44, 0x01,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xCF, 27,
0x2C, 0x1E, 0x88, 0x58, 0x13,
0x18, 0x56, 0x18, 0x1E, 0x68,
0x88, 0x00, 0x65, 0x09, 0x22,
0xC4, 0x0C, 0x77, 0x22, 0x44,
0xAA, 0x55, 0x08, 0x08, 0x12,
0xA0, 0x08,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xD5, 30,
0x40, 0x8E, 0x8D, 0x01, 0x35,
0x04, 0x92, 0x74, 0x04, 0x92,
0x74, 0x04, 0x08, 0x6A, 0x04,
0x46, 0x03, 0x03, 0x03, 0x03,
0x82, 0x01, 0x03, 0x00, 0xE0,
0x51, 0xA1, 0x00, 0x00, 0x00,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xD6, 30,
0x10, 0x32, 0x54, 0x76, 0x98,
0xBA, 0xDC, 0xFE, 0x93, 0x00,
0x01, 0x83, 0x07, 0x07, 0x00,
0x07, 0x07, 0x00, 0x03, 0x03,
0x03, 0x03, 0x03, 0x03, 0x00,
0x84, 0x00, 0x20, 0x01, 0x00,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xD7, 19,
0x03, 0x01, 0x0b, 0x09, 0x0f,
0x0d, 0x1E, 0x1F, 0x18, 0x1d,
0x1f, 0x19, 0x40, 0x8E, 0x04,
0x00, 0x20, 0xA0, 0x1F,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xD8, 12,
0x02, 0x00, 0x0a, 0x08, 0x0e,
0x0c, 0x1E, 0x1F, 0x18, 0x1d,
0x1f, 0x19,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xD9, 12,
0x1F, 0x1F, 0x1F, 0x1F, 0x1F,
0x1F, 0x1F, 0x1F, 0x1F, 0x1F,
0x1F, 0x1F,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xDD, 12,
0x1F, 0x1F, 0x1F, 0x1F, 0x1F,
0x1F, 0x1F, 0x1F, 0x1F, 0x1F,
0x1F, 0x1F,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xDF, 8,
0x44, 0x73, 0x4B, 0x69, 0x00,
0x0A, 0x02, 0x90,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xE0, 17,
0x3B, 0x28, 0x10, 0x16, 0x0c,
0x06, 0x11, 0x28, 0x5c, 0x21,
0x0D, 0x35, 0x13, 0x2C, 0x33,
0x28, 0x0D,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xE1, 17,
0x37, 0x28, 0x10, 0x16, 0x0b,
0x06, 0x11, 0x28, 0x5C, 0x21,
0x0D, 0x35, 0x14, 0x2C, 0x33,
0x28, 0x0F,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xE2, 17,
0x3B, 0x07, 0x12, 0x18, 0x0E,
0x0D, 0x17, 0x35, 0x44, 0x32,
0x0C, 0x14, 0x14, 0x36, 0x3A,
0x2F, 0x0D,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xE3, 17,
0x37, 0x07, 0x12, 0x18, 0x0E,
0x0D, 0x17, 0x35, 0x44, 0x32,
0x0C, 0x14, 0x14, 0x36, 0x32,
0x2F, 0x0F,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xE4, 17,
0x3B, 0x07, 0x12, 0x18, 0x0E,
0x0D, 0x17, 0x39, 0x44, 0x2E,
0x0C, 0x14, 0x14, 0x36, 0x3A,
0x2F, 0x0D,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xE5, 17,
0x37, 0x07, 0x12, 0x18, 0x0E,
0x0D, 0x17, 0x39, 0x44, 0x2E,
0x0C, 0x14, 0x14, 0x36, 0x3A,
0x2F, 0x0F,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xA4, 16,
0x85, 0x85, 0x95, 0x82, 0xAF,
0xAA, 0xAA, 0x80, 0x10, 0x30,
0x40, 0x40, 0x20, 0xFF, 0x60,
0x30,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xA4, 4,
0x85, 0x85, 0x95, 0x85,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xBB, 8,
0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_D8, 0x11, 0x00,
END_WRITE,
DELAY, AXS15231B_SLPOUT_DELAY,
BEGIN_WRITE,
WRITE_C8_D8, 0x29, 0x00,
END_WRITE,
DELAY, 100,
BEGIN_WRITE,
WRITE_C8_BYTES, 0x2C, 4,
0x00, 0x00, 0x00, 0x00,
END_WRITE};
static const uint8_t axs15231b_320480_type2_init_operations[] = {
BEGIN_WRITE,
WRITE_C8_D8, 0x28, 0x00,
END_WRITE,
DELAY, 20,
BEGIN_WRITE,
WRITE_C8_D8, 0x10, 0x00,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xBB, 8,
0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x5A, 0xA5,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xA0, 17,
0x00, 0x30, 0x00, 0x02, 0x00,
0x00, 0x05, 0x3F, 0x30, 0x05,
0x3F, 0x3F, 0x00, 0x00, 0x00,
0x00, 0x00,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xA2, 31,
0x30, 0x04, 0x14, 0x50, 0x80,
0x30, 0x85, 0x80, 0xB4, 0x28,
0xFF, 0xFF, 0xFF, 0x20, 0x50,
0x10, 0x02, 0x06, 0x20, 0xD0,
0xC0, 0x01, 0x12, 0xA0, 0x91,
0xC0, 0x20, 0x7F, 0xFF, 0x00,
0x06,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xD0, 30,
0x80, 0xb4, 0x21, 0x24, 0x08,
0x05, 0x10, 0x01, 0xf2, 0x02,
0xc2, 0x02, 0x22, 0x22, 0xaa,
0x03, 0x10, 0x12, 0xc0, 0x10,
0x10, 0x40, 0x04, 0x00, 0x30,
0x10, 0x00, 0x03, 0x0d, 0x12,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xA3, 22,
0xA0, 0x06, 0xAA, 0x00, 0x08,
0x02, 0x0A, 0x04, 0x04, 0x04,
0x04, 0x04, 0x04, 0x04, 0x04,
0x04, 0x04, 0x04, 0x04, 0x00,
0x55, 0x55,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xC1, 30,
0x33, 0x04, 0x02, 0x02, 0x71,
0x05, 0x24, 0x55, 0x02, 0x00,
0x01, 0x01, 0x53, 0xff, 0xff,
0xff, 0x4f, 0x52, 0x00, 0x4f,
0x52, 0x00, 0x45, 0x3b, 0x0b,
0x04, 0x0d, 0x00, 0xff, 0x42,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xC4, 29,
0x00, 0x24, 0x33, 0x80, 0x66,
0xea, 0x64, 0x32, 0xC8, 0x64,
0xC8, 0x32, 0x90, 0x90, 0x11,
0x06, 0xDC, 0xFA, 0x00, 0x00,
0x80, 0xFE, 0x10, 0x10, 0x00,
0x0A, 0x0A, 0x44, 0x50,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xC5, 23,
0x18, 0x00, 0x00, 0x03, 0xFE,
0xe8, 0x3b, 0x20, 0x30, 0x10,
0x88, 0xde, 0x0d, 0x08, 0x0f,
0x0f, 0x01, 0xe8, 0x3b, 0x20,
0x10, 0x10, 0x00,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xC6, 20,
0x05, 0x0A, 0x05, 0x0A, 0x00,
0xE0, 0x2E, 0x0B, 0x12, 0x22,
0x12, 0x22, 0x01, 0x03, 0x00,
0x02, 0x6A, 0x18, 0xC8, 0x22,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xC7, 20,
0x50, 0x36, 0x28, 0x00, 0xa2,
0x80, 0x8f, 0x00, 0x80, 0xff,
0x07, 0x11, 0x9c, 0x6f, 0xff,
0x24, 0x0c, 0x0d, 0x0e, 0x0f,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xC9, 4,
0x33, 0x44, 0x44, 0x01,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xCF, 27,
0x2c, 0x1e, 0x88, 0x58, 0x13,
0x18, 0x56, 0x18, 0x1e, 0x68,
0xf7, 0x00, 0x66, 0x0d, 0x22,
0xc4, 0x0c, 0x77, 0x22, 0x44,
0xaa, 0x55, 0x04, 0x04, 0x12,
0xa0, 0x08,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xD5, 30,
0x30, 0x30, 0x8a, 0x00, 0x44,
0x04, 0x4a, 0xe5, 0x02, 0x4a,
0xe5, 0x02, 0x04, 0xd9, 0x02,
0x47, 0x03, 0x03, 0x03, 0x03,
0x83, 0x00, 0x00, 0x00, 0x80,
0x52, 0x53, 0x50, 0x50, 0x00,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xD6, 30,
0x10, 0x32, 0x54, 0x76, 0x98,
0xba, 0xdc, 0xfe, 0x34, 0x02,
0x01, 0x83, 0xff, 0x00, 0x20,
0x50, 0x00, 0x30, 0x03, 0x03,
0x50, 0x13, 0x00, 0x00, 0x00,
0x04, 0x50, 0x20, 0x01, 0x00,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xD7, 19,
0x03, 0x01, 0x09, 0x0b, 0x0d,
0x0f, 0x1e, 0x1f, 0x18, 0x1d,
0x1f, 0x19, 0x30, 0x30, 0x04,
0x00, 0x20, 0x20, 0x1f,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xD8, 12,
0x02, 0x00, 0x08, 0x0a, 0x0c,
0x0e, 0x1e, 0x1f, 0x18, 0x1d,
0x1f, 0x19,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xDF, 8,
0x44, 0x33, 0x4b, 0x69, 0x00,
0x0a, 0x02, 0x90,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xE0, 17,
0x1f, 0x20, 0x10, 0x17, 0x0d,
0x09, 0x12, 0x2a, 0x44, 0x25,
0x0c, 0x15, 0x13, 0x31, 0x36,
0x2f, 0x02,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xE1, 17,
0x3f, 0x20, 0x10, 0x16, 0x0c,
0x08, 0x12, 0x29, 0x43, 0x25,
0x0c, 0x15, 0x13, 0x32, 0x36,
0x2f, 0x27,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xE2, 17,
0x3B, 0x07, 0x12, 0x18, 0x0E,
0x0D, 0x17, 0x35, 0x44, 0x32,
0x0C, 0x14, 0x14, 0x36, 0x3A,
0x2F, 0x0D,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xE3, 17,
0x37, 0x07, 0x12, 0x18, 0x0E,
0x0D, 0x17, 0x35, 0x44, 0x32,
0x0C, 0x14, 0x14, 0x36, 0x32,
0x2F, 0x0F,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xE4, 17,
0x3B, 0x07, 0x12, 0x18, 0x0E,
0x0D, 0x17, 0x39, 0x44, 0x2E,
0x0C, 0x14, 0x14, 0x36, 0x3A,
0x2F, 0x0D,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xE5, 17,
0x37, 0x07, 0x12, 0x18, 0x0E,
0x0D, 0x17, 0x39, 0x44, 0x2E,
0x0C, 0x14, 0x14, 0x36, 0x3A,
0x2F, 0x0F,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xA4, 16,
0x85, 0x85, 0x95, 0x82, 0xAF,
0xAA, 0xAA, 0x80, 0x10, 0x30,
0x40, 0x40, 0x20, 0xFF, 0x60,
0x30,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xBB, 8,
0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
END_WRITE,
BEGIN_WRITE,
WRITE_COMMAND_8, 0x01,
END_WRITE,
BEGIN_WRITE,
WRITE_C8_D8, 0x28, 0x00,
END_WRITE,
DELAY, 20,
BEGIN_WRITE,
WRITE_C8_D8, 0x10, 0x00,
END_WRITE,
DELAY, 200,
BEGIN_WRITE,
WRITE_C8_D8, 0x11, 0x00,
END_WRITE,
DELAY, 200,
BEGIN_WRITE,
WRITE_C8_D8, 0x29, 0x00,
END_WRITE,
DELAY, 100,
BEGIN_WRITE,
WRITE_C8_BYTES, 0x2C, 4,
0x00, 0x00, 0x00, 0x00,
END_WRITE};
class Arduino_AXS15231B : public Arduino_TFT
{
public:
Arduino_AXS15231B(
Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0,
bool ips = false, int16_t w = AXS15231B_TFTWIDTH, int16_t h = AXS15231B_TFTHEIGHT,
uint8_t col_offset1 = 0, uint8_t row_offset1 = 0, uint8_t col_offset2 = 0, uint8_t row_offset2 = 0,
const uint8_t *init_operations = axs15231b_180640_init_operations, size_t init_operations_len = sizeof(axs15231b_180640_init_operations));
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void setRotation(uint8_t r) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
protected:
void tftInit() override;
private:
const uint8_t *_init_operations;
size_t _init_operations_len;
};

View File

@@ -0,0 +1,149 @@
#include "Arduino_CO5300.h"
Arduino_CO5300::Arduino_CO5300(
Arduino_DataBus *bus, int8_t rst, uint8_t r, int16_t w, int16_t h,
uint8_t col_offset1, uint8_t row_offset1, uint8_t col_offset2, uint8_t row_offset2)
: Arduino_OLED(
bus, rst, r, w, h,
col_offset1, row_offset1, col_offset2, row_offset2)
{
}
bool Arduino_CO5300::begin(int32_t speed)
{
return Arduino_TFT::begin(speed);
}
void Arduino_CO5300::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
if ((x != _currentX) || (w != _currentW) || (y != _currentY) || (h != _currentH))
{
_currentX = x;
_currentY = y;
_currentW = w;
_currentH = h;
x += _xStart;
_bus->writeC8D16D16(CO5300_W_CASET, x, x + w - 1);
y += _yStart;
_bus->writeC8D16D16(CO5300_W_PASET, y, y + h - 1);
}
_bus->writeCommand(CO5300_W_RAMWR); // write to RAM
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_CO5300::setRotation(uint8_t r)
{
// CO5300 does not support rotation
Arduino_TFT::setRotation(r);
switch (_rotation)
{
case 1:
r = CO5300_MADCTL_COLOR_ORDER | CO5300_MADCTL_X_AXIS_FLIP;
break;
case 2:
r = CO5300_MADCTL_COLOR_ORDER | CO5300_MADCTL_X_AXIS_FLIP | CO5300_MADCTL_Y_AXIS_FLIP; // flip horizontal and flip vertical
break;
case 3:
r = CO5300_MADCTL_COLOR_ORDER | CO5300_MADCTL_Y_AXIS_FLIP;
break;
default: // case 0:
r = CO5300_MADCTL_COLOR_ORDER;
break;
}
_bus->beginWrite();
_bus->writeC8D8(CO5300_W_MADCTL, r);
_bus->endWrite();
}
void Arduino_CO5300::invertDisplay(bool i)
{
_bus->sendCommand((_ips ^ i) ? CO5300_C_INVON : CO5300_C_INVOFF);
}
void Arduino_CO5300::displayOn(void)
{
_bus->sendCommand(CO5300_C_DISPON);
delay(CO5300_SLPIN_DELAY);
_bus->sendCommand(CO5300_C_SLPOUT);
// _bus->writeC8D8(CO5300_W_DEEPSTMODE, 0x00);
delay(CO5300_SLPOUT_DELAY);
}
void Arduino_CO5300::displayOff(void)
{
_bus->sendCommand(CO5300_C_DISPOFF);
delay(CO5300_SLPIN_DELAY);
_bus->sendCommand(CO5300_C_SLPIN);
// _bus->writeC8D8(CO5300_W_DEEPSTMODE, 0x01);
delay(CO5300_SLPIN_DELAY);
}
void Arduino_CO5300::setBrightness(uint8_t brightness)
{
_bus->beginWrite();
_bus->writeC8D8(CO5300_W_WDBRIGHTNESSVALNOR, brightness);
_bus->endWrite();
}
void Arduino_CO5300::setContrast(uint8_t Contrast)
{
switch (Contrast)
{
case CO5300_ContrastOff:
_bus->beginWrite();
_bus->writeC8D8(CO5300_W_WCE, 0x00);
_bus->endWrite();
break;
case CO5300_LowContrast:
_bus->beginWrite();
_bus->writeC8D8(CO5300_W_WCE, 0x05);
_bus->endWrite();
break;
case CO5300_MediumContrast:
_bus->beginWrite();
_bus->writeC8D8(CO5300_W_WCE, 0x06);
_bus->endWrite();
break;
case CO5300_HighContrast:
_bus->beginWrite();
_bus->writeC8D8(CO5300_W_WCE, 0x07);
_bus->endWrite();
break;
default:
break;
}
}
// Companion code to the above tables. Reads and issues
// a series of LCD commands stored in PROGMEM byte array.
void Arduino_CO5300::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(10);
digitalWrite(_rst, LOW);
delay(CO5300_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(CO5300_RST_DELAY);
}
else
{
// Software Rest
_bus->sendCommand(CO5300_C_SWRESET);
delay(CO5300_RST_DELAY);
}
_bus->batchOperation(co5300_init_operations, sizeof(co5300_init_operations));
invertDisplay(false);
}

View File

@@ -0,0 +1,174 @@
#pragma once
#include "../Arduino_GFX.h"
#include "../Arduino_TFT.h"
#include "../Arduino_OLED.h"
#define CO5300_TFTWIDTH 480 ///< CO5300 max TFT width
#define CO5300_TFTHEIGHT 480 ///< CO5300 max TFT height
#define CO5300_RST_DELAY 200 ///< delay ms wait for reset finish
#define CO5300_SLPIN_DELAY 120 ///< delay ms wait for sleep in finish
#define CO5300_SLPOUT_DELAY 120 ///< delay ms wait for sleep out finish
// User Command
#define CO5300_C_NOP 0x00 // nop
#define CO5300_C_SWRESET 0x01 // Software Reset
#define CO5300_R_RDID 0x04 // Read Display Identification Information ID/1/2/3
#define CO5300_R_RDNERRORSDSI 0x05 // Read Number of Errors on DSI
#define CO5300_R_RDPOWERMODE 0x0A // Read Display Power Mode
#define CO5300_R_RDMADCTL 0x0B // Read Display MADCTL
#define CO5300_R_RDPIXFMT 0x0C // Read Display Pixel Format
#define CO5300_R_RDIMGFMT 0x0D // Read Display Image Mode
#define CO5300_R_RDSIGMODE 0x0E // Read Display Signal Mode
#define CO5300_R_RDSELFDIAG 0x0F // Read Display Self-Diagnostic Result
#define CO5300_C_SLPIN 0x10 // Sleep In
#define CO5300_C_SLPOUT 0x11 // Sleep Out
#define CO5300_C_PTLON 0x12 // Partial Display On
#define CO5300_C_NORON 0x13 // Normal Display mode on
#define CO5300_C_INVOFF 0x20 // Inversion Off
#define CO5300_C_INVON 0x21 // Inversion On
#define CO5300_C_ALLPOFF 0x22 // All pixels off
#define CO5300_C_ALLPON 0x23 // All pixels on
#define CO5300_C_DISPOFF 0x28 // Display off
#define CO5300_C_DISPON 0x29 // Display on
#define CO5300_W_CASET 0x2A // Column Address Set
#define CO5300_W_PASET 0x2B // Page Address Set
#define CO5300_W_RAMWR 0x2C // Memory Write Start
#define CO5300_W_PTLAR 0x30 // Partial Area Row Set
#define CO5300_W_PTLAC 0x31 // Partial Area Column Set
#define CO5300_C_TEAROFF 0x34 // Tearing effect off
#define CO5300_WC_TEARON 0x35 // Tearing effect on
#define CO5300_W_MADCTL 0x36 // Memory data access control
#define CO5300_C_IDLEOFF 0x38 // Idle Mode Off
#define CO5300_C_IDLEON 0x39 // Idle Mode On
#define CO5300_W_PIXFMT 0x3A // Write Display Pixel Format
#define CO5300_W_WRMC 0x3C // Memory Write Continue
#define CO5300_W_SETTSL 0x44 // Write Tearing Effect Scan Line
#define CO5300_R_GETSL 0x45 // Read Scan Line Number
#define CO5300_C_SPIROFF 0x46 // SPI read Off
#define CO5300_C_SPIRON 0x47 // SPI read On
#define CO5300_C_AODMOFF 0x48 // AOD Mode Off
#define CO5300_C_AODMON 0x49 // AOD Mode On
#define CO5300_W_WDBRIGHTNESSVALAOD 0x4A // Write Display Brightness Value in AOD Mode
#define CO5300_R_RDBRIGHTNESSVALAOD 0x4B // Read Display Brightness Value in AOD Mode
#define CO5300_W_DEEPSTMODE 0x4F // Deep Standby Mode On
#define CO5300_W_WDBRIGHTNESSVALNOR 0x51 // Write Display Brightness Value in Normal Mode
#define CO5300_R_RDBRIGHTNESSVALNOR 0x52 // Read display brightness value in Normal Mode
#define CO5300_W_WCTRLD1 0x53 // Write CTRL Display1
#define CO5300_R_RCTRLD1 0x54 // Read CTRL Display1
#define CO5300_W_WCTRLD2 0x55 // Write CTRL Display2
#define CO5300_R_RCTRLD2 0x56 // Read CTRL Display2
#define CO5300_W_WCE 0x58 // Write CE
#define CO5300_R_RCE 0x59 // Read CE
#define CO5300_W_WDBRIGHTNESSVALHBM 0x63 // Write Display Brightness Value in HBM Mode
#define CO5300_R_WDBRIGHTNESSVALHBM 0x64 // Read Display Brightness Value in HBM Mode
#define CO5300_W_WHBMCTL 0x66 // Write HBM Control
#define CO5300_W_COLORSET0 0x70 // Color Set 0
#define CO5300_W_COLORSET1 0x71 // Color Set 1
#define CO5300_W_COLORSET2 0x72 // Color Set 2
#define CO5300_W_COLORSET3 0x73 // Color Set 3
#define CO5300_W_COLORSET4 0x74 // Color Set 4
#define CO5300_W_COLORSET5 0x75 // Color Set 5
#define CO5300_W_COLORSET6 0x76 // Color Set 6
#define CO5300_W_COLORSET7 0x77 // Color Set 7
#define CO5300_W_COLORSET8 0x78 // Color Set 8
#define CO5300_W_COLORSET9 0x79 // Color Set 9
#define CO5300_W_COLORSET10 0x7A // Color Set 10
#define CO5300_W_COLORSET11 0x7B // Color Set 11
#define CO5300_W_COLORSET12 0x7C // Color Set 12
#define CO5300_W_COLORSET13 0x7D // Color Set 13
#define CO5300_W_COLORSET14 0x7E // Color Set 14
#define CO5300_W_COLORSET15 0x7F // Color Set 15
#define CO5300_W_COLOROPTION 0x80 // Color Option
#define CO5300_R_RDDBSTART 0xA1 // Read DDB start
#define CO5300_R_DDBCONTINUE 0xA8 // Read DDB Continue
#define CO5300_R_RFIRCHECKSUN 0xAA // Read First Checksum
#define CO5300_R_RCONTINUECHECKSUN 0xAF // Read Continue Checksum
#define CO5300_W_SPIMODECTL 0xC4 // SPI mode control
#define CO5300_R_RDID1 0xDA // Read ID1
#define CO5300_R_RDID2 0xDB // Read ID2
#define CO5300_R_RDID3 0xDC // Read ID3
// Flip
#define CO5300_MADCTL_X_AXIS_FLIP 0x02 // Flip Horizontal
#define CO5300_MADCTL_Y_AXIS_FLIP 0x05 // Flip Vertical
// Color Order
#define CO5300_MADCTL_RGB 0x00 // Red-Green-Blue pixel order
#define CO5300_MADCTL_BGR 0x08 // Blue-Green-Red pixel order
#define CO5300_MADCTL_COLOR_ORDER CO5300_MADCTL_RGB // RGB
enum
{
CO5300_ContrastOff = 0,
CO5300_LowContrast,
CO5300_MediumContrast,
CO5300_HighContrast
};
static const uint8_t co5300_init_operations[] = {
BEGIN_WRITE,
WRITE_COMMAND_8, CO5300_C_SLPOUT, // Sleep Out
END_WRITE,
DELAY, CO5300_SLPOUT_DELAY,
BEGIN_WRITE,
// WRITE_C8_D8, CO5300_WC_TEARON, 0x00,
WRITE_C8_D8, 0xFE, 0x00,
WRITE_C8_D8, CO5300_W_SPIMODECTL, 0x80,
// WRITE_C8_D8, CO5300_W_MADCTL, CO5300_MADCTL_COLOR_ORDER, // RGB/BGR
WRITE_C8_D8, CO5300_W_PIXFMT, 0x55, // Interface Pixel Format 16bit/pixel
// WRITE_C8_D8, CO5300_W_PIXFMT, 0x66, // Interface Pixel Format 18bit/pixel
// WRITE_C8_D8, CO5300_W_PIXFMT, 0x77, // Interface Pixel Format 24bit/pixel
WRITE_C8_D8, CO5300_W_WCTRLD1, 0x20,
WRITE_C8_D8, CO5300_W_WDBRIGHTNESSVALHBM, 0xFF,
WRITE_COMMAND_8, CO5300_C_DISPON, // Display ON
WRITE_C8_D8, CO5300_W_WDBRIGHTNESSVALNOR, 0xD0, // Brightness adjustment
// High contrast mode (Sunlight Readability Enhancement)
WRITE_C8_D8, CO5300_W_WCE, 0x00, // Off
// WRITE_C8_D8, CO5300_W_WCE, 0x05, // On Low
// WRITE_C8_D8, CO5300_W_WCE, 0x06, // On Medium
// WRITE_C8_D8, CO5300_W_WCE, 0x07, // On High
END_WRITE,
DELAY, 10};
class Arduino_CO5300 : public Arduino_OLED
{
public:
Arduino_CO5300(
Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0,
int16_t w = CO5300_TFTWIDTH, int16_t h = CO5300_TFTHEIGHT,
uint8_t col_offset1 = 0, uint8_t row_offset1 = 0, uint8_t col_offset2 = 0, uint8_t row_offset2 = 0);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void setRotation(uint8_t r) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
void setBrightness(uint8_t brightness) override;
void setContrast(uint8_t contrast) override;
protected:
void tftInit() override;
private:
};

View File

@@ -0,0 +1,554 @@
#include "../Arduino_DataBus.h"
#if defined(ESP32) && (CONFIG_IDF_TARGET_ESP32P4)
#include "../Arduino_GFX.h"
#include "Arduino_DSI_Display.h"
#define TAG "Arduino_ESP32DSIPanel"
Arduino_DSI_Display::Arduino_DSI_Display(
int16_t w, int16_t h, Arduino_ESP32DSIPanel *dsipanel, uint8_t r, bool auto_flush,
int8_t rst, const lcd_init_cmd_t *init_operations, size_t init_operations_len,
uint8_t col_offset1, uint8_t row_offset1, uint8_t col_offset2, uint8_t row_offset2)
: Arduino_GFX(w, h), _dsipanel(dsipanel), _auto_flush(auto_flush),
_rst(rst), _init_operations(init_operations), _init_operations_len(init_operations_len),
COL_OFFSET1(col_offset1), ROW_OFFSET1(row_offset1),
COL_OFFSET2(col_offset2), ROW_OFFSET2(row_offset2)
{
_fb_width = COL_OFFSET1 + WIDTH + COL_OFFSET2;
_fb_height = ROW_OFFSET1 + HEIGHT + ROW_OFFSET2;
_fb_max_x = _fb_width - 1;
_fb_max_y = _fb_height - 1;
_framebuffer_size = _fb_width * _fb_height * 2;
MAX_X = WIDTH - 1;
MAX_Y = HEIGHT - 1;
setRotation(r);
}
bool Arduino_DSI_Display::begin(int32_t speed)
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(5);
digitalWrite(_rst, LOW);
delay(10);
digitalWrite(_rst, HIGH);
delay(120);
}
_dsipanel->begin(_fb_width, _fb_height, speed, _init_operations, _init_operations_len);
_framebuffer = _dsipanel->getFrameBuffer();
if (!_framebuffer)
{
return false;
}
return true;
}
void Arduino_DSI_Display::writePixelPreclipped(int16_t x, int16_t y, uint16_t color)
{
x += COL_OFFSET1;
y += ROW_OFFSET1;
uint16_t *fb = _framebuffer;
switch (_rotation)
{
case 1:
fb += (int32_t)x * _fb_width;
fb += _fb_max_x - y;
*fb = color;
if (_auto_flush)
{
esp_cache_msync(fb, 2, ESP_CACHE_MSYNC_FLAG_DIR_C2M | ESP_CACHE_MSYNC_FLAG_UNALIGNED);
}
break;
case 2:
fb += (int32_t)(_fb_max_y - y) * _fb_width;
fb += _fb_max_x - x;
*fb = color;
if (_auto_flush)
{
esp_cache_msync(fb, 2, ESP_CACHE_MSYNC_FLAG_DIR_C2M | ESP_CACHE_MSYNC_FLAG_UNALIGNED);
}
break;
case 3:
fb += (int32_t)(_fb_max_y - x) * _fb_width;
fb += y;
*fb = color;
if (_auto_flush)
{
esp_cache_msync(fb, 2, ESP_CACHE_MSYNC_FLAG_DIR_C2M | ESP_CACHE_MSYNC_FLAG_UNALIGNED);
}
break;
default: // case 0:
fb += (int32_t)y * _fb_width;
fb += x;
*fb = color;
if (_auto_flush)
{
esp_cache_msync(fb, 2, ESP_CACHE_MSYNC_FLAG_DIR_C2M | ESP_CACHE_MSYNC_FLAG_UNALIGNED);
}
}
}
void Arduino_DSI_Display::writeFastVLine(int16_t x, int16_t y,
int16_t h, uint16_t color)
{
// log_i("writeFastVLine(x: %d, y: %d, h: %d)", x, y, h);
switch (_rotation)
{
case 1:
writeFastHLineCore(_height - y - h, x, h, color);
break;
case 2:
writeFastVLineCore(_max_x - x, _height - y - h, h, color);
break;
case 3:
writeFastHLineCore(y, _max_x - x, h, color);
break;
default: // case 0:
writeFastVLineCore(x, y, h, color);
}
}
void Arduino_DSI_Display::writeFastVLineCore(int16_t x, int16_t y,
int16_t h, uint16_t color)
{
// log_i("writeFastVLineCore(x: %d, y: %d, h: %d)", x, y, h);
if (_ordered_in_range(x, 0, MAX_X) && h)
{ // X on screen, nonzero height
if (h < 0)
{ // If negative height...
y += h + 1; // Move Y to top edge
h = -h; // Use positive height
}
if (y <= MAX_Y)
{ // Not off bottom
int16_t y2 = y + h - 1;
if (y2 >= 0)
{ // Not off top
// Line partly or fully overlaps screen
if (y < 0)
{
y = 0;
h = y2 + 1;
} // Clip top
if (y2 > MAX_Y)
{
h = MAX_Y - y + 1;
} // Clip bottom
x += COL_OFFSET1;
y += ROW_OFFSET1;
uint16_t *fb = _framebuffer + ((int32_t)y * _fb_width) + x;
if (_auto_flush)
{
while (h--)
{
*fb = color;
esp_cache_msync(fb, 2, ESP_CACHE_MSYNC_FLAG_DIR_C2M | ESP_CACHE_MSYNC_FLAG_UNALIGNED);
fb += _fb_width;
}
}
else
{
while (h--)
{
*fb = color;
fb += _fb_width;
}
}
}
}
}
}
void Arduino_DSI_Display::writeFastHLine(int16_t x, int16_t y,
int16_t w, uint16_t color)
{
// log_i("writeFastHLine(x: %d, y: %d, w: %d)", x, y, w);
switch (_rotation)
{
case 1:
writeFastVLineCore(_max_y - y, x, w, color);
break;
case 2:
writeFastHLineCore(_width - x - w, _max_y - y, w, color);
break;
case 3:
writeFastVLineCore(y, _width - x - w, w, color);
break;
default: // case 0:
writeFastHLineCore(x, y, w, color);
}
}
void Arduino_DSI_Display::writeFastHLineCore(int16_t x, int16_t y,
int16_t w, uint16_t color)
{
// log_i("writeFastHLineCore(x: %d, y: %d, w: %d)", x, y, w);
if (_ordered_in_range(y, 0, MAX_Y) && w)
{ // Y on screen, nonzero width
if (w < 0)
{ // If negative width...
x += w + 1; // Move X to left edge
w = -w; // Use positive width
}
if (x <= MAX_X)
{ // Not off right
int16_t x2 = x + w - 1;
if (x2 >= 0)
{ // Not off left
// Line partly or fully overlaps screen
if (x < 0)
{
x = 0;
w = x2 + 1;
} // Clip left
if (x2 > MAX_X)
{
w = MAX_X - x + 1;
} // Clip right
x += COL_OFFSET1;
y += ROW_OFFSET1;
uint16_t *fb = _framebuffer + ((int32_t)y * _fb_width) + x;
uint16_t *cachePos = fb;
int16_t writeSize = w * 2;
while (w--)
{
*(fb++) = color;
}
if (_auto_flush)
{
esp_cache_msync(cachePos, writeSize, ESP_CACHE_MSYNC_FLAG_DIR_C2M | ESP_CACHE_MSYNC_FLAG_UNALIGNED);
}
}
}
}
}
void Arduino_DSI_Display::writeFillRectPreclipped(int16_t x, int16_t y,
int16_t w, int16_t h, uint16_t color)
{
// log_i("writeFillRectPreclipped(x: %d, y: %d, w: %d, h: %d)", x, y, w, h);
if (_rotation > 0)
{
int16_t t = x;
switch (_rotation)
{
case 1:
x = WIDTH - y - h;
y = t;
t = w;
w = h;
h = t;
break;
case 2:
x = WIDTH - x - w;
y = HEIGHT - y - h;
break;
case 3:
x = y;
y = HEIGHT - t - w;
t = w;
w = h;
h = t;
break;
}
}
// log_i("adjusted writeFillRectPreclipped(x: %d, y: %d, w: %d, h: %d)", x, y, w, h);
x += COL_OFFSET1;
y += ROW_OFFSET1;
uint16_t *row = _framebuffer;
row += y * _fb_width;
uint16_t *cachePos = row;
row += x;
for (int j = 0; j < h; j++)
{
for (int i = 0; i < w; i++)
{
row[i] = color;
}
row += _fb_width;
}
if (_auto_flush)
{
esp_cache_msync(cachePos, _fb_width * h * 2, ESP_CACHE_MSYNC_FLAG_DIR_C2M | ESP_CACHE_MSYNC_FLAG_UNALIGNED);
}
}
void Arduino_DSI_Display::drawIndexedBitmap(int16_t x, int16_t y, uint8_t *bitmap, uint16_t *color_index, int16_t w, int16_t h, int16_t x_skip)
{
if (
((x + w - 1) < 0) || // Outside left
((y + h - 1) < 0) || // Outside top
(x > _max_x) || // Outside right
(y > _max_y) // Outside bottom
)
{
return;
}
else
{
if (_rotation > 0)
{
Arduino_GFX::drawIndexedBitmap(x, y, bitmap, color_index, w, h, x_skip);
}
else
{
if ((y + h - 1) > _max_y)
{
h -= (y + h - 1) - _max_y;
}
if (y < 0)
{
bitmap -= y * (w + x_skip);
h += y;
y = 0;
}
if ((x + w - 1) > _max_x)
{
x_skip += (x + w - 1) - _max_x;
w -= (x + w - 1) - _max_x;
}
if (x < 0)
{
bitmap -= x;
x_skip -= x;
w += x;
x = 0;
}
x += COL_OFFSET1;
y += ROW_OFFSET1;
uint16_t *row = _framebuffer;
row += y * _fb_width;
uint16_t *cachePos = row;
row += x;
for (int j = 0; j < h; j++)
{
for (int i = 0; i < w; i++)
{
row[i] = color_index[*bitmap++];
}
bitmap += x_skip;
row += _fb_width;
}
if (_auto_flush)
{
esp_cache_msync(cachePos, _fb_width * h * 2, ESP_CACHE_MSYNC_FLAG_DIR_C2M | ESP_CACHE_MSYNC_FLAG_UNALIGNED);
}
}
}
}
void Arduino_DSI_Display::draw16bitRGBBitmap(int16_t x, int16_t y,
uint16_t *bitmap, int16_t w, int16_t h)
{
if (_isRoundMode)
{
if (
((y + h - 1) < 0) || // Outside top
(y > _max_y) || // Outside bottom
(
(x > _roundMaxX[y + h - 1]) && // top left
((x + w - 1) < _roundMinX[y]) && // top right
(x > _roundMaxX[y + h - 1]) && // bottom left
((x + w - 1) < _roundMinX[y + h - 1]) // bottom right
))
{
return;
}
}
bool result;
x += COL_OFFSET1;
y += ROW_OFFSET1;
switch (_rotation)
{
case 1:
result = gfx_draw_bitmap_to_framebuffer_rotate_1(bitmap, w, h, _framebuffer, x, y, _fb_height, _fb_width);
break;
case 2:
result = gfx_draw_bitmap_to_framebuffer_rotate_2(bitmap, w, h, _framebuffer, x, y, _fb_width, _fb_height);
break;
case 3:
result = gfx_draw_bitmap_to_framebuffer_rotate_3(bitmap, w, h, _framebuffer, x, y, _fb_height, _fb_width);
break;
default: // case 0:
result = gfx_draw_bitmap_to_framebuffer(bitmap, w, h, _framebuffer, x, y, _fb_width, _fb_height);
}
if (result)
{
if (_auto_flush)
{
uint16_t *cachePos;
size_t cache_size;
switch (_rotation)
{
case 1:
cachePos = _framebuffer + (x * _fb_width);
cache_size = _fb_width * w * 2;
break;
case 2:
cachePos = _framebuffer + ((HEIGHT - y - h) * _fb_width);
cache_size = _fb_width * h * 2;
break;
case 3:
cachePos = _framebuffer + ((HEIGHT - x - w) * _fb_width);
cache_size = _fb_width * w * 2;
break;
default: // case 0:
cachePos = _framebuffer + (y * _fb_width) + x;
cache_size = (_fb_width * (h - 1) + w) * 2;
}
esp_cache_msync(cachePos, cache_size, ESP_CACHE_MSYNC_FLAG_DIR_C2M | ESP_CACHE_MSYNC_FLAG_UNALIGNED);
}
}
}
void Arduino_DSI_Display::draw16bitBeRGBBitmap(int16_t x, int16_t y,
uint16_t *bitmap, int16_t w, int16_t h)
{
if (
((x + w - 1) < 0) || // Outside left
((y + h - 1) < 0) || // Outside top
(x > _max_x) || // Outside right
(y > _max_y) // Outside bottom
)
{
return;
}
else
{
if (_rotation > 0)
{
Arduino_GFX::draw16bitBeRGBBitmap(x, y, bitmap, w, h);
}
else
{
x += COL_OFFSET1;
y += ROW_OFFSET1;
int16_t x_skip = 0;
if ((y + h - 1) > _max_y)
{
h -= (y + h - 1) - _max_y;
}
if (y < 0)
{
bitmap -= y * w;
h += y;
y = 0;
}
if ((x + w - 1) > _max_x)
{
x_skip = (x + w - 1) - _max_x;
w -= x_skip;
}
if (x < 0)
{
bitmap -= x;
x_skip -= x;
w += x;
x = 0;
}
uint16_t *row = _framebuffer;
row += y * _fb_width;
uint16_t *cachePos = row;
row += x;
uint16_t color;
for (int j = 0; j < h; j++)
{
for (int i = 0; i < w; i++)
{
color = *bitmap++;
MSB_16_SET(row[i], color);
}
bitmap += x_skip;
row += _fb_width;
}
if (_auto_flush)
{
esp_cache_msync(cachePos, _fb_width * h * 2, ESP_CACHE_MSYNC_FLAG_DIR_C2M | ESP_CACHE_MSYNC_FLAG_UNALIGNED);
}
}
}
}
void Arduino_DSI_Display::flush(bool force_flush)
{
if (force_flush || (!_auto_flush))
{
esp_cache_msync(_framebuffer, _framebuffer_size, ESP_CACHE_MSYNC_FLAG_DIR_C2M | ESP_CACHE_MSYNC_FLAG_UNALIGNED);
}
}
void Arduino_DSI_Display::drawYCbCrBitmap(int16_t x, int16_t y, uint8_t *yData, uint8_t *cbData, uint8_t *crData, int16_t w, int16_t h)
{
if (
((x + w - 1) < 0) || // Outside left
((y + h - 1) < 0) || // Outside top
(x > _max_x) || // Outside right
(y > _max_y) // Outside bottom
)
{
return;
}
else
{
int cols = w >> 1;
int rows = h >> 1;
uint16_t *dest = _framebuffer;
dest += y * _fb_width;
uint16_t *cachePos = dest;
dest += x;
uint16_t *dest2 = dest + _fb_width;
uint8_t *yData2 = yData + w;
uint8_t pxCb, pxCr;
int16_t pxR, pxG, pxB, pxY;
for (int row = 0; row < rows; ++row)
{
for (int col = 0; col < w;)
{
pxCb = *cbData++;
pxCr = *crData++;
pxR = CR2R16[pxCr];
pxG = -CB2G16[pxCb] - CR2G16[pxCr];
pxB = CB2B16[pxCb];
pxY = Y2I16[*yData++];
dest[col] = CLIPR[pxY + pxR] | CLIPG[pxY + pxG] | CLIPB[pxY + pxB];
pxY = Y2I16[*yData2++];
dest2[col++] = CLIPR[pxY + pxR] | CLIPG[pxY + pxG] | CLIPB[pxY + pxB];
pxY = Y2I16[*yData++];
dest[col] = CLIPR[pxY + pxR] | CLIPG[pxY + pxG] | CLIPB[pxY + pxB];
pxY = Y2I16[*yData2++];
dest2[col++] = CLIPR[pxY + pxR] | CLIPG[pxY + pxG] | CLIPB[pxY + pxB];
}
yData += w;
yData2 += w;
dest = dest2 + _fb_width;
dest2 = dest + _fb_width;
}
if (_auto_flush)
{
esp_cache_msync(cachePos, _fb_width * h * 2, ESP_CACHE_MSYNC_FLAG_DIR_C2M | ESP_CACHE_MSYNC_FLAG_UNALIGNED);
}
}
}
uint16_t *Arduino_DSI_Display::getFramebuffer()
{
return _framebuffer;
}
#endif // #if defined(ESP32) && (CONFIG_IDF_TARGET_ESP32P4)

View File

@@ -0,0 +1,468 @@
#pragma once
#include "../Arduino_DataBus.h"
#if defined(ESP32) && (CONFIG_IDF_TARGET_ESP32P4)
#include "../Arduino_GFX.h"
#include "../databus/Arduino_ESP32DSIPanel.h"
#include <esp_cache.h>
/* HX83xx User Define command set 用户自定义命令集 */
#define UD_SETADDRESSMODE 0x36 /* Set address mode */
#define UD_SETSEQUENCE 0xB0 /* Set sequence */
#define UD_SETPOWER 0xB1 /* Set power */
#define UD_SETDISP 0xB2 /* Set display related register */
#define UD_SETCYC 0xB4 /* Set display waveform cycles */
#define UD_SETVCOM 0xB6 /* Set VCOM voltage */
#define UD_SETTE 0xB7 /* Set internal TE function */
#define UD_SETSENSOR 0xB8 /* Set temperature sensor */
#define UD_SETEXTC 0xB9 /* Set extension command */
#define UD_SETMIPI 0xBA /* Set MIPI control */
#define UD_SETOTP 0xBB /* Set OTP */
#define UD_SETREGBANK 0xBD /* Set register bank */
#define UD_SETDGCLUT 0xC1 /* Set DGC LUT */
#define UD_SETID 0xC3 /* Set ID */
#define UD_SETDDB 0xC4 /* Set DDB */
#define UD_SETCABC 0xC9 /* Set CABC control */
#define UD_SETCABCGAIN 0xCA
#define UD_SETPANEL 0xCC
#define UD_SETOFFSET 0xD2
#define UD_SETGIP0 0xD3 /* Set GIP Option0 */
#define UD_SETGIP1 0xD5 /* Set GIP Option1 */
#define UD_SETGIP2 0xD6 /* Set GIP Option2 */
#define UD_SETGIP3 0xD8 /* Set GIP Option2 */
#define UD_SETGPO 0xD9
#define UD_SETSCALING 0xDD
#define UD_SETIDLE 0xDF
#define UD_SETGAMMA 0xE0 /* Set gamma curve related setting */
#define UD_SETCHEMODE_DYN 0xE4
#define UD_SETCHE 0xE5
#define UD_SETCESEL 0xE6 /* Enable color enhance */
#define UD_SET_SP_CMD 0xE9
#define UD_SETREADINDEX 0xFE /* Set SPI Read Index */
#define UD_GETSPIREAD 0xFF /* SPI Read Command Data */
static const lcd_init_cmd_t hx8394_init_operations[] = {
// {cmd, { data }, data_size, delay_ms}
/* 720 * 1280 */
{UD_SETADDRESSMODE, (uint8_t[]){0x01}, 1, 0},
{UD_SETEXTC, (uint8_t[]){0xFF, 0x83, 0x94}, 3, 0},
{UD_SETMIPI, (uint8_t[]){0x61, 0x03, 0x68, 0x6B, 0xB2, 0xC0}, 6, 0}, // 0x61
{UD_SETPOWER, (uint8_t[]){0x48, 0x12, 0x72, 0x09, 0x32, 0x54, 0x71, 0x71, 0x57, 0x47}, 10, 0},
{UD_SETDISP, (uint8_t[]){0x00, 0x80, 0x64, 0x0C, 0x0D, 0x2F}, 6, 0},
{UD_SETCYC, (uint8_t[]){0x73, 0x74, 0x73, 0x74, 0x73, 0x74, 0x01, 0x0C, 0x86, 0x75, 0x00, 0x3F, 0x73, 0x74, 0x73, 0x74, 0x73, 0x74, 0x01, 0x0C, 0x86}, 21, 0},
{UD_SETGIP0, (uint8_t[]){0x00, 0x00, 0x07, 0x07, 0x40, 0x07, 0x0C, 0x00, 0x08, 0x10, 0x08, 0x00, 0x08, 0x54, 0x15, 0x0A, 0x05, 0x0A, 0x02, 0x15, 0x06, 0x05, 0x06, 0x47, 0x44, 0x0A, 0x0A, 0x4B, 0x10, 0x07, 0x07, 0x0C, 0x40}, 33, 0},
{UD_SETGIP1, (uint8_t[]){0x1C, 0x1C, 0x1D, 0x1D, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x24, 0x25, 0x18, 0x18, 0x26, 0x27, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x20, 0x21, 0x18, 0x18, 0x18, 0x18}, 44, 0},
{UD_SETGIP2, (uint8_t[]){0x1C, 0x1C, 0x1D, 0x1D, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x0B, 0x0A, 0x09, 0x08, 0x21, 0x20, 0x18, 0x18, 0x27, 0x26, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x25, 0x24, 0x18, 0x18, 0x18, 0x18}, 44, 0},
{UD_SETVCOM, (uint8_t[]){0x6E, 0x6E}, 2, 0}, // caiji
{UD_SETGAMMA, (uint8_t[]){0x00, 0x0A, 0x15, 0x1B, 0x1E, 0x21, 0x24, 0x22, 0x47, 0x56, 0x65, 0x66, 0x6E, 0x82, 0x88, 0x8B, 0x9A, 0x9D, 0x98, 0xA8, 0xB9, 0x5D, 0x5C, 0x61, 0x66, 0x6A, 0x6F, 0x7F, 0x7F, 0x00, 0x0A, 0x15, 0x1B, 0x1E, 0x21, 0x24, 0x22, 0x47, 0x56, 0x65, 0x65, 0x6E, 0x81, 0x87, 0x8B, 0x98, 0x9D, 0x99, 0xA8, 0xBA, 0x5D, 0x5D, 0x62, 0x67, 0x6B, 0x72, 0x7F, 0x7F}, 58, 0},
{0xC0, (uint8_t[]){0x1F, 0x31}, 2, 0},
{UD_SETPANEL, (uint8_t[]){0x03}, 1, 0},
{0xD4, (uint8_t[]){0x02}, 1, 0},
{UD_SETREGBANK, (uint8_t[]){0x02}, 1, 0},
{UD_SETGIP3, (uint8_t[]){0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, 12, 0},
{UD_SETREGBANK, (uint8_t[]){0x00}, 1, 0},
{UD_SETREGBANK, (uint8_t[]){0x01}, 1, 0},
{UD_SETPOWER, (uint8_t[]){0x00}, 1, 0},
{UD_SETREGBANK, (uint8_t[]){0x00}, 1, 0},
{0xBF, (uint8_t[]){0x40, 0x81, 0x50, 0x00, 0x1A, 0xFC, 0x01}, 7, 0},
{0xC6, (uint8_t[]){0xED}, 1, 0},
{0x11, (uint8_t[]){0x00}, 0, 120},
{0x29, (uint8_t[]){0x00}, 0, 0},
};
static const lcd_init_cmd_t jd9165_init_operations[] = {
// {cmd, { data }, data_size, delay_ms}
//{0x11, (uint8_t []){0x00}, 1, 120},
//{0x29, (uint8_t []){0x00}, 1, 20},
{0x30, (uint8_t[]){0x00}, 1, 0},
{0xF7, (uint8_t[]){0x49, 0x61, 0x02, 0x00}, 4, 0},
{0x30, (uint8_t[]){0x01}, 1, 0},
{0x04, (uint8_t[]){0x0C}, 1, 0},
{0x05, (uint8_t[]){0x00}, 1, 0},
{0x06, (uint8_t[]){0x00}, 1, 0},
{0x0B, (uint8_t[]){0x11}, 1, 0},
{0x17, (uint8_t[]){0x00}, 1, 0},
{0x20, (uint8_t[]){0x04}, 1, 0},
{0x1F, (uint8_t[]){0x05}, 1, 0},
{0x23, (uint8_t[]){0x00}, 1, 0},
{0x25, (uint8_t[]){0x19}, 1, 0},
{0x28, (uint8_t[]){0x18}, 1, 0},
{0x29, (uint8_t[]){0x04}, 1, 0},
{0x2A, (uint8_t[]){0x01}, 1, 0},
{0x2B, (uint8_t[]){0x04}, 1, 0},
{0x2C, (uint8_t[]){0x01}, 1, 0},
{0x30, (uint8_t[]){0x02}, 1, 0},
{0x01, (uint8_t[]){0x22}, 1, 0},
{0x03, (uint8_t[]){0x12}, 1, 0},
{0x04, (uint8_t[]){0x00}, 1, 0},
{0x05, (uint8_t[]){0x64}, 1, 0},
{0x0A, (uint8_t[]){0x08}, 1, 0},
{0x0B, (uint8_t[]){0x0A, 0x1A, 0x0B, 0x0D, 0x0D, 0x11, 0x10, 0x06, 0x08, 0x1F, 0x1D}, 11, 0},
{0x0C, (uint8_t[]){0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D}, 11, 0},
{0x0D, (uint8_t[]){0x16, 0x1B, 0x0B, 0x0D, 0x0D, 0x11, 0x10, 0x07, 0x09, 0x1E, 0x1C}, 11, 0},
{0x0E, (uint8_t[]){0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D}, 11, 0},
{0x0F, (uint8_t[]){0x16, 0x1B, 0x0D, 0x0B, 0x0D, 0x11, 0x10, 0x1C, 0x1E, 0x09, 0x07}, 11, 0},
{0x10, (uint8_t[]){0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D}, 11, 0},
{0x11, (uint8_t[]){0x0A, 0x1A, 0x0D, 0x0B, 0x0D, 0x11, 0x10, 0x1D, 0x1F, 0x08, 0x06}, 11, 0},
{0x12, (uint8_t[]){0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D}, 11, 0},
{0x14, (uint8_t[]){0x00, 0x00, 0x11, 0x11}, 4, 0},
{0x18, (uint8_t[]){0x99}, 1, 0},
{0x30, (uint8_t[]){0x06}, 1, 0},
{0x12, (uint8_t[]){0x36, 0x2C, 0x2E, 0x3C, 0x38, 0x35, 0x35, 0x32, 0x2E, 0x1D, 0x2B, 0x21, 0x16, 0x29}, 14, 0},
{0x13, (uint8_t[]){0x36, 0x2C, 0x2E, 0x3C, 0x38, 0x35, 0x35, 0x32, 0x2E, 0x1D, 0x2B, 0x21, 0x16, 0x29}, 14, 0},
// {0x30, (uint8_t[]){0x08}, 1, 0},
// {0x05, (uint8_t[]){0x01}, 1, 0},
// {0x0C, (uint8_t[]){0x1A}, 1, 0},
// {0x0D, (uint8_t[]){0x0E}, 1, 0},
// {0x30, (uint8_t[]){0x07}, 1, 0},
// {0x01, (uint8_t[]){0x04}, 1, 0},
{0x30, (uint8_t[]){0x0A}, 1, 0},
{0x02, (uint8_t[]){0x4F}, 1, 0},
{0x0B, (uint8_t[]){0x40}, 1, 0},
{0x12, (uint8_t[]){0x3E}, 1, 0},
{0x13, (uint8_t[]){0x78}, 1, 0},
{0x30, (uint8_t[]){0x0D}, 1, 0},
{0x0D, (uint8_t[]){0x04}, 1, 0},
{0x10, (uint8_t[]){0x0C}, 1, 0},
{0x11, (uint8_t[]){0x0C}, 1, 0},
{0x12, (uint8_t[]){0x0C}, 1, 0},
{0x13, (uint8_t[]){0x0C}, 1, 0},
{0x30, (uint8_t[]){0x00}, 1, 0},
{0X3A, (uint8_t[]){0x55}, 1, 0},
{0x11, (uint8_t[]){0x00}, 1, 120},
{0x29, (uint8_t[]){0x00}, 1, 50},
};
static const lcd_init_cmd_t jd9365_init_operations[] = {
// {cmd, { data }, data_size, delay_ms}
{0xE0, (uint8_t[]){0x00}, 1, 0},
{0xE1, (uint8_t[]){0x93}, 1, 0},
{0xE2, (uint8_t[]){0x65}, 1, 0},
{0xE3, (uint8_t[]){0xF8}, 1, 0},
{0x80, (uint8_t[]){0x01}, 1, 0},
{0xE0, (uint8_t[]){0x01}, 1, 0},
{0x00, (uint8_t[]){0x00}, 1, 0},
{0x01, (uint8_t[]){0x39}, 1, 0},
{0x03, (uint8_t[]){0x10}, 1, 0},
{0x04, (uint8_t[]){0x41}, 1, 0},
{0x0C, (uint8_t[]){0x74}, 1, 0},
{0x17, (uint8_t[]){0x00}, 1, 0},
{0x18, (uint8_t[]){0xD7}, 1, 0},
{0x19, (uint8_t[]){0x00}, 1, 0},
{0x1A, (uint8_t[]){0x00}, 1, 0},
{0x1B, (uint8_t[]){0xD7}, 1, 0},
{0x1C, (uint8_t[]){0x00}, 1, 0},
{0x24, (uint8_t[]){0xFE}, 1, 0},
{0x35, (uint8_t[]){0x26}, 1, 0},
{0x37, (uint8_t[]){0x69}, 1, 0},
{0x38, (uint8_t[]){0x05}, 1, 0},
{0x39, (uint8_t[]){0x06}, 1, 0},
{0x3A, (uint8_t[]){0x08}, 1, 0},
{0x3C, (uint8_t[]){0x78}, 1, 0},
{0x3D, (uint8_t[]){0xFF}, 1, 0},
{0x3E, (uint8_t[]){0xFF}, 1, 0},
{0x3F, (uint8_t[]){0xFF}, 1, 0},
{0x40, (uint8_t[]){0x06}, 1, 0},
{0x41, (uint8_t[]){0xA0}, 1, 0},
{0x43, (uint8_t[]){0x14}, 1, 0},
{0x44, (uint8_t[]){0x0B}, 1, 0},
{0x45, (uint8_t[]){0x30}, 1, 0},
//{0x4A, (uint8_t[]){0x35}, 1, 0},//bist
{0x4B, (uint8_t[]){0x04}, 1, 0},
{0x55, (uint8_t[]){0x02}, 1, 0},
{0x57, (uint8_t[]){0x89}, 1, 0},
{0x59, (uint8_t[]){0x0A}, 1, 0},
{0x5A, (uint8_t[]){0x28}, 1, 0},
{0x5B, (uint8_t[]){0x15}, 1, 0},
{0x5D, (uint8_t[]){0x50}, 1, 0},
{0x5E, (uint8_t[]){0x37}, 1, 0},
{0x5F, (uint8_t[]){0x29}, 1, 0},
{0x60, (uint8_t[]){0x1E}, 1, 0},
{0x61, (uint8_t[]){0x1D}, 1, 0},
{0x62, (uint8_t[]){0x12}, 1, 0},
{0x63, (uint8_t[]){0x1A}, 1, 0},
{0x64, (uint8_t[]){0x08}, 1, 0},
{0x65, (uint8_t[]){0x25}, 1, 0},
{0x66, (uint8_t[]){0x26}, 1, 0},
{0x67, (uint8_t[]){0x28}, 1, 0},
{0x68, (uint8_t[]){0x49}, 1, 0},
{0x69, (uint8_t[]){0x3A}, 1, 0},
{0x6A, (uint8_t[]){0x43}, 1, 0},
{0x6B, (uint8_t[]){0x3A}, 1, 0},
{0x6C, (uint8_t[]){0x3B}, 1, 0},
{0x6D, (uint8_t[]){0x32}, 1, 0},
{0x6E, (uint8_t[]){0x1F}, 1, 0},
{0x6F, (uint8_t[]){0x0E}, 1, 0},
{0x70, (uint8_t[]){0x50}, 1, 0},
{0x71, (uint8_t[]){0x37}, 1, 0},
{0x72, (uint8_t[]){0x29}, 1, 0},
{0x73, (uint8_t[]){0x1E}, 1, 0},
{0x74, (uint8_t[]){0x1D}, 1, 0},
{0x75, (uint8_t[]){0x12}, 1, 0},
{0x76, (uint8_t[]){0x1A}, 1, 0},
{0x77, (uint8_t[]){0x08}, 1, 0},
{0x78, (uint8_t[]){0x25}, 1, 0},
{0x79, (uint8_t[]){0x26}, 1, 0},
{0x7A, (uint8_t[]){0x28}, 1, 0},
{0x7B, (uint8_t[]){0x49}, 1, 0},
{0x7C, (uint8_t[]){0x3A}, 1, 0},
{0x7D, (uint8_t[]){0x43}, 1, 0},
{0x7E, (uint8_t[]){0x3A}, 1, 0},
{0x7F, (uint8_t[]){0x3B}, 1, 0},
{0x80, (uint8_t[]){0x32}, 1, 0},
{0x81, (uint8_t[]){0x1F}, 1, 0},
{0x82, (uint8_t[]){0x0E}, 1, 0},
{0xE0, (uint8_t[]){0x02}, 1, 0},
{0x00, (uint8_t[]){0x1F}, 1, 0},
{0x01, (uint8_t[]){0x1F}, 1, 0},
{0x02, (uint8_t[]){0x52}, 1, 0},
{0x03, (uint8_t[]){0x51}, 1, 0},
{0x04, (uint8_t[]){0x50}, 1, 0},
{0x05, (uint8_t[]){0x4B}, 1, 0},
{0x06, (uint8_t[]){0x4A}, 1, 0},
{0x07, (uint8_t[]){0x49}, 1, 0},
{0x08, (uint8_t[]){0x48}, 1, 0},
{0x09, (uint8_t[]){0x47}, 1, 0},
{0x0A, (uint8_t[]){0x46}, 1, 0},
{0x0B, (uint8_t[]){0x45}, 1, 0},
{0x0C, (uint8_t[]){0x44}, 1, 0},
{0x0D, (uint8_t[]){0x40}, 1, 0},
{0x0E, (uint8_t[]){0x41}, 1, 0},
{0x0F, (uint8_t[]){0x1F}, 1, 0},
{0x10, (uint8_t[]){0x1F}, 1, 0},
{0x11, (uint8_t[]){0x1F}, 1, 0},
{0x12, (uint8_t[]){0x1F}, 1, 0},
{0x13, (uint8_t[]){0x1F}, 1, 0},
{0x14, (uint8_t[]){0x1F}, 1, 0},
{0x15, (uint8_t[]){0x1F}, 1, 0},
{0x16, (uint8_t[]){0x1F}, 1, 0},
{0x17, (uint8_t[]){0x1F}, 1, 0},
{0x18, (uint8_t[]){0x52}, 1, 0},
{0x19, (uint8_t[]){0x51}, 1, 0},
{0x1A, (uint8_t[]){0x50}, 1, 0},
{0x1B, (uint8_t[]){0x4B}, 1, 0},
{0x1C, (uint8_t[]){0x4A}, 1, 0},
{0x1D, (uint8_t[]){0x49}, 1, 0},
{0x1E, (uint8_t[]){0x48}, 1, 0},
{0x1F, (uint8_t[]){0x47}, 1, 0},
{0x20, (uint8_t[]){0x46}, 1, 0},
{0x21, (uint8_t[]){0x45}, 1, 0},
{0x22, (uint8_t[]){0x44}, 1, 0},
{0x23, (uint8_t[]){0x40}, 1, 0},
{0x24, (uint8_t[]){0x41}, 1, 0},
{0x25, (uint8_t[]){0x1F}, 1, 0},
{0x26, (uint8_t[]){0x1F}, 1, 0},
{0x27, (uint8_t[]){0x1F}, 1, 0},
{0x28, (uint8_t[]){0x1F}, 1, 0},
{0x29, (uint8_t[]){0x1F}, 1, 0},
{0x2A, (uint8_t[]){0x1F}, 1, 0},
{0x2B, (uint8_t[]){0x1F}, 1, 0},
{0x2C, (uint8_t[]){0x1F}, 1, 0},
{0x2D, (uint8_t[]){0x1F}, 1, 0},
{0x2E, (uint8_t[]){0x52}, 1, 0},
{0x2F, (uint8_t[]){0x40}, 1, 0},
{0x30, (uint8_t[]){0x41}, 1, 0},
{0x31, (uint8_t[]){0x48}, 1, 0},
{0x32, (uint8_t[]){0x49}, 1, 0},
{0x33, (uint8_t[]){0x4A}, 1, 0},
{0x34, (uint8_t[]){0x4B}, 1, 0},
{0x35, (uint8_t[]){0x44}, 1, 0},
{0x36, (uint8_t[]){0x45}, 1, 0},
{0x37, (uint8_t[]){0x46}, 1, 0},
{0x38, (uint8_t[]){0x47}, 1, 0},
{0x39, (uint8_t[]){0x51}, 1, 0},
{0x3A, (uint8_t[]){0x50}, 1, 0},
{0x3B, (uint8_t[]){0x1F}, 1, 0},
{0x3C, (uint8_t[]){0x1F}, 1, 0},
{0x3D, (uint8_t[]){0x1F}, 1, 0},
{0x3E, (uint8_t[]){0x1F}, 1, 0},
{0x3F, (uint8_t[]){0x1F}, 1, 0},
{0x40, (uint8_t[]){0x1F}, 1, 0},
{0x41, (uint8_t[]){0x1F}, 1, 0},
{0x42, (uint8_t[]){0x1F}, 1, 0},
{0x43, (uint8_t[]){0x1F}, 1, 0},
{0x44, (uint8_t[]){0x52}, 1, 0},
{0x45, (uint8_t[]){0x40}, 1, 0},
{0x46, (uint8_t[]){0x41}, 1, 0},
{0x47, (uint8_t[]){0x48}, 1, 0},
{0x48, (uint8_t[]){0x49}, 1, 0},
{0x49, (uint8_t[]){0x4A}, 1, 0},
{0x4A, (uint8_t[]){0x4B}, 1, 0},
{0x4B, (uint8_t[]){0x44}, 1, 0},
{0x4C, (uint8_t[]){0x45}, 1, 0},
{0x4D, (uint8_t[]){0x46}, 1, 0},
{0x4E, (uint8_t[]){0x47}, 1, 0},
{0x4F, (uint8_t[]){0x51}, 1, 0},
{0x50, (uint8_t[]){0x50}, 1, 0},
{0x51, (uint8_t[]){0x1F}, 1, 0},
{0x52, (uint8_t[]){0x1F}, 1, 0},
{0x53, (uint8_t[]){0x1F}, 1, 0},
{0x54, (uint8_t[]){0x1F}, 1, 0},
{0x55, (uint8_t[]){0x1F}, 1, 0},
{0x56, (uint8_t[]){0x1F}, 1, 0},
{0x57, (uint8_t[]){0x1F}, 1, 0},
{0x58, (uint8_t[]){0x40}, 1, 0},
{0x59, (uint8_t[]){0x00}, 1, 0},
{0x5A, (uint8_t[]){0x00}, 1, 0},
{0x5B, (uint8_t[]){0x10}, 1, 0},
{0x5C, (uint8_t[]){0x05}, 1, 0},
{0x5D, (uint8_t[]){0x50}, 1, 0},
{0x5E, (uint8_t[]){0x01}, 1, 0},
{0x5F, (uint8_t[]){0x02}, 1, 0},
{0x60, (uint8_t[]){0x50}, 1, 0},
{0x61, (uint8_t[]){0x06}, 1, 0},
{0x62, (uint8_t[]){0x04}, 1, 0},
{0x63, (uint8_t[]){0x03}, 1, 0},
{0x64, (uint8_t[]){0x64}, 1, 0},
{0x65, (uint8_t[]){0x65}, 1, 0},
{0x66, (uint8_t[]){0x0B}, 1, 0},
{0x67, (uint8_t[]){0x73}, 1, 0},
{0x68, (uint8_t[]){0x07}, 1, 0},
{0x69, (uint8_t[]){0x06}, 1, 0},
{0x6A, (uint8_t[]){0x64}, 1, 0},
{0x6B, (uint8_t[]){0x08}, 1, 0},
{0x6C, (uint8_t[]){0x00}, 1, 0},
{0x6D, (uint8_t[]){0x32}, 1, 0},
{0x6E, (uint8_t[]){0x08}, 1, 0},
{0xE0, (uint8_t[]){0x04}, 1, 0},
{0x2C, (uint8_t[]){0x6B}, 1, 0},
{0x35, (uint8_t[]){0x08}, 1, 0},
{0x37, (uint8_t[]){0x00}, 1, 0},
{0xE0, (uint8_t[]){0x00}, 1, 0},
{0x11, (uint8_t[]){0x00}, 1, 0},
{0x29, (uint8_t[]){0x00}, 1, 5},
{0x11, (uint8_t[]){0x00}, 1, 120},
{0x35, (uint8_t[]){0x00}, 1, 0},
};
static const lcd_init_cmd_t st7701_dsi_init_operations[] = {
// {cmd, { data }, data_size, delay_ms}
{0xFF, (uint8_t[]){0x77, 0x01, 0x00, 0x00, 0x13}, 5, 0},
{0xEF, (uint8_t[]){0x08}, 1, 0},
{0xFF, (uint8_t[]){0x77, 0x01, 0x00, 0x00, 0x10}, 5, 0},
{0xC0, (uint8_t[]){0x63, 0x00}, 2, 0},
{0xC1, (uint8_t[]){0x0D, 0x02}, 2, 0},
{0xC2, (uint8_t[]){0x10, 0x08}, 2, 0},
{0xCC, (uint8_t[]){0x10}, 1, 0},
{0xB0, (uint8_t[]){0x80, 0x09, 0x53, 0x0C, 0xD0, 0x07, 0x0C, 0x09, 0x09, 0x28, 0x06, 0xD4, 0x13, 0x69, 0x2B, 0x71}, 16, 0},
{0xB1, (uint8_t[]){0x80, 0x94, 0x5A, 0x10, 0xD3, 0x06, 0x0A, 0x08, 0x08, 0x25, 0x03, 0xD3, 0x12, 0x66, 0x6A, 0x0D}, 16, 0},
{0xFF, (uint8_t[]){0x77, 0x01, 0x00, 0x00, 0x11}, 5, 0},
{0xB0, (uint8_t[]){0x5D}, 1, 0},
{0xB1, (uint8_t[]){0x58}, 1, 0},
{0xB2, (uint8_t[]){0x87}, 1, 0},
{0xB3, (uint8_t[]){0x80}, 1, 0},
{0xB5, (uint8_t[]){0x4E}, 1, 0},
{0xB7, (uint8_t[]){0x85}, 1, 0},
{0xB8, (uint8_t[]){0x21}, 1, 0},
{0xB9, (uint8_t[]){0x10, 0x1F}, 2, 0},
{0xBB, (uint8_t[]){0x03}, 1, 0},
{0xBC, (uint8_t[]){0x00}, 1, 0},
{0xC1, (uint8_t[]){0x78}, 1, 0},
{0xC2, (uint8_t[]){0x78}, 1, 0},
{0xD0, (uint8_t[]){0x88}, 1, 0},
{0xE0, (uint8_t[]){0x00, 0x3A, 0x02}, 3, 0},
{0xE1, (uint8_t[]){0x04, 0xA0, 0x00, 0xA0, 0x05, 0xA0, 0x00, 0xA0, 0x00, 0x40, 0x40}, 11, 0},
{0xE2, (uint8_t[]){0x30, 0x00, 0x40, 0x40, 0x32, 0xA0, 0x00, 0xA0, 0x00, 0xA0, 0x00, 0xA0, 0x00}, 13, 0},
{0xE3, (uint8_t[]){0x00, 0x00, 0x33, 0x33}, 4, 0},
{0xE4, (uint8_t[]){0x44, 0x44}, 2, 0},
{0xE5, (uint8_t[]){0x09, 0x2E, 0xA0, 0xA0, 0x0B, 0x30, 0xA0, 0xA0, 0x05, 0x2A, 0xA0, 0xA0, 0x07, 0x2C, 0xA0, 0xA0}, 16, 0},
{0xE6, (uint8_t[]){0x00, 0x00, 0x33, 0x33}, 4, 0},
{0xE7, (uint8_t[]){0x44, 0x44}, 2, 0},
{0xE8, (uint8_t[]){0x08, 0x2D, 0xA0, 0xA0, 0x0A, 0x2F, 0xA0, 0xA0, 0x04, 0x29, 0xA0, 0xA0, 0x06, 0x2B, 0xA0, 0xA0}, 16, 0},
{0xEB, (uint8_t[]){0x00, 0x00, 0x4E, 0x4E, 0x00, 0x00, 0x00}, 7, 0},
{0xEC, (uint8_t[]){0x08, 0x01}, 2, 0},
{0xED, (uint8_t[]){0xB0, 0x2B, 0x98, 0xA4, 0x56, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xF7, 0x65, 0x4A, 0x89, 0xB2, 0x0B}, 16, 0},
{0xEF, (uint8_t[]){0x08, 0x08, 0x08, 0x45, 0x3F, 0x54}, 6, 0},
{0xFF, (uint8_t[]){0x77, 0x01, 0x00, 0x00, 0x00}, 5, 0},
{0x11, (uint8_t[]){0x00}, 1, 120}, // Sleep Out - delay de 120ms
{0x29, (uint8_t[]){0x00}, 1, 20}, // Display On - delay de 20ms
};
class Arduino_DSI_Display : public Arduino_GFX
{
public:
Arduino_DSI_Display(
int16_t w, int16_t h, Arduino_ESP32DSIPanel *dsipanel, uint8_t r = 0, bool auto_flush = true,
int8_t rst = GFX_NOT_DEFINED, const lcd_init_cmd_t *init_operations = NULL, size_t init_operations_len = GFX_NOT_DEFINED,
uint8_t col_offset1 = 0, uint8_t row_offset1 = 0, uint8_t col_offset2 = 0, uint8_t row_offset2 = 0);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void writePixelPreclipped(int16_t x, int16_t y, uint16_t color) override;
void writeFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color) override;
void writeFastVLineCore(int16_t x, int16_t y, int16_t h, uint16_t color);
void writeFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color) override;
void writeFastHLineCore(int16_t x, int16_t y, int16_t w, uint16_t color);
void writeFillRectPreclipped(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) override;
void drawIndexedBitmap(int16_t x, int16_t y, uint8_t *bitmap, uint16_t *color_index, int16_t w, int16_t h, int16_t x_skip = 0) override;
void draw16bitRGBBitmap(int16_t x, int16_t y, uint16_t *bitmap, int16_t w, int16_t h) override;
void draw16bitBeRGBBitmap(int16_t x, int16_t y, uint16_t *bitmap, int16_t w, int16_t h) override;
void flush(bool force_flush = false) override;
void drawYCbCrBitmap(int16_t x, int16_t y, uint8_t *yData, uint8_t *cbData, uint8_t *crData, int16_t w, int16_t h);
uint16_t *getFramebuffer();
protected:
uint16_t *_framebuffer;
size_t _framebuffer_size;
Arduino_ESP32DSIPanel *_dsipanel;
bool _auto_flush;
int8_t _rst;
const lcd_init_cmd_t *_init_operations;
size_t _init_operations_len;
int16_t MAX_X, MAX_Y;
uint8_t COL_OFFSET1, ROW_OFFSET1;
uint8_t COL_OFFSET2, ROW_OFFSET2;
uint8_t _xStart, _yStart;
uint16_t _fb_width, _fb_height, _fb_max_x, _fb_max_y;
private:
};
#endif // #if defined(ESP32) && (CONFIG_IDF_TARGET_ESP32P4)

View File

@@ -0,0 +1,101 @@
#include "Arduino_GC9106.h"
#include "SPI.h"
Arduino_GC9106::Arduino_GC9106(
Arduino_DataBus *bus, int8_t rst, uint8_t r,
bool ips, int16_t w, int16_t h,
uint8_t col_offset1, uint8_t row_offset1, uint8_t col_offset2, uint8_t row_offset2)
: Arduino_TFT(bus, rst, r, ips, w, h, col_offset1, row_offset1, col_offset2, row_offset2)
{
}
bool Arduino_GC9106::begin(int32_t speed)
{
_override_datamode = SPI_MODE0; // always use SPI_MODE0
return Arduino_TFT::begin(speed);
}
void Arduino_GC9106::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
if ((x != _currentX) || (w != _currentW) || (y != _currentY) || (h != _currentH))
{
_bus->writeC8D16D16(GC9106_CASET, x + _xStart, x + w - 1 + _xStart);
_bus->writeC8D16D16(GC9106_RASET, y + _yStart, y + h - 1 + _yStart);
_currentX = x;
_currentY = y;
_currentW = w;
_currentH = h;
}
_bus->writeCommand(GC9106_RAMWR); // write to RAM
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_GC9106::setRotation(uint8_t r)
{
Arduino_TFT::setRotation(r);
switch (_rotation)
{
case 3:
r = GC9106_MADCTL_MY | GC9106_MADCTL_MV | GC9106_MADCTL_BGR;
break;
case 2:
r = GC9106_MADCTL_MY | GC9106_MADCTL_MX | GC9106_MADCTL_BGR;
break;
case 1:
r = GC9106_MADCTL_MX | GC9106_MADCTL_MV | GC9106_MADCTL_BGR;
break;
default: // case 0:
r = GC9106_MADCTL_BGR;
break;
}
_bus->beginWrite();
_bus->writeC8D8(GC9106_MADCTL, r);
_bus->endWrite();
}
void Arduino_GC9106::invertDisplay(bool i)
{
_bus->sendCommand(_ips ? (i ? GC9106_INVOFF : GC9106_INVON) : (i ? GC9106_INVON : GC9106_INVOFF));
}
void Arduino_GC9106::displayOn(void)
{
_bus->sendCommand(GC9106_SLPOUT);
delay(GC9106_SLPOUT_DELAY);
}
void Arduino_GC9106::displayOff(void)
{
_bus->sendCommand(GC9106_SLPIN);
delay(GC9106_SLPIN_DELAY);
}
void Arduino_GC9106::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(GC9106_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(GC9106_RST_DELAY);
}
else
{
// Software Rest
}
_bus->batchOperation(GC9106_init_operations, sizeof(GC9106_init_operations));
invertDisplay(false);
}

View File

@@ -0,0 +1,130 @@
#ifndef _ARDUINO_GC9106_H_
#define _ARDUINO_GC9106_H_
#include "./Arduino_GFX.h"
#include "../Arduino_TFT.h"
#define GC9106_TFTWIDTH 80
#define GC9106_TFTHEIGHT 160
#define GC9106_RST_DELAY 120 ///< delay ms wait for reset finish
#define GC9106_SLPIN_DELAY 120 ///< delay ms wait for sleep in finish
#define GC9106_SLPOUT_DELAY 120 ///< delay ms wait for sleep out finish
#define GC9106_NOP 0x00
#define GC9106_SWRESET 0x01
#define GC9106_RDDID 0x04
#define GC9106_RDDST 0x09
#define GC9106_SLPIN 0x10
#define GC9106_SLPOUT 0x11
#define GC9106_PTLON 0x12
#define GC9106_NORON 0x13
#define GC9106_INVOFF 0x20
#define GC9106_INVON 0x21
#define GC9106_DISPOFF 0x28
#define GC9106_DISPON 0x29
#define GC9106_CASET 0x2A
#define GC9106_RASET 0x2B
#define GC9106_RAMWR 0x2C
#define GC9106_RAMRD 0x2E
#define GC9106_PTLAR 0x30
#define GC9106_TELON 0x35
#define GC9106_MADCTL 0x36
#define GC9106_COLMOD 0x3A
#define GC9106_SCANLSET 0x44
#define GC9106_FRMCTR1 0xB1
#define GC9106_FRMCTR2 0xB2
#define GC9106_FRMCTR3 0xB3
#define GC9106_INVCTR 0xB4
#define GC9106_VREG1CTL 0xE6
#define GC9106_VREG2CTL 0xE7
#define GC9106_GAMMA1 0xF0
#define GC9106_GAMMA2 0xF1
#define GC9106_INTERRE1 0xFE
#define GC9106_INTERRE2 0xEF
#define GC9106_MADCTL_MY 0x80
#define GC9106_MADCTL_MX 0x40
#define GC9106_MADCTL_MV 0x20
#define GC9106_MADCTL_ML 0x10
#define GC9106_MADCTL_BGR 0x08
#define GC9106_MADCTL_MH 0x04
#define GC9106_MADCTL_RGB 0x00
static const uint8_t GC9106_init_operations[] = {
BEGIN_WRITE,
WRITE_COMMAND_8, GC9106_INTERRE1,
WRITE_COMMAND_8, GC9106_INTERRE1,
WRITE_COMMAND_8, GC9106_INTERRE1,
WRITE_COMMAND_8, GC9106_INTERRE2,
WRITE_C8_D8, GC9106_FRMCTR3, 0x03,
WRITE_C8_D8, GC9106_MADCTL, 0xD8,
WRITE_C8_D8, GC9106_COLMOD, 0x05,
WRITE_C8_D8, 0xB6, 0x11,
WRITE_C8_D8, 0xAC, 0x0B,
WRITE_C8_D8, GC9106_INVCTR, 0x21,
WRITE_C8_D8, GC9106_FRMCTR1, 0xC0,
WRITE_C8_D16, GC9106_VREG1CTL, 0x50, 0x43,
WRITE_C8_D16, GC9106_VREG2CTL, 0x56, 0x43,
WRITE_COMMAND_8, GC9106_GAMMA1,
WRITE_BYTES, 14, 0x1F, 0x41, 0x1B, 0x55, 0x36, 0x3D, 0x3E,
0x00, 0x16, 0x08, 0x09, 0x15, 0x14, 0x0F,
WRITE_COMMAND_8, GC9106_GAMMA2,
WRITE_BYTES, 14, 0x1F, 0x41, 0x1B, 0x55, 0x36, 0x3D, 0x3E,
0x00, 0x16, 0x08, 0x09, 0x15, 0x14, 0x0F,
WRITE_COMMAND_8, GC9106_INTERRE1,
WRITE_COMMAND_8, 0xFF,
WRITE_C8_D8, GC9106_TELON, 0x00,
WRITE_C8_D8, GC9106_SCANLSET, 0x00,
WRITE_COMMAND_8, GC9106_SLPOUT,
END_WRITE,
DELAY, GC9106_SLPOUT_DELAY,
BEGIN_WRITE,
WRITE_COMMAND_8, GC9106_DISPON, // Display on
END_WRITE,
DELAY, 20};
class Arduino_GC9106 : public Arduino_TFT
{
public:
Arduino_GC9106(
Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0,
bool ips = false, int16_t w = GC9106_TFTWIDTH, int16_t h = GC9106_TFTHEIGHT,
uint8_t col_offset1 = 24, uint8_t row_offset1 = 0, uint8_t col_offset2 = 24, uint8_t row_offset2 = 0);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void setRotation(uint8_t r) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
protected:
void tftInit() override;
private:
};
#endif

View File

@@ -0,0 +1,101 @@
#include "Arduino_GC9107.h"
#include "SPI.h"
Arduino_GC9107::Arduino_GC9107(
Arduino_DataBus *bus, int8_t rst, uint8_t r,
bool ips, int16_t w, int16_t h,
uint8_t col_offset1, uint8_t row_offset1, uint8_t col_offset2, uint8_t row_offset2)
: Arduino_TFT(bus, rst, r, ips, w, h, col_offset1, row_offset1, col_offset2, row_offset2)
{
}
bool Arduino_GC9107::begin(int32_t speed)
{
_override_datamode = SPI_MODE0; // always use SPI_MODE0
return Arduino_TFT::begin(speed);
}
void Arduino_GC9107::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
if ((x != _currentX) || (w != _currentW) || (y != _currentY) || (h != _currentH))
{
_bus->writeC8D16D16(GC9107_CASET, x + _xStart, x + w - 1 + _xStart);
_bus->writeC8D16D16(GC9107_RASET, y + _yStart, y + h - 1 + _yStart);
_currentX = x;
_currentY = y;
_currentW = w;
_currentH = h;
}
_bus->writeCommand(GC9107_RAMWR); // write to RAM
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_GC9107::setRotation(uint8_t r)
{
Arduino_TFT::setRotation(r);
switch (_rotation)
{
case 1:
r = GC9107_MADCTL_MY | GC9107_MADCTL_MV | GC9107_MADCTL_BGR;
break;
case 2:
r = GC9107_MADCTL_BGR;
break;
case 3:
r = GC9107_MADCTL_MX | GC9107_MADCTL_MV | GC9107_MADCTL_BGR;
break;
default: // case 0:
r = GC9107_MADCTL_MY | GC9107_MADCTL_MX | GC9107_MADCTL_BGR;
break;
}
_bus->beginWrite();
_bus->writeC8D8(GC9107_MADCTL, r);
_bus->endWrite();
}
void Arduino_GC9107::invertDisplay(bool i)
{
_bus->sendCommand(_ips ? (i ? GC9107_INVOFF : GC9107_INVON) : (i ? GC9107_INVON : GC9107_INVOFF));
}
void Arduino_GC9107::displayOn(void)
{
_bus->sendCommand(GC9107_SLPOUT);
delay(GC9107_SLPOUT_DELAY);
}
void Arduino_GC9107::displayOff(void)
{
_bus->sendCommand(GC9107_SLPIN);
delay(GC9107_SLPIN_DELAY);
}
void Arduino_GC9107::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(GC9107_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(GC9107_RST_DELAY);
}
else
{
// Software Rest
}
_bus->batchOperation(GC9107_init_operations, sizeof(GC9107_init_operations));
invertDisplay(false);
}

View File

@@ -0,0 +1,202 @@
#ifndef _ARDUINO_GC9107_H_
#define _ARDUINO_GC9107_H_
#include "./Arduino_GFX.h"
#include "../Arduino_TFT.h"
#define GC9107_TFTWIDTH 128
#define GC9107_TFTHEIGHT 128
#define GC9107_RST_DELAY 120 ///< delay ms wait for reset finish
#define GC9107_SLPIN_DELAY 120 ///< delay ms wait for sleep in finish
#define GC9107_SLPOUT_DELAY 120 ///< delay ms wait for sleep out finish
#define GC9107_NOP 0x00
#define GC9107_SWRESET 0x01
#define GC9107_RDDID 0x04
#define GC9107_RDDST 0x09
#define GC9107_SLPIN 0x10
#define GC9107_SLPOUT 0x11
#define GC9107_PTLON 0x12
#define GC9107_NORON 0x13
#define GC9107_INVOFF 0x20
#define GC9107_INVON 0x21
#define GC9107_DISPOFF 0x28
#define GC9107_DISPON 0x29
#define GC9107_CASET 0x2A
#define GC9107_RASET 0x2B
#define GC9107_RAMWR 0x2C
#define GC9107_RAMRD 0x2E
#define GC9107_PTLAR 0x30
#define GC9107_TELON 0x35
#define GC9107_MADCTL 0x36
#define GC9107_COLMOD 0x3A
#define GC9107_SCANLSET 0x44
#define GC9107_FRMCTR1 0xB1
#define GC9107_FRMCTR2 0xB2
#define GC9107_FRMCTR3 0xB3
#define GC9107_INVCTR 0xB4
#define GC9107_VREG1CTL 0xE6
#define GC9107_VREG2CTL 0xE7
#define GC9107_GAMMA1 0xF0
#define GC9107_GAMMA2 0xF1
#define GC9107_INTERRE1 0xFE
#define GC9107_INTERRE2 0xEF
#define GC9107_MADCTL_MY 0x80
#define GC9107_MADCTL_MX 0x40
#define GC9107_MADCTL_MV 0x20
#define GC9107_MADCTL_ML 0x10
#define GC9107_MADCTL_BGR 0x08
#define GC9107_MADCTL_MH 0x04
#define GC9107_MADCTL_RGB 0x00
static const uint8_t GC9107_init_operations[] = {
BEGIN_WRITE,
WRITE_COMMAND_8, 0xEF,
WRITE_C8_D8, 0xEB, 0x14,
WRITE_COMMAND_8, 0xFE,
WRITE_COMMAND_8, 0xEF,
WRITE_C8_D8, 0xEB, 0x14,
WRITE_C8_D8, 0x84, 0x40,
WRITE_C8_D8, 0x85, 0xFF,
WRITE_C8_D8, 0x86, 0xFF,
WRITE_C8_D8, 0x87, 0xFF,
WRITE_C8_D8, 0x88, 0x0A,
WRITE_C8_D8, 0x89, 0x21,
WRITE_C8_D8, 0x8A, 0x00,
WRITE_C8_D8, 0x8B, 0x80,
WRITE_C8_D8, 0x8C, 0x01,
WRITE_C8_D8, 0x8D, 0x01,
WRITE_C8_D8, 0x8E, 0xFF,
WRITE_C8_D8, 0x8F, 0xFF,
WRITE_C8_D16, 0xB6, 0x00, 0x20,
WRITE_C8_D8, 0x3A, 0x05,
WRITE_COMMAND_8, 0x90,
WRITE_BYTES, 4, 0x08, 0x08, 0x08, 0x08,
WRITE_C8_D8, 0xBD, 0x06,
WRITE_C8_D8, 0xBC, 0x00,
WRITE_COMMAND_8, 0xFF,
WRITE_BYTES, 3, 0x60, 0x01, 0x04,
WRITE_C8_D8, 0xC3, 0x13,
WRITE_C8_D8, 0xC4, 0x13,
WRITE_C8_D8, 0xC9, 0x22,
WRITE_C8_D8, 0xBE, 0x11,
WRITE_C8_D16, 0xE1, 0x10, 0x0E,
WRITE_COMMAND_8, 0xDF,
WRITE_BYTES, 3, 0x21, 0x0c, 0x02,
WRITE_COMMAND_8, 0xF0,
WRITE_BYTES, 6,
0x45, 0x09, 0x08, 0x08,
0x26, 0x2A,
WRITE_COMMAND_8, 0xF1,
WRITE_BYTES, 6,
0x43, 0x70, 0x72, 0x36,
0x37, 0x6F,
WRITE_COMMAND_8, 0xF2,
WRITE_BYTES, 6,
0x45, 0x09, 0x08, 0x08,
0x26, 0x2A,
WRITE_COMMAND_8, 0xF3,
WRITE_BYTES, 6,
0x43, 0x70, 0x72, 0x36,
0x37, 0x6F,
WRITE_C8_D16, 0xED, 0x1B, 0x0B,
WRITE_C8_D8, 0xAE, 0x77,
WRITE_C8_D8, 0xCD, 0x63,
WRITE_COMMAND_8, 0x70,
WRITE_BYTES, 9,
0x07, 0x07, 0x04, 0x0E,
0x0F, 0x09, 0x07, 0x08,
0x03,
WRITE_C8_D8, 0xE8, 0x34,
WRITE_COMMAND_8, 0x62,
WRITE_BYTES, 12,
0x18, 0x0D, 0x71, 0xED,
0x70, 0x70, 0x18, 0x0F,
0x71, 0xEF, 0x70, 0x70,
WRITE_COMMAND_8, 0x63,
WRITE_BYTES, 12,
0x18, 0x11, 0x71, 0xF1,
0x70, 0x70, 0x18, 0x13,
0x71, 0xF3, 0x70, 0x70,
WRITE_COMMAND_8, 0x64,
WRITE_BYTES, 7,
0x28, 0x29, 0xF1, 0x01,
0xF1, 0x00, 0x07,
WRITE_COMMAND_8, 0x66,
WRITE_BYTES, 10,
0x3C, 0x00, 0xCD, 0x67,
0x45, 0x45, 0x10, 0x00,
0x00, 0x00,
WRITE_COMMAND_8, 0x67,
WRITE_BYTES, 10,
0x00, 0x3C, 0x00, 0x00,
0x00, 0x01, 0x54, 0x10,
0x32, 0x98,
WRITE_COMMAND_8, 0x74,
WRITE_BYTES, 7,
0x10, 0x85, 0x80, 0x00,
0x00, 0x4E, 0x00,
WRITE_C8_D16, 0x98, 0x3e, 0x07,
WRITE_COMMAND_8, 0x35,
WRITE_COMMAND_8, 0x21,
WRITE_COMMAND_8, 0x11,
END_WRITE,
DELAY, 120,
BEGIN_WRITE,
WRITE_COMMAND_8, 0x29,
END_WRITE,
DELAY, 20};
class Arduino_GC9107 : public Arduino_TFT
{
public:
Arduino_GC9107(
Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0,
bool ips = false, int16_t w = GC9107_TFTWIDTH, int16_t h = GC9107_TFTHEIGHT,
uint8_t col_offset1 = 2, uint8_t row_offset1 = 1, uint8_t col_offset2 = 2, uint8_t row_offset2 = 1);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void setRotation(uint8_t r) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
protected:
void tftInit() override;
private:
};
#endif

View File

@@ -0,0 +1,101 @@
#include "Arduino_GC9A01.h"
#include "SPI.h"
Arduino_GC9A01::Arduino_GC9A01(
Arduino_DataBus *bus, int8_t rst, uint8_t r,
bool ips, int16_t w, int16_t h,
uint8_t col_offset1, uint8_t row_offset1, uint8_t col_offset2, uint8_t row_offset2)
: Arduino_TFT(bus, rst, r, ips, w, h, col_offset1, row_offset1, col_offset2, row_offset2)
{
}
bool Arduino_GC9A01::begin(int32_t speed)
{
_override_datamode = SPI_MODE0; // always use SPI_MODE0
return Arduino_TFT::begin(speed);
}
void Arduino_GC9A01::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
if ((x != _currentX) || (w != _currentW) || (y != _currentY) || (h != _currentH))
{
_bus->writeC8D16D16(GC9A01_CASET, x + _xStart, x + w - 1 + _xStart);
_bus->writeC8D16D16(GC9A01_RASET, y + _yStart, y + h - 1 + _yStart);
_currentX = x;
_currentY = y;
_currentW = w;
_currentH = h;
}
_bus->writeCommand(GC9A01_RAMWR); // write to RAM
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_GC9A01::setRotation(uint8_t r)
{
Arduino_TFT::setRotation(r);
switch (_rotation)
{
case 3:
r = 0xA8;
break;
case 2:
r = 0xC8;
break;
case 1:
r = 0x68;
break;
default: // case 0:
r = 0x08;
break;
}
_bus->beginWrite();
_bus->writeC8D8(GC9A01_MADCTL, r);
_bus->endWrite();
}
void Arduino_GC9A01::invertDisplay(bool i)
{
_bus->sendCommand(_ips ? (i ? GC9A01_INVOFF : GC9A01_INVON) : (i ? GC9A01_INVON : GC9A01_INVOFF));
}
void Arduino_GC9A01::displayOn(void)
{
_bus->sendCommand(GC9A01_SLPOUT);
delay(GC9A01_SLPOUT_DELAY);
}
void Arduino_GC9A01::displayOff(void)
{
_bus->sendCommand(GC9A01_SLPIN);
delay(GC9A01_SLPIN_DELAY);
}
void Arduino_GC9A01::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(GC9A01_RST_DELAY);
digitalWrite(_rst, LOW);
delay(GC9A01_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(GC9A01_RST_DELAY);
}
else
{
// Software Rest
}
_bus->batchOperation(gc9a01_init_operations, sizeof(gc9a01_init_operations));
invertDisplay(false);
}

View File

@@ -0,0 +1,211 @@
#ifndef _ARDUINO_GC9A01_H_
#define _ARDUINO_GC9A01_H_
#include "./Arduino_GFX.h"
#include "../Arduino_TFT.h"
#define GC9A01_TFTWIDTH 240
#define GC9A01_TFTHEIGHT 240
#define GC9A01_RST_DELAY 200 ///< delay ms wait for reset finish
#define GC9A01_SLPIN_DELAY 120 ///< delay ms wait for sleep in finish
#define GC9A01_SLPOUT_DELAY 120 ///< delay ms wait for sleep out finish
#define GC9A01_NOP 0x00
#define GC9A01_SWRESET 0x01
#define GC9A01_RDDID 0x04
#define GC9A01_RDDST 0x09
#define GC9A01_SLPIN 0x10
#define GC9A01_SLPOUT 0x11
#define GC9A01_PTLON 0x12
#define GC9A01_NORON 0x13
#define GC9A01_INVOFF 0x20
#define GC9A01_INVON 0x21
#define GC9A01_DISPOFF 0x28
#define GC9A01_DISPON 0x29
#define GC9A01_CASET 0x2A
#define GC9A01_RASET 0x2B
#define GC9A01_RAMWR 0x2C
#define GC9A01_RAMRD 0x2E
#define GC9A01_PTLAR 0x30
#define GC9A01_COLMOD 0x3A
#define GC9A01_MADCTL 0x36
#define GC9A01_MADCTL_MY 0x80
#define GC9A01_MADCTL_MX 0x40
#define GC9A01_MADCTL_MV 0x20
#define GC9A01_MADCTL_ML 0x10
#define GC9A01_MADCTL_RGB 0x00
#define GC9A01_RDID1 0xDA
#define GC9A01_RDID2 0xDB
#define GC9A01_RDID3 0xDC
#define GC9A01_RDID4 0xDD
static const uint8_t gc9a01_init_operations[] = {
BEGIN_WRITE,
WRITE_COMMAND_8, 0xEF,
WRITE_C8_D8, 0xEB, 0x14,
WRITE_COMMAND_8, 0xFE,
WRITE_COMMAND_8, 0xEF,
WRITE_C8_D8, 0xEB, 0x14,
WRITE_C8_D8, 0x84, 0x40,
WRITE_C8_D8, 0x85, 0xFF,
WRITE_C8_D8, 0x86, 0xFF,
WRITE_C8_D8, 0x87, 0xFF,
WRITE_C8_D8, 0x88, 0x0A,
WRITE_C8_D8, 0x89, 0x21,
WRITE_C8_D8, 0x8A, 0x00,
WRITE_C8_D8, 0x8B, 0x80,
WRITE_C8_D8, 0x8C, 0x01,
WRITE_C8_D8, 0x8D, 0x01,
WRITE_C8_D8, 0x8E, 0xFF,
WRITE_C8_D8, 0x8F, 0xFF,
WRITE_C8_D16, 0xB6, 0x00, 0x20,
WRITE_C8_D8, 0x3A, 0x05,
WRITE_COMMAND_8, 0x90,
WRITE_BYTES, 4, 0x08, 0x08, 0x08, 0x08,
WRITE_C8_D8, 0xBD, 0x06,
WRITE_C8_D8, 0xBC, 0x00,
WRITE_COMMAND_8, 0xFF,
WRITE_BYTES, 3, 0x60, 0x01, 0x04,
WRITE_C8_D8, 0xC3, 0x13,
WRITE_C8_D8, 0xC4, 0x13,
WRITE_C8_D8, 0xC9, 0x22,
WRITE_C8_D8, 0xBE, 0x11,
WRITE_C8_D16, 0xE1, 0x10, 0x0E,
WRITE_COMMAND_8, 0xDF,
WRITE_BYTES, 3, 0x21, 0x0c, 0x02,
WRITE_COMMAND_8, 0xF0,
WRITE_BYTES, 6,
0x45, 0x09, 0x08, 0x08, 0x26,
0x2A,
WRITE_COMMAND_8, 0xF1,
WRITE_BYTES, 6,
0x43, 0x70, 0x72, 0x36, 0x37,
0x6F,
WRITE_COMMAND_8, 0xF2,
WRITE_BYTES, 6,
0x45, 0x09, 0x08, 0x08, 0x26,
0x2A,
WRITE_COMMAND_8, 0xF3,
WRITE_BYTES, 6,
0x43, 0x70, 0x72, 0x36, 0x37,
0x6F,
WRITE_C8_D16, 0xED, 0x1B, 0x0B,
WRITE_C8_D8, 0xAE, 0x77,
WRITE_C8_D8, 0xCD, 0x63,
WRITE_COMMAND_8, 0x70,
WRITE_BYTES, 9,
0x07, 0x07, 0x04, 0x0E, 0x0F,
0x09, 0x07, 0x08, 0x03,
WRITE_C8_D8, 0xE8, 0x34,
WRITE_COMMAND_8, 0x62,
WRITE_BYTES, 12,
0x18, 0x0D, 0x71, 0xED, 0x70,
0x70, 0x18, 0x0F, 0x71, 0xEF,
0x70, 0x70,
WRITE_COMMAND_8, 0x63,
WRITE_BYTES, 12,
0x18, 0x11, 0x71, 0xF1, 0x70,
0x70, 0x18, 0x13, 0x71, 0xF3,
0x70, 0x70,
WRITE_COMMAND_8, 0x64,
WRITE_BYTES, 7,
0x28, 0x29, 0xF1, 0x01, 0xF1,
0x00, 0x07,
WRITE_COMMAND_8, 0x66,
WRITE_BYTES, 10,
0x3C, 0x00, 0xCD, 0x67, 0x45,
0x45, 0x10, 0x00, 0x00, 0x00,
WRITE_COMMAND_8, 0x67,
WRITE_BYTES, 10,
0x00, 0x3C, 0x00, 0x00, 0x00,
0x01, 0x54, 0x10, 0x32, 0x98,
WRITE_COMMAND_8, 0x74,
WRITE_BYTES, 7,
0x10, 0x85, 0x80, 0x00, 0x00,
0x4E, 0x00,
WRITE_C8_D16, 0x98, 0x3e, 0x07,
WRITE_COMMAND_8, 0x35,
WRITE_COMMAND_8, GC9A01_SLPOUT,
END_WRITE,
DELAY, GC9A01_SLPOUT_DELAY,
BEGIN_WRITE,
WRITE_COMMAND_8, GC9A01_DISPON, // Display on
END_WRITE,
DELAY, 20};
class Arduino_GC9A01 : public Arduino_TFT
{
public:
Arduino_GC9A01(
Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0,
bool ips = false, int16_t w = GC9A01_TFTWIDTH, int16_t h = GC9A01_TFTHEIGHT,
uint8_t col_offset1 = 0, uint8_t row_offset1 = 0, uint8_t col_offset2 = 0, uint8_t row_offset2 = 0);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void setRotation(uint8_t r) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
protected:
void tftInit() override;
private:
};
#endif

View File

@@ -0,0 +1,113 @@
#include "Arduino_GC9C01.h"
#include "SPI.h"
Arduino_GC9C01::Arduino_GC9C01(
Arduino_DataBus *bus, int8_t rst, uint8_t r,
bool ips, int16_t w, int16_t h,
uint8_t col_offset1, uint8_t row_offset1, uint8_t col_offset2, uint8_t row_offset2)
: Arduino_TFT(bus, rst, r, ips, w, h, col_offset1, row_offset1, col_offset2, row_offset2)
{
}
bool Arduino_GC9C01::begin(int32_t speed)
{
_override_datamode = SPI_MODE0; // always use SPI_MODE0
return Arduino_TFT::begin(speed);
}
void Arduino_GC9C01::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
if ((x != _currentX) || (w != _currentW) || (y != _currentY) || (h != _currentH))
{
_bus->writeC8D16D16(GC9C01_CASET, x + _xStart, x + w - 1 + _xStart);
_bus->writeC8D16D16(GC9C01_RASET, y + _yStart, y + h - 1 + _yStart);
_currentX = x;
_currentY = y;
_currentW = w;
_currentH = h;
}
_bus->writeCommand(GC9C01_RAMWR); // write to RAM
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_GC9C01::setRotation(uint8_t r)
{
Arduino_TFT::setRotation(r);
switch (_rotation)
{
case 1:
r = GC9C01_MADCTL_MX | GC9C01_MADCTL_MV | GC9C01_MADCTL_RGB;
break;
case 2:
r = GC9C01_MADCTL_MX | GC9C01_MADCTL_MY | GC9C01_MADCTL_RGB;
break;
case 3:
r = GC9C01_MADCTL_MY | GC9C01_MADCTL_MV | GC9C01_MADCTL_RGB;
break;
case 4:
r = GC9C01_MADCTL_MX | GC9C01_MADCTL_RGB;
break;
case 5:
r = GC9C01_MADCTL_MX | GC9C01_MADCTL_MY | GC9C01_MADCTL_MV | GC9C01_MADCTL_RGB;
break;
case 6:
r = GC9C01_MADCTL_MY | GC9C01_MADCTL_RGB;
break;
case 7:
r = GC9C01_MADCTL_MV | GC9C01_MADCTL_RGB;
break;
default: // case 0:
r = GC9C01_MADCTL_RGB;
break;
}
_bus->beginWrite();
_bus->writeC8D8(GC9C01_MADCTL, r);
_bus->endWrite();
}
void Arduino_GC9C01::invertDisplay(bool i)
{
_bus->sendCommand(_ips ? (i ? GC9C01_INVOFF : GC9C01_INVON) : (i ? GC9C01_INVON : GC9C01_INVOFF));
}
void Arduino_GC9C01::displayOn(void)
{
_bus->sendCommand(GC9C01_SLPOUT);
delay(GC9C01_SLPOUT_DELAY);
}
void Arduino_GC9C01::displayOff(void)
{
_bus->sendCommand(GC9C01_SLPIN);
delay(GC9C01_SLPIN_DELAY);
}
void Arduino_GC9C01::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(GC9C01_RST_DELAY);
digitalWrite(_rst, LOW);
delay(GC9C01_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(GC9C01_RST_DELAY);
}
else
{
// Software Rest
}
_bus->batchOperation(gc9c01_init_operations, sizeof(gc9c01_init_operations));
invertDisplay(false);
}

View File

@@ -0,0 +1,195 @@
#pragma once
#include "./Arduino_GFX.h"
#include "../Arduino_TFT.h"
#define GC9C01_TFTWIDTH 360
#define GC9C01_TFTHEIGHT 360
#define GC9C01_RST_DELAY 200 ///< delay ms wait for reset finish
#define GC9C01_SLPIN_DELAY 120 ///< delay ms wait for sleep in finish
#define GC9C01_SLPOUT_DELAY 120 ///< delay ms wait for sleep out finish
#define GC9C01_NOP 0x00
#define GC9C01_SWRESET 0x01
#define GC9C01_RDDID 0x04
#define GC9C01_RDDST 0x09
#define GC9C01_SLPIN 0x10
#define GC9C01_SLPOUT 0x11
#define GC9C01_PTLON 0x12
#define GC9C01_NORON 0x13
#define GC9C01_INVOFF 0x20
#define GC9C01_INVON 0x21
#define GC9C01_DISPOFF 0x28
#define GC9C01_DISPON 0x29
#define GC9C01_CASET 0x2A
#define GC9C01_RASET 0x2B
#define GC9C01_RAMWR 0x2C
#define GC9C01_RAMRD 0x2E
#define GC9C01_PTLAR 0x30
#define GC9C01_COLMOD 0x3A
#define GC9C01_MADCTL 0x36
#define GC9C01_MADCTL_MY 0x80
#define GC9C01_MADCTL_MX 0x40
#define GC9C01_MADCTL_MV 0x20
#define GC9C01_MADCTL_ML 0x10
#define GC9C01_MADCTL_RGB 0x00
#define GC9C01_RDID1 0xDA
#define GC9C01_RDID2 0xDB
#define GC9C01_RDID3 0xDC
#define GC9C01_RDID4 0xDD
static const uint8_t gc9c01_init_operations[] = {
BEGIN_WRITE,
WRITE_COMMAND_8, 0xfe, // internal reg enable
WRITE_COMMAND_8, 0xef, // internal reg enable
WRITE_C8_D8, 0x80, 0x11, // reg_en for 70\74
WRITE_C8_D8, 0x81, 0x70, // reg_en for 7C\7D\7E
WRITE_C8_D8, 0x82, 0x09, // reg_en for 90\93
WRITE_C8_D8, 0x83, 0x03, // reg_en for 98\99
WRITE_C8_D8, 0x84, 0x20, // reg_en for B5
WRITE_C8_D8, 0x85, 0x42, // reg_en for B9\BE
WRITE_C8_D8, 0x86, 0xfc, // reg_en for C2~7
WRITE_C8_D8, 0x87, 0x09, // reg_en for C8\CB
WRITE_C8_D8, 0x89, 0x10, // reg_en for EC
WRITE_C8_D8, 0x8A, 0x4f, // reg_en for F0~3\F6
WRITE_C8_D8, 0x8C, 0x59, // reg_en for 60\63\64\66
WRITE_C8_D8, 0x8D, 0x51, // reg_en for 68\6C\6E
WRITE_C8_D8, 0x8E, 0xae, // reg_en for A1~3\A5\A7
WRITE_C8_D8, 0x8F, 0xf3, // reg_en for AC~F\A8\A9
WRITE_C8_D8, 0x36, 0x00,
WRITE_C8_D8, 0x3a, 0x05, // 565 frame
WRITE_C8_D8, 0xEC, 0x77,
WRITE_C8_BYTES, 0x74, 6, // rtn 60Hz
0x01, 0x80, 0x00, 0x00,
0x00, 0x00,
WRITE_C8_D8, 0x98, 0x3E,
WRITE_C8_D8, 0x99, 0x3E,
WRITE_C8_D8, 0xC3, 0x2A,
WRITE_C8_D8, 0xC4, 0x18,
WRITE_C8_D16, 0xA1, 0x01, 0x04, // SRAM RD OPTION
WRITE_C8_D16, 0xA2, 0x01, 0x04, // SRAM RD OPTION
WRITE_C8_D8, 0xA9, 0x1C, // IREF=9.8uA
WRITE_C8_D16, 0xA5, 0x11, 0x09, // VDDML=1.24V
WRITE_C8_D8, 0xB9, 0x8A, // RTERM=101O
WRITE_C8_D8, 0xA8, 0x5E, // VBG_BUF=1.003V, DVDD=1.543V
WRITE_C8_D8, 0xA7, 0x40, // BIAS=10.2uA
WRITE_C8_D8, 0xAF, 0x73, // VDDSOU=1.715V ,VDDGM=2.002V
WRITE_C8_D8, 0xAE, 0x44, // VREE=2.475V,VRDD=2.335V
WRITE_C8_D8, 0xAD, 0x38, // VRGL=1.635V ,VDDSF=2.018V
WRITE_C8_D8, 0xA3, 0x5D, // OSC=53.7MHz
WRITE_C8_D8, 0xC2, 0x02, // VREG_VREF=2.805V
WRITE_C8_D8, 0xC5, 0x11, // VREG1A=5.99V
WRITE_C8_D8, 0xC6, 0x0E, // VREG1B=1.505V
WRITE_C8_D8, 0xC7, 0x13, // VREG2A=-2.995V
WRITE_C8_D8, 0xC8, 0x0D, // VREG2B=1.497V
WRITE_C8_D8, 0xCB, 0x02, // 6.09V
WRITE_C8_D16, 0x7C, 0xB6, 0x26, // 13.12V
WRITE_C8_D8, 0xAC, 0x24, // VGLO=-8.35V
WRITE_C8_D8, 0xF6, 0x80, // EPF=2
WRITE_C8_D16, 0xB5, 0x09, 0x09, // VBP
WRITE_C8_BYTES, 0x60, 4, // STV1&2
0x38, 0x0B, 0x5B, 0x56,
WRITE_C8_BYTES, 0x63, 4, // STV3&4
0x3A, 0xE0, 0x5B, 0x56, // MAX=0x61
WRITE_C8_BYTES, 0x64, 6, // CLK_group1
0x38, 0x0D, 0x72, 0xDD,
0x5B, 0x56,
WRITE_C8_BYTES, 0x66, 6, // CLK_group1
0x38, 0x11, 0x72, 0xE1,
0x5B, 0x56,
WRITE_C8_BYTES, 0x68, 7, // FLC&FLV 1~2
0x3B, 0x08, 0x08, 0x00,
0x08, 0x29, 0x5B,
WRITE_C8_BYTES, 0x6E, 32, // gout_Mapping
0x00, 0x00, 0x00, 0x07, // gout4_swap_fw[4:0]
0x01, 0x13, 0x11, 0x0B, // gout8_swap_fw[4:0]
0x09, 0x16, 0x15, 0x1D, // gout12_swap_fw[4:0]
0x1E, 0x00, 0x00, 0x00, // gout16_swap_fw[4:0]
0x00, 0x00, 0x00, 0x1E, // gout20_swap_fw[4:0]
0x1D, 0x15, 0x16, 0x0A, // gout24_swap_fw[4:0]
0x0C, 0x12, 0x14, 0x02, // gout28_swap_fw[4:0]
0x08, 0x00, 0x00, 0x00, // gout32_swap_fw[4:0]
WRITE_C8_D8, 0xBE, 0x11, // SOU_BIAS_FIX=1
WRITE_C8_BYTES, 0x6C, 7, // precharge GATE
0xCC, 0x0C, 0xCC, 0x84,
0xCC, 0x04, 0x50,
WRITE_C8_D8, 0x7D, 0x72,
WRITE_C8_D8, 0x7E, 0x38, // VGL_BT=1 5X (BT=0:6X) RT=0
WRITE_C8_BYTES, 0x70, 10,
0x02, 0x03, 0x09, 0x05, // vgh_clk
0x0C, 0x06, 0x09, 0x05, // vgh_clk_porch 0E
0x0C, 0x06, // vcl_clk_porch 0E
WRITE_C8_BYTES, 0x90, 4,
0x06, 0x06, 0x05, 0x06, // bvdd_clk1_ad1
WRITE_C8_BYTES, 0x93, 3,
0x45, 0xFF, 0x00,
// gamma start
WRITE_C8_BYTES, 0xF0, 6,
0x45, 0x09, 0x08, 0x08,
0x26, 0x2A,
WRITE_C8_BYTES, 0xF1, 6,
0x43, 0x70, 0x72, 0x36,
0x37, 0x6F,
WRITE_C8_BYTES, 0xF2, 6,
0x45, 0x09, 0x08, 0x08,
0x26, 0x2A,
WRITE_C8_BYTES, 0xF3, 6,
0x43, 0x70, 0x72, 0x36,
0x37, 0x6F,
WRITE_COMMAND_8, GC9C01_SLPOUT,
END_WRITE,
DELAY, GC9C01_SLPOUT_DELAY,
BEGIN_WRITE,
WRITE_COMMAND_8, GC9C01_DISPON, // Display on
END_WRITE,
DELAY, 10};
class Arduino_GC9C01 : public Arduino_TFT
{
public:
Arduino_GC9C01(
Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0,
bool ips = false, int16_t w = GC9C01_TFTWIDTH, int16_t h = GC9C01_TFTHEIGHT,
uint8_t col_offset1 = 0, uint8_t row_offset1 = 0, uint8_t col_offset2 = 0, uint8_t row_offset2 = 0);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void setRotation(uint8_t r) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
protected:
void tftInit() override;
private:
};

View File

@@ -0,0 +1,101 @@
#include "Arduino_GC9D01.h"
#include "SPI.h"
Arduino_GC9D01::Arduino_GC9D01(
Arduino_DataBus *bus, int8_t rst, uint8_t r,
bool ips, int16_t w, int16_t h,
uint8_t col_offset1, uint8_t row_offset1, uint8_t col_offset2, uint8_t row_offset2)
: Arduino_TFT(bus, rst, r, ips, w, h, col_offset1, row_offset1, col_offset2, row_offset2)
{
}
bool Arduino_GC9D01::begin(int32_t speed)
{
_override_datamode = SPI_MODE0; // always use SPI_MODE0
return Arduino_TFT::begin(speed);
}
void Arduino_GC9D01::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
if ((x != _currentX) || (w != _currentW) || (y != _currentY) || (h != _currentH))
{
_bus->writeC8D16D16(GC9D01_CASET, x + _xStart, x + w - 1 + _xStart);
_bus->writeC8D16D16(GC9D01_RASET, y + _yStart, y + h - 1 + _yStart);
_currentX = x;
_currentY = y;
_currentW = w;
_currentH = h;
}
_bus->writeCommand(GC9D01_RAMWR); // write to RAM
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_GC9D01::setRotation(uint8_t r)
{
Arduino_TFT::setRotation(r);
switch (_rotation % 4)
{
case 1: // Landscape (Portrait + 90°)
r = GC9D01_MADCTL_MX | GC9D01_MADCTL_MV | GC9D01_MADCTL_BGR;
break;
case 2: // Inverter Portrait
r = GC9D01_MADCTL_MX | GC9D01_MADCTL_MY | GC9D01_MADCTL_BGR;
break;
case 3: // Inverted Landscape
r = GC9D01_MADCTL_MV | GC9D01_MADCTL_MY | GC9D01_MADCTL_BGR;
break;
default: // case 0: (Portrait)
r = GC9D01_MADCTL_BGR;
break;
}
_bus->beginWrite();
_bus->writeC8D8(GC9D01_MADCTL, r);
_bus->endWrite();
}
void Arduino_GC9D01::invertDisplay(bool i)
{
_bus->sendCommand(_ips ? (i ? GC9D01_INVOFF : GC9D01_INVON) : (i ? GC9D01_INVON : GC9D01_INVOFF));
}
void Arduino_GC9D01::displayOn(void)
{
_bus->sendCommand(GC9D01_SLPOUT);
delay(GC9D01_SLPOUT_DELAY);
}
void Arduino_GC9D01::displayOff(void)
{
_bus->sendCommand(GC9D01_SLPIN);
delay(GC9D01_SLPIN_DELAY);
}
void Arduino_GC9D01::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(GC9D01_RST_DELAY);
digitalWrite(_rst, LOW);
delay(GC9D01_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(GC9D01_RST_DELAY);
}
else
{
// Software Rest
}
_bus->batchOperation(GC9D01_init_operations, sizeof(GC9D01_init_operations));
invertDisplay(false);
}

View File

@@ -0,0 +1,168 @@
#pragma once
#include "./Arduino_GFX.h"
#include "../Arduino_TFT.h"
#define GC9D01_TFTWIDTH 160
#define GC9D01_TFTHEIGHT 160
#define GC9D01_RST_DELAY 200 ///< delay ms wait for reset finish
#define GC9D01_SLPIN_DELAY 200 ///< delay ms wait for sleep in finish
#define GC9D01_SLPOUT_DELAY 200 ///< delay ms wait for sleep out finish
#define GC9D01_NOP 0x00
#define GC9D01_SWRESET 0x01
#define GC9D01_RDDID 0x04
#define GC9D01_RDDST 0x09
#define GC9D01_SLPIN 0x10
#define GC9D01_SLPOUT 0x11
#define GC9D01_PTLON 0x12
#define GC9D01_NORON 0x13
#define GC9D01_INVOFF 0x20
#define GC9D01_INVON 0x21
#define GC9D01_DISPOFF 0x28
#define GC9D01_DISPON 0x29
#define GC9D01_CASET 0x2A // Column Address Set
#define GC9D01_RASET 0x2B // Page Address Set
#define GC9D01_RAMWR 0x2C // Memory Write
#define GC9D01_RAMRD 0x2E // Memory Read
#define GC9D01_PTLAR 0x30 // Partial Area
#define GC9D01_COLMOD 0x3A // Pixel fmt set
#define GC9D01_MADCTL 0x36 // Memory Access Ctl
#define GC9D01_MADCTL_MY 0x80
#define GC9D01_MADCTL_MX 0x40
#define GC9D01_MADCTL_MV 0x20
#define GC9D01_MADCTL_ML 0x10
#define GC9D01_MADCTL_MH 0x04
#define GC9D01_MADCTL_RGB 0x08
#define GC9D01_MADCTL_BGR 0x00
#define GC9D01_RDID1 0xDA // Read ID1
#define GC9D01_RDID2 0xDB // Read ID2
#define GC9D01_RDID3 0xDC // Read ID3
//#define GC9D01_RDID4 0xDD
static const uint8_t GC9D01_init_operations[] = {
BEGIN_WRITE,
WRITE_COMMAND_8, 0xFE, // internal reg enable
WRITE_COMMAND_8, 0xEF, // internal reg enable
WRITE_C8_D8, 0x80, 0xFF,
WRITE_C8_D8, 0x81, 0xFF,
WRITE_C8_D8, 0x82, 0xFF,
WRITE_C8_D8, 0x83, 0xFF,
WRITE_C8_D8, 0x84, 0xFF,
WRITE_C8_D8, 0x85, 0xFF,
WRITE_C8_D8, 0x86, 0xFF,
WRITE_C8_D8, 0x87, 0xFF,
WRITE_C8_D8, 0x88, 0xFF,
WRITE_C8_D8, 0x89, 0xFF,
WRITE_C8_D8, 0x8A, 0xFF,
WRITE_C8_D8, 0x8B, 0xFF,
WRITE_C8_D8, 0x8C, 0xFF,
WRITE_C8_D8, 0x8D, 0xFF,
WRITE_C8_D8, 0x8E, 0xFF,
WRITE_C8_D8, 0x8F, 0xFF,
WRITE_C8_D8, 0x3A, 0x05, // Pixel Format Set (18bpp)
WRITE_C8_D8, 0xEC, 0x01, // Inversion mode
WRITE_COMMAND_8, 0x74,
WRITE_BYTES, 7, 0x02, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00,
WRITE_C8_D8, 0x98, 0x3E,
WRITE_C8_D8, 0x99, 0x3E,
WRITE_C8_D16, 0xB5, 0x0D, 0x0D, // Blanking Porch Control
WRITE_COMMAND_8, 0x60,
WRITE_BYTES, 4, 0x38, 0x0F, 0x79, 0x67,
WRITE_COMMAND_8, 0x61,
WRITE_BYTES, 4, 0x38, 0x11, 0x79, 0x67,
WRITE_COMMAND_8, 0x64,
WRITE_BYTES, 6, 0x38, 0x17, 0x71, 0x5F, 0x79, 0x67,
WRITE_COMMAND_8, 0x65,
WRITE_BYTES, 6, 0x38, 0x13, 0x71, 0x5B, 0x79, 0x67,
WRITE_C8_D16, 0x6A, 0x00, 0x00,
WRITE_COMMAND_8, 0x6C,
WRITE_BYTES, 7, 0x22, 0x02, 0x22, 0x02, 0x22, 0x22, 0x50,
WRITE_COMMAND_8, 0x6E,
WRITE_BYTES, 32, 0x03, 0x03, 0x01, 0x01, 0x00, 0x00,
0x0f, 0x0f, 0x0d, 0x0d, 0x0b, 0x0b, 0x09, 0x09, 0x00, 0x00,
0x00, 0x00, 0x0a, 0x0a, 0x0c, 0x0c, 0x0e, 0x0e, 0x10, 0x10,
0x00, 0x00, 0x02, 0x02, 0x04, 0x04,
WRITE_C8_D8, 0xBF, 0x01, // Dual signal gate mode
WRITE_C8_D8, 0xF9, 0x40,
WRITE_C8_D8, 0x9B, 0x3B,
WRITE_COMMAND_8, 0x93,
WRITE_BYTES, 3, 0x33, 0x7F, 0x00,
WRITE_C8_D8, 0x7E, 0x30,
WRITE_COMMAND_8, 0x70,
WRITE_BYTES, 6, 0x0D, 0x02, 0x08, 0x0D, 0x02, 0x08,
WRITE_COMMAND_8, 0x71,
WRITE_BYTES, 3, 0x0D, 0x02, 0x08,
WRITE_C8_D16, 0x91, 0x0E, 0x09,
WRITE_C8_D8, 0xC3, 0x19, // Voltage Level Power control 2
WRITE_C8_D8, 0xC4, 0x19, // Voltage Level Power control 3
WRITE_C8_D8, 0xC9, 0x3C, // Voltage Level Power control 4
WRITE_COMMAND_8, 0xF0, // Set Gamma 1
WRITE_BYTES, 6, 0x53, 0x15, 0x0A, 0x04, 0x00, 0x3E,
WRITE_COMMAND_8, 0xF2, // Set Gamma 3
WRITE_BYTES, 6, 0x53, 0x15, 0x0A, 0x04, 0x00, 0x3A,
WRITE_COMMAND_8, 0xF1, // Set Gamma 2
WRITE_BYTES, 6, 0x56, 0xA8, 0x7F, 0x33, 0x34, 0x5F,
WRITE_COMMAND_8, 0xF3, // Set Gamma 4
WRITE_BYTES, 6, 0x52, 0xA4, 0x7F, 0x33, 0x34, 0xDF,
WRITE_C8_D8, 0x36, 0x00, // Memory Access Control
WRITE_COMMAND_8, GC9D01_SLPOUT, // Sleep OUT
END_WRITE,
DELAY, GC9D01_SLPOUT_DELAY, // 200 ms
BEGIN_WRITE,
WRITE_COMMAND_8, GC9D01_DISPON, // Display on
WRITE_COMMAND_8, 0x2C, // Memory Write
END_WRITE,
DELAY, 10};
class Arduino_GC9D01 : public Arduino_TFT
{
public:
Arduino_GC9D01(
Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0,
bool ips = false, int16_t w = GC9D01_TFTWIDTH, int16_t h = GC9D01_TFTHEIGHT,
uint8_t col_offset1 = 0, uint8_t row_offset1 = 0, uint8_t col_offset2 = 0, uint8_t row_offset2 = 0);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void setRotation(uint8_t r) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
protected:
void tftInit() override;
private:
};

View File

@@ -0,0 +1,422 @@
/*
* start rewrite from:
* https://github.com/adafruit/Adafruit-GFX-Library.git
*/
#include "Arduino_HX8347C.h"
Arduino_HX8347C::Arduino_HX8347C(
Arduino_DataBus *bus, int8_t rst, uint8_t r,
bool ips, int16_t w, int16_t h,
uint8_t col_offset1, uint8_t row_offset1, uint8_t col_offset2, uint8_t row_offset2)
: Arduino_TFT(bus, rst, r, ips, w, h, col_offset1, row_offset1, col_offset2, row_offset2)
{
_invert = ips;
}
bool Arduino_HX8347C::begin(int32_t speed)
{
return Arduino_TFT::begin(speed);
}
// Companion code to the above tables. Reads and issues
// a series of LCD commands stored in PROGMEM byte array.
void Arduino_HX8347C::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(HX8347C_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(HX8347C_RST_DELAY);
}
else
{
// Software Rest
}
// LCD Init For 3.0inch LCD Panel with HX8347C.
// Power Voltage Setting
_bus->sendCommand(0x1A);
_bus->sendData(0x02); // BT
_bus->sendCommand(0x1B);
_bus->sendData(0x8B); // VRH
//****VCOM offset**///
_bus->sendCommand(0x23);
_bus->sendData(0x00); // SEL_VCM
_bus->sendCommand(0x24);
_bus->sendData(0x5D); // VCM
_bus->sendCommand(0x25);
_bus->sendData(0x15); // VDV
_bus->sendCommand(0x2D);
_bus->sendData(0x01); // NOW[2:0]=001
//****OPON**//
_bus->sendCommand(0xE8);
_bus->sendData(0x60);
// Power on Setting
_bus->sendCommand(0x18);
_bus->sendData(0x04); // Frame rate 72Hz
_bus->sendCommand(0x19);
_bus->sendData(0x01); // OSC_EN='1', start Osc
_bus->sendCommand(0x01);
_bus->sendData(0x00); // DP_STB='0', out deep sleep
_bus->sendCommand(0x1F);
_bus->sendData(0x88); // STB=0
delay(5);
_bus->sendCommand(0x1F);
_bus->sendData(0x80); // DK=0
delay(5);
_bus->sendCommand(0x1F);
_bus->sendData(0x90); // PON=1
delay(5);
_bus->sendCommand(0x1F);
_bus->sendData(0xD0); // VCOMG=1
delay(5);
// 262k/65k color selection
_bus->sendCommand(0x17);
_bus->sendData(0x05); // default 0x06 262k color // 0x05 65k color
// SET PANEL
_bus->sendCommand(0x29);
_bus->sendData(0x31); // 400 lines
_bus->sendCommand(0x71);
_bus->sendData(0x1A); // RTN
// Gamma 2.2 Setting
_bus->sendCommand(0x40);
_bus->sendData(0x00);
_bus->sendCommand(0x41);
_bus->sendData(0x77);
_bus->sendCommand(0x42);
_bus->sendData(0x77);
_bus->sendCommand(0x43);
_bus->sendData(0x00);
_bus->sendCommand(0x44);
_bus->sendData(0x04);
_bus->sendCommand(0x45);
_bus->sendData(0x00);
_bus->sendCommand(0x46);
_bus->sendData(0x00);
_bus->sendCommand(0x47);
_bus->sendData(0x00);
_bus->sendCommand(0x48);
_bus->sendData(0x77);
_bus->sendCommand(0x49);
_bus->sendData(0x00);
_bus->sendCommand(0x4A);
_bus->sendData(0x00);
_bus->sendCommand(0x4B);
_bus->sendData(0x08);
_bus->sendCommand(0x4C);
_bus->sendData(0x00);
_bus->sendCommand(0x4D);
_bus->sendData(0x00);
_bus->sendCommand(0x4E);
_bus->sendData(0x00);
// Set DGC
_bus->sendCommand(0xFF);
_bus->sendData(0x01); // Page1
_bus->sendCommand(0x00);
_bus->sendData(0x01); // DGC_EN
_bus->sendCommand(0x01);
_bus->sendData(0x00);
_bus->sendCommand(0x02);
_bus->sendData(0x06);
_bus->sendCommand(0x03);
_bus->sendData(0x0C);
_bus->sendCommand(0x04);
_bus->sendData(0x12);
_bus->sendCommand(0x05);
_bus->sendData(0x16);
_bus->sendCommand(0x06);
_bus->sendData(0x1C);
_bus->sendCommand(0x07);
_bus->sendData(0x23);
_bus->sendCommand(0x08);
_bus->sendData(0x2E);
_bus->sendCommand(0x09);
_bus->sendData(0x36);
_bus->sendCommand(0x0A);
_bus->sendData(0x3F);
_bus->sendCommand(0x0B);
_bus->sendData(0x47);
_bus->sendCommand(0x0C);
_bus->sendData(0x50);
_bus->sendCommand(0x0D);
_bus->sendData(0x57);
_bus->sendCommand(0x0E);
_bus->sendData(0x5F);
_bus->sendCommand(0x0F);
_bus->sendData(0x67);
_bus->sendCommand(0x10);
_bus->sendData(0x6F);
_bus->sendCommand(0x11);
_bus->sendData(0x76);
_bus->sendCommand(0x12);
_bus->sendData(0x7F);
_bus->sendCommand(0x13);
_bus->sendData(0x87);
_bus->sendCommand(0x14);
_bus->sendData(0x90);
_bus->sendCommand(0x15);
_bus->sendData(0x99);
_bus->sendCommand(0x16);
_bus->sendData(0xA3);
_bus->sendCommand(0x17);
_bus->sendData(0xAD);
_bus->sendCommand(0x18);
_bus->sendData(0xB4);
_bus->sendCommand(0x19);
_bus->sendData(0xBB);
_bus->sendCommand(0x1A);
_bus->sendData(0xC4);
_bus->sendCommand(0x1B);
_bus->sendData(0xCE);
_bus->sendCommand(0x1C);
_bus->sendData(0xD9);
_bus->sendCommand(0x1D);
_bus->sendData(0xE3);
_bus->sendCommand(0x1E);
_bus->sendData(0xEC);
_bus->sendCommand(0x1F);
_bus->sendData(0xF3);
_bus->sendCommand(0x20);
_bus->sendData(0xF7);
_bus->sendCommand(0x21);
_bus->sendData(0xFC);
_bus->sendCommand(0x22);
_bus->sendData(0x00);
_bus->sendCommand(0x23);
_bus->sendData(0x06);
_bus->sendCommand(0x24);
_bus->sendData(0x0C);
_bus->sendCommand(0x25);
_bus->sendData(0x12);
_bus->sendCommand(0x26);
_bus->sendData(0x16);
_bus->sendCommand(0x27);
_bus->sendData(0x1C);
_bus->sendCommand(0x28);
_bus->sendData(0x23);
_bus->sendCommand(0x29);
_bus->sendData(0x2E);
_bus->sendCommand(0x2A);
_bus->sendData(0x36);
_bus->sendCommand(0x2B);
_bus->sendData(0x3F);
_bus->sendCommand(0x2C);
_bus->sendData(0x47);
_bus->sendCommand(0x2D);
_bus->sendData(0x50);
_bus->sendCommand(0x2E);
_bus->sendData(0x57);
_bus->sendCommand(0x2F);
_bus->sendData(0x5F);
_bus->sendCommand(0x30);
_bus->sendData(0x67);
_bus->sendCommand(0x31);
_bus->sendData(0x6F);
_bus->sendCommand(0x32);
_bus->sendData(0x76);
_bus->sendCommand(0x33);
_bus->sendData(0x7F);
_bus->sendCommand(0x34);
_bus->sendData(0x87);
_bus->sendCommand(0x35);
_bus->sendData(0x90);
_bus->sendCommand(0x36);
_bus->sendData(0x99);
_bus->sendCommand(0x37);
_bus->sendData(0xA3);
_bus->sendCommand(0x38);
_bus->sendData(0xAD);
_bus->sendCommand(0x39);
_bus->sendData(0xB4);
_bus->sendCommand(0x3A);
_bus->sendData(0xBB);
_bus->sendCommand(0x3B);
_bus->sendData(0xC4);
_bus->sendCommand(0x3C);
_bus->sendData(0xCE);
_bus->sendCommand(0x3D);
_bus->sendData(0xD9);
_bus->sendCommand(0x3E);
_bus->sendData(0xE3);
_bus->sendCommand(0x3F);
_bus->sendData(0xEC);
_bus->sendCommand(0x40);
_bus->sendData(0xF3);
_bus->sendCommand(0x41);
_bus->sendData(0xF7);
_bus->sendCommand(0x42);
_bus->sendData(0xFC);
_bus->sendCommand(0x43);
_bus->sendData(0x00);
_bus->sendCommand(0x44);
_bus->sendData(0x06);
_bus->sendCommand(0x45);
_bus->sendData(0x0C);
_bus->sendCommand(0x46);
_bus->sendData(0x12);
_bus->sendCommand(0x47);
_bus->sendData(0x16);
_bus->sendCommand(0x48);
_bus->sendData(0x1C);
_bus->sendCommand(0x49);
_bus->sendData(0x23);
_bus->sendCommand(0x4A);
_bus->sendData(0x2E);
_bus->sendCommand(0x4B);
_bus->sendData(0x36);
_bus->sendCommand(0x4C);
_bus->sendData(0x3F);
_bus->sendCommand(0x4D);
_bus->sendData(0x47);
_bus->sendCommand(0x4E);
_bus->sendData(0x50);
_bus->sendCommand(0x4F);
_bus->sendData(0x57);
_bus->sendCommand(0x50);
_bus->sendData(0x5F);
_bus->sendCommand(0x51);
_bus->sendData(0x67);
_bus->sendCommand(0x52);
_bus->sendData(0x6F);
_bus->sendCommand(0x53);
_bus->sendData(0x76);
_bus->sendCommand(0x54);
_bus->sendData(0x7F);
_bus->sendCommand(0x55);
_bus->sendData(0x87);
_bus->sendCommand(0x56);
_bus->sendData(0x90);
_bus->sendCommand(0x57);
_bus->sendData(0x99);
_bus->sendCommand(0x58);
_bus->sendData(0xA3);
_bus->sendCommand(0x59);
_bus->sendData(0xAD);
_bus->sendCommand(0x5A);
_bus->sendData(0xB4);
_bus->sendCommand(0x5B);
_bus->sendData(0xBB);
_bus->sendCommand(0x5C);
_bus->sendData(0xC4);
_bus->sendCommand(0x5D);
_bus->sendData(0xCE);
_bus->sendCommand(0x5E);
_bus->sendData(0xD9);
_bus->sendCommand(0x5F);
_bus->sendData(0xE3);
_bus->sendCommand(0x60);
_bus->sendData(0xEC);
_bus->sendCommand(0x61);
_bus->sendData(0xF3);
_bus->sendCommand(0x62);
_bus->sendData(0xF7);
_bus->sendCommand(0x63);
_bus->sendData(0xFC);
_bus->sendCommand(0xFF);
_bus->sendData(0x00); // Page0
// Display ON Setting
_bus->sendCommand(0x28);
_bus->sendData(0x38); // GON=1, DTE=1, D=10
delay(40);
_bus->sendCommand(0x28);
_bus->sendData(0x3C); // GON=1, DTE=1, D=11
_bus->sendCommand(0x22); // Start GRAM write
}
void Arduino_HX8347C::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
if ((x != _currentX) || (w != _currentW))
{
int16_t x_start = x + _xStart, x_end = x + w - 1 + _xStart;
_bus->writeCommand(0x02);
_bus->write(x_start >> 8);
_bus->writeCommand(0x03);
_bus->write(x_start & 0xFF);
_bus->writeCommand(0x04);
_bus->write(x_end >> 8);
_bus->writeCommand(0x05);
_bus->write(x_end & 0xFF);
_currentX = x;
_currentW = w;
}
if ((y != _currentY) || (h != _currentH))
{
int16_t y_start = y + _yStart, y_end = y + h - 1 + _yStart;
_bus->writeCommand(0x06);
_bus->write(y_start >> 8);
_bus->writeCommand(0x07);
_bus->write(y_start & 0xFF);
_bus->writeCommand(0x08);
_bus->write(y_end >> 8);
_bus->writeCommand(0x09);
_bus->write(y_end & 0xFF);
_currentY = y;
_currentH = h;
}
_bus->writeCommand(0x22); // write to RAM
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_HX8347C::setRotation(uint8_t r)
{
Arduino_TFT::setRotation(r);
switch (_rotation)
{
case 1:
_bus->sendCommand(0x36);
_bus->sendData(_invert ? 0x13 : 0x03);
_bus->sendCommand(0x16);
_bus->sendData(0x60);
break;
case 2:
_bus->sendCommand(0x36);
_bus->sendData(_invert ? 0x13 : 0x03);
_bus->sendCommand(0x16);
_bus->sendData(0x00);
break;
case 3:
_bus->sendCommand(0x36);
_bus->sendData(_invert ? 0x17 : 0x07);
_bus->sendCommand(0x16);
_bus->sendData(0x20);
break;
default: // case 0:
_bus->sendCommand(0x36);
_bus->sendData(_invert ? 0x17 : 0x07);
_bus->sendCommand(0x16);
_bus->sendData(0x40);
break;
}
}
void Arduino_HX8347C::invertDisplay(bool i)
{
_invert = _ips ^ i;
setRotation(_rotation); // set invert by calling setRotation()
}
void Arduino_HX8347C::displayOn(void)
{
_bus->sendCommand(0x28);
_bus->sendData(0x3C); // GON=1, DTE=1, D=11
}
void Arduino_HX8347C::displayOff(void)
{
_bus->sendCommand(0x28);
_bus->sendData(0x34); // GON=1, DTE=1, D=01
delay(40);
}

View File

@@ -0,0 +1,38 @@
/*
* start rewrite from:
* https://github.com/adafruit/Adafruit-GFX-Library.git
*/
#ifndef _ARDUINO_HX8347C_H_
#define _ARDUINO_HX8347C_H_
#include "../Arduino_GFX.h"
#include "../Arduino_TFT.h"
#define HX8347C_TFTWIDTH 240 ///< HX8347C max TFT width
#define HX8347C_TFTHEIGHT 320 ///< HX8347C max TFT height
#define HX8347C_RST_DELAY 120
class Arduino_HX8347C : public Arduino_TFT
{
public:
Arduino_HX8347C(
Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0,
bool ips = false, int16_t w = HX8347C_TFTWIDTH, int16_t h = HX8347C_TFTHEIGHT,
uint8_t col_offset1 = 0, uint8_t row_offset1 = 0, uint8_t col_offset2 = 0, uint8_t row_offset2 = 0);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void setRotation(uint8_t r) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
protected:
void tftInit() override;
bool _invert = false;
private:
};
#endif

View File

@@ -0,0 +1,127 @@
/*
* start rewrite from:
* https://github.com/adafruit/Adafruit-GFX-Library.git
*/
#include "Arduino_HX8347D.h"
#include "SPI.h"
Arduino_HX8347D::Arduino_HX8347D(
Arduino_DataBus *bus, int8_t rst, uint8_t r,
bool ips, int16_t w, int16_t h,
uint8_t col_offset1, uint8_t row_offset1, uint8_t col_offset2, uint8_t row_offset2)
: Arduino_TFT(bus, rst, r, ips, w, h, col_offset1, row_offset1, col_offset2, row_offset2)
{
}
bool Arduino_HX8347D::begin(int32_t speed)
{
#if defined(__AVR__)
_override_datamode = SPI_MODE0;
#endif
return Arduino_TFT::begin(speed);
}
// Companion code to the above tables. Reads and issues
// a series of LCD commands stored in PROGMEM byte array.
void Arduino_HX8347D::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(HX8347D_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(HX8347D_RST_DELAY);
}
else
{
// Software Rest
}
_bus->batchOperation(hx8347d_init_operations, sizeof(hx8347d_init_operations));
invertDisplay(false);
}
void Arduino_HX8347D::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
if ((x != _currentX) || (w != _currentW))
{
int16_t x_start = x + _xStart, x_end = x + w - 1 + _xStart;
_bus->writeC8D8(0x02, x_start >> 8);
_bus->writeC8D8(0x03, x_start & 0xFF);
_bus->writeC8D8(0x04, x_end >> 8);
_bus->writeC8D8(0x05, x_end & 0xFF);
_currentX = x;
_currentW = w;
}
if ((y != _currentY) || (h != _currentH))
{
int16_t y_start = y + _yStart, y_end = y + h - 1 + _yStart;
_bus->writeC8D8(0x06, y_start >> 8);
_bus->writeC8D8(0x07, y_start & 0xFF);
_bus->writeC8D8(0x08, y_end >> 8);
_bus->writeC8D8(0x09, y_end & 0xFF);
_currentY = y;
_currentH = h;
}
_bus->writeCommand(0x22); // write to RAM
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_HX8347D::setRotation(uint8_t r)
{
Arduino_TFT::setRotation(r);
_bus->beginWrite();
switch (_rotation)
{
case 1:
_bus->writeC8D8(0x36, 0x03);
_bus->writeC8D8(0x16, 0x20);
break;
case 2:
_bus->writeC8D8(0x36, 0x07);
_bus->writeC8D8(0x16, 0x00);
break;
case 3:
_bus->writeC8D8(0x36, 0x07);
_bus->writeC8D8(0x16, 0x60);
break;
default: // case 0:
_bus->writeC8D8(0x36, 0x03);
_bus->writeC8D8(0x16, 0x40);
break;
}
_bus->endWrite();
}
void Arduino_HX8347D::invertDisplay(bool i)
{
_bus->beginWrite();
_bus->writeC8D8(HX8347D_DISPLAY_MODE_CONTROL, (_ips ^ i) ? HX8347D_INV_ON : HX8347D_INV_OFF);
_bus->endWrite();
}
void Arduino_HX8347D::displayOn(void)
{
_bus->sendCommand(0x28);
_bus->sendData(0x3C); // GON=1, DTE=1, D=11
}
void Arduino_HX8347D::displayOff(void)
{
_bus->sendCommand(0x28);
_bus->sendData(0x34); // GON=1, DTE=1, D=01
delay(40);
}

View File

@@ -0,0 +1,97 @@
/*
* start rewrite from:
* https://github.com/adafruit/Adafruit-GFX-Library.git
*/
#ifndef _ARDUINO_HX8347D_H_
#define _ARDUINO_HX8347D_H_
#include "../Arduino_GFX.h"
#include "../Arduino_TFT.h"
#define HX8347D_TFTWIDTH 240 ///< HX8347D max TFT width
#define HX8347D_TFTHEIGHT 320 ///< HX8347D max TFT height
#define HX8347D_RST_DELAY 120
#define HX8347D_DISPLAY_MODE_CONTROL 0x01 // Display Mode control
#define HX8347D_INV_OFF 0x00 // INV_ON disable
#define HX8347D_INV_ON 0x02 // INV_ON enable
static const uint8_t hx8347d_init_operations[] = {
BEGIN_WRITE,
WRITE_C8_D8, 0xEA, 0x00,
WRITE_C8_D8, 0xEB, 0x20,
WRITE_C8_D8, 0xEC, 0x0C,
WRITE_C8_D8, 0xED, 0xC4,
WRITE_C8_D8, 0xE8, 0x38,
WRITE_C8_D8, 0xE9, 0x10,
WRITE_C8_D8, 0xF1, 0x01,
WRITE_C8_D8, 0xF2, 0x10,
WRITE_C8_D8, 0x40, 0x01,
WRITE_C8_D8, 0x41, 0x00,
WRITE_C8_D8, 0x42, 0x00,
WRITE_C8_D8, 0x43, 0x10,
WRITE_C8_D8, 0x44, 0x0E,
WRITE_C8_D8, 0x45, 0x24,
WRITE_C8_D8, 0x46, 0x04,
WRITE_C8_D8, 0x47, 0x50,
WRITE_C8_D8, 0x48, 0x02,
WRITE_C8_D8, 0x49, 0x13,
WRITE_C8_D8, 0x4A, 0x19,
WRITE_C8_D8, 0x4B, 0x19,
WRITE_C8_D8, 0x4C, 0x16,
WRITE_C8_D8, 0x50, 0x1B,
WRITE_C8_D8, 0x51, 0x31,
WRITE_C8_D8, 0x52, 0x2F,
WRITE_C8_D8, 0x53, 0x3F,
WRITE_C8_D8, 0x54, 0x3F,
WRITE_C8_D8, 0x55, 0x3E,
WRITE_C8_D8, 0x56, 0x2F,
WRITE_C8_D8, 0x57, 0x7B,
WRITE_C8_D8, 0x58, 0x09,
WRITE_C8_D8, 0x59, 0x06,
WRITE_C8_D8, 0x5A, 0x06,
WRITE_C8_D8, 0x5B, 0x0C,
WRITE_C8_D8, 0x5C, 0x1D,
WRITE_C8_D8, 0x5D, 0xCC,
WRITE_C8_D8, 0x1B, 0x1B,
WRITE_C8_D8, 0x1A, 0x01,
WRITE_C8_D8, 0x24, 0x2F,
WRITE_C8_D8, 0x25, 0x57,
WRITE_C8_D8, 0x23, 0x88,
WRITE_C8_D8, 0x18, 0x34,
WRITE_C8_D8, 0x19, 0x01,
WRITE_C8_D8, 0x1F, 0x88,
WRITE_C8_D8, 0x1F, 0x80,
WRITE_C8_D8, 0x1F, 0x90,
WRITE_C8_D8, 0x1F, 0xD0,
WRITE_C8_D8, 0x17, 0x05,
WRITE_C8_D8, 0x28, 0x38,
WRITE_C8_D8, 0x28, 0x3F,
WRITE_C8_D8, 0x16, 0x18,
END_WRITE};
class Arduino_HX8347D : public Arduino_TFT
{
public:
Arduino_HX8347D(
Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0,
bool ips = false, int16_t w = HX8347D_TFTWIDTH, int16_t h = HX8347D_TFTHEIGHT,
uint8_t col_offset1 = 0, uint8_t row_offset1 = 0, uint8_t col_offset2 = 0, uint8_t row_offset2 = 0);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void setRotation(uint8_t r) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
protected:
void tftInit() override;
bool _invert = false;
private:
};
#endif

View File

@@ -0,0 +1,422 @@
/*
* start rewrite from:
* https://github.com/adafruit/Adafruit-GFX-Library.git
*/
#include "Arduino_HX8352C.h"
Arduino_HX8352C::Arduino_HX8352C(
Arduino_DataBus *bus, int8_t rst, uint8_t r,
bool ips, int16_t w, int16_t h,
uint8_t col_offset1, uint8_t row_offset1, uint8_t col_offset2, uint8_t row_offset2)
: Arduino_TFT(bus, rst, r, ips, w, h, col_offset1, row_offset1, col_offset2, row_offset2)
{
_invert = ips;
}
bool Arduino_HX8352C::begin(int32_t speed)
{
return Arduino_TFT::begin(speed);
}
// Companion code to the above tables. Reads and issues
// a series of LCD commands stored in PROGMEM byte array.
void Arduino_HX8352C::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(HX8352C_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(HX8352C_RST_DELAY);
}
else
{
// Software Rest
}
// LCD Init For 3.0inch LCD Panel with HX8352C.
// Power Voltage Setting
_bus->sendCommand(0x1A);
_bus->sendData(0x02); // BT
_bus->sendCommand(0x1B);
_bus->sendData(0x8B); // VRH
//****VCOM offset**///
_bus->sendCommand(0x23);
_bus->sendData(0x00); // SEL_VCM
_bus->sendCommand(0x24);
_bus->sendData(0x5D); // VCM
_bus->sendCommand(0x25);
_bus->sendData(0x15); // VDV
_bus->sendCommand(0x2D);
_bus->sendData(0x01); // NOW[2:0]=001
//****OPON**//
_bus->sendCommand(0xE8);
_bus->sendData(0x60);
// Power on Setting
_bus->sendCommand(0x18);
_bus->sendData(0x04); // Frame rate 72Hz
_bus->sendCommand(0x19);
_bus->sendData(0x01); // OSC_EN='1', start Osc
_bus->sendCommand(0x01);
_bus->sendData(0x00); // DP_STB='0', out deep sleep
_bus->sendCommand(0x1F);
_bus->sendData(0x88); // STB=0
delay(5);
_bus->sendCommand(0x1F);
_bus->sendData(0x80); // DK=0
delay(5);
_bus->sendCommand(0x1F);
_bus->sendData(0x90); // PON=1
delay(5);
_bus->sendCommand(0x1F);
_bus->sendData(0xD0); // VCOMG=1
delay(5);
// 262k/65k color selection
_bus->sendCommand(0x17);
_bus->sendData(0x05); // default 0x06 262k color // 0x05 65k color
// SET PANEL
_bus->sendCommand(0x29);
_bus->sendData(0x31); // 400 lines
_bus->sendCommand(0x71);
_bus->sendData(0x1A); // RTN
// Gamma 2.2 Setting
_bus->sendCommand(0x40);
_bus->sendData(0x00);
_bus->sendCommand(0x41);
_bus->sendData(0x77);
_bus->sendCommand(0x42);
_bus->sendData(0x77);
_bus->sendCommand(0x43);
_bus->sendData(0x00);
_bus->sendCommand(0x44);
_bus->sendData(0x04);
_bus->sendCommand(0x45);
_bus->sendData(0x00);
_bus->sendCommand(0x46);
_bus->sendData(0x00);
_bus->sendCommand(0x47);
_bus->sendData(0x00);
_bus->sendCommand(0x48);
_bus->sendData(0x77);
_bus->sendCommand(0x49);
_bus->sendData(0x00);
_bus->sendCommand(0x4A);
_bus->sendData(0x00);
_bus->sendCommand(0x4B);
_bus->sendData(0x08);
_bus->sendCommand(0x4C);
_bus->sendData(0x00);
_bus->sendCommand(0x4D);
_bus->sendData(0x00);
_bus->sendCommand(0x4E);
_bus->sendData(0x00);
// Set DGC
_bus->sendCommand(0xFF);
_bus->sendData(0x01); // Page1
_bus->sendCommand(0x00);
_bus->sendData(0x01); // DGC_EN
_bus->sendCommand(0x01);
_bus->sendData(0x00);
_bus->sendCommand(0x02);
_bus->sendData(0x06);
_bus->sendCommand(0x03);
_bus->sendData(0x0C);
_bus->sendCommand(0x04);
_bus->sendData(0x12);
_bus->sendCommand(0x05);
_bus->sendData(0x16);
_bus->sendCommand(0x06);
_bus->sendData(0x1C);
_bus->sendCommand(0x07);
_bus->sendData(0x23);
_bus->sendCommand(0x08);
_bus->sendData(0x2E);
_bus->sendCommand(0x09);
_bus->sendData(0x36);
_bus->sendCommand(0x0A);
_bus->sendData(0x3F);
_bus->sendCommand(0x0B);
_bus->sendData(0x47);
_bus->sendCommand(0x0C);
_bus->sendData(0x50);
_bus->sendCommand(0x0D);
_bus->sendData(0x57);
_bus->sendCommand(0x0E);
_bus->sendData(0x5F);
_bus->sendCommand(0x0F);
_bus->sendData(0x67);
_bus->sendCommand(0x10);
_bus->sendData(0x6F);
_bus->sendCommand(0x11);
_bus->sendData(0x76);
_bus->sendCommand(0x12);
_bus->sendData(0x7F);
_bus->sendCommand(0x13);
_bus->sendData(0x87);
_bus->sendCommand(0x14);
_bus->sendData(0x90);
_bus->sendCommand(0x15);
_bus->sendData(0x99);
_bus->sendCommand(0x16);
_bus->sendData(0xA3);
_bus->sendCommand(0x17);
_bus->sendData(0xAD);
_bus->sendCommand(0x18);
_bus->sendData(0xB4);
_bus->sendCommand(0x19);
_bus->sendData(0xBB);
_bus->sendCommand(0x1A);
_bus->sendData(0xC4);
_bus->sendCommand(0x1B);
_bus->sendData(0xCE);
_bus->sendCommand(0x1C);
_bus->sendData(0xD9);
_bus->sendCommand(0x1D);
_bus->sendData(0xE3);
_bus->sendCommand(0x1E);
_bus->sendData(0xEC);
_bus->sendCommand(0x1F);
_bus->sendData(0xF3);
_bus->sendCommand(0x20);
_bus->sendData(0xF7);
_bus->sendCommand(0x21);
_bus->sendData(0xFC);
_bus->sendCommand(0x22);
_bus->sendData(0x00);
_bus->sendCommand(0x23);
_bus->sendData(0x06);
_bus->sendCommand(0x24);
_bus->sendData(0x0C);
_bus->sendCommand(0x25);
_bus->sendData(0x12);
_bus->sendCommand(0x26);
_bus->sendData(0x16);
_bus->sendCommand(0x27);
_bus->sendData(0x1C);
_bus->sendCommand(0x28);
_bus->sendData(0x23);
_bus->sendCommand(0x29);
_bus->sendData(0x2E);
_bus->sendCommand(0x2A);
_bus->sendData(0x36);
_bus->sendCommand(0x2B);
_bus->sendData(0x3F);
_bus->sendCommand(0x2C);
_bus->sendData(0x47);
_bus->sendCommand(0x2D);
_bus->sendData(0x50);
_bus->sendCommand(0x2E);
_bus->sendData(0x57);
_bus->sendCommand(0x2F);
_bus->sendData(0x5F);
_bus->sendCommand(0x30);
_bus->sendData(0x67);
_bus->sendCommand(0x31);
_bus->sendData(0x6F);
_bus->sendCommand(0x32);
_bus->sendData(0x76);
_bus->sendCommand(0x33);
_bus->sendData(0x7F);
_bus->sendCommand(0x34);
_bus->sendData(0x87);
_bus->sendCommand(0x35);
_bus->sendData(0x90);
_bus->sendCommand(0x36);
_bus->sendData(0x99);
_bus->sendCommand(0x37);
_bus->sendData(0xA3);
_bus->sendCommand(0x38);
_bus->sendData(0xAD);
_bus->sendCommand(0x39);
_bus->sendData(0xB4);
_bus->sendCommand(0x3A);
_bus->sendData(0xBB);
_bus->sendCommand(0x3B);
_bus->sendData(0xC4);
_bus->sendCommand(0x3C);
_bus->sendData(0xCE);
_bus->sendCommand(0x3D);
_bus->sendData(0xD9);
_bus->sendCommand(0x3E);
_bus->sendData(0xE3);
_bus->sendCommand(0x3F);
_bus->sendData(0xEC);
_bus->sendCommand(0x40);
_bus->sendData(0xF3);
_bus->sendCommand(0x41);
_bus->sendData(0xF7);
_bus->sendCommand(0x42);
_bus->sendData(0xFC);
_bus->sendCommand(0x43);
_bus->sendData(0x00);
_bus->sendCommand(0x44);
_bus->sendData(0x06);
_bus->sendCommand(0x45);
_bus->sendData(0x0C);
_bus->sendCommand(0x46);
_bus->sendData(0x12);
_bus->sendCommand(0x47);
_bus->sendData(0x16);
_bus->sendCommand(0x48);
_bus->sendData(0x1C);
_bus->sendCommand(0x49);
_bus->sendData(0x23);
_bus->sendCommand(0x4A);
_bus->sendData(0x2E);
_bus->sendCommand(0x4B);
_bus->sendData(0x36);
_bus->sendCommand(0x4C);
_bus->sendData(0x3F);
_bus->sendCommand(0x4D);
_bus->sendData(0x47);
_bus->sendCommand(0x4E);
_bus->sendData(0x50);
_bus->sendCommand(0x4F);
_bus->sendData(0x57);
_bus->sendCommand(0x50);
_bus->sendData(0x5F);
_bus->sendCommand(0x51);
_bus->sendData(0x67);
_bus->sendCommand(0x52);
_bus->sendData(0x6F);
_bus->sendCommand(0x53);
_bus->sendData(0x76);
_bus->sendCommand(0x54);
_bus->sendData(0x7F);
_bus->sendCommand(0x55);
_bus->sendData(0x87);
_bus->sendCommand(0x56);
_bus->sendData(0x90);
_bus->sendCommand(0x57);
_bus->sendData(0x99);
_bus->sendCommand(0x58);
_bus->sendData(0xA3);
_bus->sendCommand(0x59);
_bus->sendData(0xAD);
_bus->sendCommand(0x5A);
_bus->sendData(0xB4);
_bus->sendCommand(0x5B);
_bus->sendData(0xBB);
_bus->sendCommand(0x5C);
_bus->sendData(0xC4);
_bus->sendCommand(0x5D);
_bus->sendData(0xCE);
_bus->sendCommand(0x5E);
_bus->sendData(0xD9);
_bus->sendCommand(0x5F);
_bus->sendData(0xE3);
_bus->sendCommand(0x60);
_bus->sendData(0xEC);
_bus->sendCommand(0x61);
_bus->sendData(0xF3);
_bus->sendCommand(0x62);
_bus->sendData(0xF7);
_bus->sendCommand(0x63);
_bus->sendData(0xFC);
_bus->sendCommand(0xFF);
_bus->sendData(0x00); // Page0
// Display ON Setting
_bus->sendCommand(0x28);
_bus->sendData(0x38); // GON=1, DTE=1, D=10
delay(40);
_bus->sendCommand(0x28);
_bus->sendData(0x3C); // GON=1, DTE=1, D=11
_bus->sendCommand(0x22); // Start GRAM write
}
void Arduino_HX8352C::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
if ((x != _currentX) || (w != _currentW))
{
int16_t x_start = x + _xStart, x_end = x + w - 1 + _xStart;
_bus->writeCommand(0x02);
_bus->write(x_start >> 8);
_bus->writeCommand(0x03);
_bus->write(x_start & 0xFF);
_bus->writeCommand(0x04);
_bus->write(x_end >> 8);
_bus->writeCommand(0x05);
_bus->write(x_end & 0xFF);
_currentX = x;
_currentW = w;
}
if ((y != _currentY) || (h != _currentH))
{
int16_t y_start = y + _yStart, y_end = y + h - 1 + _yStart;
_bus->writeCommand(0x06);
_bus->write(y_start >> 8);
_bus->writeCommand(0x07);
_bus->write(y_start & 0xFF);
_bus->writeCommand(0x08);
_bus->write(y_end >> 8);
_bus->writeCommand(0x09);
_bus->write(y_end & 0xFF);
_currentY = y;
_currentH = h;
}
_bus->writeCommand(0x22); // write to RAM
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_HX8352C::setRotation(uint8_t r)
{
Arduino_TFT::setRotation(r);
switch (_rotation)
{
case 1:
_bus->sendCommand(0x36);
_bus->sendData(_invert ? 0x13 : 0x03);
_bus->sendCommand(0x16);
_bus->sendData(0x60);
break;
case 2:
_bus->sendCommand(0x36);
_bus->sendData(_invert ? 0x13 : 0x03);
_bus->sendCommand(0x16);
_bus->sendData(0x00);
break;
case 3:
_bus->sendCommand(0x36);
_bus->sendData(_invert ? 0x17 : 0x07);
_bus->sendCommand(0x16);
_bus->sendData(0x20);
break;
default: // case 0:
_bus->sendCommand(0x36);
_bus->sendData(_invert ? 0x17 : 0x07);
_bus->sendCommand(0x16);
_bus->sendData(0x40);
break;
}
}
void Arduino_HX8352C::invertDisplay(bool i)
{
_invert = _ips ^ i;
setRotation(_rotation); // set invert by calling setRotation()
}
void Arduino_HX8352C::displayOn(void)
{
_bus->sendCommand(0x28);
_bus->sendData(0x3C); // GON=1, DTE=1, D=11
}
void Arduino_HX8352C::displayOff(void)
{
_bus->sendCommand(0x28);
_bus->sendData(0x34); // GON=1, DTE=1, D=01
delay(40);
}

View File

@@ -0,0 +1,38 @@
/*
* start rewrite from:
* https://github.com/adafruit/Adafruit-GFX-Library.git
*/
#ifndef _ARDUINO_HX8352C_H_
#define _ARDUINO_HX8352C_H_
#include "../Arduino_GFX.h"
#include "../Arduino_TFT.h"
#define HX8352C_TFTWIDTH 240 ///< HX8352C max TFT width
#define HX8352C_TFTHEIGHT 400 ///< HX8352C max TFT height
#define HX8352C_RST_DELAY 120
class Arduino_HX8352C : public Arduino_TFT
{
public:
Arduino_HX8352C(
Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0,
bool ips = false, int16_t w = HX8352C_TFTWIDTH, int16_t h = HX8352C_TFTHEIGHT,
uint8_t col_offset1 = 0, uint8_t row_offset1 = 0, uint8_t col_offset2 = 0, uint8_t row_offset2 = 0);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void setRotation(uint8_t r) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
protected:
void tftInit() override;
bool _invert = false;
private:
};
#endif

View File

@@ -0,0 +1,145 @@
#include "Arduino_HX8357A.h"
Arduino_HX8357A::Arduino_HX8357A(Arduino_DataBus *bus, int8_t rst, uint8_t r, bool ips)
: Arduino_TFT(bus, rst, r, ips, HX8357A_TFTWIDTH, HX8357A_TFTHEIGHT, 0, 0, 0, 0)
{
}
bool Arduino_HX8357A::begin(int32_t speed)
{
return Arduino_TFT::begin(speed);
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_HX8357A::setRotation(uint8_t r)
{
Arduino_TFT::setRotation(r);
switch (_rotation)
{
case 3:
// TODO: not working
r = (HX8357A_MADCTL_MY | HX8357A_MADCTL_MV | HX8357A_MADCTL_BGR);
break;
case 2:
r = (HX8357A_MADCTL_MX | HX8357A_MADCTL_BGR);
break;
case 1:
// TODO: not working
r = (HX8357A_MADCTL_MX | HX8357A_MADCTL_MV | HX8357A_MADCTL_BGR);
break;
default: // case 0:
r = (HX8357A_MADCTL_MY | HX8357A_MADCTL_BGR);
break;
}
_bus->beginWrite();
_bus->writeC8D8(HX8357A_MEMORY_ACCESS_CONTROL, r);
_bus->endWrite();
}
void Arduino_HX8357A::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
if ((x != _currentX) || (w != _currentW))
{
_currentX = x;
_currentW = w;
x += _xStart;
_data16.value = x;
_bus->writeC8D8(HX8357A_COLUMN_ADDRESS_COUNTER_2, _data16.msb);
_bus->writeC8D8(HX8357A_COLUMN_ADDRESS_COUNTER_1, _data16.lsb);
_bus->writeC8D8(HX8357A_COLUMN_ADDRESS_START_2, _data16.msb);
_bus->writeC8D8(HX8357A_COLUMN_ADDRESS_START_1, _data16.lsb);
_data16.value = x + w - 1;
_bus->writeC8D8(HX8357A_COLUMN_ADDRESS_END_2, _data16.msb);
_bus->writeC8D8(HX8357A_COLUMN_ADDRESS_END_1, _data16.lsb);
}
if ((y != _currentY) || (h != _currentH))
{
_currentY = y;
_currentH = h;
y += _yStart;
_data16.value = y;
_bus->writeC8D8(HX8357A_ROW_ADDRESS_COUNTER_2, _data16.msb);
_bus->writeC8D8(HX8357A_ROW_ADDRESS_COUNTER_1, _data16.lsb);
_bus->writeC8D8(HX8357A_ROW_ADDRESS_START_2, _data16.msb);
_bus->writeC8D8(HX8357A_ROW_ADDRESS_START_1, _data16.lsb);
_data16.value = y + h - 1;
_bus->writeC8D8(HX8357A_ROW_ADDRESS_END_2, _data16.msb);
_bus->writeC8D8(HX8357A_ROW_ADDRESS_END_1, _data16.lsb);
}
_bus->writeCommand(HX8357A_SRAM_CONTROL);
}
void Arduino_HX8357A::invertDisplay(bool i)
{
_bus->beginWrite();
_bus->writeC8D8(HX8357A_DISPLAY_MODE_CONTROL, (_ips ^ i) ? HX8357A_INV_ON : HX8357A_INV_OFF);
_bus->endWrite();
}
void Arduino_HX8357A::displayOn(void)
{
_bus->beginWrite();
_bus->writeC8D8(HX8357A_OSC_CONTROL_2, 0x01); // OSC_EN=1
_bus->endWrite();
delay(5);
_bus->beginWrite();
_bus->writeC8D8(HX8357A_POWER_CONTROL_1, 0x88); // PON=0, DK=1
_bus->writeC8D8(HX8357A_DISPLAY_MODE_CONTROL, 0x00); // DP_STB=00
_bus->writeC8D8(HX8357A_POWER_CONTROL_4, 0x03); // AP=011
_bus->writeC8D8(HX8357A_POWER_CONTROL_1, 0x80); // DK=0
_bus->endWrite();
delay(3);
_bus->beginWrite();
_bus->writeC8D8(HX8357A_POWER_CONTROL_1, 0x90); // PON=1
_bus->endWrite();
delay(3);
_bus->beginWrite();
_bus->writeC8D8(HX8357A_POWER_CONTROL_1, 0xD0); // VCOMG=1
_bus->writeC8D8(HX8357A_DISPLAY_CONTROL_3, 0x3C); // GON=1, DTE=1, D[1:0]=11
_bus->endWrite();
}
void Arduino_HX8357A::displayOff(void)
{
_bus->beginWrite();
_bus->writeC8D8(HX8357A_DISPLAY_CONTROL_3, 0x34); // GON=1, DTE=1, D[1:0]=01
_bus->writeC8D8(HX8357A_POWER_CONTROL_1, 0x90); // VCOMG=0
_bus->endWrite();
delay(1);
_bus->beginWrite();
_bus->writeC8D8(HX8357A_POWER_CONTROL_1, 0x88); // PON=0, DK=1
_bus->writeC8D8(HX8357A_POWER_CONTROL_4, 0x00); // AP=000
_bus->writeC8D8(HX8357A_POWER_CONTROL_1, 0x89); // STB=1
_bus->endWrite();
}
// Companion code to the above tables. Reads and issues
// a series of LCD commands stored in PROGMEM byte array.
void Arduino_HX8357A::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(HX8357A_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(HX8357A_RST_DELAY);
}
else
{
// Software Rest
}
_bus->batchOperation(hx8357a_init_operations, sizeof(hx8357a_init_operations));
invertDisplay(false);
}

View File

@@ -0,0 +1,454 @@
#ifndef _ARDUINO_HX8357A_H_
#define _ARDUINO_HX8357A_H_
#include "../Arduino_GFX.h"
#include "../Arduino_TFT.h"
#define HX8357A_TFTWIDTH 320 // HX8357A max TFT width
#define HX8357A_TFTHEIGHT 480 // HX8357A max TFT height
#define HX8357A_RST_DELAY 1200 // delay ms wait for reset finish
#define HX8357A_HIMAX_ID 0x00 // Himax ID
#define HX8357A_DISPLAY_MODE_CONTROL 0x01 // Display Mode control
#define HX8357A_COLUMN_ADDRESS_START_2 0x02 // Column address start 2
#define HX8357A_COLUMN_ADDRESS_START_1 0x03 // Column address start 1
#define HX8357A_COLUMN_ADDRESS_END_2 0x04 // Column address end 2
#define HX8357A_COLUMN_ADDRESS_END_1 0x05 // Column address end 1
#define HX8357A_ROW_ADDRESS_START_2 0x06 // Row address start 2
#define HX8357A_ROW_ADDRESS_START_1 0x07 // Row address start 1
#define HX8357A_ROW_ADDRESS_END_2 0x08 // Row address end 2
#define HX8357A_ROW_ADDRESS_END_1 0x09 // Row address end 1
#define HX8357A_PARTIAL_ASREA_START_ROW_2 0x0A // Partial area start row 2
#define HX8357A_PARTIAL_AREA_START_ROW_1 0x0B // Partial area start row 1
#define HX8357A_PARTIAL_AREA_END_ROW_2 0x0C // Partial area end row 2
#define HX8357A_PARTIAL_AREA_END_ROW_1 0x0D // Partial area end row 1
#define HX8357A_VERTICAL_SCROLL_TOP_FIXED_AREA_2 0x0E // Vertical Scroll Top fixed area 2
#define HX8357A_VERTICAL_SCROLL_TOP_FIXED_AREA_1 0x0F // Vertical Scroll Top fixed area 1
#define HX8357A_VERTICAL_SCROLL_HEIGHT_AREA_2 0x10 // Vertical Scroll height area 2
#define HX8357A_VERTICAL_SCROLL_HEIGHT_AREA_1 0x11 // Vertical Scroll height area 1
#define HX8357A_VERTICAL_SCROLL_BUTTON_AREA_2 0x12 // Vertical Scroll Button area 2
#define HX8357A_VERTICAL_SCROLL_BUTTON_AREA_1 0x13 // Vertical Scroll Button area 1
#define HX8357A_VERTICAL_SCROLL_START_ADDRESS_2 0x14 // Vertical Scroll Start address 2
#define HX8357A_VERTICAL_SCROLL_START_ADDRESS_1 0x15 // Vertical Scroll Start address 1
#define HX8357A_MEMORY_ACCESS_CONTROL 0x16 // Memory Access control
#define HX8357A_COLMOD 0x17 // COLMOD
#define HX8357A_OSC_CONTROL_1 0x18 // OSC Control 1
#define HX8357A_OSC_CONTROL_2 0x19 // OSC Control 2
#define HX8357A_POWER_CONTROL_6 0x1A // Power Control 6
#define HX8357A_POWER_CONTROL_5 0x1B // Power Control 5
#define HX8357A_POWER_CONTROL_4 0x1C // Power Control 4
#define HX8357A_POWER_CONTROL_3 0x1D // Power Control 3
#define HX8357A_POWER_CONTROL_2 0x1E // Power Control 2
#define HX8357A_POWER_CONTROL_1 0x1F // Power Control 1
#define HX8357A_SRAM_CONTROL 0x22 // SRAM Control
#define HX8357A_VCOM_CONTROL_1 0x23 // VCOM Control 1
#define HX8357A_VCOM_CONTROL_2 0x24 // VCOM Control 2
#define HX8357A_VCOM_CONTROL_3 0x25 // VCOM Control 3
#define HX8357A_DISPLAY_CONTROL_1 0x26 // Display Control 1
#define HX8357A_DISPLAY_CONTROL_2 0x27 // Display Control 2
#define HX8357A_DISPLAY_CONTROL_3 0x28 // Display Control 3
#define HX8357A_FRAME_RATE_CONTROL_1 0x29 // Frame Rate control 1
#define HX8357A_FRAME_RATE_CONTROL_2 0x2A // Frame Rate Control 2
#define HX8357A_FRAME_RATE_CONTROL_3 0x2B // Frame Rate Control 3
#define HX8357A_FRAME_RATE_CONTROL_4 0x2C // Frame Rate Control 4
#define HX8357A_CYCLE_CONTROL_2 0x2D // Cycle Control 2
#define HX8357A_CYCLE_CONTROL_3 0x2E // Cycle Control 3
#define HX8357A_DISPLAY_INVERSION 0x2F // Display inversion
#define HX8357A_RGB_INTERFACE_CONTROL_1 0x31 // RGB interface control 1
#define HX8357A_RGB_INTERFACE_CONTROL_2 0x32 // RGB interface control 2
#define HX8357A_RGB_INTERFACE_CONTROL_3 0x33 // RGB interface control 3
#define HX8357A_RGB_INTERFACE_CONTROL_4 0x34 // RGB interface control 4
#define HX8357A_PANEL_CHARACTERIC 0x36 // Panel Characteric
#define HX8357A_OTP_CONTROL_1 0x38 // OTP Control 1
#define HX8357A_OTP_CONTROL_2 0x39 // OTP Control 2
#define HX8357A_OTP_CONTROL_3 0x3A // OTP Control 3
#define HX8357A_OTP_CONTROL_4 0x3B // OTP Control 4
#define HX8357A_CABC_CONTROL_1 0x3C // CABC Control 1
#define HX8357A_CABC_CONTROL_2 0x3D // CABC Control 2
#define HX8357A_CABC_CONTROL_3 0x3E // CABC Control 3
#define HX8357A_CABC_CONTROL_4 0x3F // CABC Control 4
#define HX8357A_R1_CONTROL_1 0x40 // r1 Control (1)
#define HX8357A_R1_CONTROL_2 0x41 // r1 Control (2)
#define HX8357A_R1_CONTROL_3 0x42 // r1 Control (3)
#define HX8357A_R1_CONTROL_4 0x43 // r1 Control (4)
#define HX8357A_R1_CONTROL_5 0x44 // r1 Control (5)
#define HX8357A_R1_CONTROL_6 0x45 // r1 Control (6)
#define HX8357A_R1_CONTROL_7 0x46 // r1 Control (7)
#define HX8357A_R1_CONTROL_8 0x47 // r1 Control (8)
#define HX8357A_R1_CONTROL_9 0x48 // r1 Control (9)
#define HX8357A_R1_CONTROL_10 0x49 // r1 Control (10)
#define HX8357A_R1_CONTROL_11 0x4A // r1 Control (11)
#define HX8357A_R1_CONTROL_12 0x4B // r1 Control (12)
#define HX8357A_R1_CONTROL_13 0x4C // r1 Control (13)
#define HX8357A_R1_CONTROL_18 0x50 // r1 Control (18)
#define HX8357A_R1_CONTROL_19 0x51 // r1 Control (19)
#define HX8357A_R1_CONTROL_20 0x52 // r1 Control (20)
#define HX8357A_R1_CONTROL_21 0x53 // r1 Control (21)
#define HX8357A_R1_CONTROL_22 0x54 // r1 Control (22)
#define HX8357A_R1_CONTROL_23 0x55 // r1 Control (23)
#define HX8357A_R1_CONTROL_24 0x56 // r1 Control (24)
#define HX8357A_R1_CONTROL_25 0x57 // r1 Control (25)
#define HX8357A_R1_CONTROL_26 0x58 // r1 Control (26)
#define HX8357A_R1_CONTROL_27 0x59 // r1 Control (27)
#define HX8357A_R1_CONTROL_28 0x5A // r1 Control (28)
#define HX8357A_R1_CONTROL_29 0x5B // r1 Control (29)
#define HX8357A_R1_CONTROL_30 0x5C // r1 Control (30)
#define HX8357A_R1_CONTROL_35 0x5D // r1 Control (35)
#define HX8357A_TE_CONTROL 0x60 // TE Control
#define HX8357A_ID1 0x61 // ID1
#define HX8357A_ID2 0x62 // ID2
#define HX8357A_ID3 0x63 // ID3
#define HX8357A_ID4 0x64 // ID4
#define HX8357A_MDDI_CONTROL_4 0x68 // MDDI Control 4
#define HX8357A_MDDI_CONTROL_5 0x69 // MDDI Control 5
#define HX8357A_GPIO_CONTROL_1 0x6B // GPIO Control 1
#define HX8357A_GPIO_CONTROL_2 0x6C // GPIO Control 2
#define HX8357A_GPIO_CONTROL_3 0x6D // GPIO Control 3
#define HX8357A_GPIO_CONTROL_4 0x6E // GPIO Control 4
#define HX8357A_GPIO_CONTROL_5 0x6F // GPIO Control 5
#define HX8357A_SUB_PANEL_CONTROL_1 0x70 // SUB_PANEL Control 1
#define HX8357A_SUB_PANEL_CONTROL_2 0x71 // SUB_PANEL Control 2
#define HX8357A_SUB_PANEL_CONTROL_3 0x72 // SUB_PANEL Control 3
#define HX8357A_SUB_PANEL_CONTROL_4 0x73 // SUB_PANEL Control 4
#define HX8357A_COLUMN_ADDRESS_COUNTER_2 0x80 // Column address counter 2
#define HX8357A_COLUMN_ADDRESS_COUNTER_1 0x81 // Column address counter 1
#define HX8357A_ROW_ADDRESS_COUNTER_2 0x82 // Row address counter 2
#define HX8357A_ROW_ADDRESS_COUNTER_1 0x83 // Row address counter 1
#define HX8357A_SET_VREF 0xE2 // Set VREF
#define HX8357A_POWER_SAVING_COUNTER_1 0xE4 // Power saving counter 1
#define HX8357A_POWER_SAVING_COUNTER_2 0xE5 // Power saving counter 2
#define HX8357A_POWER_SAVING_COUNTER_3 0xE6 // Power saving counter 3
#define HX8357A_POWER_SAVING_COUNTER_4 0xE7 // Power saving counter 4
#define HX8357A_OPON_CONTROL_1 0xE8 // OPON Control 1
#define HX8357A_OPON_CONTROL_2 0xE9 // OPON Control 2
#define HX8357A_CENON_CONTROL 0xF2 // GENON Control
#define HX8357A_SET_SPI_RRAD_INDEX 0xFD // Set SPI Rrad Index
#define HX8357A_GET_SPI_INDEX_DATA 0xFE // Get SPI Index data
#define HX8357A_PAGE_SELECT 0xFF // Page select
#define HX8357A_MADCTL_MY 0x80 // PAGE ADDRESS ORDER
#define HX8357A_MADCTL_MX 0x40 // COLUMN ADDRESS ORDER
#define HX8357A_MADCTL_MV 0x20 // PAGE/COLUMN SELECTION
#define HX8357A_MADCTL_BGR 0x08 // RGB-BGR ORDER
#define HX8357A_MADCTL_SS 0x02 // SOURCE OUTPUT ORDER
#define HX8357A_MADCTL_GS 0x01 // GATE OUTPUT ORDER
#define HX8357A_INV_ON 0x20 // INV_ON enable
#define HX8357A_INV_OFF 0x00 // INV_ON disable
static const uint8_t hx8357a_init_operations[] = {
BEGIN_WRITE,
WRITE_C8_D8, HX8357A_PAGE_SELECT, 0x00, // Command page 0
END_WRITE,
DELAY, 15,
BEGIN_WRITE,
WRITE_C8_D8, HX8357A_POWER_CONTROL_6, 0x04, // VGH VGL VCL DDVDH
WRITE_C8_D8, HX8357A_POWER_CONTROL_5, 0x1C,
// Power Settng
WRITE_C8_D8, HX8357A_VCOM_CONTROL_1, 0x94, // Set VCOM offset, VMF=0x52
WRITE_C8_D8, HX8357A_VCOM_CONTROL_2, 0x69, // Set VCOMH voltage, VHH=0x64
WRITE_C8_D8, HX8357A_VCOM_CONTROL_3, 0x63, // Set VCOML voltage, VML=0x71
WRITE_C8_D8, HX8357A_OSC_CONTROL_2, 0x01,
END_WRITE,
DELAY, 10,
BEGIN_WRITE,
WRITE_C8_D8, HX8357A_POWER_CONTROL_6, 0x00, // VGH VGL VCL DDVDH
WRITE_C8_D8, HX8357A_POWER_CONTROL_1, 0x8A, //
WRITE_C8_D8, HX8357A_DISPLAY_MODE_CONTROL, 0x00, //
WRITE_C8_D8, HX8357A_POWER_CONTROL_4, 0x05, //
WRITE_C8_D8, HX8357A_POWER_CONTROL_1, 0x82, //
END_WRITE,
DELAY, 10,
BEGIN_WRITE,
WRITE_C8_D8, HX8357A_POWER_CONTROL_1, 0x92, //
END_WRITE,
DELAY, 10,
BEGIN_WRITE,
WRITE_C8_D8, HX8357A_POWER_CONTROL_1, 0xD4, //
WRITE_C8_D8, HX8357A_COLMOD, 0x55, // 16-bit/pixel
WRITE_C8_D8, HX8357A_OSC_CONTROL_1, 0x21, // Fosc=130%*5.2MHZ 21
WRITE_C8_D8, HX8357A_POWER_CONTROL_3, 0x00, // FS0[1:0]=01, Set the operating frequency of the step-up circuit 1
WRITE_C8_D8, HX8357A_POWER_CONTROL_2, 0x00,
WRITE_C8_D8, HX8357A_DISPLAY_CONTROL_1, 0x33,
WRITE_C8_D8, HX8357A_DISPLAY_CONTROL_2, 0x01,
WRITE_C8_D8, HX8357A_FRAME_RATE_CONTROL_1, 0x00,
WRITE_C8_D8, HX8357A_FRAME_RATE_CONTROL_2, 0x00,
WRITE_C8_D8, HX8357A_FRAME_RATE_CONTROL_3, 0x01, // 0A
WRITE_C8_D8, HX8357A_FRAME_RATE_CONTROL_4, 0x0A,
WRITE_C8_D8, HX8357A_CYCLE_CONTROL_2, 0x20,
WRITE_C8_D8, HX8357A_CYCLE_CONTROL_3, 0xA3,
WRITE_C8_D8, HX8357A_DISPLAY_INVERSION, 0x00, // 00 100416
WRITE_C8_D8, HX8357A_RGB_INTERFACE_CONTROL_1, 0x00, // RGB MODE1 0X03=RGB MODE2
WRITE_C8_D8, HX8357A_RGB_INTERFACE_CONTROL_2, 0x00,
WRITE_C8_D8, HX8357A_RGB_INTERFACE_CONTROL_3, 0x08,
WRITE_C8_D8, HX8357A_RGB_INTERFACE_CONTROL_4, 0x08,
WRITE_C8_D8, HX8357A_PANEL_CHARACTERIC, 0x02, // REV
// Gamma
WRITE_C8_D8, HX8357A_R1_CONTROL_1, 0x01,
WRITE_C8_D8, HX8357A_R1_CONTROL_2, 0x0F,
WRITE_C8_D8, HX8357A_R1_CONTROL_3, 0x0F,
WRITE_C8_D8, HX8357A_R1_CONTROL_4, 0x26,
WRITE_C8_D8, HX8357A_R1_CONTROL_5, 0x2C,
WRITE_C8_D8, HX8357A_R1_CONTROL_6, 0x3C,
WRITE_C8_D8, HX8357A_R1_CONTROL_7, 0x0B,
WRITE_C8_D8, HX8357A_R1_CONTROL_8, 0x5F,
WRITE_C8_D8, HX8357A_R1_CONTROL_9, 0x00,
WRITE_C8_D8, HX8357A_R1_CONTROL_10, 0x06,
WRITE_C8_D8, HX8357A_R1_CONTROL_11, 0x09,
WRITE_C8_D8, HX8357A_R1_CONTROL_12, 0x0E,
WRITE_C8_D8, HX8357A_R1_CONTROL_13, 0x16,
WRITE_C8_D8, HX8357A_R1_CONTROL_18, 0x01,
WRITE_C8_D8, HX8357A_R1_CONTROL_19, 0x1D,
WRITE_C8_D8, HX8357A_R1_CONTROL_20, 0x21,
WRITE_C8_D8, HX8357A_R1_CONTROL_21, 0x3A,
WRITE_C8_D8, HX8357A_R1_CONTROL_22, 0x39,
WRITE_C8_D8, HX8357A_R1_CONTROL_23, 0x3F,
WRITE_C8_D8, HX8357A_R1_CONTROL_24, 0x2D,
WRITE_C8_D8, HX8357A_R1_CONTROL_25, 0x7F,
WRITE_C8_D8, HX8357A_R1_CONTROL_26, 0x02,
WRITE_C8_D8, HX8357A_R1_CONTROL_27, 0x15,
WRITE_C8_D8, HX8357A_R1_CONTROL_28, 0x1B,
WRITE_C8_D8, HX8357A_R1_CONTROL_29, 0x1B,
WRITE_C8_D8, HX8357A_R1_CONTROL_30, 0x1A,
WRITE_C8_D8, HX8357A_R1_CONTROL_35, 0x55,
// #if 1
WRITE_C8_D8, 0xff, 0x01,
WRITE_C8_D8, 0x00, 0x01,
WRITE_C8_D8, 0x01, 0x00,
WRITE_C8_D8, 0x02, 0x01,
WRITE_C8_D8, 0x03, 0x03,
WRITE_C8_D8, 0x04, 0x05,
WRITE_C8_D8, 0x05, 0x06,
WRITE_C8_D8, 0x06, 0x08,
WRITE_C8_D8, 0x07, 0x0C,
WRITE_C8_D8, 0x08, 0x0E,
WRITE_C8_D8, 0x09, 0x11,
WRITE_C8_D8, 0x0A, 0x12,
WRITE_C8_D8, 0x0B, 0x14,
WRITE_C8_D8, 0x0C, 0x1B,
WRITE_C8_D8, 0x0D, 0x23,
WRITE_C8_D8, 0x0E, 0x29,
WRITE_C8_D8, 0x0F, 0x2F,
WRITE_C8_D8, 0x10, 0x34,
WRITE_C8_D8, 0x11, 0x39,
WRITE_C8_D8, 0x12, 0x3E,
WRITE_C8_D8, 0x13, 0x43,
WRITE_C8_D8, 0x14, 0x48,
WRITE_C8_D8, 0x15, 0x4C,
WRITE_C8_D8, 0x16, 0x51,
WRITE_C8_D8, 0x17, 0x55,
WRITE_C8_D8, 0x18, 0x59,
WRITE_C8_D8, 0x19, 0x5D,
WRITE_C8_D8, 0x1A, 0x60,
WRITE_C8_D8, 0x1B, 0x64,
WRITE_C8_D8, 0x1C, 0x68,
WRITE_C8_D8, 0x1D, 0x6C,
WRITE_C8_D8, 0x1E, 0x70,
WRITE_C8_D8, 0x1F, 0x73,
WRITE_C8_D8, 0x20, 0x77,
WRITE_C8_D8, 0x21, 0x7B,
WRITE_C8_D8, 0x22, 0x7F,
WRITE_C8_D8, 0x23, 0x83,
WRITE_C8_D8, 0x24, 0x87,
WRITE_C8_D8, 0x25, 0x8A,
WRITE_C8_D8, 0x26, 0x8E,
WRITE_C8_D8, 0x27, 0x92,
WRITE_C8_D8, 0x28, 0x96,
WRITE_C8_D8, 0x29, 0x9A,
WRITE_C8_D8, 0x2A, 0x9F,
WRITE_C8_D8, 0x2B, 0xA3,
WRITE_C8_D8, 0x2C, 0xA7,
WRITE_C8_D8, 0x2D, 0xAC,
WRITE_C8_D8, 0x2E, 0xAF,
WRITE_C8_D8, 0x2F, 0xB3,
WRITE_C8_D8, 0x30, 0xB7,
WRITE_C8_D8, 0x31, 0xBA,
WRITE_C8_D8, 0x32, 0xBE,
WRITE_C8_D8, 0x33, 0xC3,
WRITE_C8_D8, 0x34, 0xC7,
WRITE_C8_D8, 0x35, 0xCC,
WRITE_C8_D8, 0x36, 0xD1,
WRITE_C8_D8, 0x37, 0xD7,
WRITE_C8_D8, 0x38, 0xDD,
WRITE_C8_D8, 0x39, 0xE3,
WRITE_C8_D8, 0x3A, 0xE8,
WRITE_C8_D8, 0x3B, 0xEA,
WRITE_C8_D8, 0x3C, 0xEC,
WRITE_C8_D8, 0x3D, 0xEF,
WRITE_C8_D8, 0x3E, 0xF3,
WRITE_C8_D8, 0x3F, 0xF6,
WRITE_C8_D8, 0x40, 0xFE,
WRITE_C8_D8, 0x41, 0x00,
WRITE_C8_D8, 0x42, 0x01,
WRITE_C8_D8, 0x43, 0x03,
WRITE_C8_D8, 0x44, 0x05,
WRITE_C8_D8, 0x45, 0x06,
WRITE_C8_D8, 0x46, 0x08,
WRITE_C8_D8, 0x47, 0x0C,
WRITE_C8_D8, 0x48, 0x0E,
WRITE_C8_D8, 0x49, 0x11,
WRITE_C8_D8, 0x4A, 0x12,
WRITE_C8_D8, 0x4B, 0x14,
WRITE_C8_D8, 0x4C, 0x1B,
WRITE_C8_D8, 0x4D, 0x23,
WRITE_C8_D8, 0x4E, 0x29,
WRITE_C8_D8, 0x4F, 0x2F,
WRITE_C8_D8, 0x50, 0x34,
WRITE_C8_D8, 0x51, 0x39,
WRITE_C8_D8, 0x52, 0x3E,
WRITE_C8_D8, 0x53, 0x43,
WRITE_C8_D8, 0x54, 0x48,
WRITE_C8_D8, 0x55, 0x4C,
WRITE_C8_D8, 0x56, 0x51,
WRITE_C8_D8, 0x57, 0x55,
WRITE_C8_D8, 0x58, 0x59,
WRITE_C8_D8, 0x59, 0x5D,
WRITE_C8_D8, 0x5A, 0x60,
WRITE_C8_D8, 0x5B, 0x64,
WRITE_C8_D8, 0x5C, 0x68,
WRITE_C8_D8, 0x5D, 0x6C,
WRITE_C8_D8, 0x5E, 0x70,
WRITE_C8_D8, 0x5F, 0x73,
WRITE_C8_D8, 0x60, 0x77,
WRITE_C8_D8, 0x61, 0x7B,
WRITE_C8_D8, 0x62, 0x7F,
WRITE_C8_D8, 0x63, 0x83,
WRITE_C8_D8, 0x64, 0x87,
WRITE_C8_D8, 0x65, 0x8A,
WRITE_C8_D8, 0x66, 0x8E,
WRITE_C8_D8, 0x67, 0x92,
WRITE_C8_D8, 0x68, 0x96,
WRITE_C8_D8, 0x69, 0x9A,
WRITE_C8_D8, 0x6A, 0x9F,
WRITE_C8_D8, 0x6B, 0xA3,
WRITE_C8_D8, 0x6C, 0xA7,
WRITE_C8_D8, 0x6D, 0xAC,
WRITE_C8_D8, 0x6E, 0xAF,
WRITE_C8_D8, 0x6F, 0xB3,
WRITE_C8_D8, 0x70, 0xB7,
WRITE_C8_D8, 0x71, 0xBA,
WRITE_C8_D8, 0x72, 0xBE,
WRITE_C8_D8, 0x73, 0xC3,
WRITE_C8_D8, 0x74, 0xC7,
WRITE_C8_D8, 0x75, 0xCC,
WRITE_C8_D8, 0x76, 0xD1,
WRITE_C8_D8, 0x77, 0xD7,
WRITE_C8_D8, 0x78, 0xDD,
WRITE_C8_D8, 0x79, 0xE3,
WRITE_C8_D8, 0x7A, 0xE8,
WRITE_C8_D8, 0x7B, 0xEA,
WRITE_C8_D8, 0x7C, 0xEC,
WRITE_C8_D8, 0x7D, 0xEF,
WRITE_C8_D8, 0x7E, 0xF3,
WRITE_C8_D8, 0x7F, 0xF6,
WRITE_C8_D8, 0x80, 0xFE,
WRITE_C8_D8, 0x81, 0x00,
WRITE_C8_D8, 0x82, 0x01,
WRITE_C8_D8, 0x83, 0x03,
WRITE_C8_D8, 0x84, 0x05,
WRITE_C8_D8, 0x85, 0x06,
WRITE_C8_D8, 0x86, 0x08,
WRITE_C8_D8, 0x87, 0x0C,
WRITE_C8_D8, 0x88, 0x0E,
WRITE_C8_D8, 0x89, 0x11,
WRITE_C8_D8, 0x8A, 0x12,
WRITE_C8_D8, 0x8B, 0x14,
WRITE_C8_D8, 0x8C, 0x1B,
WRITE_C8_D8, 0x8D, 0x23,
WRITE_C8_D8, 0x8E, 0x29,
WRITE_C8_D8, 0x8F, 0x2F,
WRITE_C8_D8, 0x90, 0x34,
WRITE_C8_D8, 0x91, 0x39,
WRITE_C8_D8, 0x92, 0x3E,
WRITE_C8_D8, 0x93, 0x43,
WRITE_C8_D8, 0x94, 0x48,
WRITE_C8_D8, 0x95, 0x4C,
WRITE_C8_D8, 0x96, 0x51,
WRITE_C8_D8, 0x97, 0x55,
WRITE_C8_D8, 0x98, 0x59,
WRITE_C8_D8, 0x99, 0x5D,
WRITE_C8_D8, 0x9A, 0x60,
WRITE_C8_D8, 0x9B, 0x64,
WRITE_C8_D8, 0x9C, 0x68,
WRITE_C8_D8, 0x9D, 0x6C,
WRITE_C8_D8, 0x9E, 0x70,
WRITE_C8_D8, 0x9F, 0x73,
WRITE_C8_D8, 0xA0, 0x77,
WRITE_C8_D8, 0xA1, 0x7B,
WRITE_C8_D8, 0xA2, 0x7F,
WRITE_C8_D8, 0xA3, 0x83,
WRITE_C8_D8, 0xA4, 0x87,
WRITE_C8_D8, 0xA5, 0x8A,
WRITE_C8_D8, 0xA6, 0x8E,
WRITE_C8_D8, 0xA7, 0x92,
WRITE_C8_D8, 0xA8, 0x96,
WRITE_C8_D8, 0xA9, 0x9A,
WRITE_C8_D8, 0xAA, 0x9F,
WRITE_C8_D8, 0xAB, 0xA3,
WRITE_C8_D8, 0xAC, 0xA7,
WRITE_C8_D8, 0xAD, 0xAC,
WRITE_C8_D8, 0xAE, 0xAF,
WRITE_C8_D8, 0xAF, 0xB3,
WRITE_C8_D8, 0xB0, 0xB7,
WRITE_C8_D8, 0xB1, 0xBA,
WRITE_C8_D8, 0xB2, 0xBE,
WRITE_C8_D8, 0xB3, 0xC3,
WRITE_C8_D8, 0xB4, 0xC7,
WRITE_C8_D8, 0xB5, 0xCC,
WRITE_C8_D8, 0xB6, 0xD1,
WRITE_C8_D8, 0xB7, 0xD7,
WRITE_C8_D8, 0xB8, 0xDD,
WRITE_C8_D8, 0xB9, 0xE3,
WRITE_C8_D8, 0xBA, 0xE8,
WRITE_C8_D8, 0xBB, 0xEA,
WRITE_C8_D8, 0xBC, 0xEC,
WRITE_C8_D8, 0xBD, 0xEF,
WRITE_C8_D8, 0xBE, 0xF3,
WRITE_C8_D8, 0xBF, 0xF6,
WRITE_C8_D8, 0xC0, 0xFE,
WRITE_C8_D8, 0xff, 0x00,
WRITE_C8_D8, HX8357A_TE_CONTROL, 0x08,
WRITE_C8_D8, HX8357A_CENON_CONTROL, 0x00,
WRITE_C8_D8, HX8357A_POWER_SAVING_COUNTER_1, 0x1F, // EQVCI_M1=0x00
WRITE_C8_D8, HX8357A_POWER_SAVING_COUNTER_2, 0x1F, // EQGND_M1=0x1C
WRITE_C8_D8, HX8357A_POWER_SAVING_COUNTER_3, 0x20, // EQVCI_M0=0x1C
WRITE_C8_D8, HX8357A_POWER_SAVING_COUNTER_4, 0x00, // EQGND_M0=0x1C
WRITE_C8_D8, HX8357A_OPON_CONTROL_1, 0xD1,
WRITE_C8_D8, HX8357A_OPON_CONTROL_2, 0xC0,
WRITE_C8_D8, HX8357A_DISPLAY_CONTROL_3, 0x38,
END_WRITE,
DELAY, 80,
BEGIN_WRITE,
WRITE_C8_D8, HX8357A_DISPLAY_CONTROL_3, 0x3C, // GON=1, DTE=1, D[1:0]=11
END_WRITE,
DELAY, 100};
class Arduino_HX8357A : public Arduino_TFT
{
public:
Arduino_HX8357A(Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0, bool ips = false);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void setRotation(uint8_t r) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
protected:
void tftInit() override;
private:
};
#endif

View File

@@ -0,0 +1,102 @@
#include "Arduino_HX8357B.h"
Arduino_HX8357B::Arduino_HX8357B(Arduino_DataBus *bus, int8_t rst, uint8_t r, bool ips /* = false */)
: Arduino_TFT(bus, rst, r, ips, HX8357B_TFTWIDTH, HX8357B_TFTHEIGHT, 0, 0, 0, 0)
{
}
bool Arduino_HX8357B::begin(int32_t speed)
{
return Arduino_TFT::begin(speed);
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_HX8357B::setRotation(uint8_t r)
{
Arduino_TFT::setRotation(r);
switch (_rotation)
{
case 3:
r = (HX8357B_MADCTL_MX | HX8357B_MADCTL_MY | HX8357B_MADCTL_MV | HX8357B_MADCTL_BGR);
break;
case 2:
r = (HX8357B_MADCTL_MY | HX8357B_MADCTL_BGR);
break;
case 1:
r = (HX8357B_MADCTL_MV | HX8357B_MADCTL_BGR);
break;
default: // case 0:
r = (HX8357B_MADCTL_MX | HX8357B_MADCTL_BGR);
break;
}
_bus->beginWrite();
_bus->writeC8D8(HX8357B_SET_ADDRESS_MODE, r);
_bus->endWrite();
}
void Arduino_HX8357B::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
if ((x != _currentX) || (w != _currentW))
{
_currentX = x;
_currentW = w;
x += _xStart;
_bus->writeC8D16D16(HX8357B_SET_COLUMN_ADDRESS, x, x + w - 1);
}
if ((y != _currentY) || (h != _currentH))
{
_currentY = y;
_currentH = h;
y += _yStart;
_bus->writeC8D16D16(HX8357B_SET_PAGE_ADDRESS, y, y + h - 1);
}
_bus->writeCommand(HX8357B_WRITE_MEMORY_START); // write to RAM
}
void Arduino_HX8357B::invertDisplay(bool i)
{
_bus->sendCommand((_ips ^ i) ? HX8357B_ENTER_INVERSION_MODE : HX8357B_EXIT_INVERSION_MODE);
}
void Arduino_HX8357B::displayOn(void)
{
_bus->sendCommand(HX8357B_EXIT_SLEEP_MODE);
delay(HX8357B_SLPOUT_DELAY);
}
void Arduino_HX8357B::displayOff(void)
{
_bus->sendCommand(HX8357B_ENTER_SLEEP_MODE);
delay(HX8357B_SLPIN_DELAY);
}
void Arduino_HX8357B::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(HX8357B_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(HX8357B_RST_DELAY);
}
else
{
// Software Rest
_bus->sendCommand(HX8357B_SOFTWARE_RESET);
delay(HX8357B_RST_DELAY);
}
_bus->batchOperation(hx8357b_init_operations, sizeof(hx8357b_init_operations));
invertDisplay(false);
}

View File

@@ -0,0 +1,177 @@
/*
* start rewrite from:
* https://github.com/adafruit/Adafruit-GFX-Library.git
*/
#ifndef _ARDUINO_HX8357B_H_
#define _ARDUINO_HX8357B_H_
#include "../Arduino_GFX.h"
#include "../Arduino_TFT.h"
#define HX8357B_TFTWIDTH 320 ///< HX8357B max TFT width
#define HX8357B_TFTHEIGHT 480 ///< HX8357B max TFT height
#define HX8357B_RST_DELAY 120 ///< delay ms wait for reset finish
#define HX8357B_SLPIN_DELAY 120 ///< delay ms wait for sleep in finish
#define HX8357B_SLPOUT_DELAY 120 ///< delay ms wait for sleep out finish
#define HX8357B_NOP 0x00 // 6.2.1 NOP
#define HX8357B_SOFTWARE_RESET 0x01 // 6.2.2 Software Reset (01h)
#define HX8357B_GET_RED_CHANNEL 0x06 // 6.2.3 Get_red_channel (06h)
#define HX8357B_GET_GREEN_CHANNEL 0x07 // 6.2.4 Get_green_channel (07h)
#define HX8357B_GET_BLUE_CHANNEL 0x08 // 6.2.5 Get_blue_channel (08h)
#define HX8357B_GET_POWER_MODE 0x0A // 6.2.6 Get_power_mode (0Ah)
#define HX8357B_READ_DISPLAY_MADCTL 0x0B // 6.2.7 Read Display MADCTL (0Bh)
#define HX8357B_GET_PIXEL_FORMAT 0x0C // 6.2.8 Get_pixel_format (0Ch)
#define HX8357B_GET_DISPLAY_MODE 0x0D // 6.2.9 Get_display_mode (0Dh)
#define HX8357B_GET_SIGNAL_MODE 0x0E // 6.2.10 Get_signal_mode (0Eh)
#define HX8357B_GET_DIAGNOSTIC_RESULT 0x0F // 6.2.11 Get_diagnostic_result (0Fh)
#define HX8357B_ENTER_SLEEP_MODE 0x10 // 6.2.12 Enter_sleep_mode (10h)
#define HX8357B_EXIT_SLEEP_MODE 0x11 // 6.2.13 Exit_sleep_mode (11h)
#define HX8357B_ENTER_PARTIAL_MODE 0x12 // 6.2.14 Enter_partial_mode (12h)
#define HX8357B_ENTER_NORMAL_MODE 0x13 // 6.2.15 Enter_normal_mode (13h)
#define HX8357B_EXIT_INVERSION_MODE 0x20 // 6.2.16 Exit_inversion_mode (20h)
#define HX8357B_ENTER_INVERSION_MODE 0x21 // 6.2.17 Enter_inversion_mode (21h)
#define HX8357B_SET_DISPLAY_OFF 0x28 // 6.2.18 Set_display_off (28h)
#define HX8357B_SET_DISPLAY_ON 0x29 // 6.2.19 Set_display_on (29h)
#define HX8357B_SET_COLUMN_ADDRESS 0x2A // 6.2.20 Set_column_address (2Ah)
#define HX8357B_SET_PAGE_ADDRESS 0x2B // 6.2.21 Set_page_address (2Bh)
#define HX8357B_WRITE_MEMORY_START 0x2C // 6.2.22 Write_memory_start (2Ch)
#define HX8357B_READ_MEMORY_START 0x2E // 6.2.23 Read_memory_start (2Eh)
#define HX8357B_SET_PARTIAL_AREA 0x30 // 6.2.24 Set_partial_area (30h)
#define HX8357B_SET_SCROLL_AREA 0x33 // 6.2.25 Set_scroll_area (33h)
#define HX8357B_SET_TEAR_OFF 0x34 // 6.2.26 Set_tear_off (34h)
#define HX8357B_SET_TEAR_ON 0x35 // 6.2.27 Set_tear_on (35h)
#define HX8357B_SET_ADDRESS_MODE 0x36 // 6.2.28 Set_address_mode (36h)
#define HX8357B_SET_SCROLL_START 0x37 // 6.2.29 Set_scroll_start (37h)
#define HX8357B_EXIT_IDLE_MODE 0x38 // 6.2.30 Exit_idle_mode (38h)
#define HX8357B_ENTER_IDLE_MODE 0x39 // 6.2.31 Enter_Idle_mode (39h)
#define HX8357B_SET_PIXEL_FORMAT 0x3A // 6.2.32 Set_pixel_format (3Ah)
#define HX8357B_WRITE_MEMORY_CONTINUE 0x3C // 6.2.33 Write_memory_contiune (3Ch)
#define HX8357B_READ_MEMORY_CONTINUE 0x3E // 6.2.34 Read_memory_continue (3Eh)
#define HX8357B_SET_TEAR_SCAN_LINES 0x44 // 6.2.35 Set tear scan lines(44h)
#define HX8357B_GET_SCAN_LINES 0x45 // 6.2.36 Get scan lines(45h)
#define HX8357B_READ_DDB_START 0xA1 // 6.2.37 Read_DDB_start (A1h)
#define HX8357B_WRITE_DISPLAY_BRIGHTNESS 0x51 // 6.2.38 Write Display Brightness (51h)
#define HX8357B_READ_DISPLAY_BRIGHTNESS 0x52 // 6.2.39 Read Display Brightness Value (52h)
#define HX8357B_WRITE_CTRL_DISPLAY 0x53 // 6.2.40 Write CTRL Display (53h)
#define HX8357B_READ_CTRL_DISPLAY 0x54 // 6.2.41 Read CTRL Value Display (54h)
#define HX8357B_WRITE_CONTENT_ADAPTIVE_BRIGHTNESS 0x55 // 6.2.42 Write Content Adaptive Brightness Control (55h)
#define HX8357B_READ_CONTENT_ADAPTIVE_BRIGHTNESS 0x56 // 6.2.43 Read Content Adaptive Brightness Control (56h)
#define HX8357B_WRITE_CABC_MINIMUM_BRIGHTNESS 0x5E // 6.2.44 Write CABC minimum brightness (5Eh)
#define HX8357B_READ_CABC_MINIMUM_BRIGHTNESS 0x5F // 6.2.45 Read CABC minimum brightness (5Fh)
#define HX8357B_READ_AUTO_BRIGHTNESS_SD_RESULT 0x68 // 6.2.46 Read Automatic Brightness Control Self-Diagnostic Result (68h)
#define HX8357B_SET_EXTENDED_COMMAND_SET 0xB0 // 6.2.47 Set extended command set (B0h)
#define HX8357B_SET_DEEP_STANDBY_MODE 0xB1 // 6.2.48 Set Deep Standby mode (B1h)
#define HX8357B_SET_GRAM_ACCESS_INTERFACE 0xB3 // 6.2.49 Set GRAM access and Interface (B3h)
#define HX8357B_SET_DISPLAY_MODE 0xB4 // 6.2.50 Set Display mode (B4h)
#define HX8357B_GET_DEVICE_ID 0xBF // 6.2.51 Get Device ID (BFh)
#define HX8357B_SET_PANEL_DRIVING 0xC0 // 6.2.52 Set Panel Driving (C0h)
#define HX8357B_SET_DISPLAY_TIMING_NORMAL 0xC1 // 6.2.53 Set display timing for Normal mode (C1h)
#define HX8357B_SET_DISPLAY_TIMING_PARTIAL 0xC2 // 6.2.54 Set display timing for Partial mode (C2h)
#define HX8357B_SET_DISPLAY_TIMING_IDLE 0xC3 // 6.2.55 Set display timing for Idle mode (C3h)
#define HX8357B_SET_DISPLAY_FRAME 0xC5 // 6.2.56 Set display frame (C5h)
#define HX8357B_SET_RGB_INTERFACE 0xC6 // 6.2.57 Set RGB Interface (C6h)
#define HX8357B_SET_GAMMA 0xC8 // 6.2.58 Set Gamma (C8h)
#define HX8357B_SET_POWER 0xD0 // 6.2.59 Set Power (D0h)
#define HX8357B_SET_VCOM 0xD1 // 6.2.60 Set VCOM (D1h)
#define HX8357B_SET_POWER_NORMAL 0xD2 // 6.2.61 Set Power for Normal mode (D2h)
#define HX8357B_SET_POWER_PARTIAL 0xD3 // 6.2.62 Set Power for Partial mode (D3h)
#define HX8357B_SET_POWER_IDLE 0xD4 // 6.2.63 Set Power for Idle mode (D4h)
#define HX8357B_SET_ID 0xE0 // 6.2.64 Set ID (E0h)
#define HX8357B_SET_OTP_SETTING 0xE2 // 6.2.65 Set OTP Related Setting (E2h)
#define HX8357B_SETOPKEY 0xE3 // 6.2.66 SETOTPKEY (E3h)
#define HX8357B_SETCABC 0xE4 // 6.2.67 SETCABC(E4h)
#define HX8357B_SET_PANEL_RELATED 0xE9 // 6.2.68 Set Panel related (E9h)
#define HX8357B_SET_EP_FUNCTION 0xEE // 6.2.69 Set EQ function (EEh)
#define HX8357B_MADCTL_MY 0x80 ///< Bottom to top
#define HX8357B_MADCTL_MX 0x40 ///< Right to left
#define HX8357B_MADCTL_MV 0x20 ///< Reverse Mode
#define HX8357B_MADCTL_ML 0x10 ///< LCD refresh Bottom to top
#define HX8357B_MADCTL_RGB 0x00 ///< Red-Green-Blue pixel order
#define HX8357B_MADCTL_BGR 0x08 ///< Blue-Green-Red pixel order
#define HX8357B_MADCTL_MH 0x04 ///< LCD refresh right to left
static const uint8_t hx8357b_init_operations[] = {
BEGIN_WRITE,
WRITE_COMMAND_8, HX8357B_EXIT_SLEEP_MODE,
END_WRITE,
DELAY, HX8357B_SLPOUT_DELAY,
BEGIN_WRITE,
WRITE_COMMAND_8, HX8357B_SET_EP_FUNCTION,
WRITE_BYTES, 4, 0x02, 0x01, 0x02, 0x01,
WRITE_C8_D8, HX8357B_SET_DISPLAY_MODE, 0x00, // Set RM, DM
WRITE_COMMAND_8, HX8357B_SET_PANEL_DRIVING,
WRITE_BYTES, 5,
0x10, // REV SM GS
0x3B, // NL[5:0]
0x00, // SCN[6:0]
0x02, // NDL 0 PTS[2:0]
0x11, // PTG ISC[3:0]
WRITE_C8_D8, HX8357B_SET_DISPLAY_TIMING_NORMAL, 0x10, // ne inversion
WRITE_COMMAND_8, HX8357B_SET_GAMMA,
WRITE_BYTES, 12,
0x00, // KP1,KP0
0x32, // KP3,KP2
0x36, // KP5,KP4
0x45, // RP1,RP0
0x06, // VRP0 01
0x16, // VRP1
0x37, // KN1,KN0
0x75, // KN3,KN2
0x77, // KN5,KN4
0x54, // RN1,RN0
0x0c, // VRN0
0x00, // VRN1 01
WRITE_COMMAND_8, HX8357B_SET_POWER,
WRITE_BYTES, 3,
0x44, // DDVDH :5.28
0x42, // BT VGH:15.84 VGL:-7.92
0x06, // VREG1 4.625V
WRITE_C8_D16, HX8357B_SET_VCOM, 0x43, 0x16, // VCOMH
WRITE_C8_D16, HX8357B_SET_POWER_NORMAL, 0x04, 0x22, // 12
WRITE_C8_D16, HX8357B_SET_POWER_PARTIAL, 0x04, 0x12,
WRITE_C8_D16, HX8357B_SET_POWER_IDLE, 0x07, 0x12,
WRITE_C8_D8, HX8357B_SET_PANEL_RELATED, 0x00,
WRITE_C8_D8, HX8357B_SET_DISPLAY_FRAME, 0x08, // 61.51Hz
WRITE_C8_D8, HX8357B_SET_PIXEL_FORMAT, 0X55,
END_WRITE,
DELAY, HX8357B_SLPOUT_DELAY,
BEGIN_WRITE,
WRITE_COMMAND_8, HX8357B_SET_DISPLAY_ON, // Display On
END_WRITE,
DELAY, 50};
class Arduino_HX8357B : public Arduino_TFT
{
public:
Arduino_HX8357B(Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0, bool ips = false);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void setRotation(uint8_t r) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
protected:
void tftInit() override;
private:
};
#endif

View File

@@ -0,0 +1,136 @@
#include "Arduino_HX8369A.h"
Arduino_HX8369A::Arduino_HX8369A(
Arduino_DataBus *bus, int8_t rst, uint8_t r,
bool ips, int16_t w, int16_t h,
uint8_t col_offset1, uint8_t row_offset1, uint8_t col_offset2, uint8_t row_offset2)
: Arduino_TFT(bus, rst, r, ips, w, h, col_offset1, row_offset1, col_offset2, row_offset2)
{
}
bool Arduino_HX8369A::begin(int32_t speed)
{
return Arduino_TFT::begin(speed);
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_HX8369A::setRotation(uint8_t r)
{
Arduino_TFT::setRotation(r);
switch (_rotation)
{
case 7:
r = (HX8369A_MADCTL_MV);
break;
case 6:
r = (HX8369A_MADCTL_MY);
break;
case 5:
r = (HX8369A_MADCTL_MY | HX8369A_MADCTL_MX | HX8369A_MADCTL_MV);
break;
case 4:
r = (HX8369A_MADCTL_MX);
break;
case 3:
r = (HX8369A_MADCTL_MY | HX8369A_MADCTL_MV);
break;
case 2:
r = (HX8369A_MADCTL_MY | HX8369A_MADCTL_MX);
break;
case 1:
r = (HX8369A_MADCTL_MX | HX8369A_MADCTL_MV);
break;
default: // case 0:
r = 0;
break;
}
_bus->beginWrite();
_bus->writeC8D8(HX8369A_SET_ADDRESS_MODE, r);
_bus->endWrite();
}
void Arduino_HX8369A::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
if ((x != _currentX) || (w != _currentW))
{
_currentX = x;
_currentW = w;
x += _xStart;
_bus->writeC8D16D16Split(HX8369A_SET_CLUMN_ADDRESS, x, x + w - 1);
}
if ((y != _currentY) || (h != _currentH))
{
_currentY = y;
_currentH = h;
y += _yStart;
_bus->writeC8D16D16Split(HX8369A_SET_PAGE_ADDRESS, y, y + h - 1);
}
_bus->writeCommand(HX8369A_WRITE_MEMORY_START);
}
void Arduino_HX8369A::invertDisplay(bool i)
{
_bus->sendCommand((_ips ^ i) ? HX8369A_ENTER_INVERSION_MODE : HX8369A_EXIT_INVERSION_MODE);
}
void Arduino_HX8369A::displayOn(void)
{
_bus->sendCommand(HX8369A_EXIT_SLEEP_MODE);
delay(120);
_bus->sendCommand(HX8369A_SET_DISPLAY_ON);
}
void Arduino_HX8369A::displayOff(void)
{
_bus->sendCommand(HX8369A_SET_DISPLAY_OFF);
delay(120);
_bus->sendCommand(HX8369A_ENTER_SLEEP_MODE);
}
// Companion code to the above tables. Reads and issues
// a series of LCD commands stored in PROGMEM byte array.
void Arduino_HX8369A::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(HX8369A_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(HX8369A_RST_DELAY);
}
else
{
_bus->sendCommand(HX8369A_SWRESET);
delay(HX8369A_RST_DELAY);
}
_bus->batchOperation(hx8369a_init_operations_part1, sizeof(hx8369a_init_operations_part1));
for (int i = 0; i <= 63; i++)
{
_bus->write(i * 8);
}
for (int i = 0; i <= 63; i++)
{
_bus->write(i * 4);
}
for (int i = 0; i <= 63; i++)
{
_bus->write(i * 8);
}
_bus->batchOperation(hx8369a_init_operations_part2, sizeof(hx8369a_init_operations_part2));
invertDisplay(false);
}

View File

@@ -0,0 +1,215 @@
#ifndef _ARDUINO_HX8369A_H_
#define _ARDUINO_HX8369A_H_
#include "../Arduino_GFX.h"
#include "../Arduino_TFT.h"
#define HX8369A_TFTWIDTH 480 // HX8369A max TFT width
#define HX8369A_TFTHEIGHT 864 // HX8369A max TFT height
#define HX8369A_RST_DELAY 150 // delay ms wait for reset finish
#define HX8369A_NOP 0x00
#define HX8369A_SWRESET 0x01
#define HX8369A_RDNUMPE 0x05 // Read number of the parity errors
#define HX8369A_GET_RED_CHANNEL 0x06
#define HX8369A_GET_GREEN_CHANNEL 0x07
#define HX8369A_GET_BLUE_CHANNEL 0x08
#define HX8369A_GET_POWER_MODE 0x0A
#define HX8369A_READ_DISPLAY_MADCTL 0x0B
#define HX8369A_GET_PIXEL_FORMAT 0x0C
#define HX8369A_GET_DISPLAY_MODE 0x0D
#define HX8369A_GET_SIGNAL_MODE 0x0E
#define HX8369A_GET_DIAGNOSTIC_RESULT 0x0F
#define HX8369A_ENTER_SLEEP_MODE 0x10
#define HX8369A_EXIT_SLEEP_MODE 0x11
#define HX8369A_ENTER_PARTIAL_MODE 0x12
#define HX8369A_ENTER_NORMAL_MODE 0x13
#define HX8369A_EXIT_INVERSION_MODE 0x20
#define HX8369A_ENTER_INVERSION_MODE 0x21
#define HX8369A_SET_GAMMA_CURVE 0x26
#define HX8369A_SET_DISPLAY_OFF 0x28
#define HX8369A_SET_DISPLAY_ON 0x29
#define HX8369A_SET_CLUMN_ADDRESS 0x2A
#define HX8369A_SET_PAGE_ADDRESS 0x2B
#define HX8369A_WRITE_MEMORY_START 0x2C
#define HX8369A_COLOUR_SET 0x2D
#define HX8369A_RAED_MEMORY_START 0x2E
#define HX8369A_SET_PARTIAL_AREA 0x30
#define HX8369A_SET_SCROLL_AREA 0x33
#define HX8369A_TEARING_EFFECT_LINE_OFF 0x34
#define HX8369A_SET_TEAR_ON 0x35
#define HX8369A_SET_ADDRESS_MODE 0x36
#define HX8369A_SET_SCROLL_START 0x37
#define HX8369A_IDLE_MODE_OFF 0x38
#define HX8369A_ENTER_IDLE_MODE 0x39
#define HX8369A_SET_PIXEL_FORMAT 0x3A
#define HX8369A_WRITE_MEMORY_CONTIUNE 0x3C
#define HX8369A_RAED_MEMORY_CONTINUE 0x3E
#define HX8369A_SET_TEAR_SCAN_LINES 0x44H
#define HX8369A_GET_THE_CURRENT_SCANLINE 0x45
#define HX8369A_WRITE_DISPLAY_BRIGHTNESS 0x51
#define HX8369A_READ_DISPLAY_BRIGHTNESS_VALUE 0x52
#define HX8369A_WRITE_CTRL_DISPLAY 0x53
#define HX8369A_READ_CTRL_VALUE_DISPLAY 0x54
#define HX8369A_WRITE_CONTENT_ADAPTIVE_BRIGHTNESS_CONTROL 0x55
#define HX8369A_READ_CONTENT_ADAPTIVE_BRIGHTNESS_CONTROL 0x56
#define HX8369A_WRITE_CABC_MINIMUM_BRIGHTNESS 0x5E
#define HX8369A_READ_CABC_MINIMUM_BRIGHTNESS 0x5F
#define HX8369A_READ_AUTOMATIC_BRIGHTNESS_CONTROL_SELF_DIAGNOSTIC_RESULT 0x68
#define HX8369A_READ_DDB_START 0xA1
#define HX8369A_READ_DDB_CONTINUE 0xA8
#define HX8369A_READ_ID1 0xDA
#define HX8369A_READ_ID2 0xDB
#define HX8369A_READ_ID3 0xDC
#define HX8369A_SETOSC 0xB0 // Set internal oscillator
#define HX8369A_SETPOWER 0xB1 // Set power
#define HX8369A_SETDISP 0xB2 // Set display related register
#define HX8369A_SETRGBIF 0xB3 // Set RGB interface related register
#define HX8369A_SETCYC 0xB4 // Set display waveform cycle
#define HX8369A_SETVCOM 0xB6 // Set VCOM voltage
#define HX8369A_SETEXTC 0xB9 // Set extension command
#define HX8369A_SETMIPI 0xBA
#define HX8369A_SETOTP 0xBB // Set OTP
#define HX8369A_SETDGCLUT 0xC1 // Set DGC LUT
#define HX8369A_SETID 0xC3 // Set ID
#define HX8369A_SETPANEL 0xCC
#define HX8369A_SETGIP 0xD5
#define HX8369A_SETTPSNR 0xD8
#define HX8369A_SETGAMMA 0xE0 // Set gamma curve related setting
#define HX8369A_SETOTPKEY 0xE9
#define HX8369A_GETHXID 0xF4
#define HX8369A_SETCNCD_GETCNCD 0xFD
#define HX8369A_SET_SPI_READ_INDEX 0xFE
#define HX8369A_GETSPIREAD 0xFF // Read command data
#define HX8369A_MADCTL_MY 0x80
#define HX8369A_MADCTL_MX 0x40
#define HX8369A_MADCTL_MV 0x20
#define HX8369A_MADCTL_ML 0x20
#define HX8369A_MADCTL_BGR 0x08
#define HX8369A_MADCTL_SS 0x04
static const uint8_t hx8369a_init_operations_part1[] = {
BEGIN_WRITE,
WRITE_COMMAND_8, HX8369A_SETEXTC,
WRITE_BYTES, 3, 0xFF, 0x83, 0x69,
WRITE_COMMAND_8, HX8369A_SETPOWER, // Set Power
WRITE_BYTES, 19,
0x01, 0x00, 0x34, 0x07,
0x00, 0x01, 0x0F, 0x2A,
0x32, 0x3F, 0x3F, 0x07,
0x10, 0x01, 0xE6, 0xE6,
0xE6, 0xE6, 0xE6,
WRITE_COMMAND_8, HX8369A_SETDISP,
WRITE_BYTES, 15,
0x00, 0x00, 0x03, 0x03,
0x70, 0x00, 0xFF, 0x00,
0x00, 0x00, 0x00, 0x03,
0x03, 0x00, 0x01,
WRITE_COMMAND_8, HX8369A_SETCYC,
WRITE_BYTES, 5, 0x00, 0x0C, 0xA0, 0x0E, 0x06,
WRITE_C8_D16, HX8369A_SETVCOM, 0x2C, 0x2C,
WRITE_COMMAND_8, HX8369A_SETGIP,
WRITE_BYTES, 26,
0x00, 0x05, 0x03, 0x00,
0x01, 0x09, 0x10, 0x80,
0x37, 0x37, 0x20, 0x31,
0x46, 0x8A, 0x57, 0x9B,
0x20, 0x31, 0x46, 0x8A,
0x57, 0x9B, 0x07, 0x0F,
0x02, 0x00,
WRITE_COMMAND_8, HX8369A_SETGAMMA,
WRITE_BYTES, 34,
0x00, 0x08, 0x0D, 0x2D,
0x34, 0x3F, 0x19, 0x38,
0x09, 0x0E, 0x0E, 0x12,
0x14, 0x12, 0x14, 0x13,
0x19, 0x00, 0x08, 0x0D,
0x2D, 0x34, 0x3F, 0x19,
0x38, 0x09, 0x0E, 0x0E,
0x12, 0x14, 0x12, 0x14,
0x13, 0x19,
WRITE_COMMAND_8, HX8369A_SETDGCLUT,
WRITE_BYTES, 127,
0x01, 0x02, 0x08, 0x12,
0x1A, 0x22, 0x2A, 0x31,
0x36, 0x3F, 0x48, 0x51,
0x58, 0x60, 0x68, 0x70,
0x78, 0x80, 0x88, 0x90,
0x98, 0xA0, 0xA7, 0xAF,
0xB6, 0xBE, 0xC7, 0xCE,
0xD6, 0xDE, 0xE6, 0xEF,
0xF5, 0xFB, 0xFC, 0xFE,
0x8C, 0xA4, 0x19, 0xEC,
0x1B, 0x4C, 0x40, 0x02,
0x08, 0x12, 0x1A, 0x22,
0x2A, 0x31, 0x36, 0x3F,
0x48, 0x51, 0x58, 0x60,
0x68, 0x70, 0x78, 0x80,
0x88, 0x90, 0x98, 0xA0,
0xA7, 0xAF, 0xB6, 0xBE,
0xC7, 0xCE, 0xD6, 0xDE,
0xE6, 0xEF, 0xF5, 0xFB,
0xFC, 0xFE, 0x8C, 0xA4,
0x19, 0xEC, 0x1B, 0x4C,
0x40, 0x02, 0x08, 0x12,
0x1A, 0x22, 0x2A, 0x31,
0x36, 0x3F, 0x48, 0x51,
0x58, 0x60, 0x68, 0x70,
0x78, 0x80, 0x88, 0x90,
0x98, 0xA0, 0xA7, 0xAF,
0xB6, 0xBE, 0xC7, 0xCE,
0xD6, 0xDE, 0xE6, 0xEF,
0xF5, 0xFB, 0xFC, 0xFE,
0x8C, 0xA4, 0x19, 0xEC,
0x1B, 0x4C, 0x40,
WRITE_COMMAND_8, HX8369A_COLOUR_SET};
static const uint8_t hx8369a_init_operations_part2[] = {
WRITE_C8_D8, HX8369A_SET_TEAR_ON, 0x00,
WRITE_C8_D8, HX8369A_SET_PIXEL_FORMAT, 0x55,
WRITE_COMMAND_8, HX8369A_EXIT_SLEEP_MODE,
END_WRITE,
DELAY, 120,
BEGIN_WRITE,
WRITE_COMMAND_8, HX8369A_SET_DISPLAY_ON, // Display On
END_WRITE};
class Arduino_HX8369A : public Arduino_TFT
{
public:
Arduino_HX8369A(
Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0, bool ips = false,
int16_t w = HX8369A_TFTWIDTH, int16_t h = HX8369A_TFTHEIGHT,
uint8_t col_offset1 = 0, uint8_t row_offset1 = 0, uint8_t col_offset2 = 0, uint8_t row_offset2 = 0);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void setRotation(uint8_t r) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
protected:
void tftInit() override;
private:
};
#endif

View File

@@ -0,0 +1,135 @@
/*
* start rewrite from:
* https://github.com/adafruit/Adafruit-GFX-Library.git
* https://github.com/lcdwiki/LCDWIKI_SPI
*/
#include "Arduino_ILI9225.h"
Arduino_ILI9225::Arduino_ILI9225(Arduino_DataBus *bus, int8_t rst, uint8_t r)
: Arduino_TFT(bus, rst, r, false, ILI9225_TFTWIDTH, ILI9225_TFTHEIGHT, 0, 0, 0, 0)
{
}
bool Arduino_ILI9225::begin(int32_t speed)
{
return Arduino_TFT::begin(speed);
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_ILI9225::setRotation(uint8_t r)
{
Arduino_TFT::setRotation(r);
_bus->beginWrite();
switch (_rotation)
{
case 3:
_bus->writeC8D16(ILI9225_DRIVER_OUTPUT_CTRL, 0x031C);
_bus->writeC8D16(ILI9225_ENTRY_MODE, 0x1038);
break;
case 2:
_bus->writeC8D16(ILI9225_DRIVER_OUTPUT_CTRL, 0x021C);
_bus->writeC8D16(ILI9225_ENTRY_MODE, 0x1030);
break;
case 1:
_bus->writeC8D16(ILI9225_DRIVER_OUTPUT_CTRL, 0x001C);
_bus->writeC8D16(ILI9225_ENTRY_MODE, 0x1038);
break;
default: // case 0:
_bus->writeC8D16(ILI9225_DRIVER_OUTPUT_CTRL, 0x011C);
_bus->writeC8D16(ILI9225_ENTRY_MODE, 0x1030);
break;
}
_bus->endWrite();
}
void Arduino_ILI9225::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
uint8_t cmd1, cmd2, cmd3;
if ((x != _currentX) || (w != _currentW))
{
_currentX = x;
_currentW = w;
x += _xStart;
if (_rotation & 0x01) // Landscape
{
cmd1 = ILI9225_VERTICAL_WINDOW_ADDR2;
cmd2 = ILI9225_VERTICAL_WINDOW_ADDR1;
cmd3 = ILI9225_RAM_ADDR_SET2;
}
else
{
cmd1 = ILI9225_HORIZONTAL_WINDOW_ADDR2;
cmd2 = ILI9225_HORIZONTAL_WINDOW_ADDR1;
cmd3 = ILI9225_RAM_ADDR_SET1;
}
_bus->writeC8D16(cmd1, x);
_bus->writeC8D16(cmd2, x + w - 1);
_bus->writeC8D16(cmd3, x);
}
if ((y != _currentY) || (h != _currentH))
{
_currentY = y;
_currentH = h;
y += _yStart;
if (_rotation & 0x01) // Landscape
{
cmd1 = ILI9225_HORIZONTAL_WINDOW_ADDR2;
cmd2 = ILI9225_HORIZONTAL_WINDOW_ADDR1;
cmd3 = ILI9225_RAM_ADDR_SET1;
}
else
{
cmd1 = ILI9225_VERTICAL_WINDOW_ADDR2;
cmd2 = ILI9225_VERTICAL_WINDOW_ADDR1;
cmd3 = ILI9225_RAM_ADDR_SET2;
}
_bus->writeC8D16(cmd1, y);
_bus->writeC8D16(cmd2, y + h - 1);
_bus->writeC8D16(cmd3, y);
}
_bus->writeCommand(ILI9225_GRAM_DATA_REG); // write to RAM
}
void Arduino_ILI9225::invertDisplay(bool)
{
// Not Implemented
}
void Arduino_ILI9225::displayOn(void)
{
_bus->sendCommand(ILI9225_POWER_CTRL1);
_bus->sendData16(0x0800); // Set SAP,DSTB,STB
}
void Arduino_ILI9225::displayOff(void)
{
_bus->sendCommand(ILI9225_POWER_CTRL1);
_bus->sendData16(0x0801); // Set SAP,DSTB,STB
}
void Arduino_ILI9225::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(ILI9225_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(ILI9225_RST_DELAY);
}
else
{
// Software Rest
}
_bus->batchOperation(ili9225_init_operations, sizeof(ili9225_init_operations));
}

View File

@@ -0,0 +1,124 @@
/*
* start rewrite from:
* https://github.com/adafruit/Adafruit-GFX-Library.git
*/
#ifndef _ARDUINO_ILI9225_H_
#define _ARDUINO_ILI9225_H_
#include "../Arduino_GFX.h"
#include "../Arduino_TFT.h"
#define ILI9225_TFTWIDTH 176 ///< ILI9225 max TFT width
#define ILI9225_TFTHEIGHT 220 ///< ILI9225 max TFT height
#define ILI9225_RST_DELAY 150 ///< delay ms wait for reset finish
#define ILI9225_SLPIN_DELAY 150 ///< delay ms wait for sleep in finish
#define ILI9225_SLPOUT_DELAY 150 ///< delay ms wait for sleep out finish
#define ILI9225_DRIVER_OUTPUT_CTRL 0x01 // Driver Output Control
#define ILI9225_LCD_AC_DRIVING_CTRL 0x02 // LCD AC Driving Control
#define ILI9225_ENTRY_MODE 0x03 // Entry Mode
#define ILI9225_DISP_CTRL1 0x07 // Display Control 1
#define ILI9225_BLANK_PERIOD_CTRL1 0x08 // Blank Period Control
#define ILI9225_FRAME_CYCLE_CTRL 0x0B // Frame Cycle Control
#define ILI9225_INTERFACE_CTRL 0x0C // Interface Control
#define ILI9225_OSC_CTRL 0x0F // Osc Control
#define ILI9225_POWER_CTRL1 0x10 // Power Control 1
#define ILI9225_POWER_CTRL2 0x11 // Power Control 2
#define ILI9225_POWER_CTRL3 0x12 // Power Control 3
#define ILI9225_POWER_CTRL4 0x13 // Power Control 4
#define ILI9225_POWER_CTRL5 0x14 // Power Control 5
#define ILI9225_VCI_RECYCLING 0x15 // VCI Recycling
#define ILI9225_RAM_ADDR_SET1 0x20 // Horizontal GRAM Address Set
#define ILI9225_RAM_ADDR_SET2 0x21 // Vertical GRAM Address Set
#define ILI9225_GRAM_DATA_REG 0x22 // GRAM Data Register
#define ILI9225_GATE_SCAN_CTRL 0x30 // Gate Scan Control Register
#define ILI9225_VERTICAL_SCROLL_CTRL1 0x31 // Vertical Scroll Control 1 Register
#define ILI9225_VERTICAL_SCROLL_CTRL2 0x32 // Vertical Scroll Control 2 Register
#define ILI9225_VERTICAL_SCROLL_CTRL3 0x33 // Vertical Scroll Control 3 Register
#define ILI9225_PARTIAL_DRIVING_POS1 0x34 // Partial Driving Position 1 Register
#define ILI9225_PARTIAL_DRIVING_POS2 0x35 // Partial Driving Position 2 Register
#define ILI9225_HORIZONTAL_WINDOW_ADDR1 0x36 // Horizontal Address Start Position
#define ILI9225_HORIZONTAL_WINDOW_ADDR2 0x37 // Horizontal Address End Position
#define ILI9225_VERTICAL_WINDOW_ADDR1 0x38 // Vertical Address Start Position
#define ILI9225_VERTICAL_WINDOW_ADDR2 0x39 // Vertical Address End Position
#define ILI9225_GAMMA_CTRL1 0x50 // Gamma Control 1
#define ILI9225_GAMMA_CTRL2 0x51 // Gamma Control 2
#define ILI9225_GAMMA_CTRL3 0x52 // Gamma Control 3
#define ILI9225_GAMMA_CTRL4 0x53 // Gamma Control 4
#define ILI9225_GAMMA_CTRL5 0x54 // Gamma Control 5
#define ILI9225_GAMMA_CTRL6 0x55 // Gamma Control 6
#define ILI9225_GAMMA_CTRL7 0x56 // Gamma Control 7
#define ILI9225_GAMMA_CTRL8 0x57 // Gamma Control 8
#define ILI9225_GAMMA_CTRL9 0x58 // Gamma Control 9
#define ILI9225_GAMMA_CTRL10 0x59 // Gamma Control 10
static const uint8_t ili9225_init_operations[] = {
BEGIN_WRITE,
WRITE_C8_D16, ILI9225_LCD_AC_DRIVING_CTRL, 0x01, 0x00,
WRITE_C8_D16, ILI9225_BLANK_PERIOD_CTRL1, 0x08, 0x08, // set BP and FP
WRITE_C8_D16, ILI9225_FRAME_CYCLE_CTRL, 0x11, 0x00, // frame cycle
WRITE_C8_D16, ILI9225_INTERFACE_CTRL, 0x00, 0x00, // RGB interface setting R0Ch=0x0110 for RGB 18Bit and R0Ch=0111for RGB16Bit
WRITE_C8_D16, ILI9225_OSC_CTRL, 0x14, 0x01, // Set frame rate----0801
WRITE_C8_D16, ILI9225_VCI_RECYCLING, 0x00, 0x00, // set system interface
END_WRITE,
DELAY, 50,
//*************Power On sequence ****************//
BEGIN_WRITE,
WRITE_C8_D16, ILI9225_POWER_CTRL1, 0x08, 0x00, // Set SAP,DSTB,STB----0A00
WRITE_C8_D16, ILI9225_POWER_CTRL2, 0x1F, 0x3F, // Set APON,PON,AON,VCI1EN,VC----1038
END_WRITE,
DELAY, 50,
BEGIN_WRITE,
WRITE_C8_D16, ILI9225_POWER_CTRL3, 0x01, 0x21, // Internal reference voltage= Vci;----1121
WRITE_C8_D16, ILI9225_POWER_CTRL4, 0x00, 0x6F, // Set GVDD----0066
WRITE_C8_D16, ILI9225_POWER_CTRL5, 0x43, 0x49, // Set VCOMH/VCOML voltage----5F60
//-------------- Set GRAM area -----------------//
WRITE_C8_D16, ILI9225_GATE_SCAN_CTRL, 0x00, 0x00,
WRITE_C8_D16, ILI9225_VERTICAL_SCROLL_CTRL1, 0x00, 0xDB,
WRITE_C8_D16, ILI9225_VERTICAL_SCROLL_CTRL2, 0x00, 0x00,
WRITE_C8_D16, ILI9225_VERTICAL_SCROLL_CTRL3, 0x00, 0x00,
WRITE_C8_D16, ILI9225_PARTIAL_DRIVING_POS1, 0x00, 0xDB,
WRITE_C8_D16, ILI9225_PARTIAL_DRIVING_POS2, 0x00, 0x00,
// ----------- Adjust the Gamma Curve ----------//
WRITE_C8_D16, ILI9225_GAMMA_CTRL1, 0x00, 0x01, // 0x0400
WRITE_C8_D16, ILI9225_GAMMA_CTRL2, 0x20, 0x0B, // 0x060B
WRITE_C8_D16, ILI9225_GAMMA_CTRL3, 0x00, 0x00, // 0x0C0A
WRITE_C8_D16, ILI9225_GAMMA_CTRL4, 0x04, 0x04, // 0x0105
WRITE_C8_D16, ILI9225_GAMMA_CTRL5, 0x0C, 0x0C, // 0x0A0C
WRITE_C8_D16, ILI9225_GAMMA_CTRL6, 0x00, 0x0C, // 0x0B06
WRITE_C8_D16, ILI9225_GAMMA_CTRL7, 0x01, 0x01, // 0x0004
WRITE_C8_D16, ILI9225_GAMMA_CTRL8, 0x04, 0x00, // 0x0501
WRITE_C8_D16, ILI9225_GAMMA_CTRL9, 0x11, 0x08, // 0x0E00
WRITE_C8_D16, ILI9225_GAMMA_CTRL10, 0x05, 0x0C, // 0x000E
END_WRITE,
DELAY, 50,
BEGIN_WRITE,
WRITE_C8_D16, ILI9225_DISP_CTRL1, 0x10, 0x17,
END_WRITE};
class Arduino_ILI9225 : public Arduino_TFT
{
public:
Arduino_ILI9225(Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void setRotation(uint8_t r) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
protected:
void tftInit() override;
private:
};
#endif

View File

@@ -0,0 +1,139 @@
/*
* start rewrite from:
* https://github.com/adafruit/Adafruit-GFX-Library.git
* https://github.com/adafruit/Adafruit_ILI9331.git
*/
#include "Arduino_ILI9331.h"
#include "SPI.h"
Arduino_ILI9331::Arduino_ILI9331(Arduino_DataBus *bus, int8_t rst, uint8_t r, bool ips)
: Arduino_TFT(bus, rst, r, ips, ILI9331_TFTWIDTH, ILI9331_TFTHEIGHT, 0, 0, 0, 0)
{
}
bool Arduino_ILI9331::begin(int32_t speed)
{
return Arduino_TFT::begin(speed);
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_ILI9331::setRotation(uint8_t r)
{
uint16_t gs, ss, org;
Arduino_TFT::setRotation(r);
switch (_rotation)
{
case 1:
gs = 0x2700;
ss = 0;
org = 0x1038;
break;
case 2:
gs = 0xA700;
ss = 0;
org = 0x1030;
break;
case 3:
gs = 0xA700;
ss = 0x100;
org = 0x1038;
break;
default: // case 0:
gs = 0x2700;
ss = 0x100;
org = 0x1030;
break;
}
_MC = 0x20, _MP = 0x21, _SC = 0x50, _EC = 0x51, _SP = 0x52, _EP = 0x53;
if ((_rotation & 1))
{
uint16_t x;
x = _MC, _MC = _MP, _MP = x;
x = _SC, _SC = _SP, _SP = x;
x = _EC, _EC = _EP, _EP = x;
}
_bus->beginWrite();
_bus->writeC16D16(ILI9331_GSC1, gs); // Set the direction of scan by the gate driver
_bus->writeC16D16(ILI9331_DRVOUTCTL, ss); // Select the shift direction of outputs from the source driver
_bus->writeC16D16(ILI9331_ENTRY_MODE, org); // Set GRAM write direction
_bus->writeCommand16(ILI9331_MW); // Write to GRAM
_bus->endWrite();
}
void Arduino_ILI9331::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
if ((x != _currentX) || (w != _currentW))
{
_currentX = x;
_currentW = w;
x += _xStart;
_bus->writeC16D16(_MC, x);
_bus->writeC16D16(_SC, x);
_bus->writeC16D16(_EC, x + w - 1);
}
if ((y != _currentY) || (h != _currentH))
{
_currentY = y;
_currentH = h;
y += _yStart;
_bus->writeC16D16(_MP, y);
_bus->writeC16D16(_SP, y);
_bus->writeC16D16(_EP, y + h - 1);
}
_bus->writeCommand16(ILI9331_MW);
}
void Arduino_ILI9331::invertDisplay(bool i)
{
_bus->beginWrite();
_bus->writeC16D16(ILI9331_GSC2, _ips != i);
_bus->endWrite();
}
void Arduino_ILI9331::displayOn(void)
{
_bus->beginWrite();
_bus->writeC16D16(ILI9331_PWCTL1, 0x1690); // Standby mode OFF
_bus->writeC16D16(ILI9331_WBRICTRL, 0x0024); // Enable backlight
_bus->writeC16D16(ILI9331_WBRI, 0x00FF); // Set maximum brightness
_bus->endWrite();
delay(100);
}
void Arduino_ILI9331::displayOff(void)
{
_bus->beginWrite();
_bus->writeC16D16(ILI9331_PWCTL1, 0x1691); // Standby mode OFF
_bus->writeC16D16(ILI9331_WBRICTRL, 0x0020); // Disable backlight
_bus->endWrite();
}
// Companion code to the above tables. Reads and issues
// a series of LCD commands stored in PROGMEM byte array.
void Arduino_ILI9331::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(ILI9331_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(ILI9331_RST_DELAY);
}
_bus->batchOperation(ili9331_init_operations, sizeof(ili9331_init_operations));
invertDisplay(false);
}

View File

@@ -0,0 +1,160 @@
/*
* start rewrite from:
* https://github.com/adafruit/Adafruit-GFX-Library.git
* https://github.com/adafruit/Adafruit_ILI9331.git
*/
#ifndef _ARDUINO_ILI9331_H_
#define _ARDUINO_ILI9331_H_
#include "../Arduino_GFX.h"
#include "../Arduino_TFT.h"
#define ILI9331_TFTWIDTH 240 /// ILI9331 max TFT width
#define ILI9331_TFTHEIGHT 320 /// ILI9331 max TFT height
#define ILI9331_RST_DELAY 150
#define ILI9331_DRVCODER 0x00 /// Driver Code Read
#define ILI9331_DRVOUTCTL 0x01 /// Driver Output Control 1
#define ILI9331_DRIVWVCTL 0x02 /// LCD Driving Control
#define ILI9331_ENTRY_MODE 0x03 /// Entry Mode
#define ILI9331_DC1 0x07 /// Display Control 1
#define ILI9331_DC2 0x08 /// Display Control 2
#define ILI9331_DC3 0x09 /// Display Control 3
#define ILI9331_DC4 0x0A /// Display Control 4
#define ILI9331_RGBDIC1 0x0C /// RGB Display Interface Control 1
#define ILI9331_FMARK 0x0D /// Frame Marker Position
#define ILI9331_RGDIC2 0x0F /// RGB Display Interface Control 2
#define ILI9331_PWCTL1 0x10 /// Power Control 1
#define ILI9331_PWCTL2 0x11 /// Power Control 2
#define ILI9331_PWCTL3 0x12 /// Power Control 3
#define ILI9331_PWCTL4 0x13 /// Power Control 4
#define ILI9331_MC 0x20 /// GRAM Horizontal Address Set
#define ILI9331_MP 0x21 /// GRAM Vertical Address Set
#define ILI9331_MW 0x22 /// Write Data to GRAM
#define ILI9331_PWCTL7 0x29 /// Power Control 7
#define ILI9331_FRCR 0x2B /// Frame Rate and Color Control
#define ILI9331_HSA 0x50 /// Horizontal RAM Address Position
#define ILI9331_HSE 0x51 /// Horizontal RAM Address Position
#define ILI9331_VSA 0x52 /// Vertical RAM Address Position
#define ILI9331_VSE 0x53 /// Vertical RAM Address Position
#define ILI9331_GSC1 0x60 /// Gate Scan Control
#define ILI9331_GSC2 0x61 /// Gate Scan Control
#define ILI9331_GSC3 0x6A /// Gate Scan Control
#define ILI9331_PANCLT1 0x90 /// Panel Interface Control 1
#define ILI9331_PANCLT2 0x92 /// Panel Interface Control 2
#define ILI9331_PANCLT4 0x95 /// Panel Interface Control 4
#define ILI9331_PANCLT5 0x97 /// Panel Interface Control 5
#define ILI9331_WBRI 0xB1 /// Write Display Brightness Value
#define ILI9331_RBRI 0xB2 /// Read Display Brightness Value
#define ILI9331_WBRICTRL 0xB3 /// Write CTRL Display Value
#define ILI9331_RBRICTRL 0xB4 /// Read CTRL Display Value
#define ILI9331_WCABC 0xB5 /// Write Content Adaptive Brightness Control Value
#define ILI9331_RCABC 0xB6 /// Read Content Adaptive Brightness Control Value
#define ILI9331_WCABCMIN 0xBE /// Write CABC Minimum Brightness
#define ILI9331_RCABCMIN 0xBF /// Read CABC Minimum Brightness
#define ILI9331_CABCCTL1 0xC8 /// CABC Control 1
#define ILI9331_CABCCTL2 0xC9 /// CABC Control 2
#define ILI9331_CABCCTL3 0xCA /// CABC Control 3
#define ILI9331_CABCCTL4 0xCB /// CABC Control 4
#define ILI9331_CABCCTL5 0xCC /// CABC Control 5
#define ILI9331_CABCCTL6 0xCD /// CABC Control 6
#define ILI9331_CABCCTL7 0xCD /// CABC Control 7
static const uint8_t ili9331_init_operations[] = {
BEGIN_WRITE,
//************* Start Initial Sequence **********//
WRITE_C16_D16, 0x00, 0xE7, 0x10, 0x14, // Not sure about this.
// This register is not in datasheet and display inits without it,
// but it mentioned in official code snippet.
WRITE_C16_D16, 0x00, 0x01, 0x01, 0x00, // set SS and SM bit
WRITE_C16_D16, 0x00, 0x02, 0x02, 0x00, // set 1 line inversion
WRITE_C16_D16, 0x00, 0x03, 0x10, 0x30, // set GRAM write direction and BGR=1.
WRITE_C16_D16, 0x00, 0x08, 0x02, 0x07, // set the back porch and front porch
WRITE_C16_D16, 0x00, 0x09, 0x00, 0x00, // set non-display area refresh cycle ISC[3:0]
WRITE_C16_D16, 0x00, 0x0A, 0x00, 0x00, // FMARK function
WRITE_C16_D16, 0x00, 0x0C, 0x00, 0x00, // RGB interface setting
WRITE_C16_D16, 0x00, 0x0D, 0x00, 0x00, // Frame marker Position
WRITE_C16_D16, 0x00, 0x0F, 0x00, 0x00, // RGB interface polarity
//*************Power On sequence ****************//
WRITE_C16_D16, 0x00, 0x10, 0x00, 0x00, // SAP, BT[3:0], AP, DSTB, SLP, STB
WRITE_C16_D16, 0x00, 0x11, 0x00, 0x01, // DC1[2:0], DC0[2:0], VC[2:0]
WRITE_C16_D16, 0x00, 0x12, 0x00, 0x00, // VREG1OUT voltage
WRITE_C16_D16, 0x00, 0x13, 0x00, 0x00, // VDV[4:0] for VCOM amplitude
DELAY, 200, // Dis-charge capacitor power voltage
WRITE_C16_D16, 0x00, 0x10, 0x16, 0x90, // SAP=1, BT=6, APE=1, AP=1, DSTB=0, SLP=0, STB=0
WRITE_C16_D16, 0x00, 0x11, 0x00, 0x01, // DC1=2, DC0=2, VC=7
DELAY, 50, // wait_ms 50ms
WRITE_C16_D16, 0x00, 0x12, 0x00, 0x0C, // Internal reference voltage= Vci; VCIRE=1, PON=0, VRH=5
DELAY, 50, // wait_ms 50ms
WRITE_C16_D16, 0x00, 0x13, 0x07, 0x00, // VDV=28 for VCOM amplitude
WRITE_C16_D16, 0x00, 0x29, 0x00, 0x05, // VCM=10 for VCOMH
WRITE_C16_D16, 0x00, 0x2B, 0x00, 0x0D, // Set Frame Rate
DELAY, 50, // wait_ms 50ms
WRITE_C16_D16, 0x00, 0x20, 0x00, 0x00, // GRAM horizontal Address
WRITE_C16_D16, 0x00, 0x21, 0x00, 0x00, // GRAM Vertical Address
// ----------- Adjust the Gamma Curve ----------//
WRITE_C16_D16, 0x00, 0x30, 0x00, 0x00,
WRITE_C16_D16, 0x00, 0x31, 0x02, 0x07,
WRITE_C16_D16, 0x00, 0x32, 0x00, 0x00,
WRITE_C16_D16, 0x00, 0x35, 0x00, 0x07,
WRITE_C16_D16, 0x00, 0x36, 0x05, 0x08,
WRITE_C16_D16, 0x00, 0x37, 0x07, 0x07,
WRITE_C16_D16, 0x00, 0x38, 0x00, 0x05,
WRITE_C16_D16, 0x00, 0x39, 0x07, 0x07,
WRITE_C16_D16, 0x00, 0x3C, 0x02, 0x02,
WRITE_C16_D16, 0x00, 0x3D, 0x0A, 0x09,
//------------------ Set GRAM area ---------------//
WRITE_C16_D16, 0x00, 0x50, 0x00, 0x00, // Horizontal GRAM Start Address
WRITE_C16_D16, 0x00, 0x51, 0x00, 0xEF, // Horizontal GRAM End Address
WRITE_C16_D16, 0x00, 0x52, 0x00, 0x00, // Vertical GRAM Start Address
WRITE_C16_D16, 0x00, 0x53, 0x01, 0x3F, // Vertical GRAM Start Address
WRITE_C16_D16, 0x00, 0x60, 0xA7, 0x00, // Gate Scan Line GS=0 [0xA700]
WRITE_C16_D16, 0x00, 0x61, 0x00, 0x01, // NDL,VLE, REV
WRITE_C16_D16, 0x00, 0x6A, 0x00, 0x00, // set scrolling line
//-------------- Partial Display Control ---------//
WRITE_C16_D16, 0x00, 0x80, 0x00, 0x00,
WRITE_C16_D16, 0x00, 0x81, 0x00, 0x00,
WRITE_C16_D16, 0x00, 0x82, 0x00, 0x00,
WRITE_C16_D16, 0x00, 0x83, 0x00, 0x00,
WRITE_C16_D16, 0x00, 0x84, 0x00, 0x00,
WRITE_C16_D16, 0x00, 0x85, 0x00, 0x00,
//-------------- Panel Control -------------------//
WRITE_C16_D16, 0x00, 0x90, 0x00, 0x10,
WRITE_C16_D16, 0x00, 0x92, 0x06, 0x00,
WRITE_C16_D16, 0x00, 0x07, 0x01, 0x33,
//-------------- Backlight Control ---------------//
WRITE_C16_D16, 0x00, 0xB3, 0x00, 0x24, // Enable backlight
WRITE_C16_D16, 0x00, 0xB1, 0x00, 0xFF, // Set maximum brightness
END_WRITE};
class Arduino_ILI9331 : public Arduino_TFT
{
public:
Arduino_ILI9331(Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0, bool ips = false);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void setRotation(uint8_t r) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
protected:
void tftInit() override;
private:
uint16_t _MC, _MP, _SC, _EC, _SP, _EP;
};
#endif

View File

@@ -0,0 +1,117 @@
/*
* start rewrite from:
* https://github.com/adafruit/Adafruit-GFX-Library.git
* https://github.com/adafruit/Adafruit_ILI9341.git
*/
#include "Arduino_ILI9341.h"
#include "SPI.h"
Arduino_ILI9341::Arduino_ILI9341(
Arduino_DataBus *bus, int8_t rst, uint8_t r,
bool ips, int16_t w, int16_t h,
uint8_t col_offset1, uint8_t row_offset1, uint8_t col_offset2, uint8_t row_offset2,
const uint8_t *init_operations, size_t init_operations_len)
: Arduino_TFT(bus, rst, r, ips, w, h, col_offset1, row_offset1, col_offset2, row_offset2),
_init_operations(init_operations), _init_operations_len(init_operations_len)
{
}
bool Arduino_ILI9341::begin(int32_t speed)
{
_override_datamode = SPI_MODE0; // always use SPI_MODE0
return Arduino_TFT::begin(speed);
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_ILI9341::setRotation(uint8_t r)
{
Arduino_TFT::setRotation(r);
switch (_rotation)
{
case 1:
r = (ILI9341_MADCTL_MV | ILI9341_MADCTL_BGR);
break;
case 2:
r = (ILI9341_MADCTL_MY | ILI9341_MADCTL_BGR);
break;
case 3:
r = (ILI9341_MADCTL_MX | ILI9341_MADCTL_MY | ILI9341_MADCTL_MV | ILI9341_MADCTL_BGR);
break;
default: // case 0:
r = (ILI9341_MADCTL_MX | ILI9341_MADCTL_BGR);
break;
}
_bus->beginWrite();
_bus->writeC8D8(ILI9341_MADCTL, r);
_bus->endWrite();
}
void Arduino_ILI9341::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
if ((x != _currentX) || (w != _currentW))
{
_currentX = x;
_currentW = w;
x += _xStart;
_bus->writeC8D16D16Split(ILI9341_CASET, x, x + w - 1);
}
if ((y != _currentY) || (h != _currentH))
{
_currentY = y;
_currentH = h;
y += _yStart;
_bus->writeC8D16D16Split(ILI9341_PASET, y, y + h - 1);
}
_bus->writeCommand(ILI9341_RAMWR); // write to RAM
}
void Arduino_ILI9341::invertDisplay(bool i)
{
_bus->sendCommand((_ips ^ i) ? ILI9341_INVON : ILI9341_INVOFF);
}
void Arduino_ILI9341::displayOn(void)
{
_bus->sendCommand(ILI9341_SLPOUT);
delay(ILI9341_SLPOUT_DELAY);
}
void Arduino_ILI9341::displayOff(void)
{
_bus->sendCommand(ILI9341_SLPIN);
delay(ILI9341_SLPIN_DELAY);
}
// Companion code to the above tables. Reads and issues
// a series of LCD commands stored in PROGMEM byte array.
void Arduino_ILI9341::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(ILI9341_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(ILI9341_RST_DELAY);
}
else
{
// Software Rest
_bus->sendCommand(ILI9341_SWRESET);
delay(ILI9341_RST_DELAY);
}
_bus->batchOperation(_init_operations, _init_operations_len);
invertDisplay(false);
}

View File

@@ -0,0 +1,194 @@
/*
* start rewrite from:
* https://github.com/adafruit/Adafruit-GFX-Library.git
* https://github.com/adafruit/Adafruit_ILI9341.git
*/
#pragma once
#include "../Arduino_GFX.h"
#include "../Arduino_TFT.h"
#define ILI9341_TFTWIDTH 240 ///< ILI9341 max TFT width
#define ILI9341_TFTHEIGHT 320 ///< ILI9341 max TFT height
#define ILI9341_RST_DELAY 150 ///< delay ms wait for reset finish
#define ILI9341_SLPIN_DELAY 150 ///< delay ms wait for sleep in finish
#define ILI9341_SLPOUT_DELAY 150 ///< delay ms wait for sleep out finish
#define ILI9341_NOP 0x00 ///< No-op register
#define ILI9341_SWRESET 0x01 ///< Software reset register
#define ILI9341_RDDID 0x04 ///< Read display identification information
#define ILI9341_RDDST 0x09 ///< Read Display Status
#define ILI9341_SLPIN 0x10 ///< Enter Sleep Mode
#define ILI9341_SLPOUT 0x11 ///< Sleep Out
#define ILI9341_PTLON 0x12 ///< Partial Mode ON
#define ILI9341_NORON 0x13 ///< Normal Display Mode ON
#define ILI9341_RDMODE 0x0A ///< Read Display Power Mode
#define ILI9341_RDMADCTL 0x0B ///< Read Display MADCTL
#define ILI9341_RDPIXFMT 0x0C ///< Read Display Pixel Format
#define ILI9341_RDIMGFMT 0x0D ///< Read Display Image Format
#define ILI9341_RDSELFDIAG 0x0F ///< Read Display Self-Diagnostic Result
#define ILI9341_INVOFF 0x20 ///< Display Inversion OFF
#define ILI9341_INVON 0x21 ///< Display Inversion ON
#define ILI9341_GAMMASET 0x26 ///< Gamma Set
#define ILI9341_DISPOFF 0x28 ///< Display OFF
#define ILI9341_DISPON 0x29 ///< Display ON
#define ILI9341_CASET 0x2A ///< Column Address Set
#define ILI9341_PASET 0x2B ///< Page Address Set
#define ILI9341_RAMWR 0x2C ///< Memory Write
#define ILI9341_RAMRD 0x2E ///< Memory Read
#define ILI9341_PTLAR 0x30 ///< Partial Area
#define ILI9341_VSCRDEF 0x33 ///< Vertical Scrolling Definition
#define ILI9341_MADCTL 0x36 ///< Memory Access Control
#define ILI9341_VSCRSADD 0x37 ///< Vertical Scrolling Start Address
#define ILI9341_PIXFMT 0x3A ///< COLMOD: Pixel Format Set
#define ILI9341_FRMCTR1 0xB1 ///< Frame Rate Control (In Normal Mode/Full Colors)
#define ILI9341_FRMCTR2 0xB2 ///< Frame Rate Control (In Idle Mode/8 colors)
#define ILI9341_FRMCTR3 0xB3 ///< Frame Rate control (In Partial Mode/Full Colors)
#define ILI9341_INVCTR 0xB4 ///< Display Inversion Control
#define ILI9341_DFUNCTR 0xB6 ///< Display Function Control
#define ILI9341_PWCTR1 0xC0 ///< Power Control 1
#define ILI9341_PWCTR2 0xC1 ///< Power Control 2
#define ILI9341_PWCTR3 0xC2 ///< Power Control 3
#define ILI9341_PWCTR4 0xC3 ///< Power Control 4
#define ILI9341_PWCTR5 0xC4 ///< Power Control 5
#define ILI9341_VMCTR1 0xC5 ///< VCOM Control 1
#define ILI9341_VMCTR2 0xC7 ///< VCOM Control 2
#define ILI9341_RDID1 0xDA ///< Read ID 1
#define ILI9341_RDID2 0xDB ///< Read ID 2
#define ILI9341_RDID3 0xDC ///< Read ID 3
#define ILI9341_RDID4 0xDD ///< Read ID 4
#define ILI9341_GMCTRP1 0xE0 ///< Positive Gamma Correction
#define ILI9341_GMCTRN1 0xE1 ///< Negative Gamma Correction
#define ILI9341_PWCTR6 0xFC
#define ILI9341_MADCTL_MY 0x80 ///< Bottom to top
#define ILI9341_MADCTL_MX 0x40 ///< Right to left
#define ILI9341_MADCTL_MV 0x20 ///< Reverse Mode
#define ILI9341_MADCTL_ML 0x10 ///< LCD refresh Bottom to top
#define ILI9341_MADCTL_RGB 0x00 ///< Red-Green-Blue pixel order
#define ILI9341_MADCTL_BGR 0x08 ///< Blue-Green-Red pixel order
#define ILI9341_MADCTL_MH 0x04 ///< LCD refresh right to left
static const uint8_t ili9341_type1_init_operations[] = {
BEGIN_WRITE,
WRITE_C8_BYTES, 0xCF, 3,
0x00, 0xC1, 0x30,
WRITE_C8_BYTES, 0xED, 4,
0x64, 0x03, 0x12, 0x81,
WRITE_C8_BYTES, 0xE8, 3,
0x85, 0x00, 0x78,
WRITE_C8_BYTES, 0xCB, 5,
0x39, 0x2C, 0x00, 0x34, 0x02,
WRITE_C8_D8, 0xF7, 0x20,
WRITE_C8_D16, 0xEA, 0x00, 0x00,
WRITE_C8_D8, ILI9341_PWCTR1, 0x10, // Power control VRH[5:0]
WRITE_C8_D8, ILI9341_PWCTR2, 0x00, // Power control SAP[2:0];BT[3:0]
WRITE_C8_D16, ILI9341_VMCTR1, 0x30, 0x30, // VCM control
WRITE_C8_D8, ILI9341_VMCTR2, 0xB7, // VCM control2
WRITE_C8_D8, ILI9341_PIXFMT, 0x55,
WRITE_C8_D16, ILI9341_FRMCTR1, 0x00, 0x1A,
WRITE_C8_BYTES, ILI9341_DFUNCTR, 3, // Display Function Control
0x08, 0x82, 0x27,
WRITE_C8_D8, 0xF2, 0x00, // 3Gamma Function Disable
WRITE_C8_D8, ILI9341_GAMMASET, 0x01, // Gamma curve selected
WRITE_COMMAND_8, ILI9341_SLPOUT, // Exit Sleep
WRITE_COMMAND_8, ILI9341_DISPON, // Display on
END_WRITE};
static const uint8_t ili9341_type2_init_operations[] = {
BEGIN_WRITE,
WRITE_C8_BYTES, 0xEF, 3,
0x03, 0x80, 0x02,
WRITE_C8_BYTES, 0xCF, 3,
0x00, 0xC1, 0x30,
WRITE_C8_BYTES, 0xED, 4,
0x64, 0x03, 0x12, 0x81,
WRITE_C8_BYTES, 0xE8, 3,
0x85, 0x00, 0x78,
WRITE_C8_BYTES, 0xCB, 5,
0x39, 0x2C, 0x00, 0x34, 0x02,
WRITE_C8_D8, 0xF7, 0x20,
WRITE_C8_D16, 0xEA, 0x00, 0x00,
WRITE_C8_D8, ILI9341_PWCTR1, 0x23, // Power control VRH[5:0]
WRITE_C8_D8, ILI9341_PWCTR2, 0x10, // Power control SAP[2:0];BT[3:0]
WRITE_C8_D16, ILI9341_VMCTR1, 0x3e, 0x28, // VCM control
WRITE_C8_D8, ILI9341_VMCTR2, 0x86, // VCM control2
WRITE_C8_D8, ILI9341_PIXFMT, 0x55,
WRITE_C8_D16, ILI9341_FRMCTR1, 0x00, 0x18,
WRITE_C8_BYTES, ILI9341_DFUNCTR, 3, // Display Function Control
0x08, 0x82, 0x27,
WRITE_C8_D8, 0xF2, 0x00, // 3Gamma Function Disable
WRITE_C8_D8, ILI9341_GAMMASET, 0x01, // Gamma curve selected
WRITE_C8_BYTES, ILI9341_GMCTRP1, 15, // Set Gamma
0x0F, 0x31, 0x2B, 0x0C,
0x0E, 0x08, 0x4E, 0xF1,
0x37, 0x07, 0x10, 0x03,
0x0E, 0x09, 0x00,
WRITE_C8_BYTES, ILI9341_GMCTRN1, 15, // Set Gamma
0x00, 0x0E, 0x14, 0x03,
0x11, 0x07, 0x31, 0xC1,
0x48, 0x08, 0x0F, 0x0C,
0x31, 0x36, 0x0F,
WRITE_COMMAND_8, ILI9341_SLPOUT, // Exit Sleep
WRITE_COMMAND_8, ILI9341_DISPON, // Display on
END_WRITE};
static const uint8_t ili9341_type3_init_operations[] = {
BEGIN_WRITE,
WRITE_C8_BYTES, 0xCF, 3,
0x00, 0xC1, 0x30,
WRITE_C8_BYTES, 0xED, 4,
0x64, 0x03, 0x12, 0x81,
WRITE_C8_BYTES, 0xE8, 3,
0x85, 0x00, 0x78,
WRITE_C8_BYTES, 0xCB, 5,
0x39, 0x2C, 0x00, 0x34, 0x02,
WRITE_C8_D8, 0xF7, 0x20,
WRITE_C8_D16, 0xEA, 0x00, 0x00,
WRITE_C8_D8, ILI9341_PWCTR1, 0x10, // Power control VRH[5:0]
WRITE_C8_D8, ILI9341_PWCTR2, 0x00, // Power control SAP[2:0];BT[3:0]
WRITE_C8_D16, ILI9341_VMCTR1, 0x30, 0x30, // VCM control
WRITE_C8_D8, ILI9341_VMCTR2, 0x86, // VCM control2
WRITE_C8_D8, ILI9341_PIXFMT, 0x55,
WRITE_C8_D16, ILI9341_FRMCTR1, 0x00, 0x1A,
WRITE_C8_BYTES, ILI9341_DFUNCTR, 3, // Display Function Control
0x08, 0x82, 0x27,
WRITE_C8_D8, 0xF2, 0x00, // 3Gamma Function Disable
WRITE_C8_D8, ILI9341_GAMMASET, 0x01, // Gamma curve selected
WRITE_COMMAND_8, ILI9341_SLPOUT, // Exit Sleep
WRITE_COMMAND_8, ILI9341_DISPON, // Display on
END_WRITE};
class Arduino_ILI9341 : public Arduino_TFT
{
public:
Arduino_ILI9341(
Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0,
bool ips = false, int16_t w = ILI9341_TFTWIDTH, int16_t h = ILI9341_TFTHEIGHT,
uint8_t col_offset1 = 0, uint8_t row_offset1 = 0, uint8_t col_offset2 = 0, uint8_t row_offset2 = 0,
const uint8_t *init_operations = ili9341_type1_init_operations, size_t init_operations_len = sizeof(ili9341_type1_init_operations));
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void setRotation(uint8_t r) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
protected:
void tftInit() override;
private:
const uint8_t *_init_operations;
size_t _init_operations_len;
};

View File

@@ -0,0 +1,112 @@
/*
* start rewrite from:
* https://github.com/adafruit/Adafruit-GFX-Library.git
* https://github.com/adafruit/Adafruit_ILI9342.git
*/
#include "Arduino_ILI9342.h"
#include "SPI.h"
Arduino_ILI9342::Arduino_ILI9342(Arduino_DataBus *bus, int8_t rst, uint8_t r, bool ips)
: Arduino_TFT(bus, rst, r, ips, ILI9342_TFTWIDTH, ILI9342_TFTHEIGHT, 0, 0, 0, 0)
{
}
bool Arduino_ILI9342::begin(int32_t speed)
{
_override_datamode = SPI_MODE0; // always use SPI_MODE0
return Arduino_TFT::begin(speed);
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_ILI9342::setRotation(uint8_t r)
{
Arduino_TFT::setRotation(r);
switch (_rotation)
{
case 1:
r = (ILI9342_MADCTL_MV | ILI9342_MADCTL_MY | ILI9342_MADCTL_BGR);
break;
case 2:
r = (ILI9342_MADCTL_BGR);
break;
case 3:
r = (ILI9342_MADCTL_MV | ILI9342_MADCTL_MX | ILI9342_MADCTL_BGR);
break;
default: // case 0:
r = (ILI9342_MADCTL_MX | ILI9342_MADCTL_MY | ILI9342_MADCTL_BGR);
break;
}
_bus->beginWrite();
_bus->writeC8D8(ILI9342_MADCTL, r);
_bus->endWrite();
}
void Arduino_ILI9342::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
if ((x != _currentX) || (w != _currentW))
{
_currentX = x;
_currentW = w;
x += _xStart;
_bus->writeC8D16D16(ILI9342_CASET, x, x + w - 1);
}
if ((y != _currentY) || (h != _currentH))
{
_currentY = y;
_currentH = h;
y += _yStart;
_bus->writeC8D16D16(ILI9342_PASET, y, y + h - 1);
}
_bus->writeCommand(ILI9342_RAMWR); // write to RAM
}
void Arduino_ILI9342::invertDisplay(bool i)
{
_bus->sendCommand((_ips ^ i) ? ILI9342_INVON : ILI9342_INVOFF);
}
void Arduino_ILI9342::displayOn(void)
{
_bus->sendCommand(ILI9342_SLPOUT);
delay(ILI9342_SLPOUT_DELAY);
}
void Arduino_ILI9342::displayOff(void)
{
_bus->sendCommand(ILI9342_SLPIN);
delay(ILI9342_SLPIN_DELAY);
}
// Companion code to the above tables. Reads and issues
// a series of LCD commands stored in PROGMEM byte array.
void Arduino_ILI9342::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(ILI9342_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(ILI9342_RST_DELAY);
}
else
{
// Software Rest
_bus->sendCommand(ILI9342_SWRESET);
delay(ILI9342_RST_DELAY);
}
_bus->batchOperation(ili9342_init_operations, sizeof(ili9342_init_operations));
invertDisplay(false);
}

View File

@@ -0,0 +1,121 @@
#ifndef _ARDUINO_ILI9342_H_
#define _ARDUINO_ILI9342_H_
#include "../Arduino_GFX.h"
#include "../Arduino_TFT.h"
#define ILI9342_TFTWIDTH 320 ///< ILI9342 max TFT width
#define ILI9342_TFTHEIGHT 240 ///< ILI9342 max TFT height
#define ILI9342_RST_DELAY 150 ///< delay ms wait for reset finish
#define ILI9342_SLPIN_DELAY 150 ///< delay ms wait for sleep in finish
#define ILI9342_SLPOUT_DELAY 150 ///< delay ms wait for sleep out finish
#define ILI9342_NOP 0x00 ///< No-op register
#define ILI9342_SWRESET 0x01 ///< Software reset register
#define ILI9342_RDDID 0x04 ///< Read display identification information
#define ILI9342_RDDST 0x09 ///< Read Display Status
#define ILI9342_SLPIN 0x10 ///< Enter Sleep Mode
#define ILI9342_SLPOUT 0x11 ///< Sleep Out
#define ILI9342_PTLON 0x12 ///< Partial Mode ON
#define ILI9342_NORON 0x13 ///< Normal Display Mode ON
#define ILI9342_RDMODE 0x0A ///< Read Display Power Mode
#define ILI9342_RDMADCTL 0x0B ///< Read Display MADCTL
#define ILI9342_RDPIXFMT 0x0C ///< Read Display Pixel Format
#define ILI9342_RDIMGFMT 0x0D ///< Read Display Image Format
#define ILI9342_RDSELFDIAG 0x0F ///< Read Display Self-Diagnostic Result
#define ILI9342_INVOFF 0x20 ///< Display Inversion OFF
#define ILI9342_INVON 0x21 ///< Display Inversion ON
#define ILI9342_GAMMASET 0x26 ///< Gamma Set
#define ILI9342_DISPOFF 0x28 ///< Display OFF
#define ILI9342_DISPON 0x29 ///< Display ON
#define ILI9342_CASET 0x2A ///< Column Address Set
#define ILI9342_PASET 0x2B ///< Page Address Set
#define ILI9342_RAMWR 0x2C ///< Memory Write
#define ILI9342_RAMRD 0x2E ///< Memory Read
#define ILI9342_PTLAR 0x30 ///< Partial Area
#define ILI9342_VSCRDEF 0x33 ///< Vertical Scrolling Definition
#define ILI9342_MADCTL 0x36 ///< Memory Access Control
#define ILI9342_VSCRSADD 0x37 ///< Vertical Scrolling Start Address
#define ILI9342_PIXFMT 0x3A ///< COLMOD: Pixel Format Set
#define ILI9342_FRMCTR1 0xB1 ///< Frame Rate Control (In Normal Mode/Full Colors)
#define ILI9342_FRMCTR2 0xB2 ///< Frame Rate Control (In Idle Mode/8 colors)
#define ILI9342_FRMCTR3 0xB3 ///< Frame Rate control (In Partial Mode/Full Colors)
#define ILI9342_INVCTR 0xB4 ///< Display Inversion Control
#define ILI9342_DFUNCTR 0xB6 ///< Display Function Control
#define ILI9342_PWCTR1 0xC0 ///< Power Control 1
#define ILI9342_PWCTR2 0xC1 ///< Power Control 2
#define ILI9342_PWCTR3 0xC2 ///< Power Control 3
#define ILI9342_PWCTR4 0xC3 ///< Power Control 4
#define ILI9342_PWCTR5 0xC4 ///< Power Control 5
#define ILI9342_VMCTR1 0xC5 ///< VCOM Control 1
#define ILI9342_VMCTR2 0xC7 ///< VCOM Control 2
#define ILI9342_RDID1 0xDA ///< Read ID 1
#define ILI9342_RDID2 0xDB ///< Read ID 2
#define ILI9342_RDID3 0xDC ///< Read ID 3
#define ILI9342_RDID4 0xDD ///< Read ID 4
#define ILI9342_GMCTRP1 0xE0 ///< Positive Gamma Correction
#define ILI9342_GMCTRN1 0xE1 ///< Negative Gamma Correction
#define ILI9342_PWCTR6 0xFC
#define ILI9342_MADCTL_MY 0x80 ///< Bottom to top
#define ILI9342_MADCTL_MX 0x40 ///< Right to left
#define ILI9342_MADCTL_MV 0x20 ///< Reverse Mode
#define ILI9342_MADCTL_ML 0x10 ///< LCD refresh Bottom to top
#define ILI9342_MADCTL_RGB 0x00 ///< Red-Green-Blue pixel order
#define ILI9342_MADCTL_BGR 0x08 ///< Blue-Green-Red pixel order
#define ILI9342_MADCTL_MH 0x04 ///< LCD refresh right to left
static const uint8_t ili9342_init_operations[] = {
BEGIN_WRITE,
WRITE_C8_D8, ILI9342_PWCTR1, 0x23, // Power control VRH[5:0]
WRITE_C8_D8, ILI9342_PWCTR2, 0x10, // Power control SAP[2:0];BT[3:0]
WRITE_C8_D16, ILI9342_VMCTR1, 0x3e, 0x28, // VCM control
WRITE_C8_D8, ILI9342_VMCTR2, 0x86, // VCM control2
WRITE_C8_D8, ILI9342_VSCRSADD, 0x00, // Vertical scroll zero
WRITE_C8_D8, ILI9342_PIXFMT, 0x55,
WRITE_C8_D16, ILI9342_FRMCTR1, 0x00, 0x18,
WRITE_C8_BYTES, ILI9342_DFUNCTR, 3, // Display Function Control
0x08, 0x82, 0x27,
WRITE_COMMAND_8, ILI9342_SLPOUT, // Exit Sleep
END_WRITE,
DELAY, ILI9342_SLPOUT_DELAY,
BEGIN_WRITE,
WRITE_COMMAND_8, ILI9342_DISPON, // Display on
END_WRITE};
class Arduino_ILI9342 : public Arduino_TFT
{
public:
Arduino_ILI9342(Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0, bool ips = false);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void setRotation(uint8_t r) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
protected:
void tftInit() override;
private:
};
#endif

View File

@@ -0,0 +1,203 @@
/*
* start rewrite from:
* https://github.com/adafruit/Adafruit-GFX-Library.git
*/
#include "Arduino_ILI9481_18bit.h"
Arduino_ILI9481_18bit::Arduino_ILI9481_18bit(Arduino_DataBus *bus, int8_t rst, uint8_t r, bool ips)
: Arduino_TFT_18bit(bus, rst, r, ips, ILI9481_TFTWIDTH, ILI9481_TFTHEIGHT, 0, 0, 0, 0)
{
}
bool Arduino_ILI9481_18bit::begin(int32_t speed)
{
#if defined(ESP8266) || defined(ESP32)
if (speed == GFX_NOT_DEFINED)
{
speed = 12000000UL;
}
// Teensy 4.x
#elif defined(__IMXRT1052__) || defined(__IMXRT1062__)
if (speed == GFX_NOT_DEFINED)
{
speed = 12000000UL;
}
#endif
return Arduino_TFT::begin(speed);
}
// Companion code to the above tables. Reads and issues
// a series of LCD commands stored in PROGMEM byte array.
void Arduino_ILI9481_18bit::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(ILI9481_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(ILI9481_RST_DELAY);
}
else
{
// Software Rest
_bus->sendCommand(ILI9481_SWRESET);
delay(ILI9481_RST_DELAY);
}
_bus->sendCommand(ILI9481_SLPOUT);
delay(280);
_bus->sendCommand(0xd0); // Power_Setting
_bus->sendData(0x07); // 07 VC[2:0] Sets the ratio factor of Vci to generate the reference voltages Vci1
_bus->sendData(0x44); // 41 BT[2:0] Sets the Step up factor and output voltage level from the reference voltages Vci1
_bus->sendData(0x1E); // 1f 17 1C VRH[3:0]: Sets the factor to generate VREG1OUT from VCILVL
delay(220);
_bus->sendCommand(0xd1); // VCOM Control
_bus->sendData(0x00); // 00
_bus->sendData(0x0C); // 1A VCM [6:0] is used to set factor to generate VCOMH voltage from the reference voltage VREG1OUT 15 09
_bus->sendData(0x1A); // 1F VDV[4:0] is used to set the VCOM alternating amplitude in the range of VREG1OUT x 0.70 to VREG1OUT 1F 18
_bus->sendCommand(0xC5); // Frame Rate
_bus->sendData(0x03); // 03 02
_bus->sendCommand(0xd2); // Power_Setting for Normal Mode
_bus->sendData(0x01); // 01
_bus->sendData(0x11); // 11
_bus->sendCommand(0xE4); //
_bus->sendData(0xa0);
_bus->sendCommand(0xf3);
_bus->sendData(0x00);
_bus->sendData(0x2a);
// 1 OK
_bus->sendCommand(0xc8);
_bus->sendData(0x00);
_bus->sendData(0x26);
_bus->sendData(0x21);
_bus->sendData(0x00);
_bus->sendData(0x00);
_bus->sendData(0x1f);
_bus->sendData(0x65);
_bus->sendData(0x23);
_bus->sendData(0x77);
_bus->sendData(0x00);
_bus->sendData(0x0f);
_bus->sendData(0x00);
// GAMMA SETTING
_bus->sendCommand(0xC0); // Panel Driving Setting
_bus->sendData(0x00); // 1//00 REV SM GS
_bus->sendData(0x3B); // 2//NL[5:0]: Sets the number of lines to drive the LCD at an interval of 8 lines.
_bus->sendData(0x00); // 3//SCN[6:0]
_bus->sendData(0x02); // 4//PTV: Sets the Vcom output in non-display area drive period
_bus->sendData(0x11); // 5//NDL: Sets the source output level in non-display area. PTG: Sets the scan mode in non-display area.
_bus->sendCommand(0xc6); // Interface Control
_bus->sendData(0x83);
// GAMMA SETTING
_bus->sendCommand(0xf0); //?
_bus->sendData(0x01);
_bus->sendCommand(0xE4); //?
_bus->sendData(0xa0);
_bus->sendCommand(ILI9481_PIXFMT);
_bus->sendData(0x66);
_bus->sendCommand(0xb4); // Display Mode and Frame Memory Write Mode Setting
_bus->sendData(0x02);
_bus->sendData(0x00); //
_bus->sendData(0x00);
_bus->sendData(0x01);
delay(280);
_bus->sendCommand(0x29);
invertDisplay(false);
}
void Arduino_ILI9481_18bit::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
if ((x != _currentX) || (w != _currentW))
{
int16_t x_start = x + _xStart, x_end = x + w - 1 + _xStart;
_bus->writeCommand(ILI9481_CASET); // Column addr set
_bus->write(x_start >> 8);
_bus->write(x_start & 0xFF); // XSTART
_bus->write(x_end >> 8);
_bus->write(x_end & 0xFF); // XEND
_currentX = x;
_currentW = w;
}
if ((y != _currentY) || (h != _currentH))
{
int16_t y_start = y + _yStart, y_end = y + h - 1 + _yStart;
_bus->writeCommand(ILI9481_PASET); // Row addr set
_bus->write(y_start >> 8);
_bus->write(y_start & 0xFF); // YSTART
_bus->write(y_end >> 8);
_bus->write(y_end & 0xFF); // YEND
_currentY = y;
_currentH = h;
}
_bus->writeCommand(ILI9481_RAMWR); // write to RAM
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_ILI9481_18bit::setRotation(uint8_t r)
{
Arduino_TFT::setRotation(r);
switch (_rotation)
{
case 1:
r = (ILI9481_MADCTL_MV | ILI9481_MADCTL_BGR | ILI9481_MADCTL_HF | ILI9481_MADCTL_VF);
break;
case 2:
r = (ILI9481_MADCTL_BGR | ILI9481_MADCTL_HF);
break;
case 3:
r = (ILI9481_MADCTL_MV | ILI9481_MADCTL_BGR);
break;
default: // case 0:
r = (ILI9481_MADCTL_BGR | ILI9481_MADCTL_VF);
break;
}
_bus->beginWrite();
_bus->writeC8D8(ILI9481_MADCTL, r);
_bus->endWrite();
}
void Arduino_ILI9481_18bit::invertDisplay(bool i)
{
_bus->sendCommand((_ips ^ i) ? ILI9481_INVON : ILI9481_INVOFF);
}
void Arduino_ILI9481_18bit::displayOn(void)
{
_bus->sendCommand(ILI9481_SLPOUT);
delay(ILI9481_SLPOUT_DELAY);
}
void Arduino_ILI9481_18bit::displayOff(void)
{
_bus->sendCommand(ILI9481_SLPIN);
delay(ILI9481_SLPIN_DELAY);
}

View File

@@ -0,0 +1,65 @@
/*
* start rewrite from:
* https://github.com/adafruit/Adafruit-GFX-Library.git
*/
#ifndef _ARDUINO_ILI9481_18BIT_H_
#define _ARDUINO_ILI9481_18BIT_H_
#include "../Arduino_GFX.h"
#include "../Arduino_TFT_18bit.h"
#define ILI9481_TFTWIDTH 320 ///< ILI9481 max TFT width
#define ILI9481_TFTHEIGHT 480 ///< ILI9481 max TFT height
#define ILI9481_RST_DELAY 150 ///< delay ms wait for reset finish
#define ILI9481_SLPIN_DELAY 150 ///< delay ms wait for sleep in finish
#define ILI9481_SLPOUT_DELAY 150 ///< delay ms wait for sleep out finish
#define ILI9481_NOP 0x00 ///< No-op register
#define ILI9481_SWRESET 0x01 ///< Software reset register
#define ILI9481_SLPIN 0x10 ///< Enter Sleep Mode
#define ILI9481_SLPOUT 0x11 ///< Sleep Out
#define ILI9481_NORON 0x13 ///< Normal Display Mode ON
#define ILI9481_INVOFF 0x20 ///< Display Inversion OFF
#define ILI9481_INVON 0x21 ///< Display Inversion ON
#define ILI9481_DISPOFF 0x28 ///< Display OFF
#define ILI9481_DISPON 0x29 ///< Display ON
#define ILI9481_CASET 0x2A ///< Column Address Set
#define ILI9481_PASET 0x2B ///< Page Address Set
#define ILI9481_RAMWR 0x2C ///< Memory Write
#define ILI9481_RAMRD 0x2E ///< Memory Read
#define ILI9481_MADCTL 0x36 ///< Memory Access Control
#define ILI9481_PIXFMT 0x3A ///< COLMOD: Pixel Format Set
#define ILI9481_MADCTL_MY 0x80 ///< Bottom to top
#define ILI9481_MADCTL_MX 0x40 ///< Right to left
#define ILI9481_MADCTL_MV 0x20 ///< Reverse Mode
#define ILI9481_MADCTL_ML 0x10 ///< LCD refresh Bottom to top
#define ILI9481_MADCTL_RGB 0x00 ///< Red-Green-Blue pixel order
#define ILI9481_MADCTL_BGR 0x08 ///< Blue-Green-Red pixel order
#define ILI9481_MADCTL_HF 0x02
#define ILI9481_MADCTL_VF 0x01
class Arduino_ILI9481_18bit : public Arduino_TFT_18bit
{
public:
Arduino_ILI9481_18bit(Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0, bool ips = false);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void setRotation(uint8_t r) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
protected:
void tftInit() override;
private:
};
#endif

View File

@@ -0,0 +1,116 @@
#include "Arduino_ILI9486.h"
Arduino_ILI9486::Arduino_ILI9486(Arduino_DataBus *bus, int8_t rst, uint8_t r, bool ips)
: Arduino_TFT(bus, rst, r, ips, ILI9486_TFTWIDTH, ILI9486_TFTHEIGHT, 0, 0, 0, 0)
{
}
bool Arduino_ILI9486::begin(int32_t speed)
{
return Arduino_TFT::begin(speed);
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_ILI9486::setRotation(uint8_t r)
{
Arduino_TFT::setRotation(r);
switch (_rotation)
{
case 1:
r = (ILI9486_MADCTL_MV | ILI9486_MADCTL_BGR);
break;
case 2:
r = (ILI9486_MADCTL_MY | ILI9486_MADCTL_BGR);
break;
case 3:
r = (ILI9486_MADCTL_MY | ILI9486_MADCTL_MX | ILI9486_MADCTL_MV | ILI9486_MADCTL_BGR);
break;
case 4:
r = (ILI9486_MADCTL_BGR);
break;
case 5:
r = (ILI9486_MADCTL_MY | ILI9486_MADCTL_MV | ILI9486_MADCTL_BGR);
break;
case 6:
r = (ILI9486_MADCTL_MY | ILI9486_MADCTL_MX | ILI9486_MADCTL_BGR);
break;
case 7:
r = (ILI9486_MADCTL_MX | ILI9486_MADCTL_MV | ILI9486_MADCTL_BGR);
break;
default: // case 0:
r = (ILI9486_MADCTL_MX | ILI9486_MADCTL_BGR);
break;
}
_bus->beginWrite();
_bus->writeC8D8(ILI9486_MADCTL, r);
_bus->endWrite();
}
void Arduino_ILI9486::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
if ((x != _currentX) || (w != _currentW))
{
_currentX = x;
_currentW = w;
x += _xStart;
_bus->writeC8D16D16Split(ILI9486_CASET, x, x + w - 1);
}
if ((y != _currentY) || (h != _currentH))
{
_currentY = y;
_currentH = h;
y += _yStart;
_bus->writeC8D16D16Split(ILI9486_PASET, y, y + h - 1);
}
_bus->writeCommand(ILI9486_RAMWR); // write to RAM
}
void Arduino_ILI9486::invertDisplay(bool i)
{
_bus->sendCommand((_ips ^ i) ? ILI9486_INVON : ILI9486_INVOFF);
}
void Arduino_ILI9486::displayOn(void)
{
_bus->sendCommand(ILI9486_SLPOUT);
delay(ILI9486_SLPOUT_DELAY);
}
void Arduino_ILI9486::displayOff(void)
{
_bus->sendCommand(ILI9486_SLPIN);
delay(ILI9486_SLPIN_DELAY);
}
// Companion code to the above tables. Reads and issues
// a series of LCD commands stored in PROGMEM byte array.
void Arduino_ILI9486::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(ILI9486_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(ILI9486_RST_DELAY);
}
else
{
// Software Rest
_bus->sendCommand(ILI9486_SWRESET);
delay(ILI9486_RST_DELAY);
}
_bus->batchOperation(ili9486_init_operations, sizeof(ili9486_init_operations));
invertDisplay(false);
}

View File

@@ -0,0 +1,108 @@
#pragma once
#include "../Arduino_GFX.h"
#include "../Arduino_TFT.h"
#define ILI9486_TFTWIDTH 320 ///< ILI9486 max TFT width
#define ILI9486_TFTHEIGHT 480 ///< ILI9486 max TFT height
#define ILI9486_RST_DELAY 120 ///< delay ms wait for reset finish
#define ILI9486_SLPIN_DELAY 120 ///< delay ms wait for sleep in finish
#define ILI9486_SLPOUT_DELAY 150 ///< delay ms wait for sleep out finish
#define ILI9486_NOP 0x00 ///< No-op register
#define ILI9486_SWRESET 0x01 ///< Software reset register
#define ILI9486_RDDID 0x04 ///< Read display identification information
#define ILI9486_RDDST 0x09 ///< Read Display Status
#define ILI9486_SLPIN 0x10 ///< Enter Sleep Mode
#define ILI9486_SLPOUT 0x11 ///< Sleep Out
#define ILI9486_PTLON 0x12 ///< Partial Mode ON
#define ILI9486_NORON 0x13 ///< Normal Display Mode ON
#define ILI9486_RDMODE 0x0A ///< Read Display Power Mode
#define ILI9486_RDMADCTL 0x0B ///< Read Display MADCTL
#define ILI9486_RDPIXFMT 0x0C ///< Read Display Pixel Format
#define ILI9486_RDIMGFMT 0x0D ///< Read Display Image Format
#define ILI9486_RDSELFDIAG 0x0F ///< Read Display Self-Diagnostic Result
#define ILI9486_INVOFF 0x20 ///< Display Inversion OFF
#define ILI9486_INVON 0x21 ///< Display Inversion ON
#define ILI9486_GAMMASET 0x26 ///< Gamma Set
#define ILI9486_DISPOFF 0x28 ///< Display OFF
#define ILI9486_DISPON 0x29 ///< Display ON
#define ILI9486_CASET 0x2A ///< Column Address Set
#define ILI9486_PASET 0x2B ///< Page Address Set
#define ILI9486_RAMWR 0x2C ///< Memory Write
#define ILI9486_RAMRD 0x2E ///< Memory Read
#define ILI9486_MADCTL 0x36 ///< Memory Access Control
#define ILI9486_PIXFMT 0x3A ///< COLMOD: Pixel Format Set
#define ILI9486_GMCTRP1 0xE0 ///< Positive Gamma Correction
#define ILI9486_GMCTRN1 0xE1 ///< Negative Gamma Correction
#define ILI9486_MADCTL_MY 0x80 ///< Bottom to top
#define ILI9486_MADCTL_MX 0x40 ///< Right to left
#define ILI9486_MADCTL_MV 0x20 ///< Reverse Mode
#define ILI9486_MADCTL_ML 0x10 ///< LCD refresh Bottom to top
#define ILI9486_MADCTL_RGB 0x00 ///< Red-Green-Blue pixel order
#define ILI9486_MADCTL_BGR 0x08 ///< Blue-Green-Red pixel order
#define ILI9486_MADCTL_MH 0x04 ///< LCD refresh right to left
#define ILI9486_MADCTL_SS 0x02
#define ILI9486_MADCTL_GS 0x01
static const uint8_t ili9486_init_operations[] = {
BEGIN_WRITE,
WRITE_COMMAND_8, ILI9486_SLPOUT,
END_WRITE,
DELAY, ILI9486_SLPOUT_DELAY,
BEGIN_WRITE,
WRITE_C8_D8, ILI9486_PIXFMT, 0x55, // 16 bit colour interface
WRITE_C8_D8, 0xC2, 0x44,
WRITE_COMMAND_8, 0xC5,
WRITE_BYTES, 4, 0x00, 0x00, 0x00, 0x00,
WRITE_COMMAND_8, 0xE0,
WRITE_BYTES, 15,
0x0F, 0x1F, 0x1C, 0x0C,
0x0F, 0x08, 0x48, 0x98,
0x37, 0x0A, 0x13, 0x04,
0x11, 0x0D, 0x00,
WRITE_COMMAND_8, 0xE1,
WRITE_BYTES, 15,
0x0F, 0x32, 0x2E, 0x0B,
0x0D, 0x05, 0x47, 0x75,
0x37, 0x06, 0x10, 0x03,
0x24, 0x20, 0x00,
WRITE_COMMAND_8, ILI9486_DISPON,
END_WRITE,
DELAY, ILI9486_SLPOUT_DELAY};
class Arduino_ILI9486 : public Arduino_TFT
{
public:
Arduino_ILI9486(Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0, bool ips = false);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void setRotation(uint8_t r) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
protected:
void tftInit() override;
private:
};

View File

@@ -0,0 +1,116 @@
#include "Arduino_ILI9486_18bit.h"
Arduino_ILI9486_18bit::Arduino_ILI9486_18bit(Arduino_DataBus *bus, int8_t rst, uint8_t r, bool ips)
: Arduino_TFT_18bit(bus, rst, r, ips, ILI9486_TFTWIDTH, ILI9486_TFTHEIGHT, 0, 0, 0, 0)
{
}
bool Arduino_ILI9486_18bit::begin(int32_t speed)
{
return Arduino_TFT::begin(speed);
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_ILI9486_18bit::setRotation(uint8_t r)
{
Arduino_TFT::setRotation(r);
switch (_rotation)
{
case 1:
r = (ILI9486_MADCTL_MV | ILI9486_MADCTL_BGR);
break;
case 2:
r = (ILI9486_MADCTL_MY | ILI9486_MADCTL_BGR);
break;
case 3:
r = (ILI9486_MADCTL_MY | ILI9486_MADCTL_MX | ILI9486_MADCTL_MV | ILI9486_MADCTL_BGR);
break;
case 4:
r = (ILI9486_MADCTL_BGR);
break;
case 5:
r = (ILI9486_MADCTL_MY | ILI9486_MADCTL_MV | ILI9486_MADCTL_BGR);
break;
case 6:
r = (ILI9486_MADCTL_MY | ILI9486_MADCTL_MX | ILI9486_MADCTL_BGR);
break;
case 7:
r = (ILI9486_MADCTL_MX | ILI9486_MADCTL_MV | ILI9486_MADCTL_BGR);
break;
default: // case 0:
r = (ILI9486_MADCTL_MX | ILI9486_MADCTL_BGR);
break;
}
_bus->beginWrite();
_bus->writeC8D8(ILI9486_MADCTL, r);
_bus->endWrite();
}
void Arduino_ILI9486_18bit::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
if ((x != _currentX) || (w != _currentW))
{
_currentX = x;
_currentW = w;
x += _xStart;
_bus->writeC8D16D16Split(ILI9486_CASET, x, x + w - 1);
}
if ((y != _currentY) || (h != _currentH))
{
_currentY = y;
_currentH = h;
y += _yStart;
_bus->writeC8D16D16Split(ILI9486_PASET, y, y + h - 1);
}
_bus->writeCommand(ILI9486_RAMWR); // write to RAM
}
void Arduino_ILI9486_18bit::invertDisplay(bool i)
{
_bus->sendCommand((_ips ^ i) ? ILI9486_INVON : ILI9486_INVOFF);
}
void Arduino_ILI9486_18bit::displayOn(void)
{
_bus->sendCommand(ILI9486_SLPOUT);
delay(ILI9486_SLPOUT_DELAY);
}
void Arduino_ILI9486_18bit::displayOff(void)
{
_bus->sendCommand(ILI9486_SLPIN);
delay(ILI9486_SLPIN_DELAY);
}
// Companion code to the above tables. Reads and issues
// a series of LCD commands stored in PROGMEM byte array.
void Arduino_ILI9486_18bit::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(ILI9486_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(ILI9486_RST_DELAY);
}
else
{
// Software Rest
_bus->sendCommand(ILI9486_SWRESET);
delay(ILI9486_RST_DELAY);
}
_bus->batchOperation(ili9486_18bit_init_operations, sizeof(ili9486_18bit_init_operations));
invertDisplay(false);
}

View File

@@ -0,0 +1,58 @@
#pragma once
#include "Arduino_ILI9486.h"
#include "../Arduino_TFT_18bit.h"
static const uint8_t ili9486_18bit_init_operations[] = {
BEGIN_WRITE,
WRITE_COMMAND_8, ILI9486_SLPOUT,
END_WRITE,
DELAY, ILI9486_SLPOUT_DELAY,
BEGIN_WRITE,
WRITE_C8_D8, ILI9486_PIXFMT, 0x66, // 18-bit color
WRITE_C8_D8, 0xC2, 0x44,
WRITE_COMMAND_8, 0xC5,
WRITE_BYTES, 4, 0x00, 0x00, 0x00, 0x00,
WRITE_COMMAND_8, 0xE0,
WRITE_BYTES, 15,
0x0F, 0x1F, 0x1C, 0x0C,
0x0F, 0x08, 0x48, 0x98,
0x37, 0x0A, 0x13, 0x04,
0x11, 0x0D, 0x00,
WRITE_COMMAND_8, 0xE1,
WRITE_BYTES, 15,
0x0F, 0x32, 0x2E, 0x0B,
0x0D, 0x05, 0x47, 0x75,
0x37, 0x06, 0x10, 0x03,
0x24, 0x20, 0x00,
WRITE_COMMAND_8, ILI9486_DISPON,
END_WRITE,
DELAY, 25};
class Arduino_ILI9486_18bit : public Arduino_TFT_18bit
{
public:
Arduino_ILI9486_18bit(Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0, bool ips = false);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void setRotation(uint8_t r) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
protected:
void tftInit() override;
private:
};

View File

@@ -0,0 +1,107 @@
#include "Arduino_ILI9488.h"
Arduino_ILI9488::Arduino_ILI9488(Arduino_DataBus *bus, int8_t rst, uint8_t r, bool ips)
: Arduino_TFT(bus, rst, r, ips, ILI9488_TFTWIDTH, ILI9488_TFTHEIGHT, 0, 0, 0, 0)
{
}
bool Arduino_ILI9488::begin(int32_t speed)
{
return Arduino_TFT::begin(speed);
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_ILI9488::setRotation(uint8_t r)
{
Arduino_TFT::setRotation(r);
switch (_rotation)
{
case 1:
r = (ILI9488_MADCTL_BGR | ILI9488_MADCTL_MV);
break;
case 2:
r = (ILI9488_MADCTL_BGR | ILI9488_MADCTL_MY);
break;
case 3:
r = (ILI9488_MADCTL_BGR | ILI9488_MADCTL_MV | ILI9488_MADCTL_MX | ILI9488_MADCTL_MY);
break;
default: // case 0:
r = (ILI9488_MADCTL_BGR | ILI9488_MADCTL_MX);
break;
}
_bus->beginWrite();
_bus->writeC8D8(ILI9488_MADCTL, r);
_bus->endWrite();
}
void Arduino_ILI9488::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
if ((x != _currentX) || (w != _currentW))
{
_currentX = x;
_currentW = w;
x += _xStart;
_bus->writeC8D16D16Split(ILI9488_CASET, x, x + w - 1);
}
if ((y != _currentY) || (h != _currentH))
{
_currentY = y;
_currentH = h;
y += _yStart;
_bus->writeC8D16D16Split(ILI9488_PASET, y, y + h - 1);
}
_bus->writeCommand(ILI9488_RAMWR); // write to RAM
}
void Arduino_ILI9488::invertDisplay(bool i)
{
_bus->sendCommand((_ips ^ i) ? ILI9488_INVON : ILI9488_INVOFF);
}
void Arduino_ILI9488::displayOn(void)
{
_bus->sendCommand(ILI9488_SLPOUT);
delay(ILI9488_SLPOUT_DELAY);
}
void Arduino_ILI9488::displayOff(void)
{
_bus->sendCommand(ILI9488_SLPIN);
delay(ILI9488_SLPIN_DELAY);
}
// Companion code to the above tables. Reads and issues
// a series of LCD commands stored in PROGMEM byte array.
void Arduino_ILI9488::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(ILI9488_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(ILI9488_RST_DELAY);
}
else
{
// Software Rest
_bus->sendCommand(ILI9488_SWRESET);
delay(ILI9488_RST_DELAY);
}
_bus->batchOperation(ili9488_init_operations, sizeof(ili9488_init_operations));
_bus->beginWrite();
_bus->writeC8D8(0x3A, 0x55); // Interface Pixel Format, 16 bit
_bus->endWrite();
invertDisplay(false);
}

View File

@@ -0,0 +1,122 @@
/*
* start rewrite from:
* https://github.com/nopnop2002/esp-idf-parallel-tft
*/
#ifndef _ARDUINO_ILI9488_H_
#define _ARDUINO_ILI9488_H_
#include "../Arduino_GFX.h"
#include "../Arduino_TFT.h"
#define ILI9488_TFTWIDTH 320 ///< ILI9488 max TFT width
#define ILI9488_TFTHEIGHT 480 ///< ILI9488 max TFT height
#define ILI9488_RST_DELAY 150 ///< delay ms wait for reset finish
#define ILI9488_SLPIN_DELAY 150 ///< delay ms wait for sleep in finish
#define ILI9488_SLPOUT_DELAY 150 ///< delay ms wait for sleep out finish
// Generic commands used by ILI9488_eSPI.cpp
#define ILI9488_NOP 0x00
#define ILI9488_SWRESET 0x01
#define ILI9488_SLPIN 0x10
#define ILI9488_SLPOUT 0x11
#define ILI9488_INVOFF 0x20
#define ILI9488_INVON 0x21
#define ILI9488_DISPOFF 0x28
#define ILI9488_DISPON 0x29
#define ILI9488_CASET 0x2A
#define ILI9488_PASET 0x2B
#define ILI9488_RAMWR 0x2C
#define ILI9488_RAMRD 0x2E
#define ILI9488_MADCTL 0x36
#define ILI9488_MADCTL_MY 0x80
#define ILI9488_MADCTL_MX 0x40
#define ILI9488_MADCTL_MV 0x20
#define ILI9488_MADCTL_ML 0x10
#define ILI9488_MADCTL_RGB 0x00
#define ILI9488_MADCTL_BGR 0x08
#define ILI9488_MADCTL_MH 0x04
#define ILI9488_MADCTL_SS 0x02
#define ILI9488_MADCTL_GS 0x01
static const uint8_t ili9488_init_operations[] = {
BEGIN_WRITE,
WRITE_COMMAND_8, 0xE0,
WRITE_BYTES, 15,
0x00, 0x03, 0x09, 0x08,
0x16, 0x0A, 0x3F, 0x78,
0x4C, 0x09, 0x0A, 0x08,
0x16, 0x1A, 0x0F,
WRITE_COMMAND_8, 0xE1,
WRITE_BYTES, 15,
0x00, 0x16, 0x19, 0x03,
0x0F, 0x05, 0x32, 0x45,
0x46, 0x04, 0x0E, 0x0D,
0x35, 0x37, 0x0F,
WRITE_C8_D16, 0XC0, // Power Control 1
0x17, // Vreg1out
0x15, // Verg2out
WRITE_C8_D8, 0xC1, // Power Control 2
0x41, // VGH,VGL
WRITE_COMMAND_8, 0xC5, // Power Control 3
WRITE_BYTES, 3,
0x00,
0x12, // Vcom
0x80,
WRITE_C8_D8, 0xB0, 0x80, // Interface Mode Control, SDO NOT USE
WRITE_C8_D8, 0xB1, 0xA0, // Frame rate, 60Hz
WRITE_C8_D8, 0xB4, 0x02, // Display Inversion Control, 2-dot
WRITE_C8_D16, 0xB6, // Display Function Control RGB/MCU Interface Control
0x02, // MCU
0x02, // Source,Gate scan dieection
WRITE_C8_D8, 0xE9, 0x00, // Set Image Function, disable 24 bit data
WRITE_COMMAND_8, 0xF7, // Adjust Control
WRITE_BYTES, 4, 0xA9, 0x51, 0x2C, 0x82, // D7 stream, loose
WRITE_COMMAND_8, ILI9488_SLPOUT, // Sleep Out
END_WRITE,
DELAY, ILI9488_SLPOUT_DELAY,
BEGIN_WRITE,
WRITE_COMMAND_8, ILI9488_DISPON, // Display on
END_WRITE};
class Arduino_ILI9488 : public Arduino_TFT
{
public:
Arduino_ILI9488(Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0, bool ips = false);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void setRotation(uint8_t r) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
protected:
void tftInit() override;
private:
};
#endif // #ifndef _ARDUINO_ILI9488_H_

View File

@@ -0,0 +1,107 @@
#include "Arduino_ILI9488_18bit.h"
Arduino_ILI9488_18bit::Arduino_ILI9488_18bit(Arduino_DataBus *bus, int8_t rst, uint8_t r, bool ips)
: Arduino_TFT_18bit(bus, rst, r, ips, ILI9488_TFTWIDTH, ILI9488_TFTHEIGHT, 0, 0, 0, 0)
{
}
bool Arduino_ILI9488_18bit::begin(int32_t speed)
{
return Arduino_TFT::begin(speed);
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_ILI9488_18bit::setRotation(uint8_t r)
{
Arduino_TFT::setRotation(r);
switch (_rotation)
{
case 1:
r = (ILI9488_MADCTL_BGR | ILI9488_MADCTL_MV);
break;
case 2:
r = (ILI9488_MADCTL_BGR | ILI9488_MADCTL_MY);
break;
case 3:
r = (ILI9488_MADCTL_BGR | ILI9488_MADCTL_MV | ILI9488_MADCTL_MX | ILI9488_MADCTL_MY);
break;
default: // case 0:
r = (ILI9488_MADCTL_BGR | ILI9488_MADCTL_MX);
break;
}
_bus->beginWrite();
_bus->writeC8D8(ILI9488_MADCTL, r);
_bus->endWrite();
}
void Arduino_ILI9488_18bit::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
if ((x != _currentX) || (w != _currentW))
{
_currentX = x;
_currentW = w;
x += _xStart;
_bus->writeC8D16D16(ILI9488_CASET, x, x + w - 1);
}
if ((y != _currentY) || (h != _currentH))
{
_currentY = y;
_currentH = h;
y += _yStart;
_bus->writeC8D16D16(ILI9488_PASET, y, y + h - 1);
}
_bus->writeCommand(ILI9488_RAMWR); // write to RAM
}
void Arduino_ILI9488_18bit::invertDisplay(bool i)
{
_bus->sendCommand((_ips ^ i) ? ILI9488_INVON : ILI9488_INVOFF);
}
void Arduino_ILI9488_18bit::displayOn(void)
{
_bus->sendCommand(ILI9488_SLPOUT);
delay(ILI9488_SLPOUT_DELAY);
}
void Arduino_ILI9488_18bit::displayOff(void)
{
_bus->sendCommand(ILI9488_SLPIN);
delay(ILI9488_SLPIN_DELAY);
}
// Companion code to the above tables. Reads and issues
// a series of LCD commands stored in PROGMEM byte array.
void Arduino_ILI9488_18bit::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(ILI9488_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(ILI9488_RST_DELAY);
}
else
{
// Software Rest
_bus->sendCommand(ILI9488_SWRESET);
delay(ILI9488_RST_DELAY);
}
_bus->batchOperation(ili9488_init_operations, sizeof(ili9488_init_operations));
_bus->beginWrite();
_bus->writeC8D8(0x3A, 0x66); // Interface Pixel Format, 18 bit
_bus->endWrite();
invertDisplay(false);
}

View File

@@ -0,0 +1,32 @@
/*
* start rewrite from:
* https://github.com/adafruit/Adafruit-GFX-Library.git
*/
#ifndef _ARDUINO_ILI9488_18BIT_H_
#define _ARDUINO_ILI9488_18BIT_H_
#include "Arduino_ILI9488.h"
#include "../Arduino_TFT_18bit.h"
class Arduino_ILI9488_18bit : public Arduino_TFT_18bit
{
public:
Arduino_ILI9488_18bit(Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0, bool ips = false);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void setRotation(uint8_t r) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
protected:
void tftInit() override;
private:
};
#endif

View File

@@ -0,0 +1,129 @@
#include "Arduino_DataBus.h"
#if !defined(LITTLE_FOOT_PRINT)
#include "Arduino_ILI9488_3bit.h"
Arduino_ILI9488_3bit::Arduino_ILI9488_3bit(Arduino_DataBus *bus, int8_t rst, uint8_t r, bool ips)
: Arduino_G(ILI9488_TFTWIDTH, ILI9488_TFTHEIGHT), _bus(bus), _rst(rst), _rotation(r), _ips(ips)
{
}
bool Arduino_ILI9488_3bit::begin(int32_t speed)
{
if (speed != GFX_SKIP_DATABUS_BEGIN)
{
if (!_bus->begin(speed))
{
return false;
}
}
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(ILI9488_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(ILI9488_RST_DELAY);
}
else
{
// Software Rest
_bus->sendCommand(ILI9488_SWRESET);
delay(ILI9488_RST_DELAY);
}
_bus->batchOperation(ili9488_init_operations, sizeof(ili9488_init_operations));
_bus->beginWrite();
_bus->writeC8D8(0x3A, 0x01); // Interface Pixel Format, 3 bit
_bus->endWrite();
if (_ips)
{
_bus->sendCommand(ILI9488_INVON);
}
else
{
_bus->sendCommand(ILI9488_INVOFF);
}
uint16_t r;
// setRotation
switch (_rotation)
{
case 1:
r = (ILI9488_MADCTL_BGR | ILI9488_MADCTL_MV);
break;
case 2:
r = (ILI9488_MADCTL_BGR | ILI9488_MADCTL_MY);
break;
case 3:
r = (ILI9488_MADCTL_BGR | ILI9488_MADCTL_MV | ILI9488_MADCTL_MX | ILI9488_MADCTL_MY);
break;
default: // case 0:
r = (ILI9488_MADCTL_BGR | ILI9488_MADCTL_MX);
break;
}
_bus->beginWrite();
_bus->writeC8D8(ILI9488_MADCTL, r);
_bus->endWrite();
return true;
}
void Arduino_ILI9488_3bit::drawBitmap(int16_t, int16_t, uint8_t *, int16_t, int16_t, uint16_t, uint16_t)
{
printf("Not Implemented drawBitmap()");
}
void Arduino_ILI9488_3bit::drawIndexedBitmap(int16_t, int16_t, uint8_t *, uint16_t *, int16_t, int16_t, int16_t)
{
printf("Not Implemented drawIndexedBitmap()");
}
void Arduino_ILI9488_3bit::draw3bitRGBBitmap(int16_t, int16_t, uint8_t *bitmap, int16_t w, int16_t h)
{
_bus->beginWrite();
writeAddrWindow(0, 0, w, h);
_bus->writeBytes(bitmap, w * h / 2);
_bus->endWrite();
}
void Arduino_ILI9488_3bit::draw16bitRGBBitmap(int16_t, int16_t, uint16_t *, int16_t, int16_t)
{
printf("Not Implemented draw16bitRGBBitmap()");
}
void Arduino_ILI9488_3bit::draw24bitRGBBitmap(int16_t, int16_t, uint8_t *, int16_t, int16_t)
{
printf("Not Implemented draw24bitRGBBitmap()");
}
void Arduino_ILI9488_3bit::invertDisplay(bool i)
{
_bus->sendCommand(i ? ILI9488_INVON : ILI9488_INVOFF);
}
void Arduino_ILI9488_3bit::displayOn(void)
{
_bus->sendCommand(ILI9488_SLPOUT);
delay(ILI9488_SLPOUT_DELAY);
}
void Arduino_ILI9488_3bit::displayOff(void)
{
_bus->sendCommand(ILI9488_SLPIN);
delay(ILI9488_SLPIN_DELAY);
}
void Arduino_ILI9488_3bit::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
_bus->writeC8D16D16(ILI9488_CASET, x, x + w - 1);
_bus->writeC8D16D16(ILI9488_PASET, y, y + h - 1);
_bus->writeCommand(ILI9488_RAMWR);
}
#endif // !defined(LITTLE_FOOT_PRINT)

View File

@@ -0,0 +1,38 @@
#include "Arduino_DataBus.h"
#if !defined(LITTLE_FOOT_PRINT)
#ifndef _ARDUINO_ILI9488_3BIT_H_
#define _ARDUINO_ILI9488_3BIT_H_
#include "Arduino_ILI9488.h"
class Arduino_ILI9488_3bit : public Arduino_G
{
public:
Arduino_ILI9488_3bit(Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0, bool ips = false);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void drawBitmap(int16_t x, int16_t y, uint8_t *bitmap, int16_t w, int16_t h, uint16_t color, uint16_t bg) override;
void drawIndexedBitmap(int16_t x, int16_t y, uint8_t *bitmap, uint16_t *color_index, int16_t w, int16_t h, int16_t x_skip = 0) override;
void draw3bitRGBBitmap(int16_t x, int16_t y, uint8_t *bitmap, int16_t w, int16_t h) override;
void draw16bitRGBBitmap(int16_t x, int16_t y, uint16_t *bitmap, int16_t w, int16_t h) override;
void draw24bitRGBBitmap(int16_t x, int16_t y, uint8_t *bitmap, int16_t w, int16_t h) override;
void invertDisplay(bool);
void displayOn();
void displayOff();
protected:
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h);
Arduino_DataBus *_bus;
int8_t _rst;
uint8_t _rotation;
bool _ips;
private:
};
#endif // _ARDUINO_ILI9488_3BIT_H_
#endif // !defined(LITTLE_FOOT_PRINT)

View File

@@ -0,0 +1,110 @@
#include "Arduino_ILI9806.h"
#include "SPI.h"
Arduino_ILI9806::Arduino_ILI9806(Arduino_DataBus *bus, int8_t rst, uint8_t r, bool ips)
: Arduino_TFT(bus, rst, r, ips, ILI9806_TFTWIDTH, ILI9806_TFTHEIGHT, 0, 0, 0, 0)
{
}
bool Arduino_ILI9806::begin(int32_t speed)
{
_override_datamode = SPI_MODE0; // always use SPI_MODE0
return Arduino_TFT::begin(speed);
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_ILI9806::setRotation(uint8_t r)
{
Arduino_TFT::setRotation(r);
switch (_rotation)
{
case 3:
r = (ILI9806_MADCTL_MY | ILI9806_MADCTL_MV | ILI9806_MADCTL_RGB);
break;
case 2:
r = (ILI9806_MADCTL_MX | ILI9806_MADCTL_MY | ILI9806_MADCTL_RGB);
break;
case 1:
r = (ILI9806_MADCTL_MX | ILI9806_MADCTL_MV | ILI9806_MADCTL_RGB);
break;
default: // case 0:
r = ILI9806_MADCTL_RGB;
break;
}
_bus->beginWrite();
_bus->writeC8D8(ILI9806_MADCTL, r);
_bus->endWrite();
}
void Arduino_ILI9806::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
if ((x != _currentX) || (w != _currentW))
{
_currentX = x;
_currentW = w;
x += _xStart;
_bus->writeC8D16D16Split(ILI9806_CASET, x, x + w - 1);
}
if ((y != _currentY) || (h != _currentH))
{
_currentY = y;
_currentH = h;
y += _yStart;
_bus->writeC8D16D16Split(ILI9806_PASET, y, y + h - 1);
}
_bus->writeCommand(ILI9806_RAMWR); // write to RAM
}
void Arduino_ILI9806::invertDisplay(bool i)
{
_bus->sendCommand((_ips ^ i) ? ILI9806_INVON : ILI9806_INVOFF);
}
void Arduino_ILI9806::displayOn(void)
{
_bus->sendCommand(ILI9806_SLPOUT);
delay(ILI9806_SLPOUT_DELAY);
_bus->sendCommand(ILI9806_DISPON);
}
void Arduino_ILI9806::displayOff(void)
{
_bus->sendCommand(ILI9806_DISPOFF);
delay(10);
_bus->sendCommand(ILI9806_SLPIN);
delay(ILI9806_SLPIN_DELAY);
}
// Companion code to the above tables. Reads and issues
// a series of LCD commands stored in PROGMEM byte array.
void Arduino_ILI9806::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(1);
digitalWrite(_rst, LOW);
delay(10);
digitalWrite(_rst, HIGH);
delay(ILI9806_RST_DELAY);
}
else
{
// Software Rest
_bus->sendCommand(ILI9806_SWRESET);
delay(ILI9806_RST_DELAY);
}
_bus->batchOperation(ili9806_init_operations, sizeof(ili9806_init_operations));
invertDisplay(false);
}

View File

@@ -0,0 +1,219 @@
#ifndef _ARDUINO_ILI9806_H_
#define _ARDUINO_ILI9806_H_
#include "../Arduino_GFX.h"
#include "../Arduino_TFT.h"
#define ILI9806_TFTWIDTH 480 ///< ILI9806 max TFT width
#define ILI9806_TFTHEIGHT 854 ///< ILI9806 max TFT height
#define ILI9806_RST_DELAY 120 ///< delay ms wait for reset finish
#define ILI9806_SLPIN_DELAY 120 ///< delay ms wait for sleep in finish
#define ILI9806_SLPOUT_DELAY 120 ///< delay ms wait for sleep out finish
#define ILI9806_NOP 0x00 ///< No-op register
#define ILI9806_SWRESET 0x01 ///< Software reset register
#define ILI9806_RDDID 0x04 ///< Read display identification information
#define ILI9806_RDDST 0x09 ///< Read Display Status
#define ILI9806_SLPIN 0x10 ///< Enter Sleep Mode
#define ILI9806_SLPOUT 0x11 ///< Sleep Out
#define ILI9806_PTLON 0x12 ///< Partial Mode ON
#define ILI9806_NORON 0x13 ///< Normal Display Mode ON
#define ILI9806_RDMODE 0x0A ///< Read Display Power Mode
#define ILI9806_RDMADCTL 0x0B ///< Read Display MADCTL
#define ILI9806_RDPIXFMT 0x0C ///< Read Display Pixel Format
#define ILI9806_RDIMGFMT 0x0D ///< Read Display Image Format
#define ILI9806_RDSELFDIAG 0x0F ///< Read Display Self-Diagnostic Result
#define ILI9806_INVOFF 0x20 ///< Display Inversion OFF
#define ILI9806_INVON 0x21 ///< Display Inversion ON
#define ILI9806_GAMMASET 0x26 ///< Gamma Set
#define ILI9806_DISPOFF 0x28 ///< Display OFF
#define ILI9806_DISPON 0x29 ///< Display ON
#define ILI9806_CASET 0x2A ///< Column Address Set
#define ILI9806_PASET 0x2B ///< Page Address Set
#define ILI9806_RAMWR 0x2C ///< Memory Write
#define ILI9806_RAMRD 0x2E ///< Memory Read
#define ILI9806_PTLAR 0x30 ///< Partial Area
#define ILI9806_VSCRDEF 0x33 ///< Vertical Scrolling Definition
#define ILI9806_MADCTL 0x36 ///< Memory Access Control
#define ILI9806_VSCRSADD 0x37 ///< Vertical Scrolling Start Address
#define ILI9806_PIXFMT 0x3A ///< COLMOD: Pixel Format Set
#define ILI9806_FRMCTR1 0xB1 ///< Frame Rate Control (In Normal Mode/Full Colors)
#define ILI9806_FRMCTR2 0xB2 ///< Frame Rate Control (In Idle Mode/8 colors)
#define ILI9806_FRMCTR3 0xB3 ///< Frame Rate control (In Partial Mode/Full Colors)
#define ILI9806_INVCTR 0xB4 ///< Display Inversion Control
#define ILI9806_DFUNCTR 0xB6 ///< Display Function Control
#define ILI9806_PWCTR1 0xC0 ///< Power Control 1
#define ILI9806_PWCTR2 0xC1 ///< Power Control 2
#define ILI9806_PWCTR3 0xC2 ///< Power Control 3
#define ILI9806_PWCTR4 0xC3 ///< Power Control 4
#define ILI9806_PWCTR5 0xC4 ///< Power Control 5
#define ILI9806_VMCTR1 0xC5 ///< VCOM Control 1
#define ILI9806_VMCTR2 0xC7 ///< VCOM Control 2
#define ILI9806_RDID1 0xDA ///< Read ID 1
#define ILI9806_RDID2 0xDB ///< Read ID 2
#define ILI9806_RDID3 0xDC ///< Read ID 3
#define ILI9806_RDID4 0xDD ///< Read ID 4
#define ILI9806_GMCTRP1 0xE0 ///< Positive Gamma Correction
#define ILI9806_GMCTRN1 0xE1 ///< Negative Gamma Correction
#define ILI9806_PWCTR6 0xFC
#define ILI9806_MADCTL_MY 0x80 ///< Bottom to top
#define ILI9806_MADCTL_MX 0x40 ///< Right to left
#define ILI9806_MADCTL_MV 0x20 ///< Reverse Mode
#define ILI9806_MADCTL_ML 0x10 ///< LCD refresh Bottom to top
#define ILI9806_MADCTL_RGB 0x00 ///< Red-Green-Blue pixel order
#define ILI9806_MADCTL_BGR 0x08 ///< Blue-Green-Red pixel order
#define ILI9806_MADCTL_MH 0x04 ///< LCD refresh right to left
static const uint8_t ili9806_init_operations[] = {
BEGIN_WRITE,
WRITE_COMMAND_8, 0xFF, // EXTC Command Set enable register
WRITE_BYTES, 3, 0xFF, 0x98, 0x06,
WRITE_C8_D8, 0xBA, 0x60, // SPI Interface Setting
WRITE_COMMAND_8, 0xBC, // GIP 1
WRITE_BYTES, 21,
0x01, 0x10, 0x00, 0x00, 0x01,
0x01, 0x0B, 0x11, 0x32, 0x10,
0x00, 0x00, 0x01, 0x01, 0x01,
0x01, 0x50, 0x52, 0x01, 0x00,
0x40,
WRITE_COMMAND_8, 0xBD, // GIP 2
WRITE_BYTES, 8,
0x01, 0x23, 0x45, 0x67, 0x01,
0x23, 0x45, 0x67,
WRITE_COMMAND_8, 0xBE, // GIP 3
WRITE_BYTES, 9,
0x00, 0x21, 0xAB, 0x60, 0x22,
0x22, 0x22, 0x22, 0x22,
WRITE_C8_D8, 0xC7, 0x30, // VCOM Control
WRITE_COMMAND_8, 0xED, // EN_volt_reg
WRITE_BYTES, 3, 0x7F, 0x0F, 0x00,
WRITE_COMMAND_8, 0xC0, // Power Control 1
WRITE_BYTES, 3, 0x03, 0x0B, 0x0C, // 0A VGH VGL
WRITE_COMMAND_8, 0xFD, // External Power Selection Set
WRITE_BYTES, 2, 0x0A, 0x00,
WRITE_C8_D8, 0xFC, 0x08, // LVGL
WRITE_COMMAND_8, 0xDF, // Engineering Setting
WRITE_BYTES, 6,
0x00, 0x00, 0x00, 0x00, 0x00,
0x20,
WRITE_C8_D8, 0xF3, 0x74, // DVDD Voltage Setting
WRITE_COMMAND_8, 0xB4, // Display Inversion Control
WRITE_BYTES, 3, 0x00, 0x00, 0x00,
WRITE_COMMAND_8, 0xB5, // Blanking Porch Control
WRITE_BYTES, 2, 0x08, 0x15,
WRITE_C8_D8, 0xF7, 0x81, // 480x854
WRITE_COMMAND_8, 0xB1, // Frame Rate Control
WRITE_BYTES, 3, 0x00, 0x13, 0x13,
WRITE_COMMAND_8, 0xF2, // Panel Timing Control
WRITE_BYTES, 4, 0x80, 0x04, 0x40, 0x28,
WRITE_COMMAND_8, 0xC1, // Power Control 2
WRITE_BYTES, 3,
0x17,
0x71, // VGMP
0x71, // VGMN
WRITE_COMMAND_8, 0xE0, // P_Gamma
WRITE_BYTES, 16,
0x00, // P1
0x13, // P2
0x1A, // P3
0x0C, // P4
0x0E, // P5
0x0B, // P6
0x07, // P7
0x05, // P8
0x05, // P9
0x0A, // P10
0x0F, // P11
0x0F, // P12
0x0E, // P13
0x1C, // P14
0x16, // P15
0x00, // P16
WRITE_COMMAND_8, 0xE1, // N_Gamma
WRITE_BYTES, 16,
0x00, // P1
0x13, // P2
0x1A, // P3
0x0C, // P4
0x0E, // P5
0x0B, // P6
0x07, // P7
0x05, // P8
0x05, // P9
0x0A, // P10
0x0F, // P11
0x0F, // P12
0x0E, // P13
0x1C, // P14
0x16, // P15
0x00, // P16
WRITE_C8_D8, 0x3A, 0x55, // 55-16BIT,66-18BIT,77-24BIT
WRITE_COMMAND_8, 0x11,
END_WRITE,
DELAY, ILI9806_SLPOUT_DELAY,
BEGIN_WRITE,
WRITE_COMMAND_8, 0x29,
END_WRITE,
DELAY, 25,
BEGIN_WRITE,
WRITE_COMMAND_8, 0x2C,
END_WRITE};
class Arduino_ILI9806 : public Arduino_TFT
{
public:
Arduino_ILI9806(Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0, bool ips = false);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void setRotation(uint8_t r) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
protected:
void tftInit() override;
private:
};
#endif

View File

@@ -0,0 +1,182 @@
/*
* start rewrite from:
* https://github.com/adafruit/Adafruit-GFX-Library.git
* https://github.com/gitcnd/LCDWIKI_SPI.git
*/
#include "Arduino_JBT6K71.h"
#include "SPI.h"
Arduino_JBT6K71::Arduino_JBT6K71(
Arduino_DataBus *bus, int8_t rst, uint8_t r, bool ips, int16_t w, int16_t h,
uint8_t col_offset1, uint8_t row_offset1, uint8_t col_offset2, uint8_t row_offset2)
: Arduino_TFT(bus, rst, r, ips, w, h, col_offset1, row_offset1, col_offset2, row_offset2)
{
}
bool Arduino_JBT6K71::begin(int32_t speed)
{
return Arduino_TFT::begin(speed);
}
// Companion code to the above tables. Reads and issues
// a series of LCD commands stored in PROGMEM byte array.
void Arduino_JBT6K71::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(JBT6K71_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(JBT6K71_RST_DELAY);
}
else
{
// Software Rest
}
_bus->batchOperation(jbt6k71_init_operations, sizeof(jbt6k71_init_operations));
invertDisplay(false);
}
void Arduino_JBT6K71::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
uint16_t cmd1, cmd2, cmd3;
if ((x != _currentX) || (w != _currentW))
{
int16_t x_start, x_end, x_pos;
if (_rotation & 0x01) // Landscape
{
cmd1 = 0x0408;
cmd2 = 0x0409;
cmd3 = 0x0201;
}
else
{
cmd1 = 0x0406;
cmd2 = 0x0407;
cmd3 = 0x0200;
}
if (_rotation == 1)
{
x_start = JBT6K71_TFTHEIGHT - x - w - _xStart;
x_end = JBT6K71_TFTHEIGHT - x - 1 - _xStart;
x_pos = x_end;
}
else
{
x_start = x + _xStart;
x_end = x + w - 1 + _xStart;
x_pos = x_start;
}
_bus->writeCommand16(cmd1);
_bus->write16(x_start);
_bus->writeCommand16(cmd2);
_bus->write16(x_end);
_bus->writeCommand16(cmd3);
_bus->write16(x_pos);
_currentX = x;
_currentW = w;
}
if ((y != _currentY) || (h != _currentH))
{
int16_t y_start, y_end, y_pos;
if (_rotation & 0x01) // Portrait
{
cmd1 = 0x0406;
cmd2 = 0x0407;
cmd3 = 0x0200;
}
else
{
cmd1 = 0x0408;
cmd2 = 0x0409;
cmd3 = 0x0201;
}
if (_rotation == 0)
{
y_start = JBT6K71_TFTHEIGHT - y - h - _yStart;
y_end = JBT6K71_TFTHEIGHT - y - 1 - _yStart;
y_pos = y_end;
}
else
{
y_start = y + _yStart;
y_end = y + h - 1 + _yStart;
y_pos = y_start;
}
_bus->writeCommand16(cmd1);
_bus->write16(y_start);
_bus->writeCommand16(cmd2);
_bus->write16(y_end);
_bus->writeCommand16(cmd3);
_bus->write16(y_pos);
_currentY = y;
_currentH = h;
}
_bus->writeCommand16(0x0202); // write to RAM
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_JBT6K71::setRotation(uint8_t r)
{
Arduino_TFT::setRotation(r);
uint16_t output_control, entry_mode;
switch (_rotation)
{
case 1:
output_control = 0x0127; // SS=1
entry_mode = 0x0018;
break;
case 2:
output_control = 0x0127; // SS=1
entry_mode = 0x0030;
break;
case 3:
output_control = 0x0027; // SS=0
entry_mode = 0x0038;
break;
default: // case 0:
output_control = 0x0027; // SS=0
entry_mode = 0x0010; // ID=01
break;
}
_bus->beginWrite();
_bus->writeCommand16(0x0001); // Driver output control
_bus->write16(output_control);
_bus->writeCommand16(0x0003); // Entry mode
_bus->write16(entry_mode);
_bus->endWrite();
}
void Arduino_JBT6K71::invertDisplay(bool i)
{
_bus->beginWrite();
_bus->writeCommand16(0x0007); // Display mode
_bus->write16((_ips ^ i) ? 0x4004 : 0x4000);
_bus->endWrite();
}
void Arduino_JBT6K71::displayOn(void)
{
// Not Implemented
}
void Arduino_JBT6K71::displayOff(void)
{
// Not Implemented
}

View File

@@ -0,0 +1,140 @@
/*
* start rewrite from:
* https://github.com/adafruit/Adafruit-GFX-Library.git
* https://github.com/gitcnd/LCDWIKI_SPI.git
*/
#ifndef _ARDUINO_JBT6K71_H_
#define _ARDUINO_JBT6K71_H_
#include "../Arduino_GFX.h"
#include "../Arduino_TFT.h"
#define JBT6K71_TFTWIDTH 240 ///< JBT6K71 max TFT width
#define JBT6K71_TFTHEIGHT 320 ///< JBT6K71 max TFT height
#define JBT6K71_RST_DELAY 150
static const uint8_t jbt6k71_init_operations[] = {
BEGIN_WRITE,
WRITE_COMMAND_16, 0x00, 0x00, // exiting from deep standby mode
END_WRITE,
DELAY, 10, // spec 1ms
BEGIN_WRITE,
WRITE_COMMAND_16, 0x00, 0x00,
END_WRITE,
DELAY, 10, // spec 1ms
BEGIN_WRITE,
WRITE_COMMAND_16, 0x00, 0x00,
END_WRITE,
DELAY, 10, // spec 1ms
BEGIN_WRITE,
WRITE_C16_D16, 0x00, 0x1d, // mode setting
0x00, 0x05, // exit standby
END_WRITE,
DELAY, 100, // spec 1ms
BEGIN_WRITE,
WRITE_C16_D16, 0x00, 0x00, // oscillation setting
0x00, 0x01, // set to on
END_WRITE,
DELAY, 100, // spec 1ms
// Display control
BEGIN_WRITE,
WRITE_C16_D16, 0x00, 0x02, // LCD driver AC control
0x02, 0x00, // line inversion
WRITE_C16_D16, 0x00, 0x0d, // FR period adjustment setting
0x00, 0x11, // Ffr=60Hz optimized
END_WRITE,
DELAY, 100, // spec 1ms
// LTPS control settings
BEGIN_WRITE,
WRITE_C16_D16, 0x00, 0x12, // LTPS control setting 1
0x03, 0x03,
WRITE_C16_D16, 0x00, 0x13, // LTPS control setting 2
0x01, 0x02,
WRITE_C16_D16, 0x00, 0x1c, // Amplifier capability setting
0x00, 0x00, // Maximum
// Power settings
WRITE_C16_D16, 0x01, 0x02, // Power supply control (1)
0x00, 0xf6, // VCOMD Output voltage: 1.4V(Initial), VCS output voltage: 4.5V, VGM output voltage: 4.3V
END_WRITE,
DELAY, 250, // uint8_t max value 255
DELAY, 250,
BEGIN_WRITE,
WRITE_C16_D16, 0x01, 0x03, // Power Supply Control (2)
0x00, 0x07, // Boosting clock mode: Dual mode, XVDD output voltage: 5.4V
END_WRITE,
DELAY, 100,
BEGIN_WRITE,
WRITE_C16_D16, 0x01, 0x05, // Power supply control (4)
0x01, 0x11, // Mask period (DCEW1/DCEW2): 1.0 clock, DCCLK frequency for external regulate circuit: 1H, DCCLK frequency for XVDD regulate circuit: 1/2H, DCCLK frequency for AVDD regulate circuit: 1H
END_WRITE,
DELAY, 100,
// Gray scale settings (gamma c
BEGIN_WRITE,
WRITE_C16_D16, 0x03, 0x00, 0x02, 0x00, // chan
WRITE_C16_D16, 0x03, 0x01, 0x00, 0x02, //
WRITE_C16_D16, 0x03, 0x02, 0x00, 0x00,
WRITE_C16_D16, 0x03, 0x03, 0x03, 0x00, //
WRITE_C16_D16, 0x03, 0x04, 0x07, 0x00,
WRITE_C16_D16, 0x03, 0x05, 0x00, 0x70, //
WRITE_C16_D16, 0x04, 0x02, 0x00, 0x00, // First screen start, 0
WRITE_C16_D16, 0x04, 0x03, 0x01, 0x3f, // First screen end, 319
WRITE_C16_D16, 0x01, 0x00, 0xC0, 0x10, // Display Control
END_WRITE,
DELAY, 250, // uint8_t max value 255
DELAY, 250,
BEGIN_WRITE,
WRITE_C16_D16, 0x01, 0x01, 0x00, 0x01, // Auto sequence Control, AUTO
WRITE_C16_D16, 0x01, 0x00, 0xF7, 0xFE, // Display Control
END_WRITE,
DELAY, 250, // uint8_t max value 255
DELAY, 250,
DELAY, 250};
class Arduino_JBT6K71 : public Arduino_TFT
{
public:
Arduino_JBT6K71(
Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0,
bool ips = false, int16_t w = JBT6K71_TFTWIDTH, int16_t h = JBT6K71_TFTHEIGHT,
uint8_t col_offset1 = 0, uint8_t row_offset1 = 0, uint8_t col_offset2 = 0, uint8_t row_offset2 = 0);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void setRotation(uint8_t r) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
protected:
void tftInit() override;
private:
};
#endif

View File

@@ -0,0 +1,121 @@
#include "Arduino_JD9613.h"
#include "SPI.h"
Arduino_JD9613::Arduino_JD9613(
Arduino_DataBus *bus, int8_t rst, uint8_t r, int16_t w, int16_t h,
uint8_t col_offset1, uint8_t row_offset1, uint8_t col_offset2, uint8_t row_offset2)
: Arduino_OLED(
bus, rst, r, w, h,
col_offset1, row_offset1, col_offset2, row_offset2)
{
}
bool Arduino_JD9613::begin(int32_t speed)
{
_override_datamode = SPI_MODE0; // always use SPI_MODE0
return Arduino_TFT::begin(speed);
}
void Arduino_JD9613::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
if ((x != _currentX) || (w != _currentW))
{
_currentX = x;
_currentW = w;
x += _xStart;
_bus->writeC8D16D16(JD9613_CASET, x, x + w - 1);
}
if ((y != _currentY) || (h != _currentH))
{
_currentY = y;
_currentH = h;
y += _yStart;
_bus->writeC8D16D16(JD9613_RASET, y, y + h - 1);
}
_bus->writeCommand(JD9613_RAMWR); // write to RAM
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_JD9613::setRotation(uint8_t r)
{
Arduino_TFT::setRotation(r);
switch (_rotation)
{
case 1:
r = JD9613_MADCTL_MX | JD9613_MADCTL_MV | JD9613_MADCTL_RGB;
break;
case 2:
r = JD9613_MADCTL_MY | JD9613_MADCTL_MX | JD9613_MADCTL_RGB;
break;
case 3:
r = JD9613_MADCTL_MY | JD9613_MADCTL_MV | JD9613_MADCTL_RGB;
break;
default: // case 0:
r = JD9613_MADCTL_RGB;
break;
}
_bus->beginWrite();
_bus->writeC8D8(JD9613_MADCTL, r);
_bus->endWrite();
}
void Arduino_JD9613::invertDisplay(bool i)
{
_bus->sendCommand((_ips ^ i) ? JD9613_INVON : JD9613_INVOFF);
}
void Arduino_JD9613::displayOn(void)
{
_bus->sendCommand(JD9613_SLPOUT);
delay(JD9613_SLPOUT_DELAY);
}
void Arduino_JD9613::displayOff(void)
{
_bus->sendCommand(JD9613_SLPIN);
delay(JD9613_SLPIN_DELAY);
}
void Arduino_JD9613::setBrightness(uint8_t brightness)
{
_bus->beginWrite();
_bus->writeC8D8(0x51, brightness);
_bus->endWrite();
}
void Arduino_JD9613::setContrast(uint8_t contrast)
{
// not implemented.
}
void Arduino_JD9613::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(JD9613_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(JD9613_RST_DELAY);
}
else
{
// Software Rest
_bus->sendCommand(JD9613_SWRESET);
delay(JD9613_RST_DELAY);
}
_bus->batchOperation(jd9613_init_operations, sizeof(jd9613_init_operations));
invertDisplay(false);
}

View File

@@ -0,0 +1,467 @@
#pragma once
#include "../Arduino_GFX.h"
#include "../Arduino_TFT.h"
#include "../Arduino_OLED.h"
#define JD9613_TFTWIDTH 126
#define JD9613_TFTHEIGHT 294
#define JD9613_RST_DELAY 100 ///< delay ms wait for reset finish
#define JD9613_SLPIN_DELAY 120 ///< delay ms wait for sleep in finish
#define JD9613_SLPOUT_DELAY 120 ///< delay ms wait for sleep out finish
#define JD9613_NOP 0x00
#define JD9613_SWRESET 0x01
#define JD9613_RDDID 0x04
#define JD9613_RDDST 0x09
#define JD9613_SLPIN 0x10
#define JD9613_SLPOUT 0x11
#define JD9613_PTLON 0x12
#define JD9613_NORON 0x13
#define JD9613_INVOFF 0x20
#define JD9613_INVON 0x21
#define JD9613_DISPOFF 0x28
#define JD9613_DISPON 0x29
#define JD9613_CASET 0x2A
#define JD9613_RASET 0x2B
#define JD9613_RAMWR 0x2C
#define JD9613_RAMRD 0x2E
#define JD9613_PTLAR 0x30
#define JD9613_TELON 0x35
#define JD9613_MADCTL 0x36
#define JD9613_COLMOD 0x3A
#define JD9613_SCANLSET 0x44
#define JD9613_MADCTL_MY 0x80
#define JD9613_MADCTL_MX 0x40
#define JD9613_MADCTL_MV 0x20
#define JD9613_MADCTL_ML 0x10
#define JD9613_MADCTL_BGR 0x08
#define JD9613_MADCTL_MH 0x04
#define JD9613_MADCTL_RGB 0x00
static const uint8_t jd9613_init_operations[] = {
BEGIN_WRITE,
WRITE_C8_D8, 0xfe, 0x01,
WRITE_COMMAND_8, 0xf7,
WRITE_BYTES, 3, 0x96, 0x13, 0xa9,
WRITE_C8_D8, 0x90, 0x01,
WRITE_COMMAND_8, 0x2c,
WRITE_BYTES, 14,
0x19, 0x0b, 0x24, 0x1b,
0x1b, 0x1b, 0xaa, 0x50,
0x01, 0x16, 0x04, 0x04,
0x04, 0xd7,
WRITE_COMMAND_8, 0x2d,
WRITE_BYTES, 3, 0x66, 0x56, 0x55,
WRITE_COMMAND_8, 0x2e,
WRITE_BYTES, 9,
0x24, 0x04, 0x3f, 0x30,
0x30, 0xa8, 0xb8, 0xb8,
0x07,
WRITE_COMMAND_8, 0x33,
WRITE_BYTES, 12,
0x03, 0x03, 0x03, 0x19,
0x19, 0x19, 0x13, 0x13,
0x13, 0x1a, 0x1a, 0x1a,
WRITE_COMMAND_8, 0x10,
WRITE_BYTES, 13,
0x0b, 0x08, 0x64, 0xae,
0x0b, 0x08, 0x64, 0xae,
0x00, 0x80, 0x00, 0x00,
0x01,
WRITE_COMMAND_8, 0x11,
WRITE_BYTES, 5,
0x01, 0x1e, 0x01, 0x1e,
0x00,
WRITE_COMMAND_8, 0x03,
WRITE_BYTES, 5,
0x93, 0x1c, 0x00, 0x01,
0x7e,
WRITE_C8_D8, 0x19, 0x00,
WRITE_COMMAND_8, 0x31,
WRITE_BYTES, 6,
0x1b, 0x00, 0x06, 0x05,
0x05, 0x05,
WRITE_COMMAND_8, 0x35,
WRITE_BYTES, 4, 0x00, 0x80, 0x80, 0x00,
WRITE_C8_D8, 0x12, 0x1b,
WRITE_COMMAND_8, 0x1a,
WRITE_BYTES, 8,
0x01, 0x20, 0x00, 0x08,
0x01, 0x06, 0x06, 0x06,
WRITE_COMMAND_8, 0x74,
WRITE_BYTES, 7,
0xbd, 0x00, 0x01, 0x08,
0x01, 0xbb, 0x98,
WRITE_COMMAND_8, 0x6c,
WRITE_BYTES, 9,
0xdc, 0x08, 0x02, 0x01,
0x08, 0x01, 0x30, 0x08,
0x00,
WRITE_COMMAND_8, 0x6d,
WRITE_BYTES, 9,
0xdc, 0x08, 0x02, 0x01,
0x08, 0x02, 0x30, 0x08,
0x00,
WRITE_COMMAND_8, 0x76,
WRITE_BYTES, 9,
0xda, 0x00, 0x02, 0x20,
0x39, 0x80, 0x80, 0x50,
0x05,
WRITE_COMMAND_8, 0x6e,
WRITE_BYTES, 9,
0xdc, 0x00, 0x02, 0x01,
0x00, 0x02, 0x4f, 0x02,
0x00,
WRITE_COMMAND_8, 0x6f,
WRITE_BYTES, 9,
0xdc, 0x00, 0x02, 0x01,
0x00, 0x01, 0x4f, 0x02,
0x00,
WRITE_COMMAND_8, 0x80,
WRITE_BYTES, 7,
0xbd, 0x00, 0x01, 0x08,
0x01, 0xbb, 0x98,
WRITE_COMMAND_8, 0x78,
WRITE_BYTES, 9,
0xdc, 0x08, 0x02, 0x01,
0x08, 0x01, 0x30, 0x08,
0x00,
WRITE_COMMAND_8, 0x79,
WRITE_BYTES, 9,
0xdc, 0x08, 0x02, 0x01,
0x08, 0x02, 0x30, 0x08,
0x00,
WRITE_COMMAND_8, 0x82,
WRITE_BYTES, 9,
0xda, 0x40, 0x02, 0x20,
0x39, 0x00, 0x80, 0x50,
0x05,
WRITE_COMMAND_8, 0x7a,
WRITE_BYTES, 9,
0xdc, 0x00, 0x02, 0x01,
0x00, 0x02, 0x4f, 0x02,
0x00,
WRITE_COMMAND_8, 0x7b,
WRITE_BYTES, 9,
0xdc, 0x00, 0x02, 0x01,
0x00, 0x01, 0x4f, 0x02,
0x00,
WRITE_COMMAND_8, 0x84,
WRITE_BYTES, 10,
0x01, 0x00, 0x09, 0x19,
0x19, 0x19, 0x19, 0x19,
0x19, 0x19,
WRITE_COMMAND_8, 0x85,
WRITE_BYTES, 10,
0x19, 0x19, 0x19, 0x03,
0x02, 0x08, 0x19, 0x19,
0x19, 0x19,
WRITE_COMMAND_8, 0x20,
WRITE_BYTES, 12,
0x20, 0x00, 0x08, 0x00,
0x02, 0x00, 0x40, 0x00,
0x10, 0x00, 0x04, 0x00,
WRITE_COMMAND_8, 0x1e,
WRITE_BYTES, 12,
0x40, 0x00, 0x10, 0x00,
0x04, 0x00, 0x20, 0x00,
0x08, 0x00, 0x02, 0x00,
WRITE_COMMAND_8, 0x24,
WRITE_BYTES, 12,
0x20, 0x00, 0x08, 0x00,
0x02, 0x00, 0x40, 0x00,
0x10, 0x00, 0x04, 0x00,
WRITE_COMMAND_8, 0x22,
WRITE_BYTES, 12,
0x40, 0x00, 0x10, 0x00,
0x04, 0x00, 0x20, 0x00,
0x08, 0x00, 0x02, 0x00,
WRITE_COMMAND_8, 0x13,
WRITE_BYTES, 3, 0x63, 0x52, 0x41,
WRITE_COMMAND_8, 0x14,
WRITE_BYTES, 3, 0x36, 0x25, 0x14,
WRITE_COMMAND_8, 0x15,
WRITE_BYTES, 3, 0x63, 0x52, 0x41,
WRITE_COMMAND_8, 0x16,
WRITE_BYTES, 3, 0x36, 0x25, 0x14,
WRITE_COMMAND_8, 0x1d,
WRITE_BYTES, 3, 0x10, 0x00, 0x00,
WRITE_C8_D16, 0x2a, 0x0d, 0x07,
WRITE_COMMAND_8, 0x27,
WRITE_BYTES, 6,
0x00, 0x01, 0x02, 0x03,
0x04, 0x05,
WRITE_COMMAND_8, 0x28,
WRITE_BYTES, 6,
0x00, 0x01, 0x02, 0x03,
0x04, 0x05,
WRITE_C8_D16, 0x26, 0x01, 0x01,
WRITE_C8_D16, 0x86, 0x01, 0x01,
WRITE_C8_D8, 0xfe, 0x02,
WRITE_COMMAND_8, 0x16,
WRITE_BYTES, 5,
0x81, 0x43, 0x23, 0x1e,
0x03,
WRITE_C8_D8, 0xfe, 0x03,
WRITE_C8_D8, 0x60, 0x01,
WRITE_COMMAND_8, 0x61,
WRITE_BYTES, 15,
0x00, 0x00, 0x00, 0x00,
0x11, 0x00, 0x0d, 0x26,
0x5a, 0x80, 0x80, 0x95,
0xf8, 0x3b, 0x75,
WRITE_COMMAND_8, 0x62,
WRITE_BYTES, 15,
0x21, 0x22, 0x32, 0x43,
0x44, 0xd7, 0x0a, 0x59,
0xa1, 0xe1, 0x52, 0xb7,
0x11, 0x64, 0xb1,
WRITE_COMMAND_8, 0x63,
WRITE_BYTES, 11,
0x54, 0x55, 0x66, 0x06,
0xfb, 0x3f, 0x81, 0xc6,
0x06, 0x45, 0x83,
WRITE_COMMAND_8, 0x64,
WRITE_BYTES, 15,
0x00, 0x00, 0x11, 0x11,
0x21, 0x00, 0x23, 0x6a,
0xf8, 0x63, 0x67, 0x70,
0xa5, 0xdc, 0x02,
WRITE_COMMAND_8, 0x65,
WRITE_BYTES, 15,
0x22, 0x22, 0x32, 0x43,
0x44, 0x24, 0x44, 0x82,
0xc1, 0xf8, 0x61, 0xbf,
0x13, 0x62, 0xad,
WRITE_COMMAND_8, 0x66,
WRITE_BYTES, 11,
0x54, 0x55, 0x65, 0x06,
0xf5, 0x37, 0x76, 0xb8,
0xf5, 0x31, 0x6c,
WRITE_COMMAND_8, 0x67,
WRITE_BYTES, 15,
0x00, 0x10, 0x22, 0x22,
0x22, 0x00, 0x37, 0xa4,
0x7e, 0x22, 0x25, 0x2c,
0x4c, 0x72, 0x9a,
WRITE_COMMAND_8, 0x68,
WRITE_BYTES, 15,
0x22, 0x33, 0x43, 0x44,
0x55, 0xc1, 0xe5, 0x2d,
0x6f, 0xaf, 0x23, 0x8f,
0xf3, 0x50, 0xa6,
WRITE_COMMAND_8, 0x69,
WRITE_BYTES, 11,
0x65, 0x66, 0x77, 0x07,
0xfd, 0x4e, 0x9c, 0xed,
0x39, 0x86, 0xd3,
WRITE_C8_D8, 0xfe, 0x05,
WRITE_COMMAND_8, 0x61,
WRITE_BYTES, 15,
0x00, 0x31, 0x44, 0x54,
0x55, 0x00, 0x92, 0xb5,
0x88, 0x19, 0x90, 0xe8,
0x3e, 0x71, 0xa5,
WRITE_COMMAND_8, 0x62,
WRITE_BYTES, 15,
0x55, 0x66, 0x76, 0x77,
0x88, 0xce, 0xf2, 0x32,
0x6e, 0xc4, 0x34, 0x8b,
0xd9, 0x2a, 0x7d,
WRITE_COMMAND_8, 0x63,
WRITE_BYTES, 11,
0x98, 0x99, 0xaa, 0x0a,
0xdc, 0x2e, 0x7d, 0xc3,
0x0d, 0x5b, 0x9e,
WRITE_COMMAND_8, 0x64,
WRITE_BYTES, 15,
0x00, 0x31, 0x44, 0x54,
0x55, 0x00, 0xa2, 0xe5,
0xcd, 0x5c, 0x94, 0xcf,
0x09, 0x4a, 0x72,
WRITE_COMMAND_8, 0x65,
WRITE_BYTES, 15,
0x55, 0x65, 0x66, 0x77,
0x87, 0x9c, 0xc2, 0xff,
0x36, 0x6a, 0xec, 0x45,
0x91, 0xd8, 0x20,
WRITE_COMMAND_8, 0x66,
WRITE_BYTES, 11,
0x88, 0x98, 0x99, 0x0a,
0x68, 0xb0, 0xfb, 0x43,
0x8c, 0xd5, 0x0e,
WRITE_COMMAND_8, 0x67,
WRITE_BYTES, 15,
0x00, 0x42, 0x55, 0x55,
0x55, 0x00, 0xcb, 0x62,
0xc5, 0x09, 0x44, 0x72,
0xa9, 0xd6, 0xfd,
WRITE_COMMAND_8, 0x68,
WRITE_BYTES, 15,
0x66, 0x66, 0x77, 0x87,
0x98, 0x21, 0x45, 0x96,
0xed, 0x29, 0x90, 0xee,
0x4b, 0xb1, 0x13,
WRITE_COMMAND_8, 0x69,
WRITE_BYTES, 11,
0x99, 0xaa, 0xba, 0x0b,
0x6a, 0xb8, 0x0d, 0x62,
0xb8, 0x0e, 0x54,
WRITE_C8_D8, 0xfe, 0x07,
WRITE_C8_D8, 0x3e, 0x00,
WRITE_C8_D16, 0x42, 0x03, 0x10,
WRITE_C8_D8, 0x4a, 0x31,
WRITE_C8_D8, 0x5c, 0x01,
WRITE_COMMAND_8, 0x3c,
WRITE_BYTES, 6,
0x07, 0x00, 0x24, 0x04,
0x3f, 0xe2,
WRITE_COMMAND_8, 0x44,
WRITE_BYTES, 4, 0x03, 0x40, 0x3f, 0x02,
WRITE_COMMAND_8, 0x12,
WRITE_BYTES, 10,
0xaa, 0xaa, 0xc0, 0xc8,
0xd0, 0xd8, 0xe0, 0xe8,
0xf0, 0xf8,
WRITE_COMMAND_8, 0x11,
WRITE_BYTES, 15,
0xaa, 0xaa, 0xaa, 0x60,
0x68, 0x70, 0x78, 0x80,
0x88, 0x90, 0x98, 0xa0,
0xa8, 0xb0, 0xb8,
WRITE_COMMAND_8, 0x10,
WRITE_BYTES, 15,
0xaa, 0xaa, 0xaa, 0x00,
0x08, 0x10, 0x18, 0x20,
0x28, 0x30, 0x38, 0x40,
0x48, 0x50, 0x58,
WRITE_COMMAND_8, 0x14,
WRITE_BYTES, 16,
0x03, 0x1f, 0x3f, 0x5f,
0x7f, 0x9f, 0xbf, 0xdf,
0x03, 0x1f, 0x3f, 0x5f,
0x7f, 0x9f, 0xbf, 0xdf,
WRITE_COMMAND_8, 0x18,
WRITE_BYTES, 12,
0x70, 0x1a, 0x22, 0xbb,
0xaa, 0xff, 0x24, 0x71,
0x0f, 0x01, 0x00, 0x03,
WRITE_C8_D8, 0xfe, 0x00,
WRITE_C8_D8, 0x3a, 0x55,
WRITE_C8_D8, 0xc4, 0x80,
WRITE_C8_D8, 0x35, 0x00,
WRITE_C8_D8, 0x53, 0x28,
WRITE_C8_D8, 0x51, 0xff,
WRITE_COMMAND_8, 0x11,
END_WRITE,
DELAY, JD9613_SLPOUT_DELAY,
BEGIN_WRITE,
WRITE_COMMAND_8, 0x29,
END_WRITE,
DELAY, JD9613_SLPOUT_DELAY};
class Arduino_JD9613 : public Arduino_OLED
{
public:
Arduino_JD9613(
Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0,
int16_t w = JD9613_TFTWIDTH, int16_t h = JD9613_TFTHEIGHT,
uint8_t col_offset1 = 0, uint8_t row_offset1 = 0, uint8_t col_offset2 = 0, uint8_t row_offset2 = 0);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void setRotation(uint8_t r) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
void setBrightness(uint8_t brightness) override;
void setContrast(uint8_t contrast) override;
protected:
void tftInit() override;
private:
};

View File

@@ -0,0 +1,109 @@
/*
* start rewrite from:
* https://github.com/adafruit/Adafruit-GFX-Library.git
* https://github.com/daumemo/IPS_LCD_NT35310_FT6236_Arduino_eSPI_Test
*/
#include "Arduino_NT35310.h"
Arduino_NT35310::Arduino_NT35310(
Arduino_DataBus *bus, int8_t rst, uint8_t r,
bool ips, int16_t w, int16_t h,
uint8_t col_offset1, uint8_t row_offset1, uint8_t col_offset2, uint8_t row_offset2)
: Arduino_TFT(bus, rst, r, ips, w, h, col_offset1, row_offset1, col_offset2, row_offset2)
{
}
bool Arduino_NT35310::begin(int32_t speed)
{
return Arduino_TFT::begin(speed);
}
void Arduino_NT35310::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
if ((x != _currentX) || (w != _currentW))
{
_bus->writeC8D16D16(NT35310_SET_HORIZONTAL_ADDRESS, x + _xStart, x + w - 1 + _xStart);
_currentX = x;
_currentW = w;
}
if ((y != _currentY) || (h != _currentH))
{
_bus->writeC8D16D16(NT35310_SET_VERTICAL_ADDRESS, y + _yStart, y + h - 1 + _yStart);
_currentY = y;
_currentH = h;
}
_bus->writeCommand(NT35310_WRITE_MEMORY_START); // write to RAM
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_NT35310::setRotation(uint8_t r)
{
Arduino_TFT::setRotation(r);
switch (_rotation)
{
case 3:
r = NT35310_MADCTL_MY | NT35310_MADCTL_MV | NT35310_MADCTL_RGB;
break;
case 2:
r = NT35310_MADCTL_MY | NT35310_MADCTL_MX | NT35310_MADCTL_RGB;
break;
case 1:
r = NT35310_MADCTL_MX | NT35310_MADCTL_MV | NT35310_MADCTL_RGB;
break;
default: // case 0:
r = NT35310_MADCTL_RGB;
break;
}
_bus->beginWrite();
_bus->writeC8D8(NT35310_SET_ADDRESS_MODE, r);
_bus->endWrite();
}
void Arduino_NT35310::invertDisplay(bool i)
{
_bus->sendCommand((_ips ^ i) ? NT35310_ENTER_INVERT_MODE : NT35310_EXIT_INVERT_MODE);
}
void Arduino_NT35310::displayOn(void)
{
_bus->sendCommand(NT35310_EXIT_SLEEP_MODE);
delay(NT35310_SLPOUT_DELAY);
}
void Arduino_NT35310::displayOff(void)
{
_bus->sendCommand(NT35310_ENTER_SLEEP_MODE);
delay(NT35310_SLPIN_DELAY);
}
void Arduino_NT35310::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(NT35310_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(NT35310_RST_DELAY);
}
else
{
// Software Rest
_bus->sendCommand(NT35310_SOFT_RESET);
delay(NT35310_RST_DELAY);
}
_bus->batchOperation(nt35310_init_operations, sizeof(nt35310_init_operations));
invertDisplay(false);
}

View File

@@ -0,0 +1,427 @@
/*
* start rewrite from:
* https://github.com/adafruit/Adafruit-GFX-Library.git
* https://github.com/daumemo/IPS_LCD_NT35310_FT6236_Arduino_eSPI_Test
* Data Sheet:
* http://read.pudn.com/downloads648/ebook/2620902/NT35310.pdf
*/
#ifndef _ARDUINO_NT35310_H_
#define _ARDUINO_NT35310_H_
#include "../Arduino_GFX.h"
#include "../Arduino_TFT.h"
#define NT35310_TFTWIDTH 320 // NT35310 max width
#define NT35310_TFTHEIGHT 480 // NT35310 max height
#define NT35310_RST_DELAY 100 // delay ms wait for reset finish
#define NT35310_SLPIN_DELAY 100 // delay ms wait for sleep in finish
#define NT35310_SLPOUT_DELAY 100 // delay ms wait for sleep out finish
// User Command
#define NT35310_NOP 0x00 // No Operation
#define NT35310_SOFT_RESET 0x01 // Software Reset
#define NT35310_RDID 0x04 // Read Display ID
#define NT35310_RDNUMED 0x05 // Read Number of the Errors on DSI
#define NT35310_GET_POWER_MODE 0x0A // Read Display Power Mode
#define NT35310_GET_ADDRESS_MODE 0x0B // Get the Frame Memory to the Display Panel Read Order
#define NT35310_GET_PIXEL_MODE 0x0C // Read Input Pixel Format
#define NT35310_GET_DISPLAY_MODE 0x0D // Read the Current Display Mode
#define NT35310_GET_SIGNAL_MODE 0x0E // Get Display Module Signaling Mode
#define NT35310_RDDSDR1 0x0F // Read Display Self-Diagnostic Result
#define NT35310_ENTER_SLEEP_MODE 0x10 // Enter the Sleep-In Mode
#define NT35310_EXIT_SLEEP_MODE 0x11 // Exit the Sleep-In Mode
#define NT35310_ENTER_PARTIAL_MODE 0x12 // Partial Display Mode On
#define NT35310_ENTER_NORMAL_MODE 0x13 // Normal Display Mode On
#define NT35310_EXIT_INVERT_MODE 0x20 // Display Inversion Off
#define NT35310_ENTER_INVERT_MODE 0x21 // Display Inversion On
#define NT35310_ALLPOFF 0x22 // All Pixel Off
#define NT35310_ALLPON 0x23 // All Pixel On
#define NT35310_GMASET 0x26 // Gamma Curves Selection
#define NT35310_SET_DISPLAY_OFF 0x28 // Display Off
#define NT35310_SET_DISPLAY_ON 0x29 // Display On
#define NT35310_SET_HORIZONTAL_ADDRESS 0x2A // Set the Column Address
#define NT35310_SET_VERTICAL_ADDRESS 0x2B // Set Page Address
#define NT35310_WRITE_MEMORY_START 0x2C // Memory Write Start Command
#define NT35310_SET_MDDI_RAM_READ_ADDRESS 0x2D // Set the RAM Horizontal and Vertical Address
#define NT35310_READ_MEMORY_START 0x2E // Memory Read Start Command
#define NT35310_SET_PARTIAL_AREA 0x30 // Defines the Partial Display Area
#define NT35310_SCRLAR 0x33 // Set Scroll Area
#define NT35310_SET_TEAR_ON 0x35 // Tearing Effect Line ON
#define NT35310_SET_ADDRESS_MODE 0x36 // Memory Data Access Control
#define NT35310_VSCSAD 0x37 // Vertical Scroll Start Address of RAM
#define NT35310_EXIT_IDLE_MODE 0x38 // Idle Mode Off
#define NT35310_ENTER_IDLE_MODE 0x39 // Idle Mode On
#define NT35310_SET_PIXEL_FORMAT 0x3A // Set the Interface Pixel Format
#define NT35310_RGBCTRL 0x3B // RGB Interface Signal Control
#define NT35310_RAMWRC 0x3C // Memory Write Continuously
#define NT35310_RAMRDC 0x3E // RAM Read Continuously
#define NT35310_SET_TEAR_SCANLINE 0x44 // Set Tear Line
#define NT35310_RDSCL 0x45 // Read Scan Line
#define NT35310_ENTER_DSTB_MODE 0x4F // Enter the Deep Standby Mode
#define NT35310_WRDISBV 0x51 // Write Display Brightness
#define NT35310_RDDISBV 0x52 // Read Display Brightness
#define NT35310_WRCTRLD1 0x53 // Write CTRL Display
#define NT35310_RDCTRLD 0x54 // Read CTRL Display
#define NT35310_WRCTRLD2 0x55 // Write CTRL Display
#define NT35310_RDCABC 0x56 // Read Content Adaptive Brightness Control (CABC) Mode
#define NT35310_RDCABCMB 0x5F // Read CABC Minimum Brightness
#define NT35310_RDDSDR2 0x68 // Read Display Self-Diagnostic Result
#define NT35310_SET_MDDI 0x8F
#define NT35310_RDDDBS 0xA1 // Read DDB Start
#define NT35310_RDDDBC 0xA8 // Read DDB Continue
#define NT35310_RDFCS 0xAA // Read First Checksum
#define NT35310_MDDI_WAKE_TOGGLE 0xAD // MDDI VSYNC BASED LINK WAKE-UP
#define NT35310_STB_EDGE_POSITION 0xAE
#define NT35310_RDCCS 0xAF // Read Continue Checksum
#define NT35310_RDID1 0xDA // Read ID1
#define NT35310_RDID2 0xDB // Read ID2
#define NT35310_RDID3 0xDC // Read ID3
#define NT35310_WRITE_IDLEMODE_BL 0xE1 // Write IDLEMODE_BL_Control
#define NT35310_READ_IDLEMODE_BL 0xE2 // Read IDLEMODE_BL_Control
#define NT35310_PAGE_CTRL 0xED // Unlock CMD2
#define NT35310_PAGE_STATUS 0xFF // PAGE unlock status
// 6.2 CMD2_P0 REGISTER LIST
#define NT35310_DISPLAY_CTRL 0xB0
#define NT35310_PORCH_CTRL 0xB1 // Front & Back Porch Setting
#define NT35310_FRAMERATE_CTRL 0xB2
#define NT35310_SPI_RGB_IF_SETTING 0xB3 // SPI&RGB INTERFACE SETTING
#define NT35310_INVCTRL 0xB4 // Inversion Control
#define NT35310_PMTCTL 0xB5 // Partial and Idle Mode Timing Control
#define NT35310_DISPLAY_CTRL_NORM 0xB6
#define NT35310_DISPLAY_CTRL2 0xB7 // Set the States for LED Control
#define NT35310_MTP_SELECTION 0xB8
#define NT35310_PWR_CTRL1 0xC0
#define NT35310_PWR_CTRL2 0xC1
#define NT35310_PWR_CTRL3 0xC2
#define NT35310_PWR_CTRL5 0xC3
#define NT35310_PWR_CTRL6 0xC4
#define NT35310_PWR_CTRL7 0xC5
#define NT35310_PWR_CTRL8 0xC6
#define NT35310_WID_CTRL1 0xD1 // WID1
#define NT35310_WID_CTRL2 0xD2 // WID2
#define NT35310_WID_CTRL3 0xD3 // WID3
#define NT35310_READID4 0xD4 // Read ID4
#define NT35310_DDB_CTRL 0xD5 // Write DDB Info
#define NT35310_RDVNT 0xDD // Read NV Memory Flag Status
#define NT35310_EPWRITE 0xDE // NV Memory Write Command
#define NT35310_MTPPWR 0xDF // MTP Write function enable
#define NT35310_RDREGEXT1 0xEB // Register read command in SPI interface
#define NT35310_RDREGEXT2 0xEC // Register read command in SPI interface
#define NT35310_PAGE_LOCK1 0xEF // Set the Register to command1
#define NT35310_PAGE_LOCK2 0xBF // Set the Register to command2
// 6.3 CMD2_P1 REGISTER LIST
#define NT35310_3GAMMAR_CTRL_RED_P 0xE0
#define NT35310_3GAMAR_CTRL_RED_N 0xE1
#define NT35310_3GAMMAR_CTRL_GREEN_P 0xE2
#define NT35310_3GAMMAR_CTRL_GREEN_N 0xE3
#define NT35310_3GAMMAR_CTRL_BLUE_P 0xE4
#define NT35310_3GAMMAR_CTRL_BLUE_N 0xE5
#define NT35310_CABC_GAMMA1 0xE6
#define NT35310_CABC_GAMMA2 0xE7
#define NT35310_CABC_GAMMA3 0xE8
#define NT35310_PAGE_LOCK3 0x00 // Set the Register to command2 Page 0
// parameters
#define NT35310_MADCTL_MY 0x80 // Bottom to top
#define NT35310_MADCTL_MX 0x40 // Right to left
#define NT35310_MADCTL_MV 0x20 // Reverse Mode
#define NT35310_MADCTL_ML 0x10 // LCD refresh Bottom to top
#define NT35310_MADCTL_RGB 0x00 // Red-Green-Blue pixel order
#define NT35310_MADCTL_BGR 0x08 // Blue-Green-Red pixel order
#define NT35310_MADCTL_MH 0x04 // LCD refresh right to left
static const uint8_t nt35310_init_operations[] = {
BEGIN_WRITE,
WRITE_C8_D16, NT35310_PAGE_CTRL, 0x01, 0xFE,
WRITE_C8_D16, 0xEE, 0xDE, 0x21, // PAGE_CTRL Into CMD3
WRITE_C8_D8, 0xF1, 0x01,
WRITE_C8_D8, 0xDF, 0x10,
// VCOMvoltage//
WRITE_C8_D8, NT35310_PWR_CTRL6, 0x8F, // 5f
WRITE_COMMAND_8, NT35310_PWR_CTRL8,
WRITE_BYTES, 4, 0x00, 0xE2, 0xE2, 0xE2,
WRITE_C8_D8, NT35310_PAGE_LOCK2, 0xAA,
WRITE_COMMAND_8, 0xB0,
WRITE_BYTES, 18,
0x0D, 0x00, 0x0D, 0x00, 0x11,
0x00, 0x19, 0x00, 0x21, 0x00,
0x2D, 0x00, 0x3D, 0x00, 0x5D,
0x00, 0x5D, 0x00,
WRITE_COMMAND_8, 0xB1,
WRITE_BYTES, 6,
0x80, 0x00, 0x8B, 0x00, 0x96,
0x00,
WRITE_COMMAND_8, 0xB2,
WRITE_BYTES, 6,
0x00, 0x00, 0x02, 0x00, 0x03,
0x00,
WRITE_COMMAND_8, 0xB3,
WRITE_BYTES, 24,
0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
WRITE_COMMAND_8, 0xB4,
WRITE_BYTES, 6,
0x8B, 0x00, 0x96, 0x00, 0xA1,
0x00,
WRITE_COMMAND_8, 0xB5,
WRITE_BYTES, 6,
0x02, 0x00, 0x03, 0x00, 0x04,
0x00,
WRITE_C8_D16, 0xB6, 0x00, 0x00,
WRITE_COMMAND_8, 0xB7,
WRITE_BYTES, 22,
0x00, 0x00, 0x3F, 0x00, 0x5E,
0x00, 0x64, 0x00, 0x8C, 0x00,
0xAC, 0x00, 0xDC, 0x00, 0x70,
0x00, 0x90, 0x00, 0xEB, 0x00,
0xDC, 0x00,
WRITE_COMMAND_8, 0xB8,
WRITE_BYTES, 8,
0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
WRITE_COMMAND_8, 0xBA,
WRITE_BYTES, 4,
0x24, 0x00, 0x00, 0x00,
WRITE_COMMAND_8, 0xC1,
WRITE_BYTES, 6,
0x20, 0x00, 0x54, 0x00, 0xFF,
0x00,
WRITE_COMMAND_8, 0xC2,
WRITE_BYTES, 4,
0x0A, 0x00, 0x04, 0x00,
WRITE_COMMAND_8, 0xC3,
WRITE_BYTES, 48,
0x3C, 0x00, 0x3A, 0x00, 0x39,
0x00, 0x37, 0x00, 0x3C, 0x00,
0x36, 0x00, 0x32, 0x00, 0x2F,
0x00, 0x2C, 0x00, 0x29, 0x00,
0x26, 0x00, 0x24, 0x00, 0x24,
0x00, 0x23, 0x00, 0x3C, 0x00,
0x36, 0x00, 0x32, 0x00, 0x2F,
0x00, 0x2C, 0x00, 0x29, 0x00,
0x26, 0x00, 0x24, 0x00, 0x24,
0x00, 0x23, 0x00,
WRITE_COMMAND_8, 0xC4,
WRITE_BYTES, 26,
0x62, 0x00, 0x05, 0x00, 0x84,
0x00, 0xF0, 0x00, 0x18, 0x00,
0xA4, 0x00, 0x18, 0x00, 0x50,
0x00, 0x0C, 0x00, 0x17, 0x00,
0x95, 0x00, 0xF3, 0x00, 0xE6,
0x00,
WRITE_COMMAND_8, 0xC5,
WRITE_BYTES, 10,
0x32, 0x00, 0x44, 0x00, 0x65,
0x00, 0x76, 0x00, 0x88, 0x00,
WRITE_COMMAND_8, 0xC6,
WRITE_BYTES, 6,
0x20, 0x00, 0x17, 0x00, 0x01,
0x00,
WRITE_COMMAND_8, 0xC7,
WRITE_BYTES, 4,
0x00, 0x00, 0x00, 0x00,
WRITE_COMMAND_8, 0xC8,
WRITE_BYTES, 4,
0x00, 0x00, 0x00, 0x00,
WRITE_COMMAND_8, 0xC9,
WRITE_BYTES, 16,
0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
WRITE_COMMAND_8, NT35310_3GAMMAR_CTRL_RED_P,
WRITE_BYTES, 36,
0x16, 0x00, 0x1C, 0x00, 0x21,
0x00, 0x36, 0x00, 0x46, 0x00,
0x52, 0x00, 0x64, 0x00, 0x7A,
0x00, 0x8B, 0x00, 0x99, 0x00,
0xA8, 0x00, 0xB9, 0x00, 0xC4,
0x00, 0xCA, 0x00, 0xD2, 0x00,
0xD9, 0x00, 0xE0, 0x00, 0xF3,
0x00,
// WRITE_COMMAND_8, NT35310_3GAMAR_CTRL_RED_N,
// WRITE_BYTES, 36,
// 0x16, 0x00, 0x1C, 0x00, 0x22,
// 0x00, 0x36, 0x00, 0x45, 0x00,
// 0x52, 0x00, 0x64, 0x00, 0x7A,
// 0x00, 0x8B, 0x00, 0x99, 0x00,
// 0xA8, 0x00, 0xB9, 0x00, 0xC4,
// 0x00, 0xCA, 0x00, 0xD2, 0x00,
// 0xD8, 0x00, 0xE0, 0x00, 0xF3,
// 0x00,
WRITE_COMMAND_8, NT35310_3GAMMAR_CTRL_GREEN_P,
WRITE_BYTES, 36,
0x05, 0x00, 0x0B, 0x00, 0x1B,
0x00, 0x34, 0x00, 0x44, 0x00,
0x4F, 0x00, 0x61, 0x00, 0x79,
0x00, 0x88, 0x00, 0x97, 0x00,
0xA6, 0x00, 0xB7, 0x00, 0xC2,
0x00, 0xC7, 0x00, 0xD1, 0x00,
0xD6, 0x00, 0xDD, 0x00, 0xF3,
0x00,
// WRITE_COMMAND_8, NT35310_3GAMMAR_CTRL_GREEN_N,
// WRITE_BYTES, 36,
// 0x05, 0x00, 0x0A, 0x00, 0x1C,
// 0x00, 0x33, 0x00, 0x44, 0x00,
// 0x50, 0x00, 0x62, 0x00, 0x78,
// 0x00, 0x88, 0x00, 0x97, 0x00,
// 0xA6, 0x00, 0xB7, 0x00, 0xC2,
// 0x00, 0xC7, 0x00, 0xD1, 0x00,
// 0xD5, 0x00, 0xDD, 0x00, 0xF3,
// 0x00,
WRITE_COMMAND_8, NT35310_3GAMMAR_CTRL_BLUE_P,
WRITE_BYTES, 36,
// 0x01, 0x00, 0x01, 0x00, 0x02,
// 0x00, 0x2A, 0x00, 0x3C, 0x00,
// 0x4B, 0x00, 0x5D, 0x00, 0x74,
// 0x00, 0x84, 0x00, 0x93, 0x00,
// 0xA2, 0x00, 0xB3, 0x00, 0xBE,
// 0x00, 0xC4, 0x00, 0xCD, 0x00,
// 0xD3, 0x00, 0xDD, 0x00, 0xF3,
// 0x00,
0x05, 0x00, 0x0B, 0x00, 0x1B,
0x00, 0x34, 0x00, 0x44, 0x00,
0x4F, 0x00, 0x61, 0x00, 0x79,
0x00, 0x88, 0x00, 0x97, 0x00,
0xA6, 0x00, 0xB7, 0x00, 0xC2,
0x00, 0xC7, 0x00, 0xD1, 0x00,
0xD6, 0x00, 0xDD, 0x00, 0xF3,
0x00,
// WRITE_COMMAND_8, NT35310_3GAMMAR_CTRL_BLUE_N,
// WRITE_BYTES, 36,
// 0x00, 0x00, 0x00, 0x00, 0x02,
// 0x00, 0x29, 0x00, 0x3C, 0x00,
// 0x4B, 0x00, 0x5D, 0x00, 0x74,
// 0x00, 0x84, 0x00, 0x93, 0x00,
// 0xA2, 0x00, 0xB3, 0x00, 0xBE,
// 0x00, 0xC4, 0x00, 0xCD, 0x00,
// 0xD3, 0x00, 0xDC, 0x00, 0xF3,
// 0x00,
WRITE_COMMAND_8, 0xE6,
WRITE_BYTES, 32,
0x11, 0x00, 0x34, 0x00, 0x56,
0x00, 0x76, 0x00, 0x77, 0x00,
0x66, 0x00, 0x88, 0x00, 0x99,
0x00, 0xBB, 0x00, 0x99, 0x00,
0x66, 0x00, 0x55, 0x00, 0x55,
0x00, 0x45, 0x00, 0x43, 0x00,
0x44, 0x00,
WRITE_COMMAND_8, 0xE7,
WRITE_BYTES, 32,
0x32, 0x00, 0x55, 0x00, 0x76,
0x00, 0x66, 0x00, 0x67, 0x00,
0x67, 0x00, 0x87, 0x00, 0x99,
0x00, 0xBB, 0x00, 0x99, 0x00,
0x77, 0x00, 0x44, 0x00, 0x56,
0x00, 0x23, 0x00, 0x33, 0x00,
0x45, 0x00,
WRITE_COMMAND_8, 0xE8,
WRITE_BYTES, 32,
0x00, 0x00, 0x99, 0x00, 0x87,
0x00, 0x88, 0x00, 0x77, 0x00,
0x66, 0x00, 0x88, 0x00, 0xAA,
0x00, 0xBB, 0x00, 0x99, 0x00,
0x66, 0x00, 0x55, 0x00, 0x55,
0x00, 0x44, 0x00, 0x44, 0x00,
0x55, 0x00,
WRITE_COMMAND_8, 0xE9,
WRITE_BYTES, 4,
0xAA, 0x00, 0x00, 0x00,
WRITE_C8_D8, 0x00, 0xAA,
WRITE_COMMAND_8, 0xCF,
WRITE_BYTES, 17,
0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00,
WRITE_COMMAND_8, 0xF0,
WRITE_BYTES, 5,
0x00, 0x50, 0x00, 0x00, 0x00,
WRITE_C8_D8, 0xF3, 0x00,
WRITE_COMMAND_8, 0xF9,
WRITE_BYTES, 4,
0x06, 0x10, 0x29, 0x00,
WRITE_C8_D8, NT35310_SET_PIXEL_FORMAT, 0x55, // 66
WRITE_COMMAND_8, NT35310_EXIT_SLEEP_MODE,
END_WRITE,
DELAY, NT35310_SLPOUT_DELAY,
BEGIN_WRITE,
WRITE_COMMAND_8, NT35310_SET_DISPLAY_ON,
WRITE_C8_D8, NT35310_SET_TEAR_ON, 0x00,
WRITE_C8_D8, NT35310_WRDISBV, 0xFF,
WRITE_C8_D8, NT35310_WRCTRLD1, 0x2C,
WRITE_C8_D8, NT35310_WRCTRLD2, 0x82,
END_WRITE};
class Arduino_NT35310 : public Arduino_TFT
{
public:
Arduino_NT35310(
Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0,
bool ips = false, int16_t w = NT35310_TFTWIDTH, int16_t h = NT35310_TFTHEIGHT,
uint8_t col_offset1 = 0, uint8_t row_offset1 = 0, uint8_t col_offset2 = 0, uint8_t row_offset2 = 0);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void setRotation(uint8_t r) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
protected:
void tftInit() override;
private:
};
#endif // _ARDUINO_NT35310_H_

View File

@@ -0,0 +1,195 @@
/*
* start rewrite from:
* https://github.com/hi631/LCD_NT35510-MRB3971.git
*/
#include "Arduino_NT35510.h"
Arduino_NT35510::Arduino_NT35510(
Arduino_DataBus *bus, int8_t rst, uint8_t r,
bool ips, int16_t w, int16_t h,
uint8_t col_offset1, uint8_t row_offset1, uint8_t col_offset2, uint8_t row_offset2)
: Arduino_TFT(bus, rst, r, ips, w, h, col_offset1, row_offset1, col_offset2, row_offset2)
{
}
bool Arduino_NT35510::begin(int32_t speed)
{
return Arduino_TFT::begin(speed);
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_NT35510::setRotation(uint8_t r)
{
Arduino_TFT::setRotation(r);
switch (_rotation)
{
case 3:
r = (NT35510_MADCTL_MY | NT35510_MADCTL_MV);
break;
case 2:
r = (NT35510_MADCTL_MY | NT35510_MADCTL_MX);
break;
case 1:
r = (NT35510_MADCTL_MX | NT35510_MADCTL_MV);
break;
default: // case 0:
r = 0;
break;
}
_bus->beginWrite();
_bus->writeCommand16(NT35510_MADCTR);
_bus->write16(r);
_bus->endWrite();
}
void Arduino_NT35510::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
if ((x != _currentX) || (w != _currentW))
{
_currentX = x;
_currentW = w;
_data16.value = x + _xStart;
_bus->writeC16D16(NT35510_CASET, _data16.msb);
_bus->writeC16D16(NT35510_CASET + 1, _data16.lsb);
_data16.value += w - 1;
_bus->writeC16D16(NT35510_CASET + 2, _data16.msb);
_bus->writeC16D16(NT35510_CASET + 3, _data16.lsb);
}
if ((y != _currentY) || (h != _currentH))
{
_currentY = y;
_currentH = h;
_data16.value = y + _yStart;
_bus->writeC16D16(NT35510_PASET, _data16.msb);
_bus->writeC16D16(NT35510_PASET + 1, _data16.lsb);
_data16.value += h - 1;
_bus->writeC16D16(NT35510_PASET + 2, _data16.msb);
_bus->writeC16D16(NT35510_PASET + 3, _data16.lsb);
}
_bus->writeCommand16(NT35510_RAMWR); // write to RAM
}
void Arduino_NT35510::invertDisplay(bool)
{
// Not Implemented
}
void Arduino_NT35510::displayOn(void)
{
// Not Implemented
}
void Arduino_NT35510::displayOff(void)
{
// Not Implemented
}
void Arduino_NT35510::WriteRegM(uint16_t adr, uint16_t len, uint8_t dat[])
{
for (uint16_t i = 0; i < len; i++)
{
_bus->writeCommand16(adr++);
_bus->write16(dat[i]);
}
}
// Companion code to the above tables. Reads and issues
// a series of LCD commands stored in PROGMEM byte array.
void Arduino_NT35510::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(NT35510_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(NT35510_RST_DELAY);
}
else
{
// Software Rest
}
//************* NT35510**********//
_bus->beginWrite();
uint8_t ini01[] = {0x55, 0xAA, 0x52, 0x08, 0x01};
WriteRegM(0xF000, sizeof(ini01), ini01);
uint8_t ini03[] = {0x34, 0x34, 0x34};
WriteRegM(0xB600, sizeof(ini03), ini03);
uint8_t ini02[] = {0x0D, 0x0D, 0x0D};
WriteRegM(0xB000, sizeof(ini02), ini02); // AVDD Set AVDD 5.2V
uint8_t ini05[] = {0x34, 0x34, 0x34};
WriteRegM(0xB700, sizeof(ini05), ini05); // AVEE ratio
uint8_t ini04[] = {0x0D, 0x0D, 0x0D};
WriteRegM(0xB100, sizeof(ini04), ini04); // AVEE -5.2V
uint8_t ini07[] = {0x24, 0x24, 0x24};
WriteRegM(0xB800, sizeof(ini07), ini07); // VCL ratio
uint8_t ini10[] = {0x34, 0x34, 0x34};
WriteRegM(0xB900, sizeof(ini10), ini10); // VGH ratio
uint8_t ini09[] = {0x0F, 0x0F, 0x0F};
WriteRegM(0xB300, sizeof(ini09), ini09);
uint8_t ini14[] = {0x24, 0x24, 0x24};
WriteRegM(0xBA00, sizeof(ini14), ini14); // VGLX ratio
uint8_t ini12[] = {0x08, 0x08};
WriteRegM(0xB500, sizeof(ini12), ini12);
uint8_t ini15[] = {0x00, 0x78, 0x00};
WriteRegM(0xBC00, sizeof(ini15), ini15); // VGMP/VGSP 4.5V/0V
uint8_t ini16[] = {0x00, 0x78, 0x00};
WriteRegM(0xBD00, sizeof(ini16), ini16); // VGMN/VGSN -4.5V/0V
uint8_t ini17[] = {0x00, 0x89};
WriteRegM(0xBE00, sizeof(ini17), ini17); // VCOM -1.325V
// Gamma Setting
uint8_t ini20[] = {
0x00, 0x2D, 0x00, 0x2E, 0x00, 0x32, 0x00, 0x44, 0x00, 0x53, 0x00, 0x88, 0x00, 0xB6, 0x00, 0xF3, 0x01, 0x22, 0x01, 0x64,
0x01, 0x92, 0x01, 0xD4, 0x02, 0x07, 0x02, 0x08, 0x02, 0x34, 0x02, 0x5F, 0x02, 0x78, 0x02, 0x94, 0x02, 0xA6, 0x02, 0xBB,
0x02, 0xCA, 0x02, 0xDB, 0x02, 0xE8, 0x02, 0xF9, 0x03, 0x1F, 0x03, 0x7F};
WriteRegM(0xD100, sizeof(ini20), ini20);
WriteRegM(0xD400, sizeof(ini20), ini20); // R+ R-
WriteRegM(0xD200, sizeof(ini20), ini20);
WriteRegM(0xD500, sizeof(ini20), ini20); // G+ G-
WriteRegM(0xD300, sizeof(ini20), ini20);
WriteRegM(0xD600, sizeof(ini20), ini20); // B+ B-
//
uint8_t ini21[] = {0x55, 0xAA, 0x52, 0x08, 0x00};
WriteRegM(0xF000, sizeof(ini21), ini21); // #Enable Page0
uint8_t ini22[] = {0x08, 0x05, 0x02, 0x05, 0x02};
WriteRegM(0xB000, sizeof(ini22), ini22); // # RGB I/F Setting
_bus->writeCommand16(0xB600);
_bus->write16(0x08);
_bus->writeCommand16(0xB500);
_bus->write16(0x50); // ## SDT: //0x6b ?? 480x854 0x50 ?? 480x800
uint8_t ini24[] = {0x00, 0x00};
WriteRegM(0xB700, sizeof(ini24), ini24); // ## Gate EQ:
uint8_t ini25[] = {0x01, 0x05, 0x05, 0x05};
WriteRegM(0xB800, sizeof(ini25), ini25); // ## Source EQ:
uint8_t ini26[] = {0x00, 0x00, 0x00};
WriteRegM(0xBC00, sizeof(ini26), ini26); // # Inversion: Column inversion (NVT)
uint8_t ini27[] = {0x03, 0x00, 0x00};
WriteRegM(0xCC00, sizeof(ini27), ini27); // # BOE's Setting(default)
uint8_t ini28[] = {0x01, 0x84, 0x07, 0x31, 0x00, 0x01};
WriteRegM(0xBD00, sizeof(ini28), ini28); // # Display Timing:
//
uint8_t ini30[] = {0xAA, 0x55, 0x25, 0x01};
WriteRegM(0xFF00, sizeof(ini30), ini30);
_bus->writeCommand16(NT35510_TEON);
_bus->write16(0x00);
_bus->writeCommand16(NT35510_COLMOD);
_bus->write16(0x55); // 0x55=16bit Mode
_bus->writeCommand16(NT35510_SLPOUT);
_bus->endWrite();
delay(NT35510_SLPOUT_DELAY);
_bus->sendCommand16(NT35510_DISPON);
delay(NT35510_SLPOUT_DELAY);
}

View File

@@ -0,0 +1,123 @@
/*
* start rewrite from:
* https://github.com/hi631/LCD_NT35510-MRB3971.git
*/
#ifndef _ARDUINO_NT35510_H_
#define _ARDUINO_NT35510_H_
#include "../Arduino_GFX.h"
#include "../Arduino_TFT.h"
#define NT35510_TFTWIDTH 480 ///< NT35510 max TFT width
#define NT35510_TFTHEIGHT 800 ///< NT35510 max TFT height
#define NT35510_RST_DELAY 500 ///< delay ms wait for reset finish
#define NT35510_SLPIN_DELAY 120 ///< delay ms wait for sleep in finish
#define NT35510_SLPOUT_DELAY 120 ///< delay ms wait for sleep out finish
#define NT35510_NOP 0x0000
#define NT35510_SWRESET 0x0100
#define NT35510_RDNUMED 0x0500
#define NT35510_RDDPM 0x0A00
#define NT35510_RDDMADCTR 0x0B00
#define NT35510_RDDCOLMOD 0x0C00
#define NT35510_RDDIM 0x0D00
#define NT35510_RDDSM 0x0E00
#define NT35510_RDDSDR 0x0F00
#define NT35510_SLPIN 0x1000
#define NT35510_SLPOUT 0x1100
#define NT35510_PTLON 0x1200
#define NT35510_NORON 0x1300
#define NT35510_INVOFF 0x2000
#define NT35510_INVON 0x2100
#define NT35510_ALLPOFF 0x2200
#define NT35510_ALLPON 0x2300
#define NT35510_GAMSET 0x2600
#define NT35510_DISPOFF 0x2800
#define NT35510_DISPON 0x2900
#define NT35510_CASET 0x2A00
#define NT35510_PASET 0x2B00
#define NT35510_RAMWR 0x2C00
#define NT35510_RAMRD 0x2E00
#define NT35510_PTLAR 0x3000
#define NT35510_TEOFF 0x3400
#define NT35510_TEON 0x3500
#define NT35510_MADCTR 0x3600
#define NT35510_IDMOFF 0x3800
#define NT35510_IDMON 0x3900
#define NT35510_COLMOD 0x3A00
#define NT35510_RAMWRCNT 0x3C00
#define NT35510_RAMRDCNT 0x3E00
#define NT35510_WRTESCN 0x4400
#define NT35510_RDSCNL 0x4500
#define NT35510_WRDISBV 0x5100
#define NT35510_RDDISBV 0x5200
#define NT35510_WRCTRLD 0x5300
#define NT35510_RDCTRLD 0x5400
#define NT35510_WRCABC 0x5500
#define NT35510_RDCABC 0x5600
#define NT35510_WRCABCMB 0x5E00
#define NT35510_RDCABCMB 0x5F00
#define NT35510_RDPWMSDR 0x6800
#define NT35510_RDBWLB 0x7000
#define NT35510_RDBKX 0x7100
#define NT35510_RDBKY 0x7200
#define NT35510_RDWX 0x7300
#define NT35510_RDWY 0x7400
#define NT35510_RDRGLB 0x7500
#define NT35510_RDRX 0x7600
#define NT35510_RDRY 0x7700
#define NT35510_RDGX 0x7800
#define NT35510_RDGY 0x7900
#define NT35510_RDBALB 0x7A00
#define NT35510_RDBX 0x7B00
#define NT35510_RDBY 0x7C00
#define NT35510_RDAX 0x7D00
#define NT35510_RDAY 0x7E00
#define NT35510_RDDDBSTR 0xA100
#define NT35510_RDDDBCNT 0xA800
#define NT35510_RDFCS 0xAA00
#define NT35510_RDCCS 0xAF00
#define NT35510_RDID1 0xDA00
#define NT35510_RDID2 0xDB00
#define NT35510_RDID3 0xDC00
#define NT35510_MADCTL_MY 0x80
#define NT35510_MADCTL_MX 0x40
#define NT35510_MADCTL_MV 0x20
class Arduino_NT35510 : public Arduino_TFT
{
public:
Arduino_NT35510(
Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0,
bool ips = false, int16_t w = NT35510_TFTWIDTH, int16_t h = NT35510_TFTHEIGHT,
uint8_t col_offset1 = 0, uint8_t row_offset1 = 0, uint8_t col_offset2 = 0, uint8_t row_offset2 = 0);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void setRotation(uint8_t r) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
protected:
void WriteRegM(uint16_t adr, uint16_t len, uint8_t dat[]);
void tftInit() override;
private:
};
#endif

View File

@@ -0,0 +1,109 @@
/*
* start rewrite from:
* https://github.com/adafruit/Adafruit-GFX-Library.git
* https://github.com/daumemo/IPS_LCD_NT39125_FT6236_Arduino_eSPI_Test
*/
#include "Arduino_NT39125.h"
Arduino_NT39125::Arduino_NT39125(
Arduino_DataBus *bus, int8_t rst, uint8_t r,
bool ips, int16_t w, int16_t h,
uint8_t col_offset1, uint8_t row_offset1, uint8_t col_offset2, uint8_t row_offset2)
: Arduino_TFT(bus, rst, r, ips, w, h, col_offset1, row_offset1, col_offset2, row_offset2)
{
}
bool Arduino_NT39125::begin(int32_t speed)
{
return Arduino_TFT::begin(speed);
}
void Arduino_NT39125::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
if ((x != _currentX) || (w != _currentW))
{
_bus->writeC8D16D16(NT39125_CASET, x + _xStart, x + w - 1 + _xStart);
_currentX = x;
_currentW = w;
}
if ((y != _currentY) || (h != _currentH))
{
_bus->writeC8D16D16(NT39125_RASET, y + _yStart, y + h - 1 + _yStart);
_currentY = y;
_currentH = h;
}
_bus->writeCommand(NT39125_RAMWR); // write to RAM
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_NT39125::setRotation(uint8_t r)
{
Arduino_TFT::setRotation(r);
switch (_rotation)
{
case 3:
r = NT39125_MADCTL_BGR | NT39125_MADCTL_MV | NT39125_MADCTL_MX | NT39125_MADCTL_MY;
break;
case 2:
r = NT39125_MADCTL_BGR | NT39125_MADCTL_MY;
break;
case 1:
r = NT39125_MADCTL_BGR | NT39125_MADCTL_MV;
break;
default: // case 0:
r = NT39125_MADCTL_BGR | NT39125_MADCTL_MX;
break;
}
_bus->beginWrite();
_bus->writeC8D8(NT39125_MADCTL, r);
_bus->endWrite();
}
void Arduino_NT39125::invertDisplay(bool i)
{
_bus->sendCommand((_ips ^ i) ? NT39125_INVON : NT39125_INVOFF);
}
void Arduino_NT39125::displayOn(void)
{
_bus->sendCommand(NT39125_SLPOUT);
delay(NT39125_SLPOUT_DELAY);
}
void Arduino_NT39125::displayOff(void)
{
_bus->sendCommand(NT39125_SLPIN);
delay(NT39125_SLPIN_DELAY);
}
void Arduino_NT39125::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(NT39125_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(NT39125_RST_DELAY);
}
else
{
// Software Rest
_bus->sendCommand(NT39125_SWRESET);
delay(NT39125_RST_DELAY);
}
_bus->batchOperation(nt39125_init_operations, sizeof(nt39125_init_operations));
invertDisplay(false);
}

View File

@@ -0,0 +1,215 @@
/*
* start rewrite from:
* https://github.com/adafruit/Adafruit-GFX-Library.git
* https://github.com/daumemo/IPS_LCD_NT39125_FT6236_Arduino_eSPI_Test
* Data Sheet:
* http://read.pudn.com/downloads648/ebook/2620902/NT39125.pdf
*/
#ifndef _ARDUINO_NT39125_H_
#define _ARDUINO_NT39125_H_
#include "../Arduino_GFX.h"
#include "../Arduino_TFT.h"
#define NT39125_TFTWIDTH 240 // NT39125 max width
#define NT39125_TFTHEIGHT 432 // NT39125 max height
#define NT39125_RST_DELAY 200 // delay ms wait for reset finish
#define NT39125_SLPIN_DELAY 20 // delay ms wait for sleep in finish
#define NT39125_SLPOUT_DELAY 1200 // delay ms wait for sleep out finish
// User Command
#define NT39125_NOP 0x00 // NOP
#define NT39125_SWRESET 0x01 // Software Reset
#define NT39125_RDDID 0x04 // Read Display ID
#define NT39125_RDDST 0x09 // Read Display Status
#define NT39125_RDDPM 0x0A // Read Display Power Mode
#define NT39125_RDDMADCTR 0x0B // Read Display MADCTR
#define NT39125_RDDCOLMOD 0x0C // Read Display Pixel Format
#define NT39125_RDDIM 0x0D // Read Display Image Mode
#define NT39125_RDDSM 0x0E // Read Display Signal Mode
#define NT39125_RDDSDR 0x0F // Read Display Self-Diagnostic Result
#define NT39125_SLPIN 0x10 // Sleep In
#define NT39125_SLPOUT 0x11 // Sleep Out
#define NT39125_PTLON 0x12 // Partial Display Mode On
#define NT39125_NORON 0x13 // Normal Display Mode On
#define NT39125_INVOFF 0x20 // Display Inversion Off
#define NT39125_INVON 0x21 // Display Inversion On
#define NT39125_GAMSET 0x26 // Gamma Set
#define NT39125_DISPOFF 0x28 // Display Off
#define NT39125_DISPON 0x29 // Display On
#define NT39125_CASET 0x2A // Column Address Set
#define NT39125_RASET 0x2B // Row Address Set
#define NT39125_RAMWR 0x2C // Memory Write
#define NT39125_RAMRD 0x2E // Memory Read
#define NT39125_RGBSET 0x2D // Color Set for 65k or 4k-Color Display
#define NT39125_PTLAR 0x30 // Partial Area
#define NT39125_SCRLAR 0x33 // Scroll Area
#define NT39125_TEOFF 0x34 // Tearing Effect Line OFF
#define NT39125_TEON 0x35 // Tearing Effect Line ON
#define NT39125_MADCTL 0x36 // Memory Data Access Control
#define NT39125_VSCSAD 0x37 // Vertical Scroll Start Address of RAM
#define NT39125_IDMOFF 0x38 // Idle Mode Off
#define NT39125_IDMON 0x39 // Idle Mode On
#define NT39125_COLMOD 0x3A // Interface Pixel Format
#define NT39125_RDID1 0xDA // Read ID1 Value
#define NT39125_RDID2 0xDB // Read ID2 Value
#define NT39125_RDID3 0xDC // Read ID3 Value
#define NT39125_IFMODE 0xB0 // Set Display Interface Mode
#define NT39125_FRMCTR1 0xB1 // Set Division ratio for internal clocks of Normal mode
#define NT39125_FRMCTR2 0xB2 // Set Division ratio for internal clocks of Idle mode
#define NT39125_FRMCTR3 0xB3 // Set Division ratio for internal clocks of Partial mode (Idle mode off)
#define NT39125_INVCTR 0xB4 // Inversion Control
#define NT39125_RESCTR 0xB5 // Display Resolution Control
#define NT39125_DISSET5 0xB6 // Display Function set 5
#define NT39125_PWCTR1 0xC0 // Power Control 1
#define NT39125_PWCTR2 0xC1 // Power Control 2
#define NT39125_PWCTR3 0xC2 // Power Control 3 (in Normal mode/ Full colors)
#define NT39125_PWCTR4 0xC3 // Power Control 4 (in Idle mode/ 8-colors)
#define NT39125_PWCTR5 0xC4 // Power Control 5 (in Partial mode/ full-colors)
#define NT39125_VMCTR1 0xC5 // VCOM Control
#define NT39125_VMFCTR 0xC7 // VCOM offset control
#define NT39125_RDVMF 0xC8 // Read VCOM offset value
#define NT39125_WRID2 0xD1 // Write ID2 for MTP program
#define NT39125_WRID3 0xD2 // Write ID3 for MTP program
#define NT39125_RDID4 0xD3 // Read ID4 for IC Vender Code
#define NT39125_RDVNT 0xD4 // Read NV Memory Flag Status
#define NT39125_EPWRITE 0xDE // MTP write command
#define NT39125_DNVRS 0xDF // NV Memory Control
#define NT39125_GMCTRP0 0xE0 // Positive RED Gamma Control
#define NT39125_GMCTRN0 0xE1 // Negative RED Gamma Control
#define NT39125_GMCTRP1 0xE2 // Positive GREEN Gamma Control
#define NT39125_GMCTRN1 0xE3 // Negative GREEN Gamma Control
#define NT39125_GMCTRP2 0xE4 // Positive BLUE Gamma Control
#define NT39125_GMCTRN2 0xE5 // Negative BLUE Gamma Control
#define NT39125_GAM_R_SEL 0xEA // Gamma Selection
#define NT39125_TSTGVDD 0xEB // GVDD output control
// parameters
#define NT39125_MADCTL_MY 0x80 // Bottom to top
#define NT39125_MADCTL_MX 0x40 // Right to left
#define NT39125_MADCTL_MV 0x20 // Reverse Mode
#define NT39125_MADCTL_ML 0x10 // LCD refresh Bottom to top
#define NT39125_MADCTL_RGB 0x00 // Red-Green-Blue pixel order
#define NT39125_MADCTL_BGR 0x08 // Blue-Green-Red pixel order
#define NT39125_MADCTL_MH 0x04 // LCD refresh right to left
static const uint8_t nt39125_init_operations[] = {
// Initializing
BEGIN_WRITE,
WRITE_COMMAND_8, NT39125_SLPOUT, // Sleep Out
END_WRITE,
DELAY, 250,
DELAY, 250,
DELAY, 250,
DELAY, 250,
DELAY, 200,
// Display Settings
BEGIN_WRITE,
WRITE_C8_D8, NT39125_TEOFF, // Tearing Effect Line OFF
WRITE_C8_D16, NT39125_FRMCTR1, 0x11, 0x1b, // Set Division ratio for internal clocks of Normal mode
WRITE_C8_D16, NT39125_FRMCTR2, 0x11, 0x1b, // Set Division ratio for internal clocks of Idle mode
WRITE_C8_D16, NT39125_FRMCTR3, 0x11, 0x1b, // Set Division ratio for internal clocks of Partial mode (Idle mode off)
WRITE_C8_D8, NT39125_INVCTR, 0x02, // Inversion Control
WRITE_C8_D16, NT39125_DISSET5, 0x01, 0x02, // Display Function set 5
WRITE_C8_D8, NT39125_PWCTR1, 0x24, // Power Control 1, 4.1V
// VGL -7V
WRITE_C8_D16, NT39125_PWCTR2, 0x02, 0x00, // Power Control 2
// WRITE_C8_D16, NT39125_PWCTR2, 0x02, 0x07, // gate modulation removed (spec 1.03 version)
// VGL -7V
WRITE_C8_D16, NT39125_PWCTR3, 0x05, 0x01, // Power Control 3 (in Normal mode/ Full colors), e1 setting
WRITE_C8_D16, NT39125_PWCTR4, 0x02, 0x05, // Power Control 4 (in Idle mode/ 8-colors)
WRITE_C8_D16, NT39125_PWCTR5, 0x02, 0x04, // Power Control 5 (in Partial mode/ full-colors)
WRITE_C8_D16, NT39125_VMCTR1, // VCOM Control, Chameleon
0x14, // 3 . VcomH
0x2e, // -1.35 .VcomL
WRITE_C8_D8, NT39125_GAM_R_SEL, 0x01, // Gamma Selection
///////////////////////////////////////// gamma //////////////////////
WRITE_COMMAND_8, NT39125_GMCTRP0, // Positive RED Gamma Control, d1 third vibration
WRITE_BYTES, 15,
0x27, 0x2B, 0x2E, 0x06,
0x0D, 0x11, 0x28, 0x7B,
0x35, 0x0C, 0x20, 0x26,
0x25, 0x28, 0x3C,
WRITE_COMMAND_8, NT39125_GMCTRN0, // Negative RED Gamma Control
WRITE_BYTES, 15,
0x08, 0x21, 0x26, 0x09,
0x0F, 0x12, 0x1F, 0x38,
0x31, 0x0D, 0x23, 0x29,
0x2C, 0x2F, 0x33,
WRITE_COMMAND_8, NT39125_GMCTRP1, // Positive GREEN Gamma Control
WRITE_BYTES, 15,
0x27, 0x2C, 0x2F, 0x07,
0x0E, 0x11, 0x29, 0x7A,
0x35, 0x0C, 0x20, 0x26,
0x24, 0x29, 0x3C,
WRITE_COMMAND_8, NT39125_GMCTRN1, // Negative GREEN Gamma Control
WRITE_BYTES, 15,
0x08, 0x20, 0x26, 0x09,
0x0F, 0x12, 0x1F, 0x48,
0x30, 0x0D, 0x22, 0x28,
0x2B, 0x2E, 0x33,
WRITE_COMMAND_8, NT39125_GMCTRP2, // Positive BLUE Gamma Control
WRITE_BYTES, 15,
0x1F, 0x24, 0x27, 0x08,
0x0F, 0x12, 0x25, 0x7B,
0x32, 0x0C, 0x20, 0x26,
0x20, 0x25, 0x3C,
WRITE_COMMAND_8, NT39125_GMCTRN2, // Negative BLUE Gamma Control
WRITE_BYTES, 15,
0x08, 0x24, 0x2B, 0x09,
0x0F, 0x12, 0x22, 0x38,
0x35, 0x0C, 0x21, 0x27,
0x33, 0x36, 0x3B,
//////////////////////////////////////////////////////////
WRITE_C8_D8, 0x3A, 0x55, // Color mode, 16-bit
WRITE_COMMAND_8, 0x11, // SLEEP MODE OUT / BOOSTER ON
END_WRITE,
DELAY, 250,
DELAY, 250,
DELAY, 250,
DELAY, 250,
DELAY, 200,
BEGIN_WRITE,
// WRITE_COMMAND_8, 0x13, //
WRITE_COMMAND_8, 0x29,
END_WRITE};
class Arduino_NT39125 : public Arduino_TFT
{
public:
Arduino_NT39125(
Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0,
bool ips = false, int16_t w = NT39125_TFTWIDTH, int16_t h = NT39125_TFTHEIGHT,
uint8_t col_offset1 = 0, uint8_t row_offset1 = 0, uint8_t col_offset2 = 0, uint8_t row_offset2 = 0);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void setRotation(uint8_t r) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
protected:
void tftInit() override;
private:
};
#endif // _ARDUINO_NT39125_H_

View File

@@ -0,0 +1,115 @@
#include "Arduino_NV3007.h"
#include "SPI.h"
Arduino_NV3007::Arduino_NV3007(
Arduino_DataBus *bus, int8_t rst, uint8_t r,
bool ips, int16_t w, int16_t h,
uint8_t col_offset1, uint8_t row_offset1, uint8_t col_offset2, uint8_t row_offset2,
const uint8_t *init_operations, size_t init_operations_len)
: Arduino_TFT(bus, rst, r, ips, w, h, col_offset1, row_offset1, col_offset2, row_offset2),
_init_operations(init_operations), _init_operations_len(init_operations_len)
{
}
bool Arduino_NV3007::begin(int32_t speed)
{
_override_datamode = SPI_MODE0; // always use SPI_MODE0
return Arduino_TFT::begin(speed);
}
void Arduino_NV3007::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
if ((x != _currentX) || (w != _currentW) || (y != _currentY) || (h != _currentH))
{
_bus->writeC8D16D16(NV3007_CASET, x + _xStart, x + w - 1 + _xStart);
_bus->writeC8D16D16(NV3007_RASET, y + _yStart, y + h - 1 + _yStart);
_currentX = x;
_currentY = y;
_currentW = w;
_currentH = h;
}
_bus->writeCommand(NV3007_RAMWR); // write to RAM
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_NV3007::setRotation(uint8_t r)
{
Arduino_TFT::setRotation(r);
switch (_rotation)
{
case 1:
r = NV3007_MADCTL_MX | NV3007_MADCTL_MV | NV3007_MADCTL_RGB;
break;
case 2:
r = NV3007_MADCTL_MX | NV3007_MADCTL_MY | NV3007_MADCTL_RGB;
break;
case 3:
r = NV3007_MADCTL_MY | NV3007_MADCTL_MV | NV3007_MADCTL_RGB;
break;
case 4:
r = NV3007_MADCTL_MX | NV3007_MADCTL_RGB;
break;
case 5:
r = NV3007_MADCTL_MX | NV3007_MADCTL_MY | NV3007_MADCTL_MV | NV3007_MADCTL_RGB;
break;
case 6:
r = NV3007_MADCTL_MY | NV3007_MADCTL_RGB;
break;
case 7:
r = NV3007_MADCTL_MV | NV3007_MADCTL_RGB;
break;
default: // case 0:
r = NV3007_MADCTL_RGB;
break;
}
_bus->beginWrite();
_bus->writeC8D8(NV3007_MADCTL, r);
_bus->endWrite();
}
void Arduino_NV3007::invertDisplay(bool i)
{
_bus->sendCommand(_ips ? (i ? NV3007_INVOFF : NV3007_INVON) : (i ? NV3007_INVON : NV3007_INVOFF));
}
void Arduino_NV3007::displayOn(void)
{
_bus->sendCommand(NV3007_SLPOUT);
delay(NV3007_SLPOUT_DELAY);
}
void Arduino_NV3007::displayOff(void)
{
_bus->sendCommand(NV3007_SLPIN);
delay(NV3007_SLPIN_DELAY);
}
void Arduino_NV3007::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(NV3007_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(NV3007_RST_DELAY);
}
else
{
// Software Rest
}
_bus->batchOperation(_init_operations, _init_operations_len);
invertDisplay(false);
}

View File

@@ -0,0 +1,334 @@
#pragma once
#include "../Arduino_GFX.h"
#include "../Arduino_TFT.h"
#define NV3007_TFTWIDTH 168
#define NV3007_TFTHEIGHT 428
#define NV3007_RST_DELAY 120 ///< delay ms wait for reset finish
#define NV3007_SLPIN_DELAY 120 ///< delay ms wait for sleep in finish
#define NV3007_SLPOUT_DELAY 120 ///< delay ms wait for sleep out finish
#define NV3007_SLPIN 0x10
#define NV3007_SLPOUT 0x11
#define NV3007_INVOFF 0x20
#define NV3007_INVON 0x21
#define NV3007_DISPOFF 0x28
#define NV3007_DISPON 0x29
#define NV3007_CASET 0x2A
#define NV3007_RASET 0x2B
#define NV3007_RAMWR 0x2C
#define NV3007_RAMRD 0x2E
#define NV3007_MADCTL 0x36
#define NV3007_MADCTL_MY 0x80
#define NV3007_MADCTL_MX 0x40
#define NV3007_MADCTL_MV 0x20
#define NV3007_MADCTL_ML 0x10
#define NV3007_MADCTL_RGB 0x00
static const uint8_t nv3007_init_operations[] = {
BEGIN_WRITE,
WRITE_C8_D8, 0xFF, 0xA5,
WRITE_COMMAND_8, 0x11,
DELAY, 120, // 120ms
WRITE_C8_D8, 0xff, 0xa5,
WRITE_C8_D8, 0x9a, 0x08,
WRITE_C8_D8, 0x9b, 0x08,
WRITE_C8_D8, 0x9c, 0xb0,
WRITE_C8_D8, 0x9d, 0x17,
WRITE_C8_D8, 0x9e, 0xc2,
WRITE_C8_D16, 0x8f, 0x22, 0x04,
WRITE_C8_D8, 0x84, 0x90,
WRITE_C8_D8, 0x83, 0x7B,
WRITE_C8_D8, 0x85, 0x4F,
////GAMMA---------------------------------/////////////
// V0[3:0]
WRITE_C8_D8, 0x6e, 0x0f,
WRITE_C8_D8, 0x7e, 0x0f,
// V63[3:0]
WRITE_C8_D8, 0x60, 0x00,
WRITE_C8_D8, 0x70, 0x00,
// V1[5:0]
WRITE_C8_D8, 0x6d, 0x39,
WRITE_C8_D8, 0x7d, 0x31,
// V62[5:0]
WRITE_C8_D8, 0x61, 0x0A,
WRITE_C8_D8, 0x71, 0x0A,
// V2[5:0]
WRITE_C8_D8, 0x6c, 0x35,
WRITE_C8_D8, 0x7c, 0x29,
// V61[5:0]
WRITE_C8_D8, 0x62, 0x0F,
WRITE_C8_D8, 0x72, 0x0F,
// V20[6:0]
WRITE_C8_D8, 0x68, 0x4f,
WRITE_C8_D8, 0x78, 0x45,
// V43[6:0]
WRITE_C8_D8, 0x66, 0x33,
WRITE_C8_D8, 0x76, 0x33,
// V4[4:0]
WRITE_C8_D8, 0x6b, 0x14,
WRITE_C8_D8, 0x7b, 0x14,
// V59[4:0]
WRITE_C8_D8, 0x63, 0x09,
WRITE_C8_D8, 0x73, 0x09,
// V6[4:0]
WRITE_C8_D8, 0x6a, 0x13,
WRITE_C8_D8, 0x7a, 0x16,
// V57[4:0]
WRITE_C8_D8, 0x64, 0x08,
WRITE_C8_D8, 0x74, 0x08,
WRITE_C8_D8, 0x69, 0x07,
WRITE_C8_D8, 0x79, 0x0d,
WRITE_C8_D8, 0x65, 0x05,
WRITE_C8_D8, 0x75, 0x05,
WRITE_C8_D8, 0x67, 0x33,
WRITE_C8_D8, 0x77, 0x33,
WRITE_C8_D8, 0x6f, 0x00,
WRITE_C8_D8, 0x7f, 0x00,
WRITE_C8_D8, 0x50, 0x00,
WRITE_C8_D8, 0x52, 0xd6,
WRITE_C8_D8, 0x53, 0x04,
WRITE_C8_D8, 0x54, 0x04,
WRITE_C8_D8, 0x55, 0x1b,
WRITE_C8_D8, 0x56, 0x1b,
WRITE_COMMAND_8, 0xa0,
WRITE_BYTES, 3, 0x2a, 0x24, 0x00,
WRITE_C8_D8, 0xa1, 0x84,
WRITE_C8_D8, 0xa2, 0x85,
WRITE_C8_D8, 0xa8, 0x34,
WRITE_C8_D8, 0xa9, 0x80,
WRITE_C8_D8, 0xaa, 0x73,
WRITE_C8_D16, 0xAB, 0x03, 0x61,
WRITE_C8_D16, 0xAC, 0x03, 0x65,
WRITE_C8_D16, 0xAD, 0x03, 0x60,
WRITE_C8_D16, 0xAE, 0x03, 0x64,
WRITE_C8_D8, 0xB9, 0x82,
WRITE_C8_D8, 0xBA, 0x83,
WRITE_C8_D8, 0xBB, 0x80,
WRITE_C8_D8, 0xBC, 0x81,
WRITE_C8_D8, 0xBD, 0x02,
WRITE_C8_D8, 0xBE, 0x01,
WRITE_C8_D8, 0xBF, 0x04,
WRITE_C8_D8, 0xC0, 0x03,
WRITE_C8_D8, 0xc4, 0x33,
WRITE_C8_D8, 0xc5, 0x80,
WRITE_C8_D8, 0xc6, 0x73,
WRITE_C8_D8, 0xc7, 0x00,
WRITE_C8_D16, 0xC8, 0x33, 0x33,
WRITE_C8_D8, 0xC9, 0x5b,
WRITE_C8_D8, 0xCA, 0x5a,
WRITE_C8_D8, 0xCB, 0x5d,
WRITE_C8_D8, 0xCC, 0x5c,
WRITE_C8_D16, 0xCD, 0x33, 0x33,
WRITE_C8_D8, 0xCE, 0x5f,
WRITE_C8_D8, 0xCF, 0x5e,
WRITE_C8_D8, 0xD0, 0x61,
WRITE_C8_D8, 0xD1, 0x60,
WRITE_COMMAND_8, 0xB0,
WRITE_BYTES, 4, 0x3a, 0x3a, 0x00, 0x00,
WRITE_C8_D8, 0xB6, 0x32,
WRITE_C8_D8, 0xB7, 0x80,
WRITE_C8_D8, 0xB8, 0x73,
WRITE_C8_D8, 0xe0, 0x00,
WRITE_C8_D16, 0xe1, 0x03, 0x0f,
WRITE_C8_D8, 0xe2, 0x04,
WRITE_C8_D8, 0xe3, 0x01,
WRITE_C8_D8, 0xe4, 0x0e,
WRITE_C8_D8, 0xe5, 0x01,
WRITE_C8_D8, 0xe6, 0x19,
WRITE_C8_D8, 0xe7, 0x10,
WRITE_C8_D8, 0xe8, 0x10,
WRITE_C8_D8, 0xe9, 0x21,
WRITE_C8_D8, 0xea, 0x12,
WRITE_C8_D8, 0xeb, 0xd0,
WRITE_C8_D8, 0xec, 0x04,
WRITE_C8_D8, 0xed, 0x07,
WRITE_C8_D8, 0xee, 0x07,
WRITE_C8_D8, 0xef, 0x09,
WRITE_C8_D8, 0xF0, 0xD0,
WRITE_C8_D8, 0xF1, 0x0E,
WRITE_C8_D8, 0xF9, 0x56,
WRITE_COMMAND_8, 0xf2,
WRITE_BYTES, 4, 0x26, 0x1b, 0x0b, 0x20,
WRITE_C8_D8, 0xec, 0x04,
WRITE_C8_D8, 0x35, 0x00,
WRITE_C8_D16, 0x44, 0x00, 0x10,
WRITE_C8_D8, 0x46, 0x10,
WRITE_C8_D8, 0xff, 0x00,
WRITE_C8_D8, 0x3a, 0x05,
WRITE_COMMAND_8, NV3007_SLPOUT,
END_WRITE,
DELAY, 200,
BEGIN_WRITE,
WRITE_COMMAND_8, NV3007_DISPON,
END_WRITE,
DELAY, 150};
static const uint8_t nv3007_279_init_operations[] = {
BEGIN_WRITE,
WRITE_C8_D8, 0xff, 0xa5,
WRITE_C8_D8, 0x9a, 0x08,
WRITE_C8_D8, 0x9b, 0x08,
WRITE_C8_D8, 0x9c, 0xb0,
WRITE_C8_D8, 0x9d, 0x16,
WRITE_C8_D8, 0x9e, 0xc4,
WRITE_C8_D16, 0x8f, 0x55, 0x04,
WRITE_C8_D8, 0x84, 0x90,
WRITE_C8_D8, 0x83, 0x7b,
WRITE_C8_D8, 0x85, 0x33,
WRITE_C8_D8, 0x60, 0x00,
WRITE_C8_D8, 0x70, 0x00,
WRITE_C8_D8, 0x61, 0x02,
WRITE_C8_D8, 0x71, 0x02,
WRITE_C8_D8, 0x62, 0x04,
WRITE_C8_D8, 0x72, 0x04,
WRITE_C8_D8, 0x6c, 0x29,
WRITE_C8_D8, 0x7c, 0x29,
WRITE_C8_D8, 0x6d, 0x31,
WRITE_C8_D8, 0x7d, 0x31,
WRITE_C8_D8, 0x6e, 0x0f,
WRITE_C8_D8, 0x7e, 0x0f,
WRITE_C8_D8, 0x66, 0x21,
WRITE_C8_D8, 0x76, 0x21,
WRITE_C8_D8, 0x68, 0x3A,
WRITE_C8_D8, 0x78, 0x3A,
WRITE_C8_D8, 0x63, 0x07,
WRITE_C8_D8, 0x73, 0x07,
WRITE_C8_D8, 0x64, 0x05,
WRITE_C8_D8, 0x74, 0x05,
WRITE_C8_D8, 0x65, 0x02,
WRITE_C8_D8, 0x75, 0x02,
WRITE_C8_D8, 0x67, 0x23,
WRITE_C8_D8, 0x77, 0x23,
WRITE_C8_D8, 0x69, 0x08,
WRITE_C8_D8, 0x79, 0x08,
WRITE_C8_D8, 0x6a, 0x13,
WRITE_C8_D8, 0x7a, 0x13,
WRITE_C8_D8, 0x6b, 0x13,
WRITE_C8_D8, 0x7b, 0x13,
WRITE_C8_D8, 0x6f, 0x00,
WRITE_C8_D8, 0x7f, 0x00,
WRITE_C8_D8, 0x50, 0x00,
WRITE_C8_D8, 0x52, 0xd6,
WRITE_C8_D8, 0x53, 0x08,
WRITE_C8_D8, 0x54, 0x08,
WRITE_C8_D8, 0x55, 0x1e,
WRITE_C8_D8, 0x56, 0x1c,
WRITE_COMMAND_8, 0xa0,
WRITE_BYTES, 3, 0x2b, 0x24, 0x00,
WRITE_C8_D8, 0xa1, 0x87,
WRITE_C8_D8, 0xa2, 0x86,
WRITE_C8_D8, 0xa5, 0x00,
WRITE_C8_D8, 0xa6, 0x00,
WRITE_C8_D8, 0xa7, 0x00,
WRITE_C8_D8, 0xa8, 0x36,
WRITE_C8_D8, 0xa9, 0x7e,
WRITE_C8_D8, 0xaa, 0x7e,
WRITE_C8_D8, 0xB9, 0x85,
WRITE_C8_D8, 0xBA, 0x84,
WRITE_C8_D8, 0xBB, 0x83,
WRITE_C8_D8, 0xBC, 0x82,
WRITE_C8_D8, 0xBD, 0x81,
WRITE_C8_D8, 0xBE, 0x80,
WRITE_C8_D8, 0xBF, 0x01,
WRITE_C8_D8, 0xC0, 0x02,
WRITE_C8_D8, 0xc1, 0x00,
WRITE_C8_D8, 0xc2, 0x00,
WRITE_C8_D8, 0xc3, 0x00,
WRITE_C8_D8, 0xc4, 0x33,
WRITE_C8_D8, 0xc5, 0x7e,
WRITE_C8_D8, 0xc6, 0x7e,
WRITE_C8_D16, 0xC8, 0x33, 0x33,
WRITE_C8_D8, 0xC9, 0x68,
WRITE_C8_D8, 0xCA, 0x69,
WRITE_C8_D8, 0xCB, 0x6a,
WRITE_C8_D8, 0xCC, 0x6b,
WRITE_C8_D16, 0xCD, 0x33, 0x33,
WRITE_C8_D8, 0xCE, 0x6c,
WRITE_C8_D8, 0xCF, 0x6d,
WRITE_C8_D8, 0xD0, 0x6e,
WRITE_C8_D8, 0xD1, 0x6f,
WRITE_C8_D16, 0xAB, 0x03, 0x67,
WRITE_C8_D16, 0xAC, 0x03, 0x6b,
WRITE_C8_D16, 0xAD, 0x03, 0x68,
WRITE_C8_D16, 0xAE, 0x03, 0x6c,
WRITE_C8_D8, 0xb3, 0x00,
WRITE_C8_D8, 0xb4, 0x00,
WRITE_C8_D8, 0xb5, 0x00,
WRITE_C8_D8, 0xB6, 0x32,
WRITE_C8_D8, 0xB7, 0x7e,
WRITE_C8_D8, 0xB8, 0x7e,
WRITE_C8_D8, 0xe0, 0x00,
WRITE_C8_D16, 0xe1, 0x03, 0x0f,
WRITE_C8_D8, 0xe2, 0x04,
WRITE_C8_D8, 0xe3, 0x01,
WRITE_C8_D8, 0xe4, 0x0e,
WRITE_C8_D8, 0xe5, 0x01,
WRITE_C8_D8, 0xe6, 0x19,
WRITE_C8_D8, 0xe7, 0x10,
WRITE_C8_D8, 0xe8, 0x10,
WRITE_C8_D8, 0xea, 0x12,
WRITE_C8_D8, 0xeb, 0xd0,
WRITE_C8_D8, 0xec, 0x04,
WRITE_C8_D8, 0xed, 0x07,
WRITE_C8_D8, 0xee, 0x07,
WRITE_C8_D8, 0xef, 0x09,
WRITE_C8_D8, 0xf0, 0xd0,
WRITE_C8_D8, 0xf1, 0x0e,
WRITE_C8_D8, 0xF9, 0x17,
WRITE_COMMAND_8, 0xf2,
WRITE_BYTES, 4, 0x2c, 0x1b, 0x0b, 0x20,
WRITE_C8_D8, 0xe9, 0x29,
WRITE_C8_D8, 0xec, 0x04,
WRITE_C8_D8, 0x35, 0x00,
WRITE_C8_D16, 0x44, 0x00, 0x10,
WRITE_C8_D8, 0x46, 0x10,
WRITE_C8_D8, 0xff, 0x00,
WRITE_C8_D8, 0x3a, 0x05,
WRITE_COMMAND_8, NV3007_SLPOUT,
DELAY, 120,
WRITE_COMMAND_8, NV3007_DISPON,
END_WRITE};
class Arduino_NV3007 : public Arduino_TFT
{
public:
Arduino_NV3007(
Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0,
bool ips = false, int16_t w = NV3007_TFTWIDTH, int16_t h = NV3007_TFTHEIGHT,
uint8_t col_offset1 = 0, uint8_t row_offset1 = 0, uint8_t col_offset2 = 0, uint8_t row_offset2 = 0,
const uint8_t *init_operations = nv3007_init_operations, size_t init_operations_len = sizeof(nv3007_init_operations));
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void setRotation(uint8_t r) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
protected:
void tftInit() override;
private:
const uint8_t *_init_operations;
size_t _init_operations_len;
};

View File

@@ -0,0 +1,101 @@
#include "Arduino_NV3023.h"
#include "SPI.h"
Arduino_NV3023::Arduino_NV3023(
Arduino_DataBus *bus, int8_t rst, uint8_t r,
bool ips, int16_t w, int16_t h,
uint8_t col_offset1, uint8_t row_offset1, uint8_t col_offset2, uint8_t row_offset2)
: Arduino_TFT(bus, rst, r, ips, w, h, col_offset1, row_offset1, col_offset2, row_offset2)
{
}
bool Arduino_NV3023::begin(int32_t speed)
{
_override_datamode = SPI_MODE0; // always use SPI_MODE0
return Arduino_TFT::begin(speed);
}
void Arduino_NV3023::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
if ((x != _currentX) || (w != _currentW) || (y != _currentY) || (h != _currentH))
{
_bus->writeC8D16D16(NV3023_CASET, x + _xStart, x + w - 1 + _xStart);
_bus->writeC8D16D16(NV3023_RASET, y + _yStart, y + h - 1 + _yStart);
_currentX = x;
_currentY = y;
_currentW = w;
_currentH = h;
}
_bus->writeCommand(NV3023_RAMWR); // write to RAM
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_NV3023::setRotation(uint8_t r)
{
Arduino_TFT::setRotation(r);
switch (_rotation)
{
case 1:
r = NV3023_MADCTL_MY | NV3023_MADCTL_MV | NV3023_MADCTL_MX | NV3023_MADCTL_BGR;
break;
case 2:
r = NV3023_MADCTL_MX | NV3023_MADCTL_BGR;
break;
case 3:
r = NV3023_MADCTL_MV | NV3023_MADCTL_BGR;
break;
default: // case 0:
r = NV3023_MADCTL_MY | NV3023_MADCTL_BGR;
break;
}
_bus->beginWrite();
_bus->writeC8D8(NV3023_MADCTL, r);
_bus->endWrite();
}
void Arduino_NV3023::invertDisplay(bool i)
{
_bus->sendCommand(_ips ? (i ? NV3023_INVOFF : NV3023_INVON) : (i ? NV3023_INVON : NV3023_INVOFF));
}
void Arduino_NV3023::displayOn(void)
{
_bus->sendCommand(NV3023_SLPOUT);
delay(NV3023_SLPOUT_DELAY);
}
void Arduino_NV3023::displayOff(void)
{
_bus->sendCommand(NV3023_SLPIN);
delay(NV3023_SLPIN_DELAY);
}
void Arduino_NV3023::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(NV3023_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(NV3023_RST_DELAY);
}
else
{
// Software Rest
}
_bus->batchOperation(NV3023_init_operations, sizeof(NV3023_init_operations));
invertDisplay(false);
}

View File

@@ -0,0 +1,157 @@
#ifndef _ARDUINO_NV3023_H_
#define _ARDUINO_NV3023_H_
#include <Arduino.h>
#include <Print.h>
#include "./Arduino_GFX.h"
#include "../Arduino_TFT.h"
#define NV3023_TFTWIDTH 128
#define NV3023_TFTHEIGHT 128
#define NV3023_RST_DELAY 120 ///< delay ms wait for reset finish
#define NV3023_SLPIN_DELAY 120 ///< delay ms wait for sleep in finish
#define NV3023_SLPOUT_DELAY 120 ///< delay ms wait for sleep out finish
#define NV3023_NOP 0x00
#define NV3023_SWRESET 0x01
#define NV3023_RDDID 0x04
#define NV3023_RDDST 0x09
#define NV3023_SLPIN 0x10
#define NV3023_SLPOUT 0x11
#define NV3023_PTLON 0x12
#define NV3023_NORON 0x13
#define NV3023_INVOFF 0x20
#define NV3023_INVON 0x21
#define NV3023_DISPOFF 0x28
#define NV3023_DISPON 0x29
#define NV3023_CASET 0x2A
#define NV3023_RASET 0x2B
#define NV3023_RAMWR 0x2C
#define NV3023_RAMRD 0x2E
#define NV3023_PTLAR 0x30
#define NV3023_TELON 0x35
#define NV3023_MADCTL 0x36
#define NV3023_COLMOD 0x3A
#define NV3023_SCANLSET 0x44
#define NV3023_FRMCTR1 0xB1
#define NV3023_FRMCTR2 0xB2
#define NV3023_FRMCTR3 0xB3
#define NV3023_INVCTR 0xB4
#define NV3023_VREG1CTL 0xE6
#define NV3023_VREG2CTL 0xE7
#define NV3023_GAMMA1 0xF0
#define NV3023_GAMMA2 0xF1
#define NV3023_INTERRE1 0xFE
#define NV3023_INTERRE2 0xEF
#define NV3023_MADCTL_MY 0x80
#define NV3023_MADCTL_MX 0x40
#define NV3023_MADCTL_MV 0x20
#define NV3023_MADCTL_ML 0x10
#define NV3023_MADCTL_BGR 0x08
#define NV3023_MADCTL_MH 0x04
#define NV3023_MADCTL_RGB 0x00
static const uint8_t NV3023_init_operations[] = {
BEGIN_WRITE,
WRITE_C8_D8, 0xFF, 0xA5,
WRITE_C8_D8, 0x3E, 0x09,
WRITE_C8_D8, 0x3A, 0x65,
WRITE_C8_D8, 0x82, 0x00,
WRITE_C8_D8, 0x98, 0x00,
WRITE_C8_D8, 0x63, 0x0F,
WRITE_C8_D8, 0x64, 0x0F,
WRITE_C8_D8, 0xB4, 0x34,
WRITE_C8_D8, 0xB5, 0x30,
WRITE_C8_D8, 0x83, 0x03,
WRITE_C8_D8, 0x86, 0x04,
WRITE_C8_D8, 0x87, 0x16,
WRITE_C8_D8, 0x88, 0x0A,
WRITE_C8_D8, 0x89, 0x27,
WRITE_C8_D8, 0x93, 0x63,
WRITE_C8_D8, 0x96, 0x81,
WRITE_C8_D8, 0xC3, 0x10,
WRITE_C8_D8, 0xE6, 0x00,
WRITE_C8_D8, 0x99, 0x01,
////////////////////////gamma_set////////vrp+ v- vrn//////////////////////////////
WRITE_C8_D8, 0x70, 0x09,
WRITE_C8_D8, 0x71, 0x1D,
WRITE_C8_D8, 0x72, 0x14,
WRITE_C8_D8, 0x73, 0x0A,
WRITE_C8_D8, 0x74, 0x11,
WRITE_C8_D8, 0x75, 0x16,
WRITE_C8_D8, 0x76, 0x38,
WRITE_C8_D8, 0x77, 0x0B,
WRITE_C8_D8, 0x78, 0x08,
WRITE_C8_D8, 0x79, 0x3E,
WRITE_C8_D8, 0x7A, 0x07,
WRITE_C8_D8, 0x7B, 0x0D,
WRITE_C8_D8, 0x7C, 0x16,
WRITE_C8_D8, 0x7D, 0x0F,
WRITE_C8_D8, 0x7E, 0x14,
WRITE_C8_D8, 0x7F, 0x05,
WRITE_C8_D8, 0xA0, 0x04,
WRITE_C8_D8, 0xA1, 0x28,
WRITE_C8_D8, 0xA2, 0x0C,
WRITE_C8_D8, 0xA3, 0x11,
WRITE_C8_D8, 0xA4, 0x0B,
WRITE_C8_D8, 0xA5, 0x23,
WRITE_C8_D8, 0xA6, 0x45,
WRITE_C8_D8, 0xA7, 0x07,
WRITE_C8_D8, 0xA8, 0x0A,
WRITE_C8_D8, 0xA9, 0x3B,
WRITE_C8_D8, 0xAA, 0x0D,
WRITE_C8_D8, 0xAB, 0x18,
WRITE_C8_D8, 0xAC, 0x14,
WRITE_C8_D8, 0xAD, 0x0F,
WRITE_C8_D8, 0xAE, 0x19,
WRITE_C8_D8, 0xAF, 0x08,
//////////////////////////////////////////////////////////////////
WRITE_C8_D8, 0xFF, 0x00,
WRITE_COMMAND_8, 0x11,
END_WRITE,
DELAY, 120,
BEGIN_WRITE,
// WRITE_COMMAND_8, 0x21,
// WRITE_C8_D8, 0x36, 0x80,
WRITE_COMMAND_8, 0x29,
END_WRITE,
DELAY, 20};
class Arduino_NV3023 : public Arduino_TFT
{
public:
Arduino_NV3023(
Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0,
bool ips = false, int16_t w = NV3023_TFTWIDTH, int16_t h = NV3023_TFTHEIGHT,
uint8_t col_offset1 = 0, uint8_t row_offset1 = 0, uint8_t col_offset2 = 0, uint8_t row_offset2 = 0);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void setRotation(uint8_t r) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
protected:
void tftInit() override;
private:
};
#endif

View File

@@ -0,0 +1,112 @@
#include "Arduino_NV3041A.h"
#include "SPI.h"
Arduino_NV3041A::Arduino_NV3041A(
Arduino_DataBus *bus, int8_t rst, uint8_t r,
bool ips, int16_t w, int16_t h,
uint8_t col_offset1, uint8_t row_offset1, uint8_t col_offset2, uint8_t row_offset2)
: Arduino_TFT(bus, rst, r, ips, w, h, col_offset1, row_offset1, col_offset2, row_offset2)
{
}
bool Arduino_NV3041A::begin(int32_t speed)
{
if (speed == GFX_NOT_DEFINED)
{
speed = 32000000UL; // NV3041A Maximum supported speed
}
return Arduino_TFT::begin(speed);
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_NV3041A::setRotation(uint8_t r)
{
Arduino_TFT::setRotation(r);
switch (_rotation)
{
case 1:
r = NV3041A_MADCTL_MY | NV3041A_MADCTL_MV | NV3041A_MADCTL_RGB;
break;
case 2:
r = NV3041A_MADCTL_RGB;
break;
case 3:
r = NV3041A_MADCTL_MX | NV3041A_MADCTL_MV | NV3041A_MADCTL_RGB;
break;
default: // case 0:
r = NV3041A_MADCTL_MX | NV3041A_MADCTL_MY | NV3041A_MADCTL_RGB;
break;
}
_bus->beginWrite();
_bus->writeC8D8(NV3041A_MADCTL, r);
_bus->endWrite();
}
void Arduino_NV3041A::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
if ((x != _currentX) || (w != _currentW))
{
_currentX = x;
_currentW = w;
x += _xStart;
_bus->writeC8D16D16Split(NV3041A_CASET, x, x + w - 1);
}
if ((y != _currentY) || (h != _currentH))
{
_currentY = y;
_currentH = h;
y += _yStart;
_bus->writeC8D16D16Split(NV3041A_RASET, y, y + h - 1);
}
_bus->writeCommand(NV3041A_RAMWR); // write to RAM
}
void Arduino_NV3041A::invertDisplay(bool i)
{
_bus->sendCommand((_ips ^ i) ? NV3041A_INVON : NV3041A_INVOFF);
}
void Arduino_NV3041A::displayOn(void)
{
_bus->sendCommand(NV3041A_SLPOUT);
delay(NV3041A_SLPOUT_DELAY);
}
void Arduino_NV3041A::displayOff(void)
{
_bus->sendCommand(NV3041A_SLPIN);
delay(NV3041A_SLPIN_DELAY);
}
// Companion code to the above tables. Reads and issues
// a series of LCD commands stored in PROGMEM byte array.
void Arduino_NV3041A::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(NV3041A_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(NV3041A_RST_DELAY);
}
else
{
// Software Rest
_bus->sendCommand(NV3041A_SWRESET);
delay(NV3041A_RST_DELAY);
}
_bus->batchOperation(nv3041a_init_operations, sizeof(nv3041a_init_operations));
invertDisplay(false);
}

View File

@@ -0,0 +1,333 @@
#ifndef _ARDUINO_NV3041A_H_
#define _ARDUINO_NV3041A_H_
#include "../Arduino_GFX.h"
#include "../Arduino_TFT.h"
#define NV3041A_TFTWIDTH 480
#define NV3041A_TFTHEIGHT 272
#define NV3041A_RST_DELAY 120 ///< delay ms wait for reset finish
#define NV3041A_SLPIN_DELAY 120 ///< delay ms wait for sleep in finish
#define NV3041A_SLPOUT_DELAY 120 ///< delay ms wait for sleep out finish
#define NV3041A_NOP 0x00
#define NV3041A_SWRESET 0x01
#define NV3041A_SLPIN 0x10
#define NV3041A_SLPOUT 0x11
#define NV3041A_INVOFF 0x20
#define NV3041A_INVON 0x21
#define NV3041A_DISPOFF 0x28
#define NV3041A_DISPON 0x29
#define NV3041A_CASET 0x2A
#define NV3041A_RASET 0x2B
#define NV3041A_RAMWR 0x2C
#define NV3041A_MADCTL 0x36
#define NV3041A_COLMOD 0x3A
#define NV3041A_MADCTL_MY 0x80
#define NV3041A_MADCTL_MX 0x40
#define NV3041A_MADCTL_MV 0x20
#define NV3041A_MADCTL_ML 0x10
#define NV3041A_MADCTL_RGB 0x00
static const uint8_t nv3041a_init_operations[] = {
BEGIN_WRITE,
WRITE_C8_D8, 0xff,
0xa5,
WRITE_C8_D8, 0x36, //
0xc0,
WRITE_C8_D8, 0x3A, //
0x01, // 01---56500---666
WRITE_C8_D8, 0x41,
0x03, // 01--8bit, 03-16bit
WRITE_C8_D8, 0x44, // VBP ?????
0x15, // 21
WRITE_C8_D8, 0x45, // VFP ?????
0x15, // 21
WRITE_C8_D8, 0x7d, // vdds_trim[2:0]
0x03,
WRITE_C8_D8, 0xc1, // avdd_clp_en avdd_clp[1:0] avcl_clp_en avcl_clp[1:0]
0xbb, // 0xbb 88 a2
WRITE_C8_D8, 0xc2, // vgl_clp_en vgl_clp[2:0]
0x05,
WRITE_C8_D8, 0xc3, // vgl_clp_en vgl_clp[2:0]
0x10,
WRITE_C8_D8, 0xc6, // avdd_ratio_sel avcl_ratio_sel vgh_ratio_sel[1:0] vgl_ratio_sel[1:0]
0x3e, // 35
WRITE_C8_D8, 0xc7, // mv_clk_sel[1:0] avdd_clk_sel[1:0] avcl_clk_sel[1:0]
0x25, // 2e
WRITE_C8_D8, 0xc8, // VGL_CLK_sel
0x11, //
WRITE_C8_D8, 0x7a, // user_vgsp
0x5f, // 4f:0.8V 3f:1.04V 5f
WRITE_C8_D8, 0x6f, // user_gvdd
0x44, // 1C:5.61 5f 53 2a 3a
WRITE_C8_D8, 0x78, // user_gvcl
0x70, // 50:-3.22 75 58 66
WRITE_C8_D8, 0xc9, //
0x00,
WRITE_C8_D8, 0x67, //
0x21,
// gate_ed
WRITE_C8_D8, 0x51, // gate_st_o[7:0]
0x0a,
WRITE_C8_D8, 0x52, // gate_ed_o[7:0]
0x76, // 76
WRITE_C8_D8, 0x53, // gate_st_e[7:0]
0x0a, // 76
WRITE_C8_D8, 0x54, // gate_ed_e[7:0]
0x76,
////sorce
WRITE_C8_D8, 0x46, // fsm_hbp_o[5:0]
0x0a,
WRITE_C8_D8, 0x47, // fsm_hfp_o[5:0]
0x2a,
WRITE_C8_D8, 0x48, // fsm_hbp_e[5:0]
0x0a,
WRITE_C8_D8, 0x49, // fsm_hfp_e[5:0]
0x1a,
WRITE_C8_D8, 0x56, // src_ld_wd[1:0] src_ld_st[5:0]
0x43,
WRITE_C8_D8, 0x57, // pn_cs_en src_cs_st[5:0]
0x42,
WRITE_C8_D8, 0x58, // src_cs_p_wd[6:0]
0x3c,
WRITE_C8_D8, 0x59, // src_cs_n_wd[6:0]
0x64,
WRITE_C8_D8, 0x5a, // src_pchg_st_o[6:0]
0x41, // 41
WRITE_C8_D8, 0x5b, // src_pchg_wd_o[6:0]
0x3c,
WRITE_C8_D8, 0x5c, // src_pchg_st_e[6:0]
0x02, // 02
WRITE_C8_D8, 0x5d, // src_pchg_wd_e[6:0]
0x3c, // 3c
WRITE_C8_D8, 0x5e, // src_pol_sw[7:0]
0x1f,
WRITE_C8_D8, 0x60, // src_op_st_o[7:0]
0x80,
WRITE_C8_D8, 0x61, // src_op_st_e[7:0]
0x3f,
WRITE_C8_D8, 0x62, // src_op_ed_o[9:8] src_op_ed_e[9:8]
0x21,
WRITE_C8_D8, 0x63, // src_op_ed_o[7:0]
0x07,
WRITE_C8_D8, 0x64, // src_op_ed_e[7:0]
0xe0,
WRITE_C8_D8, 0x65, // chopper
0x02,
WRITE_C8_D8, 0xca, // avdd_mux_st_o[7:0]
0x20,
WRITE_C8_D8, 0xcb, // avdd_mux_ed_o[7:0]
0x52, // 52
WRITE_C8_D8, 0xcc, // avdd_mux_st_e[7:0]
0x10,
WRITE_C8_D8, 0xcD, // avdd_mux_ed_e[7:0]
0x42,
WRITE_C8_D8, 0xD0, // avcl_mux_st_o[7:0]
0x20,
WRITE_C8_D8, 0xD1, // avcl_mux_ed_o[7:0]
0x52,
WRITE_C8_D8, 0xD2, // avcl_mux_st_e[7:0]
0x10,
WRITE_C8_D8, 0xD3, // avcl_mux_ed_e[7:0]
0x42,
WRITE_C8_D8, 0xD4, // vgh_mux_st[7:0]
0x0a,
WRITE_C8_D8, 0xD5, // vgh_mux_ed[7:0]
0x32,
// 2-1
////gammma weihuan pianguangpian 0913
WRITE_C8_D8, 0x80, // gam_vrp0 0 6bit
0x00,
WRITE_C8_D8, 0xA0, // gam_VRN0 0-
0x00,
WRITE_C8_D8, 0x81, // gam_vrp1 1 6bit
0x07,
WRITE_C8_D8, 0xA1, // gam_VRN1 1-
0x06,
WRITE_C8_D8, 0x82, // gam_vrp2 2 6bit
0x02,
WRITE_C8_D8, 0xA2, // gam_VRN2 2-
0x01,
WRITE_C8_D8, 0x86, // gam_prp0 7bit 8 7bit
0x11, // 33
WRITE_C8_D8, 0xA6, // gam_PRN0 8-
0x10, // 2a
WRITE_C8_D8, 0x87, // gam_prp1 7bit 40 7bit
0x27, // 2d
WRITE_C8_D8, 0xA7, // gam_PRN1 40-
0x27, // 2d
WRITE_C8_D8, 0x83, // gam_vrp3 61 6bit
0x37,
WRITE_C8_D8, 0xA3, // gam_VRN3 61-
0x37,
WRITE_C8_D8, 0x84, // gam_vrp4 62 6bit
0x35,
WRITE_C8_D8, 0xA4, // gam_VRN4 62-
0x35,
WRITE_C8_D8, 0x85, // gam_vrp5 63 6bit
0x3f,
WRITE_C8_D8, 0xA5, // gam_VRN5 63-
0x3f,
//
WRITE_C8_D8, 0x88, // gam_pkp0 4 5bit
0x0b, // 0b
WRITE_C8_D8, 0xA8, // gam_PKN0 4-
0x0b, // 0b
WRITE_C8_D8, 0x89, // gam_pkp1 5 5bit
0x14, // 14
WRITE_C8_D8, 0xA9, // gam_PKN1 5-
0x14, // 14
WRITE_C8_D8, 0x8a, // gam_pkp2 7 5bit
0x1a, // 1a
WRITE_C8_D8, 0xAa, // gam_PKN2 7-
0x1a, // 1a
WRITE_C8_D8, 0x8b, // gam_PKP3 10 5bit
0x0a,
WRITE_C8_D8, 0xAb, // gam_PKN3 10-
0x0a,
WRITE_C8_D8, 0x8c, // gam_PKP4 16 5bit
0x14,
WRITE_C8_D8, 0xAc, // gam_PKN4 16-
0x08,
WRITE_C8_D8, 0x8d, // gam_PKP5 22 5bit
0x17,
WRITE_C8_D8, 0xAd, // gam_PKN5 22-
0x07,
WRITE_C8_D8, 0x8e, // gam_PKP6 28 5bit
0x16, // 16 change
WRITE_C8_D8, 0xAe, // gam_PKN6 28-
0x06, // 13change
WRITE_C8_D8, 0x8f, // gam_PKP7 34 5bit
0x1B,
WRITE_C8_D8, 0xAf, // gam_PKN7 34-
0x07,
WRITE_C8_D8, 0x90, // gam_PKP8 46 5bit
0x04,
WRITE_C8_D8, 0xB0, // gam_PKN8 46-
0x04,
WRITE_C8_D8, 0x91, // gam_PKP9 52 5bit
0x0A,
WRITE_C8_D8, 0xB1, // gam_PKN9 52-
0x0A,
WRITE_C8_D8, 0x92, // gam_PKP10 58 5bit
0x16,
WRITE_C8_D8, 0xB2, // gam_PKN10 58-
0x15,
WRITE_C8_D8, 0xff,
0x00,
WRITE_C8_D8, 0x11,
0x00,
END_WRITE,
DELAY, 120,
BEGIN_WRITE,
WRITE_C8_D8, 0x29,
0x00,
END_WRITE,
DELAY, 100};
class Arduino_NV3041A : public Arduino_TFT
{
public:
Arduino_NV3041A(
Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0,
bool ips = false, int16_t w = NV3041A_TFTWIDTH, int16_t h = NV3041A_TFTHEIGHT,
uint8_t col_offset1 = 0, uint8_t row_offset1 = 0, uint8_t col_offset2 = 0, uint8_t row_offset2 = 0);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void setRotation(uint8_t r) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
protected:
void tftInit() override;
private:
};
#endif

View File

@@ -0,0 +1,244 @@
#include "Arduino_OTM8009A.h"
Arduino_OTM8009A::Arduino_OTM8009A(
Arduino_DataBus *bus, int8_t rst, uint8_t r,
bool ips, int16_t w, int16_t h,
uint8_t col_offset1, uint8_t row_offset1, uint8_t col_offset2, uint8_t row_offset2)
: Arduino_TFT(bus, rst, r, ips, w, h, col_offset1, row_offset1, col_offset2, row_offset2)
{
}
bool Arduino_OTM8009A::begin(int32_t speed)
{
return Arduino_TFT::begin(speed);
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_OTM8009A::setRotation(uint8_t r)
{
Arduino_TFT::setRotation(r);
switch (_rotation)
{
case 3:
r = (OTM8009A_MADCTL_MY | OTM8009A_MADCTL_MV);
break;
case 2:
r = (OTM8009A_MADCTL_MY | OTM8009A_MADCTL_MX);
break;
case 1:
r = (OTM8009A_MADCTL_MX | OTM8009A_MADCTL_MV);
break;
default: // case 0:
r = 0;
break;
}
_bus->beginWrite();
_bus->writeCommand16(OTM8009A_MADCTR);
_bus->write16(r);
_bus->endWrite();
}
void Arduino_OTM8009A::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
if ((x != _currentX) || (w != _currentW))
{
_currentX = x;
_currentW = w;
_data16.value = x + _xStart;
_bus->writeC16D16(OTM8009A_CASET, _data16.msb);
_bus->writeC16D16(OTM8009A_CASET + 1, _data16.lsb);
_data16.value += w - 1;
_bus->writeC16D16(OTM8009A_CASET + 2, _data16.msb);
_bus->writeC16D16(OTM8009A_CASET + 3, _data16.lsb);
}
if ((y != _currentY) || (h != _currentH))
{
_currentY = y;
_currentH = h;
_data16.value = y + _yStart;
_bus->writeC16D16(OTM8009A_PASET, _data16.msb);
_bus->writeC16D16(OTM8009A_PASET + 1, _data16.lsb);
_data16.value += h - 1;
_bus->writeC16D16(OTM8009A_PASET + 2, _data16.msb);
_bus->writeC16D16(OTM8009A_PASET + 3, _data16.lsb);
}
_bus->writeCommand16(OTM8009A_RAMWR); // write to RAM
}
void Arduino_OTM8009A::invertDisplay(bool)
{
// Not Implemented
}
void Arduino_OTM8009A::displayOn(void)
{
// Not Implemented
}
void Arduino_OTM8009A::displayOff(void)
{
// Not Implemented
}
void Arduino_OTM8009A::WriteRegM(uint16_t adr, uint16_t len, uint8_t dat[])
{
for (uint16_t i = 0; i < len; i++)
{
_bus->writeCommand16(adr++);
_bus->write16(dat[i]);
}
}
// Companion code to the above tables. Reads and issues
// a series of LCD commands stored in PROGMEM byte array.
void Arduino_OTM8009A::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(OTM8009A_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(OTM8009A_RST_DELAY);
}
else
{
// Software Rest
}
//************* OTM8009A**********//
_bus->beginWrite();
// 3.97inch OTM8009 Init 20190116
/* Enter CMD2 */
uint8_t ini01[] = {0x80, 0x09, 0x01, 0x01};
WriteRegM(0xFF00, sizeof(ini01), ini01);
/* Enter Orise Command2 */
uint8_t ini02[] = {0x80, 0x09};
WriteRegM(0xFF80, sizeof(ini02), ini02);
/* Command not documented */
_bus->writeCommand16(0xf5b6);
_bus->write16(0x06); //??
/* Source Driver Precharge Control */
uint8_t ini03[] = {0x30, 0x83};
WriteRegM(0xC480, sizeof(ini03), ini03);
/* Command not documented: 0xC48A */
_bus->writeCommand16(0xC48A);
_bus->write16(0x40);
/* Source Driver Timing Setting */
_bus->writeCommand16(0xC0A2 + 1);
_bus->write16(0x1B);
/* Command not documented */
_bus->writeCommand16(0xc0ba); //--> (0xc0b4); // column inversion // 2013.12.16 modify
_bus->write16(0x50);
/* Oscillator Adjustment for Idle/Normal mode */
_bus->writeCommand16(0xC181);
_bus->write16(0x66); /* 65Hz */
/* RGB Video Mode Setting */
_bus->writeCommand16(0xC1A1);
_bus->write16(0x0E);
/* Power Control Setting 1 */
_bus->writeCommand16(0xC580 + 2);
_bus->write16(0x83);
/* Power Control Setting 2 for Normal Mode */
uint8_t ini04[] = {0x96, 0x2B, 0x01, 0x33, 0x34};
WriteRegM(0xC590, sizeof(ini04), ini04);
/* Power Control Setting 4 for DC Voltage */
_bus->writeCommand16(0xC5B0 + 1);
_bus->write16(0xa9);
/* GOA VST Setting */
uint8_t ini05[] = {0x86, 0x01, 0x00, 0x85, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
WriteRegM(0xCE80, sizeof(ini05), ini05);
/* GOA CLKA1 Setting */
uint8_t ini06[] = {0x18, 0x04, 0x03, 0x21, 0x00, 0x00, 0x00};
WriteRegM(0xCEA0, sizeof(ini06), ini06);
/* GOA CLKA2 Setting */
uint8_t ini07[] = {0x18, 0x03, 0x03, 0x22, 0x00, 0x00, 0x00};
WriteRegM(0xCEA7, sizeof(ini07), ini07);
/* GOA CLKA3 Setting */
uint8_t ini08[] = {0x18, 0x02, 0x03, 0x23, 0x00, 0x00, 0x00};
WriteRegM(0xCEB0, sizeof(ini08), ini08);
/* GOA CLKA4 Setting */
uint8_t ini09[] = {0x18, 0x01, 0x03, 0x24, 0x00, 0x00, 0x00};
WriteRegM(0xCEB7, sizeof(ini09), ini09);
/* GOA ECLK Setting */
uint8_t ini10[] = {0x01, 0x01, 0x20, 0x20, 0x00, 0x00};
WriteRegM(0xCFC0, sizeof(ini10), ini10);
/* GOA Other Options 1 */
_bus->writeCommand16(0xCFC6); // cfc7[7:0] : 00, vstmask, vendmask, 00, dir1, dir2 (0=VGL, 1=VGH)
_bus->write16(0x01);
/* GOA Signal Toggle Option Setting */
uint8_t ini11[] = {0x00, 0x00, 0x00};
WriteRegM(0xCFC7, sizeof(ini11), ini11); // cfc8[7:0] : reg_goa_gnd_opt, reg_goa_dpgm_tail_set, reg_goa_f_gating_en, reg_goa_f_odd_gating, toggle_mod1, 2, 3, 4
/* Command not documented: 0xCFD0 */
_bus->writeCommand16(0xCFD0); // cfd1[7:0] : 0000000, reg_goa_frame_odd_high
_bus->write16(0x00);
/* Panel Control Setting 5 */
uint8_t ini12[] = {0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
WriteRegM(0xCBC0, sizeof(ini12), ini12); // cbc[7:0] : enmode H-byte of sig (pwrof_0, pwrof_1, norm, pwron_4 )
/* Panel Control Setting 6 */
uint8_t ini13[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00};
WriteRegM(0xCBD0, sizeof(ini13), ini13); // cbd1[7:0] : enmode H-byte of sig16 (pwrof_0, pwrof_1, norm, pwron_4 )
/* Panel Control Setting 7 */
uint8_t ini14[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
WriteRegM(0xCBE0, sizeof(ini14), ini14); // cbe1[7:0] : enmode H-byte of sig31 (pwrof_0, pwrof_1, norm, pwron_4 )
/* Panel U2D Setting 1 */
// cc8x
uint8_t ini15[] = {0x00, 0x26, 0x09, 0x0B, 0x01, 0x25, 0x00, 0x00, 0x00, 0x00};
WriteRegM(0xCC80, sizeof(ini15), ini15); // cc81[7:0] : reg setting for signal01 selection with u2d mode
/* Panel U2D Setting 2 */
// cc9x
uint8_t ini16[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x26, 0x0A, 0x0C, 0x02};
WriteRegM(0xCC90, sizeof(ini16), ini16); // cc91[7:0] : reg setting for signal11 selection with u2d mode
/* Panel U2D Setting 3 */
// ccax
uint8_t ini17[] = {0x25, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
WriteRegM(0xCCA0, sizeof(ini17), ini17); // cca1[7:0] : reg setting for signal26 selection with u2d mode
/* Command not documented: 0x3A00 */
_bus->writeCommand16(0x3A00); // ccaa[7:0] : reg setting for signal35 selection with u2d mode
_bus->write16(0x55); // 0x55
_bus->endWrite();
/* Sleep out */
_bus->sendCommand16(0x1100);
delay(100);
/* Display on */
_bus->sendCommand16(0x2900);
delay(50);
}

View File

@@ -0,0 +1,119 @@
#ifndef _ARDUINO_OTM8009A_H_
#define _ARDUINO_OTM8009A_H_
#include "../Arduino_GFX.h"
#include "../Arduino_TFT.h"
#define OTM8009A_TFTWIDTH 480 ///< OTM8009A max TFT width
#define OTM8009A_TFTHEIGHT 800 ///< OTM8009A max TFT height
#define OTM8009A_RST_DELAY 500 ///< delay ms wait for reset finish
#define OTM8009A_SLPIN_DELAY 120 ///< delay ms wait for sleep in finish
#define OTM8009A_SLPOUT_DELAY 120 ///< delay ms wait for sleep out finish
#define OTM8009A_NOP 0x0000
#define OTM8009A_SWRESET 0x0100
#define OTM8009A_RDNUMED 0x0500
#define OTM8009A_RDDPM 0x0A00
#define OTM8009A_RDDMADCTR 0x0B00
#define OTM8009A_RDDCOLMOD 0x0C00
#define OTM8009A_RDDIM 0x0D00
#define OTM8009A_RDDSM 0x0E00
#define OTM8009A_RDDSDR 0x0F00
#define OTM8009A_SLPIN 0x1000
#define OTM8009A_SLPOUT 0x1100
#define OTM8009A_PTLON 0x1200
#define OTM8009A_NORON 0x1300
#define OTM8009A_INVOFF 0x2000
#define OTM8009A_INVON 0x2100
#define OTM8009A_ALLPOFF 0x2200
#define OTM8009A_ALLPON 0x2300
#define OTM8009A_GAMSET 0x2600
#define OTM8009A_DISPOFF 0x2800
#define OTM8009A_DISPON 0x2900
#define OTM8009A_CASET 0x2A00
#define OTM8009A_PASET 0x2B00
#define OTM8009A_RAMWR 0x2C00
#define OTM8009A_RAMRD 0x2E00
#define OTM8009A_PTLAR 0x3000
#define OTM8009A_TEOFF 0x3400
#define OTM8009A_TEON 0x3500
#define OTM8009A_MADCTR 0x3600
#define OTM8009A_IDMOFF 0x3800
#define OTM8009A_IDMON 0x3900
#define OTM8009A_COLMOD 0x3A00
#define OTM8009A_RAMWRCNT 0x3C00
#define OTM8009A_RAMRDCNT 0x3E00
#define OTM8009A_WRTESCN 0x4400
#define OTM8009A_RDSCNL 0x4500
#define OTM8009A_WRDISBV 0x5100
#define OTM8009A_RDDISBV 0x5200
#define OTM8009A_WRCTRLD 0x5300
#define OTM8009A_RDCTRLD 0x5400
#define OTM8009A_WRCABC 0x5500
#define OTM8009A_RDCABC 0x5600
#define OTM8009A_WRCABCMB 0x5E00
#define OTM8009A_RDCABCMB 0x5F00
#define OTM8009A_RDPWMSDR 0x6800
#define OTM8009A_RDBWLB 0x7000
#define OTM8009A_RDBKX 0x7100
#define OTM8009A_RDBKY 0x7200
#define OTM8009A_RDWX 0x7300
#define OTM8009A_RDWY 0x7400
#define OTM8009A_RDRGLB 0x7500
#define OTM8009A_RDRX 0x7600
#define OTM8009A_RDRY 0x7700
#define OTM8009A_RDGX 0x7800
#define OTM8009A_RDGY 0x7900
#define OTM8009A_RDBALB 0x7A00
#define OTM8009A_RDBX 0x7B00
#define OTM8009A_RDBY 0x7C00
#define OTM8009A_RDAX 0x7D00
#define OTM8009A_RDAY 0x7E00
#define OTM8009A_RDDDBSTR 0xA100
#define OTM8009A_RDDDBCNT 0xA800
#define OTM8009A_RDFCS 0xAA00
#define OTM8009A_RDCCS 0xAF00
#define OTM8009A_RDID1 0xDA00
#define OTM8009A_RDID2 0xDB00
#define OTM8009A_RDID3 0xDC00
#define OTM8009A_MADCTL_MY 0x80
#define OTM8009A_MADCTL_MX 0x40
#define OTM8009A_MADCTL_MV 0x20
class Arduino_OTM8009A : public Arduino_TFT
{
public:
Arduino_OTM8009A(
Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0,
bool ips = false, int16_t w = OTM8009A_TFTWIDTH, int16_t h = OTM8009A_TFTHEIGHT,
uint8_t col_offset1 = 0, uint8_t row_offset1 = 0, uint8_t col_offset2 = 0, uint8_t row_offset2 = 0);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void setRotation(uint8_t r) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
protected:
void WriteRegM(uint16_t adr, uint16_t len, uint8_t dat[]);
void tftInit() override;
private:
};
#endif

View File

@@ -0,0 +1,106 @@
/*
* start rewrite from:
* https://github.com/adafruit/Adafruit-GFX-Library.git
* https://github.com/daumemo/IPS_LCD_R61529_FT6236_Arduino_eSPI_Test
*/
#include "Arduino_R61529.h"
Arduino_R61529::Arduino_R61529(Arduino_DataBus *bus, int8_t rst, uint8_t r, bool ips)
: Arduino_TFT(bus, rst, r, ips, R61529_TFTWIDTH, R61529_TFTHEIGHT, 0, 0, 0, 0)
{
}
bool Arduino_R61529::begin(int32_t speed)
{
return Arduino_TFT::begin(speed);
}
// Companion code to the above tables. Reads and issues
// a series of LCD commands stored in PROGMEM byte array.
void Arduino_R61529::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(R61529_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(R61529_RST_DELAY);
}
else
{
// Software Rest
_bus->sendCommand(R61529_SWRESET);
delay(R61529_RST_DELAY);
}
_bus->batchOperation(r61529_init_operations, sizeof(r61529_init_operations));
}
void Arduino_R61529::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
if ((x != _currentX) || (w != _currentW))
{
_bus->writeC8D16D16Split(R61529_CASET, x + _xStart, x + w - 1 + _xStart);
_currentX = x;
_currentW = w;
}
if ((y != _currentY) || (h != _currentH))
{
_bus->writeC8D16D16Split(R61529_PASET, y + _yStart, y + h - 1 + _yStart);
_currentY = y;
_currentH = h;
}
_bus->writeCommand(R61529_RAMWR); // write to RAM
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_R61529::setRotation(uint8_t r)
{
Arduino_TFT::setRotation(r);
switch (_rotation)
{
case 1:
r = R61529_MADCTL_MV | R61529_MADCTL_MX | R61529_MADCTL_RGB;
break;
case 2:
r = R61529_MADCTL_RGB | R61529_MADCTL_GS | R61529_MADCTL_MX;
break;
case 3:
r = R61529_MADCTL_MV | R61529_MADCTL_RGB | R61529_MADCTL_GS;
break;
default: // case 0:
r = R61529_MADCTL_RGB;
break;
}
_bus->beginWrite();
_bus->writeC8D8(R61529_MADCTL, r);
_bus->endWrite();
}
void Arduino_R61529::invertDisplay(bool i)
{
_bus->sendCommand(i ? R61529_INVON : R61529_INVOFF);
}
void Arduino_R61529::displayOn(void)
{
_bus->sendCommand(R61529_SLPOUT);
delay(R61529_SLPOUT_DELAY);
}
void Arduino_R61529::displayOff(void)
{
_bus->sendCommand(R61529_SLPIN);
delay(R61529_SLPIN_DELAY);
}

View File

@@ -0,0 +1,283 @@
/*
* start rewrite from:
* https://github.com/adafruit/Adafruit-GFX-Library.git
* https://github.com/daumemo/IPS_LCD_R61529_FT6236_Arduino_eSPI_Test
* Data Sheet:
* http://read.pudn.com/downloads648/ebook/2620902/R61529.pdf
*/
#ifndef _ARDUINO_R61529_H_
#define _ARDUINO_R61529_H_
#include "../Arduino_GFX.h"
#include "../Arduino_TFT.h"
#define R61529_TFTWIDTH 320 // R61529 max width
#define R61529_TFTHEIGHT 480 // R61529 max height
#define R61529_RST_DELAY 20 // delay ms wait for reset finish
#define R61529_SLPIN_DELAY 20 // delay ms wait for sleep in finish
#define R61529_SLPOUT_DELAY 200 // delay ms wait for sleep out finish
// User Command
#define R61529_NOP 0x00 // nop
#define R61529_SWRESET 0x01 // soft_reset
#define R61529_RDDID 0x04 // read_DDB_start
#define R61529_RDMODE 0x0A // get_power_mode
#define R61529_RDMADCTL 0x0B // get_address_mode
#define R61529_RDPIXFMT 0x0C // get_pixel_format
#define R61529_RDIMGFMT 0x0D // get_display_mode
#define R61529_RDSIGMODE 0x0E // get_signal_mode
#define R61529_RDSELFDIAG 0x0F // get_diagnostic_result
#define R61529_SLPIN 0x10 // enter_sleep_mode
#define R61529_SLPOUT 0x11 // exit_sleep_mode
#define R61529_PTLON 0x12 // enter_partial_mode
#define R61529_NORON 0x13 // enter_normal_mode
#define R61529_INVOFF 0x20 // exit_invert_mode
#define R61529_INVON 0x21 // enter_invert_mode
#define R61529_DISPOFF 0x28 // set_display_off
#define R61529_DISPON 0x29 // set_display_on
#define R61529_CASET 0x2A // set_column_address
#define R61529_PASET 0x2B // set_page_address
#define R61529_RAMWR 0x2C // write_memory_start
#define R61529_RAMRD 0x2E // read_memory_start
#define R61529_PTLAR 0x30 // set_partial_area
#define R61529_TEAROFF 0x34 // set_tear_off
#define R61529_TEARON 0x35 // set_tear_on
#define R61529_MADCTL 0x36 // set_address_mode
#define R61529_IDLEOFF 0x38 // exit_idle_mode
#define R61529_IDLEON 0x39 // enter_idle_mode
#define R61529_PIXFMT 0x3A // set_pixel_format
#define R61529_WRMC 0x3C // write_memory_continue
#define R61529_RDMC 0x3E // read_memory_continue
#define R61529_SETTSL 0x44 // set_tear_scanline
#define R61529_GETSL 0x45 // get_scanline
#define R61529_RDDDBS 0xA1 // read_DDB_start
#define R61529_MCAP 0xB0 // Manufacturer Command Access Protect
#define R61529_LPMC 0xB1 // Low Power Mode Control
#define R61529_FMAIS 0xB3 // Frame Memory Access and Interface Setting
#define R61529_DISPMODE 0xB4 // Display Mode
#define R61529_RCEEC 0xB5 // Read Checksum and ECC Error Count
#define R61529_DSICTL 0xB6 // DSI Control
#define R61529_MDDICTL 0xB7 // MDDI Control
#define R61529_BLCTL1 0xB8 // Backlight Control (1)
#define R61529_BLCTL2 0xB9 // Backlight Control (2)
#define R61529_BLCTL3 0xBA // Backlight Control (3)
#define R61529_DCRD 0xBF // Device Code Read
#define R61529_PDS 0xC0 // Panel Driving Setting
#define R61529_DTSFNM 0xC1 // Display Timing Setting for Normal Mode
#define R61529_TESTMODE1 0xC3 // Test Mode 1
#define R61529_SGDTS 0xC4 // Source/Gate Driving Timing Setting
#define R61529_DPIPCTL 0xC6 // DPI Polarity Control
#define R61529_TESTMODE2 0xC7 // Test Mode 2
#define R61529_GAMMASETA 0xC8 // Gamma Setting A Set
#define R61529_GAMMASETB 0xC9 // Gamma Setting B Set
#define R61529_GAMMASETC 0xCA // Gamma Setting C Set
#define R61529_TESTMODE3 0xCC // Test Mode 3
#define R61529_PWSET 0xD0 // Power Setting (Charge Pump Setting)
#define R61529_VCOMSET 0xD1 // VCOM Setting
#define R61529_TESTMODE4 0xD6 // Test Mode 4
#define R61529_TESTMODE5 0xD7 // Test Mode 5
#define R61529_TESTMODE6 0xD8 // Test Mode 6
#define R61529_TESTMODE7 0xD9 // Test Mode 7
#define R61529_TESTMODE8 0xDA // Test Mode 8
#define R61529_NVMAC 0xE0 // NVM Access Control
#define R61529_SETDDBWRCTL 0xE1 // set_DDB_write_control
#define R61529_NVMLC 0xE2 // NVM Load Control
#define R61529_TESTMODE9 0xE4 // Test Mode 9
#define R61529_TESTMODE10 0xE5 // Test Mode 10
#define R61529_TESTMODE11 0xE6 // Test Mode 11
#define R61529_TESTMODE12 0xE7 // Test Mode 12
#define R61529_TESTMODE13 0xF3 // Test Mode 13
#define R61529_RDMODEIN 0xF5 // Read Mode In for DBI Only
#define R61529_RDMODEOUT 0xF6 // Read Mode Out for DBI Only
#define R61529_TESTMODE14 0xF8 // Test Mode 14
#define R61529_TESTMODE15 0xFA // Test Mode 15
#define R61529_TESTMODE16 0xFC // Test Mode 16
#define R61529_TESTMODE17 0xFD // Test Mode 17
#define R61529_TESTMODE18 0xFE // Test Mode 18
// parameters
#define R61529_MADCTL_MY 0x80 // Bottom to top
#define R61529_MADCTL_MX 0x40 // Right to left
#define R61529_MADCTL_MV 0x20 // Reverse Mode
#define R61529_MADCTL_ML 0x10 // LCD refresh Bottom to top
#define R61529_MADCTL_RGB 0x00 // Red-Green-Blue pixel order
#define R61529_MADCTL_BGR 0x08 // Blue-Green-Red pixel order
#define R61529_MADCTL_MH 0x04 // LCD refresh right to left
#define R61529_MADCTL_SS 0x02
#define R61529_MADCTL_GS 0x01
static const uint8_t r61529_init_operations[] = {
BEGIN_WRITE,
WRITE_COMMAND_8, R61529_SLPOUT,
END_WRITE,
DELAY, R61529_SLPOUT_DELAY,
BEGIN_WRITE,
WRITE_C8_D8, R61529_MCAP, 0x04,
WRITE_COMMAND_8, R61529_BLCTL1, // lcd pwm
WRITE_BYTES, 20,
0x02, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
WRITE_COMMAND_8, R61529_BLCTL2, // lcd pwm
WRITE_BYTES, 4,
0x01, // PWMON = 1;
0x00, // BDCV = 255;
0xff, // pwm freq = 13.7 kHz
0x18, // PWMWM = 1; LEDPWME = 1;
// additional commands:
WRITE_COMMAND_8, R61529_FMAIS, // Frame Memory Access and Interface Setting
WRITE_BYTES, 5,
0x02, // reset start position of a window area address...
0x00, // TE pin is used. TE signal is output every frame.
0x00, // empty according to the datasheet - does nothing;
0x00, // convert 16/18 bits to 24bits data by writing zeroes to LSBs. Sets image data write/read format(?)
0x00, // ???? (not needed?)
END_WRITE,
DELAY, 2,
BEGIN_WRITE,
WRITE_C8_D8, R61529_DISPMODE, 0x00, // Display Mode, Uses internal oscillator
WRITE_COMMAND_8, R61529_PDS, // Panel Driving Setting;
WRITE_BYTES, 8,
0x03, // Output polarity is inverted. Left/right interchanging scan. Forward scan. BGR mode (depends on other settings). S960 → S1 (depends)
0xDF, // Number of lines for driver to drive - 480.
0x40, // Scan start position - Gate1. (depend on other param);
0x10, // Dot inversion. Dot inversion in not-lit display area. If 0x13 - both will be set to 'column inversion'.
0x00, // settings for non-lit display area...
0x01, // 3 frame scan interval in non-display area...
0x00, // Source output level in retrace period...
0x55, // 54 . Internal clock divider = 5 (low and high periods).
WRITE_COMMAND_8, R61529_DTSFNM, // Display Timing Setting for Normal Mode
WRITE_BYTES, 5,
0x07, // Clock devider = 12. 14MHz/12. Used by display circuit and step-up circuit.
0x27, // These bits set the number of clocks in 1 line period. 0x27 - 39 clocks.
0x08, // Number of back porch lines. 0x08 - 8 lines.
0x08, // Number of front porch lines. 0x08 - 8lines.
0x00, // Spacial configuriation mode 1 (?). 1 line inversion mode (?).
WRITE_COMMAND_8, R61529_SGDTS, // Source/Gate Driving Timing Setting
WRITE_BYTES, 4,
0x57, // falling position (stop) of gate driver - 4 clocks... gate start position - 8 clocks...
0x00, // nothing to set up according to the datasheet
0x05, // Source precharge period (GND) - 5 clocks.
0x03, // source precharge period (VCI) - 3 clocks.
WRITE_C8_D8, R61529_DPIPCTL, 0x04, // DPI polarity control, VSYNC -Active Low. HSYNC - Active Low. DE pin enable data write in when DE=1. Reads data on the rising edge of the PCLK signal.
//----Gamma setting start-----
WRITE_COMMAND_8, R61529_GAMMASETA,
WRITE_BYTES, 24,
0x03, 0x12, 0x1A, 0x24,
0x32, 0x4B, 0x3B, 0x29,
0x1F, 0x18, 0x12, 0x04,
0x03, 0x12, 0x1A, 0x24,
0x32, 0x4B, 0x3B, 0x29,
0x1F, 0x18, 0x12, 0x04,
WRITE_COMMAND_8, R61529_GAMMASETB,
WRITE_BYTES, 24,
0x03, 0x12, 0x1A, 0x24,
0x32, 0x4B, 0x3B, 0x29,
0x1F, 0x18, 0x12, 0x04,
0x03, 0x12, 0x1A, 0x24,
0x32, 0x4B, 0x3B, 0x29,
0x1F, 0x18, 0x12, 0x04,
WRITE_COMMAND_8, R61529_GAMMASETC,
WRITE_BYTES, 24,
0x03, 0x12, 0x1A, 0x24,
0x32, 0x4B, 0x3B, 0x29,
0x1F, 0x18, 0x12, 0x04,
0x03, 0x12, 0x1A, 0x24,
0x32, 0x4B, 0x3B, 0x29,
0x1F, 0x18, 0x12, 0x04,
//---Gamma setting end--------
// old ones:
WRITE_COMMAND_8, R61529_PWSET,
WRITE_BYTES, 16,
0x99, // DC4~1//A5. Set up clock cycle of the internal step up controller.
0x06, // BT // Set Voltage step up factor.
0x08, // default according to the datasheet - does nothing.
0x20, // VCN step up cycles.
0x29, // VC1, VC2// VCI3 voltage = 2.70V; VCI2 voltage = 3.8V.
0x04, // default
0x01, // default
0x00, // default
0x08, // default
0x01, // default
0x00, // default
0x06, // default
0x01, // default
0x00, // default
0x00, // default
0x20, // default
WRITE_COMMAND_8, R61529_VCOMSET, // VCOM setting
WRITE_BYTES, 4,
0x00, // disable write to VDC[7:0]
0x20, // 45 38 VPLVL// voltage of γ correction registers for positive polarity
0x20, // 45 38 VNLVL// voltage of γ correction registers for negative polarity
0x15, // 32 2A VCOMDC// VNLVL x 0.063
WRITE_COMMAND_8, R61529_NVMAC, // NVM Access Control
WRITE_BYTES, 3,
0x00, // NVM access is disabled
0x00, // Erase operation (disabled).
0x00, // TE pin works as tearing effect pin.
// should be one more writeData(0x00}, according to the datasheet.
WRITE_COMMAND_8, R61529_SETDDBWRCTL, // set_DDB_write_control
WRITE_BYTES, 6,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00,
WRITE_C8_D8, R61529_NVMLC, 0x00, // NVM Load Control, does not execute data load from the NVM to each command
WRITE_C8_D8, 0x3A, 0x55, // set_pixel_format, 16-Bit/pixel = 55h, 24-bit/pixel = 77h
WRITE_COMMAND_8, R61529_DISPON,
END_WRITE,
DELAY, 20};
class Arduino_R61529 : public Arduino_TFT
{
public:
Arduino_R61529(Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0, bool ips = false);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void setRotation(uint8_t r) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
protected:
void tftInit() override;
private:
};
#endif

View File

@@ -0,0 +1,566 @@
#include "../Arduino_DataBus.h"
// #if defined(ESP32) && (CONFIG_IDF_TARGET_ESP32S3)
#if defined(ESP32) && (CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32P4) // Modify
#include "../Arduino_GFX.h"
#include "Arduino_RGB_Display.h"
Arduino_RGB_Display::Arduino_RGB_Display(
int16_t w, int16_t h, Arduino_ESP32RGBPanel *rgbpanel, uint8_t r, bool auto_flush,
Arduino_DataBus *bus, int8_t rst, const uint8_t *init_operations, size_t init_operations_len,
uint8_t col_offset1, uint8_t row_offset1, uint8_t col_offset2, uint8_t row_offset2)
: Arduino_GFX(w, h), _rgbpanel(rgbpanel), _auto_flush(auto_flush),
_bus(bus), _rst(rst), _init_operations(init_operations), _init_operations_len(init_operations_len),
COL_OFFSET1(col_offset1), ROW_OFFSET1(row_offset1),
COL_OFFSET2(col_offset2), ROW_OFFSET2(row_offset2)
{
_fb_width = COL_OFFSET1 + WIDTH + COL_OFFSET2;
_fb_height = ROW_OFFSET1 + HEIGHT + ROW_OFFSET2;
_fb_max_x = _fb_width - 1;
_fb_max_y = _fb_height - 1;
_framebuffer_size = _fb_width * _fb_height * 2;
MAX_X = WIDTH - 1;
MAX_Y = HEIGHT - 1;
setRotation(r);
}
bool Arduino_RGB_Display::begin(int32_t speed)
{
if (speed != GFX_SKIP_DATABUS_BEGIN)
{
if (_bus)
{
if (!_bus->begin())
{
return false;
}
}
}
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(120);
digitalWrite(_rst, HIGH);
delay(120);
}
else
{
if (_bus)
{
// Software Rest
_bus->sendCommand(0x01);
delay(120);
}
}
if (_bus)
{
if (_init_operations_len > 0)
{
_bus->batchOperation((uint8_t *)_init_operations, _init_operations_len);
}
}
_rgbpanel->begin(speed);
_framebuffer = _rgbpanel->getFrameBuffer(_fb_width, _fb_height);
if (!_framebuffer)
{
return false;
}
return true;
}
void Arduino_RGB_Display::writePixelPreclipped(int16_t x, int16_t y, uint16_t color)
{
int32_t y2 = y;
switch (_rotation)
{
case 1:
y2 = x;
x = WIDTH - 1 - y;
break;
case 2:
x = WIDTH - 1 - x;
y2 = HEIGHT - 1 - y;
break;
case 3:
y2 = HEIGHT - 1 - x;
x = y;
break;
}
x += COL_OFFSET1;
y2 += ROW_OFFSET1;
uint16_t *fb = _framebuffer + (y2 * _fb_width) + x;
*fb = color;
if (_auto_flush)
{
Cache_WriteBack_Addr((uint32_t)fb, 2);
}
}
void Arduino_RGB_Display::writeFastVLine(int16_t x, int16_t y,
int16_t h, uint16_t color)
{
// log_i("writeFastVLine(x: %d, y: %d, h: %d)", x, y, h);
switch (_rotation)
{
case 1:
writeFastHLineCore(_height - y - h, x, h, color);
break;
case 2:
writeFastVLineCore(_max_x - x, _height - y - h, h, color);
break;
case 3:
writeFastHLineCore(y, _max_x - x, h, color);
break;
default: // case 0:
writeFastVLineCore(x, y, h, color);
}
}
void Arduino_RGB_Display::writeFastVLineCore(int16_t x, int16_t y,
int16_t h, uint16_t color)
{
// log_i("writeFastVLineCore(x: %d, y: %d, h: %d)", x, y, h);
if (_ordered_in_range(x, 0, MAX_X) && h)
{ // X on screen, nonzero height
if (h < 0)
{ // If negative height...
y += h + 1; // Move Y to top edge
h = -h; // Use positive height
}
if (y <= MAX_Y)
{ // Not off bottom
int16_t y2 = y + h - 1;
if (y2 >= 0)
{ // Not off top
// Line partly or fully overlaps screen
if (y < 0)
{
y = 0;
h = y2 + 1;
} // Clip top
if (y2 > MAX_Y)
{
h = MAX_Y - y + 1;
} // Clip bottom
x += COL_OFFSET1;
y += ROW_OFFSET1;
uint16_t *fb = _framebuffer + ((int32_t)y * _fb_width) + x;
if (_auto_flush)
{
while (h--)
{
*fb = color;
Cache_WriteBack_Addr((uint32_t)fb, 2);
fb += _fb_width;
}
}
else
{
while (h--)
{
*fb = color;
fb += _fb_width;
}
}
}
}
}
}
void Arduino_RGB_Display::writeFastHLine(int16_t x, int16_t y,
int16_t w, uint16_t color)
{
// log_i("writeFastHLine(x: %d, y: %d, w: %d)", x, y, w);
switch (_rotation)
{
case 1:
writeFastVLineCore(_max_y - y, x, w, color);
break;
case 2:
writeFastHLineCore(_width - x - w, _max_y - y, w, color);
break;
case 3:
writeFastVLineCore(y, _width - x - w, w, color);
break;
default: // case 0:
writeFastHLineCore(x, y, w, color);
}
}
void Arduino_RGB_Display::writeFastHLineCore(int16_t x, int16_t y,
int16_t w, uint16_t color)
{
// log_i("writeFastHLineCore(x: %d, y: %d, w: %d)", x, y, w);
if (_ordered_in_range(y, 0, MAX_Y) && w)
{ // Y on screen, nonzero width
if (w < 0)
{ // If negative width...
x += w + 1; // Move X to left edge
w = -w; // Use positive width
}
if (x <= MAX_X)
{ // Not off right
int16_t x2 = x + w - 1;
if (x2 >= 0)
{ // Not off left
// Line partly or fully overlaps screen
if (x < 0)
{
x = 0;
w = x2 + 1;
} // Clip left
if (x2 > MAX_X)
{
w = MAX_X - x + 1;
} // Clip right
x += COL_OFFSET1;
y += ROW_OFFSET1;
uint16_t *fb = _framebuffer + ((int32_t)y * _fb_width) + x;
uint32_t cachePos = (uint32_t)fb;
int16_t writeSize = w * 2;
while (w--)
{
*(fb++) = color;
}
if (_auto_flush)
{
Cache_WriteBack_Addr(cachePos, writeSize);
}
}
}
}
}
void Arduino_RGB_Display::writeFillRectPreclipped(int16_t x, int16_t y,
int16_t w, int16_t h, uint16_t color)
{
// log_i("writeFillRectPreclipped(x: %d, y: %d, w: %d, h: %d)", x, y, w, h);
if (_rotation > 0)
{
int16_t t = x;
switch (_rotation)
{
case 1:
x = WIDTH - y - h;
y = t;
t = w;
w = h;
h = t;
break;
case 2:
x = WIDTH - x - w;
y = HEIGHT - y - h;
break;
case 3:
x = y;
y = HEIGHT - t - w;
t = w;
w = h;
h = t;
break;
}
}
// log_i("adjusted writeFillRectPreclipped(x: %d, y: %d, w: %d, h: %d)", x, y, w, h);
x += COL_OFFSET1;
y += ROW_OFFSET1;
uint16_t *row = _framebuffer;
row += y * _fb_width;
uint32_t cachePos = (uint32_t)row;
row += x;
for (int j = 0; j < h; j++)
{
for (int i = 0; i < w; i++)
{
row[i] = color;
}
row += _fb_width;
}
if (_auto_flush)
{
Cache_WriteBack_Addr(cachePos, _fb_width * h * 2);
}
}
void Arduino_RGB_Display::drawIndexedBitmap(int16_t x, int16_t y, uint8_t *bitmap, uint16_t *color_index, int16_t w, int16_t h, int16_t x_skip)
{
if (
((x + w - 1) < 0) || // Outside left
((y + h - 1) < 0) || // Outside top
(x > _max_x) || // Outside right
(y > _max_y) // Outside bottom
)
{
return;
}
else
{
if (_rotation > 0)
{
Arduino_GFX::drawIndexedBitmap(x, y, bitmap, color_index, w, h, x_skip);
}
else
{
if ((y + h - 1) > _max_y)
{
h -= (y + h - 1) - _max_y;
}
if (y < 0)
{
bitmap -= y * (w + x_skip);
h += y;
y = 0;
}
if ((x + w - 1) > _max_x)
{
x_skip += (x + w - 1) - _max_x;
w -= (x + w - 1) - _max_x;
}
if (x < 0)
{
bitmap -= x;
x_skip -= x;
w += x;
x = 0;
}
x += COL_OFFSET1;
y += ROW_OFFSET1;
uint16_t *row = _framebuffer;
row += y * _fb_width;
uint32_t cachePos = (uint32_t)row;
row += x;
for (int j = 0; j < h; j++)
{
for (int i = 0; i < w; i++)
{
row[i] = color_index[*bitmap++];
}
bitmap += x_skip;
row += _fb_width;
}
if (_auto_flush)
{
Cache_WriteBack_Addr(cachePos, _fb_width * h * 2);
}
}
}
}
void Arduino_RGB_Display::draw16bitRGBBitmap(int16_t x, int16_t y,
uint16_t *bitmap, int16_t w, int16_t h)
{
if (_isRoundMode)
{
if (
((y + h - 1) < 0) || // Outside top
(y > _max_y) || // Outside bottom
(
(x > _roundMaxX[y + h - 1]) && // top left
((x + w - 1) < _roundMinX[y]) && // top right
(x > _roundMaxX[y + h - 1]) && // bottom left
((x + w - 1) < _roundMinX[y + h - 1]) // bottom right
))
{
return;
}
}
bool result;
x += COL_OFFSET1;
y += ROW_OFFSET1;
switch (_rotation)
{
case 1:
result = gfx_draw_bitmap_to_framebuffer_rotate_1(bitmap, w, h, _framebuffer, x, y, _fb_height, _fb_width);
break;
case 2:
result = gfx_draw_bitmap_to_framebuffer_rotate_2(bitmap, w, h, _framebuffer, x, y, _fb_width, _fb_height);
break;
case 3:
result = gfx_draw_bitmap_to_framebuffer_rotate_3(bitmap, w, h, _framebuffer, x, y, _fb_height, _fb_width);
break;
default: // case 0:
result = gfx_draw_bitmap_to_framebuffer(bitmap, w, h, _framebuffer, x, y, _fb_width, _fb_height);
}
if (result)
{
if (_auto_flush)
{
uint32_t cachePos;
size_t cache_size;
switch (_rotation)
{
case 1:
cachePos = (uint32_t)(_framebuffer + (x * _fb_width));
cache_size = _fb_width * w * 2;
break;
case 2:
cachePos = (uint32_t)(_framebuffer + ((HEIGHT - y - h) * _fb_width));
cache_size = _fb_width * h * 2;
break;
case 3:
cachePos = (uint32_t)(_framebuffer + ((HEIGHT - x - w) * _fb_width));
cache_size = _fb_width * w * 2;
break;
default: // case 0:
cachePos = (uint32_t)(_framebuffer + (y * _fb_width) + x);
cache_size = (_fb_width * (h - 1) + w) * 2;
}
Cache_WriteBack_Addr(cachePos, cache_size);
}
}
}
void Arduino_RGB_Display::draw16bitBeRGBBitmap(int16_t x, int16_t y,
uint16_t *bitmap, int16_t w, int16_t h)
{
if (
((x + w - 1) < 0) || // Outside left
((y + h - 1) < 0) || // Outside top
(x > _max_x) || // Outside right
(y > _max_y) // Outside bottom
)
{
return;
}
else
{
if (_rotation > 0)
{
Arduino_GFX::draw16bitBeRGBBitmap(x, y, bitmap, w, h);
}
else
{
x += COL_OFFSET1;
y += ROW_OFFSET1;
int16_t x_skip = 0;
if ((y + h - 1) > _max_y)
{
h -= (y + h - 1) - _max_y;
}
if (y < 0)
{
bitmap -= y * w;
h += y;
y = 0;
}
if ((x + w - 1) > _max_x)
{
x_skip = (x + w - 1) - _max_x;
w -= x_skip;
}
if (x < 0)
{
bitmap -= x;
x_skip -= x;
w += x;
x = 0;
}
uint16_t *row = _framebuffer;
row += y * _fb_width;
uint32_t cachePos = (uint32_t)row;
row += x;
uint16_t color;
for (int j = 0; j < h; j++)
{
for (int i = 0; i < w; i++)
{
color = *bitmap++;
MSB_16_SET(row[i], color);
}
bitmap += x_skip;
row += _fb_width;
}
if (_auto_flush)
{
Cache_WriteBack_Addr(cachePos, _fb_width * h * 2);
}
}
}
}
void Arduino_RGB_Display::drawYCbCrBitmap(int16_t x, int16_t y, uint8_t *yData, uint8_t *cbData, uint8_t *crData, int16_t w, int16_t h)
{
if (
((x + w - 1) < 0) || // Outside left
((y + h - 1) < 0) || // Outside top
(x > _max_x) || // Outside right
(y > _max_y) // Outside bottom
)
{
return;
}
else
{
int rows = h >> 1;
uint16_t *dest = _framebuffer;
dest += y * _fb_width;
uint16_t *cachePos = dest;
dest += x;
uint16_t *dest2 = dest + _fb_width;
uint8_t *yData2 = yData + w;
uint8_t pxCb, pxCr;
int16_t pxR, pxG, pxB, pxY;
for (int row = 0; row < rows; ++row)
{
for (int col = 0; col < w;)
{
pxCb = *cbData++;
pxCr = *crData++;
pxR = CR2R16[pxCr];
pxG = -CB2G16[pxCb] - CR2G16[pxCr];
pxB = CB2B16[pxCb];
pxY = Y2I16[*yData++];
dest[col] = CLIPR[pxY + pxR] | CLIPG[pxY + pxG] | CLIPB[pxY + pxB];
pxY = Y2I16[*yData2++];
dest2[col++] = CLIPR[pxY + pxR] | CLIPG[pxY + pxG] | CLIPB[pxY + pxB];
pxY = Y2I16[*yData++];
dest[col] = CLIPR[pxY + pxR] | CLIPG[pxY + pxG] | CLIPB[pxY + pxB];
pxY = Y2I16[*yData2++];
dest2[col++] = CLIPR[pxY + pxR] | CLIPG[pxY + pxG] | CLIPB[pxY + pxB];
}
yData += w;
yData2 += w;
dest = dest2 + _fb_width;
dest2 = dest + _fb_width;
}
if (_auto_flush)
{
Cache_WriteBack_Addr((uint32_t)cachePos, _fb_width * h * 2);
}
}
}
void Arduino_RGB_Display::flush(bool force_flush)
{
if (force_flush || (!_auto_flush))
{
Cache_WriteBack_Addr((uint32_t)_framebuffer, _framebuffer_size);
}
}
uint16_t *Arduino_RGB_Display::getFramebuffer()
{
return _framebuffer;
}
#endif // #if defined(ESP32) && (CONFIG_IDF_TARGET_ESP32S3)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,105 @@
#include "Arduino_RM67162.h"
#include "SPI.h"
Arduino_RM67162::Arduino_RM67162(Arduino_DataBus *bus, int8_t rst, uint8_t r, bool ips)
: Arduino_TFT(bus, rst, r, ips, RM67162_TFTWIDTH, RM67162_TFTHEIGHT, 0, 0, 0, 0)
{
}
bool Arduino_RM67162::begin(int32_t speed)
{
return Arduino_TFT::begin(speed);
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_RM67162::setRotation(uint8_t r)
{
Arduino_TFT::setRotation(r);
switch (_rotation)
{
case 1:
r = RM67162_MADCTL_MX | RM67162_MADCTL_MV | RM67162_MADCTL_RGB;
break;
case 2:
r = RM67162_MADCTL_MX | RM67162_MADCTL_MY | RM67162_MADCTL_RGB;
break;
case 3:
r = RM67162_MADCTL_MV | RM67162_MADCTL_MY | RM67162_MADCTL_RGB;
break;
default: // case 0:
r = RM67162_MADCTL_RGB;
break;
}
_bus->beginWrite();
_bus->writeC8D8(RM67162_MADCTL, r);
_bus->endWrite();
}
void Arduino_RM67162::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
if ((x != _currentX) || (w != _currentW))
{
_currentX = x;
_currentW = w;
x += _xStart;
_bus->writeC8D16D16(RM67162_CASET, x, x + w - 1);
}
if ((y != _currentY) || (h != _currentH))
{
_currentY = y;
_currentH = h;
y += _yStart;
_bus->writeC8D16D16(RM67162_PASET, y, y + h - 1);
}
_bus->writeCommand(RM67162_RAMWR); // write to RAM
}
void Arduino_RM67162::invertDisplay(bool i)
{
_bus->sendCommand((_ips ^ i) ? RM67162_INVON : RM67162_INVOFF);
}
void Arduino_RM67162::displayOn(void)
{
_bus->sendCommand(RM67162_SLPOUT);
delay(RM67162_SLPOUT_DELAY);
}
void Arduino_RM67162::displayOff(void)
{
_bus->sendCommand(RM67162_SLPIN);
delay(RM67162_SLPIN_DELAY);
}
// Companion code to the above tables. Reads and issues
// a series of LCD commands stored in PROGMEM byte array.
void Arduino_RM67162::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(RM67162_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(RM67162_RST_DELAY);
}
else
{
// Software Rest
_bus->sendCommand(RM67162_SWRESET);
delay(RM67162_RST_DELAY);
}
_bus->batchOperation(rm67162_init_operations, sizeof(rm67162_init_operations));
invertDisplay(false);
}

View File

@@ -0,0 +1,74 @@
#pragma once
#include "../Arduino_GFX.h"
#include "../Arduino_TFT.h"
#define RM67162_TFTWIDTH 240 ///< RM67162 max TFT width
#define RM67162_TFTHEIGHT 536 ///< RM67162 max TFT height
#define RM67162_RST_DELAY 120 ///< delay ms wait for reset finish
#define RM67162_SLPIN_DELAY 120 ///< delay ms wait for sleep in finish
#define RM67162_SLPOUT_DELAY 120 ///< delay ms wait for sleep out finish
#define RM67162_SWRESET 0x01 ///< Software reset register
#define RM67162_SLPIN 0x10 ///< Enter Sleep Mode
#define RM67162_SLPOUT 0x11 ///< Sleep Out
#define RM67162_INVOFF 0x20 ///< Display Inversion OFF
#define RM67162_INVON 0x21 ///< Display Inversion ON
#define RM67162_DISPOFF 0x28 ///< Display OFF
#define RM67162_DISPON 0x29 ///< Display ON
#define RM67162_CASET 0x2A ///< Column Address Set
#define RM67162_PASET 0x2B ///< Page Address Set
#define RM67162_RAMWR 0x2C ///< Memory Write
#define RM67162_RAMRD 0x2E ///< Memory Read
#define RM67162_MADCTL 0x36
#define RM67162_PIXFMT 0x3A // Interface Pixel Format
#define RM67162_BRIGHTNESS 0x51 // Write Display Brightness
#define RM67162_MADCTL_MY 0x80
#define RM67162_MADCTL_MX 0x40
#define RM67162_MADCTL_MV 0x20
#define RM67162_MADCTL_ML 0x10
#define RM67162_MADCTL_RGB 0x00
#define RM67162_MADCTL_MH 0x04
#define RM67162_MADCTL_BGR 0x08
static const uint8_t rm67162_init_operations[] = {
BEGIN_WRITE,
WRITE_COMMAND_8, RM67162_SLPOUT, // Sleep Out
END_WRITE,
DELAY, RM67162_SLPOUT_DELAY,
BEGIN_WRITE,
WRITE_C8_D8, RM67162_PIXFMT, 0x55, // Interface Pixel Format 16bit/pixel
WRITE_COMMAND_8, RM67162_DISPON, // Display on
WRITE_C8_D8, RM67162_BRIGHTNESS, 0xBF, // Write Display Brightness MAX_VAL=0XFF
END_WRITE};
class Arduino_RM67162 : public Arduino_TFT
{
public:
Arduino_RM67162(Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0, bool ips = false);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void setRotation(uint8_t r) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h);
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
protected:
void tftInit() override;
private:
};

View File

@@ -0,0 +1,120 @@
#include "Arduino_RM690B0.h"
Arduino_RM690B0::Arduino_RM690B0(
Arduino_DataBus *bus, int8_t rst, uint8_t r, int16_t w, int16_t h,
uint8_t col_offset1, uint8_t row_offset1, uint8_t col_offset2, uint8_t row_offset2)
: Arduino_OLED(
bus, rst, r, w, h,
col_offset1, row_offset1, col_offset2, row_offset2)
{
}
bool Arduino_RM690B0::begin(int32_t speed)
{
return Arduino_TFT::begin(speed);
}
void Arduino_RM690B0::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
if ((x != _currentX) || (w != _currentW))
{
_currentX = x;
_currentW = w;
x += _xStart;
_bus->writeC8D16D16(RM690B0_CASET, x, x + w - 1);
}
if ((y != _currentY) || (h != _currentH))
{
_currentY = y;
_currentH = h;
y += _yStart;
_bus->writeC8D16D16(RM690B0_PASET, y, y + h - 1);
}
_bus->writeCommand(RM690B0_RAMWR); // write to RAM
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_RM690B0::setRotation(uint8_t r)
{
Arduino_TFT::setRotation(r);
switch (_rotation)
{
case 1:
r = RM690B0_MADCTL_MX | RM690B0_MADCTL_MV | RM690B0_MADCTL_RGB;
break;
case 2:
r = RM690B0_MADCTL_MX | RM690B0_MADCTL_MY | RM690B0_MADCTL_RGB;
break;
case 3:
r = RM690B0_MADCTL_MV | RM690B0_MADCTL_MY | RM690B0_MADCTL_RGB;
break;
default: // case 0:
r = RM690B0_MADCTL_RGB;
break;
}
_bus->beginWrite();
_bus->writeC8D8(RM690B0_MADCTL, r);
_bus->endWrite();
}
void Arduino_RM690B0::invertDisplay(bool i)
{
_bus->sendCommand((_ips ^ i) ? RM690B0_INVON : RM690B0_INVOFF);
}
void Arduino_RM690B0::displayOn(void)
{
_bus->sendCommand(RM690B0_SLPOUT);
delay(RM690B0_SLPOUT_DELAY);
}
void Arduino_RM690B0::displayOff(void)
{
_bus->sendCommand(RM690B0_SLPIN);
delay(RM690B0_SLPIN_DELAY);
}
void Arduino_RM690B0::setBrightness(uint8_t brightness)
{
_bus->beginWrite();
_bus->writeC8D8(RM690B0_BRIGHTNESS, brightness);
_bus->endWrite();
}
void Arduino_RM690B0::setContrast(uint8_t contrast)
{
// not implemented.
}
// Companion code to the above tables. Reads and issues
// a series of LCD commands stored in PROGMEM byte array.
void Arduino_RM690B0::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(RM690B0_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(RM690B0_RST_DELAY);
}
else
{
// Software Rest
_bus->sendCommand(RM690B0_SWRESET);
delay(RM690B0_RST_DELAY);
}
_bus->batchOperation(rm690b0_init_operations, sizeof(rm690b0_init_operations));
invertDisplay(false);
}

View File

@@ -0,0 +1,91 @@
#pragma once
#include "../Arduino_GFX.h"
#include "../Arduino_TFT.h"
#include "../Arduino_OLED.h"
#define RM690B0_TFTWIDTH 482 ///< RM690B0 max TFT width
#define RM690B0_TFTHEIGHT 600 ///< RM690B0 max TFT height
#define RM690B0_RST_DELAY 120 ///< delay ms wait for reset finish
#define RM690B0_SLPIN_DELAY 120 ///< delay ms wait for sleep in finish
#define RM690B0_SLPOUT_DELAY 120 ///< delay ms wait for sleep out finish
#define RM690B0_SWRESET 0x01 ///< Software reset register
#define RM690B0_SLPIN 0x10 ///< Enter Sleep Mode
#define RM690B0_SLPOUT 0x11 ///< Sleep Out
#define RM690B0_INVOFF 0x20 ///< Display Inversion OFF
#define RM690B0_INVON 0x21 ///< Display Inversion ON
#define RM690B0_DISPOFF 0x28 ///< Display OFF
#define RM690B0_DISPON 0x29 ///< Display ON
#define RM690B0_CASET 0x2A ///< Column Address Set
#define RM690B0_PASET 0x2B ///< Page Address Set
#define RM690B0_RAMWR 0x2C ///< Memory Write
#define RM690B0_RAMRD 0x2E ///< Memory Read
#define RM690B0_MADCTL 0x36
#define RM690B0_PIXFMT 0x3A // Interface Pixel Format
#define RM690B0_BRIGHTNESS 0x51 // Write Display Brightness
#define RM690B0_MADCTL_MY 0x80
#define RM690B0_MADCTL_MX 0x40
#define RM690B0_MADCTL_MV 0x20
#define RM690B0_MADCTL_ML 0x10
#define RM690B0_MADCTL_RGB 0x00
#define RM690B0_MADCTL_MH 0x04
#define RM690B0_MADCTL_BGR 0x08
static const uint8_t rm690b0_init_operations[] = {
BEGIN_WRITE,
WRITE_C8_D8, 0xFE, 0x20, // SET PAGE
WRITE_C8_D8, 0x26, 0x0A, // MIPI OFF
WRITE_C8_D8, 0x24, 0x80, // SPI write RAM
WRITE_C8_D8, 0x5A, 0x51, //! 230918:SWIRE FOR BV6804
WRITE_C8_D8, 0x5B, 0x2E, //! 230918:SWIRE FOR BV6804
WRITE_C8_D8, 0xFE, 0x00, // SET PAGE
WRITE_C8_D8, RM690B0_PIXFMT, 0x55, // Interface Pixel Format 16bit/pixel
WRITE_COMMAND_8, 0xC2, // delay_ms(10);
END_WRITE,
DELAY, 10, // delay_ms(10);
BEGIN_WRITE,
WRITE_C8_D8, 0x35, 0x00, // TE ON
WRITE_C8_D8, RM690B0_BRIGHTNESS, 0x00, // Write Display Brightness MAX_VAL=0XFF
WRITE_COMMAND_8, RM690B0_SLPOUT, // Sleep Out
END_WRITE,
DELAY, RM690B0_SLPOUT_DELAY,
BEGIN_WRITE,
WRITE_COMMAND_8, RM690B0_DISPON, // Display on delay_ms(10);
END_WRITE,
DELAY, 10,
BEGIN_WRITE,
WRITE_C8_D8, RM690B0_BRIGHTNESS, 0xD0, // Write Display Brightness MAX_VAL=0XFF
END_WRITE};
class Arduino_RM690B0 : public Arduino_OLED
{
public:
Arduino_RM690B0(
Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0,
int16_t w = RM690B0_TFTWIDTH, int16_t h = RM690B0_TFTHEIGHT,
uint8_t col_offset1 = 0, uint8_t row_offset1 = 0, uint8_t col_offset2 = 0, uint8_t row_offset2 = 0);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void setRotation(uint8_t r) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
void setBrightness(uint8_t brightness) override;
void setContrast(uint8_t contrast) override;
protected:
void tftInit() override;
private:
};

View File

@@ -0,0 +1,217 @@
/*
* start rewrite from:
* https://github.com/adafruit/Adafruit-GFX-Library.git
*/
#include "Arduino_SEPS525.h"
#include "SPI.h"
Arduino_SEPS525::Arduino_SEPS525(
Arduino_DataBus *bus, int8_t rst, uint8_t r, int16_t w, int16_t h,
uint8_t col_offset1, uint8_t row_offset1, uint8_t col_offset2, uint8_t row_offset2)
: Arduino_TFT(bus, rst, r, false, w, h, col_offset1, row_offset1, col_offset2, row_offset2)
{
}
bool Arduino_SEPS525::begin(int32_t speed)
{
return Arduino_TFT::begin(speed);
}
// Companion code to the above tables. Reads and issues
// a series of LCD commands stored in PROGMEM byte array.
void Arduino_SEPS525::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(SEPS525_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(SEPS525_RST_DELAY);
}
else
{
// Software Rest
_bus->sendCommand(SEPS525_SOFT_RST);
_bus->sendData(0x01);
delay(SEPS525_RST_DELAY);
}
_bus->sendCommand(SEPS525_REDUCE_CURRENT);
_bus->sendData(0x01);
delay(1);
// normal mode
_bus->sendCommand(SEPS525_REDUCE_CURRENT);
_bus->sendData(0x00);
delay(1);
// display off
_bus->sendCommand(SEPS525_DISP_ON_OFF);
_bus->sendData(0x00);
// turn on internal oscillator using external resistor
_bus->sendCommand(SEPS525_OSC_CTL);
_bus->sendData(0x01);
// 90 hz frame rate, divider 0
_bus->sendCommand(SEPS525_CLOCK_DIV);
_bus->sendData(0x30);
// duty cycle 127
_bus->sendCommand(0x28);
_bus->sendData(0x7f);
// start on line 0
_bus->sendCommand(0x29);
_bus->sendData(0x00);
// rgb_if
_bus->sendCommand(SEPS525_RGB_IF);
_bus->sendData(0x31);
// driving current r g b (uA)
_bus->sendCommand(SEPS525_DRIVING_CURRENT_R);
_bus->sendData(0x45);
_bus->sendCommand(SEPS525_DRIVING_CURRENT_G);
_bus->sendData(0x34);
_bus->sendCommand(SEPS525_DRIVING_CURRENT_B);
_bus->sendData(0x33);
// precharge time r g b
_bus->sendCommand(SEPS525_PRECHARGE_TIME_R);
_bus->sendData(0x04);
_bus->sendCommand(SEPS525_PRECHARGE_TIME_G);
_bus->sendData(0x05);
_bus->sendCommand(SEPS525_PRECHARGE_TIME_B);
_bus->sendData(0x05);
// precharge current r g b (uA)
_bus->sendCommand(SEPS525_PRECHARGE_CURRENT_R);
_bus->sendData(0x9d);
_bus->sendCommand(SEPS525_PRECHARGE_CURRENT_G);
_bus->sendData(0x8c);
_bus->sendCommand(SEPS525_PRECHARGE_CURRENT_B);
_bus->sendData(0x57);
_bus->sendCommand(SEPS525_IREF);
_bus->sendData(0x00);
// display on
_bus->sendCommand(SEPS525_DISP_ON_OFF);
_bus->sendData(0x01);
}
void Arduino_SEPS525::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
uint8_t cmd1, cmd2, cmd3;
if ((x != _currentX) || (w != _currentW))
{
int16_t x_start = x + _xStart, x_end = x + w - 1 + _xStart;
if (_rotation & 0x01) // Portrait
{
cmd1 = SEPS525_MY1_ADDR;
cmd2 = SEPS525_M_AP_Y;
cmd3 = SEPS525_MY2_ADDR;
}
else
{
cmd1 = SEPS525_MX1_ADDR;
cmd2 = SEPS525_M_AP_X;
cmd3 = SEPS525_MX2_ADDR;
}
_bus->writeCommand(cmd1);
_bus->write16(x_start);
_bus->writeCommand(cmd2);
_bus->write16(x_start);
_bus->writeCommand(cmd3);
_bus->write16(x_end);
_currentX = x;
_currentW = w;
}
if ((y != _currentY) || (h != _currentH))
{
int16_t y_start = y + _yStart, y_end = y + h - 1 + _yStart;
if (_rotation & 0x01) // Portrait
{
cmd1 = SEPS525_MX1_ADDR;
cmd2 = SEPS525_M_AP_X;
cmd3 = SEPS525_MX2_ADDR;
}
else
{
cmd1 = SEPS525_MY1_ADDR;
cmd2 = SEPS525_M_AP_Y;
cmd3 = SEPS525_MY2_ADDR;
}
_bus->writeCommand(cmd1);
_bus->write16(y_start);
_bus->writeCommand(cmd2);
_bus->write16(y_start);
_bus->writeCommand(cmd3);
_bus->write16(y_end);
_currentY = y;
_currentH = h;
}
_bus->writeCommand(SEPS525_RAMWR); // write to RAM
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_SEPS525::setRotation(uint8_t r)
{
Arduino_TFT::setRotation(r);
switch (_rotation)
{
case 1:
_bus->sendCommand(SEPS525_DISPLAY_MODE_SET);
_bus->sendData(0x10);
_bus->sendCommand(SEPS525_MEMORY_WRITE_MODE);
_bus->sendData(0x67);
break;
case 2:
_bus->sendCommand(SEPS525_DISPLAY_MODE_SET);
_bus->sendData(0x30);
_bus->sendCommand(SEPS525_MEMORY_WRITE_MODE);
_bus->sendData(0x66);
break;
case 3:
_bus->sendCommand(SEPS525_DISPLAY_MODE_SET);
_bus->sendData(0x20);
_bus->sendCommand(SEPS525_MEMORY_WRITE_MODE);
_bus->sendData(0x67);
break;
default: // case 0:
_bus->sendCommand(SEPS525_DISPLAY_MODE_SET);
_bus->sendData(0x00);
_bus->sendCommand(SEPS525_MEMORY_WRITE_MODE);
_bus->sendData(0x66);
break;
}
}
void Arduino_SEPS525::invertDisplay(bool)
{
// Not Implemented
}
void Arduino_SEPS525::displayOn(void)
{
_bus->sendCommand(SEPS525_DISP_ON_OFF);
_bus->sendData(0x01);
}
void Arduino_SEPS525::displayOff(void)
{
_bus->sendCommand(SEPS525_DISP_ON_OFF);
_bus->sendData(0x00);
}

View File

@@ -0,0 +1,66 @@
/*
* start rewrite from:
* https://github.com/adafruit/Adafruit-GFX-Library.git
*/
#ifndef _ARDUINO_SEPS525_H_
#define _ARDUINO_SEPS525_H_
#include "../Arduino_GFX.h"
#include "../Arduino_TFT.h"
#define SEPS525_TFTWIDTH 160 ///< SEPS525 max TFT width
#define SEPS525_TFTHEIGHT 128 ///< SEPS525 max TFT height
#define SEPS525_RST_DELAY 1
#define SEPS525_INDEX 0x00
#define SEPS525_STATUS_RD 0x01
#define SEPS525_OSC_CTL 0x02
#define SEPS525_IREF 0x80
#define SEPS525_CLOCK_DIV 0x03
#define SEPS525_REDUCE_CURRENT 0x04
#define SEPS525_SOFT_RST 0x05
#define SEPS525_DISP_ON_OFF 0x06
#define SEPS525_PRECHARGE_TIME_R 0x08
#define SEPS525_PRECHARGE_TIME_G 0x09
#define SEPS525_PRECHARGE_TIME_B 0x0A
#define SEPS525_PRECHARGE_CURRENT_R 0x0B
#define SEPS525_PRECHARGE_CURRENT_G 0x0C
#define SEPS525_PRECHARGE_CURRENT_B 0x0D
#define SEPS525_DRIVING_CURRENT_R 0x10
#define SEPS525_DRIVING_CURRENT_G 0x11
#define SEPS525_DRIVING_CURRENT_B 0x12
#define SEPS525_DISPLAY_MODE_SET 0x13
#define SEPS525_RGB_IF 0x14
#define SEPS525_RGB_POL 0x15
#define SEPS525_MEMORY_WRITE_MODE 0x16
#define SEPS525_MX1_ADDR 0x17
#define SEPS525_MX2_ADDR 0x18
#define SEPS525_MY1_ADDR 0x19
#define SEPS525_MY2_ADDR 0x1a
#define SEPS525_M_AP_X 0x20
#define SEPS525_M_AP_Y 0x21
#define SEPS525_RAMWR 0x22
class Arduino_SEPS525 : public Arduino_TFT
{
public:
Arduino_SEPS525(
Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0,
int16_t w = SEPS525_TFTWIDTH, int16_t h = SEPS525_TFTHEIGHT,
uint8_t col_offset1 = 0, uint8_t row_offset1 = 0, uint8_t col_offset2 = 0, uint8_t row_offset2 = 0);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void setRotation(uint8_t r) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
protected:
void tftInit() override;
private:
};
#endif

View File

@@ -0,0 +1,131 @@
#include "Arduino_SH1106.h"
Arduino_SH1106::Arduino_SH1106(Arduino_DataBus *bus, int8_t rst, int16_t w, int16_t h)
: Arduino_G(w, h), _bus(bus), _rst(rst)
{
_rotation = 0;
_pages = (h + 7) / 8;
}
bool Arduino_SH1106::begin(int32_t speed)
{
if (speed != GFX_SKIP_DATABUS_BEGIN)
{
if (!_bus->begin(speed))
{
return false;
}
}
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(20);
digitalWrite(_rst, LOW);
delay(20);
digitalWrite(_rst, HIGH);
delay(20);
}
static const uint8_t init_sequence[] = {
BEGIN_WRITE,
WRITE_COMMAND_BYTES, 25,
SH110X_DISPLAYOFF, // 0xAE
SH110X_SETDISPLAYCLOCKDIV, 0x80, // 0xD5, 0x80
SH110X_SETMULTIPLEX, 0x3F, // 0xA8, 0x3F
SH110X_SETDISPLAYOFFSET, 0x00, // 0xD3, 0x00
SH110X_SETSTARTLINE, // 0x40
SH110X_SETDCDCMODE, 0x8B, // 0xAD, DC/DC on
SH110X_SEGREMAP + 1, // 0xA1
SH110X_COMSCANDEC, // 0xC8
SH110X_SETCOMPINS, 0x12, // 0xDA, 0x12
SH110X_SETCONTRAST, _contrast, // 0x81, contrast
SH110X_SETPRECHARGE, 0x1F, // 0xD9, 0x1F
SH110X_SETVCOMDETECT, 0x40, // 0xDB, 0x40
0x33, // Set VPP to 9V
SH110X_NORMALDISPLAY, // 0xA6
SH110X_MEMORYMODE, 0x10, // 0x20, 0x10
SH110X_DISPLAYALLON_RESUME, // 0xA4
END_WRITE,
DELAY, 100,
BEGIN_WRITE,
WRITE_COMMAND_8, SH110X_DISPLAYON, // 0xAF
END_WRITE};
_bus->batchOperation(init_sequence, sizeof(init_sequence));
return true;
}
void Arduino_SH1106::setBrightness(uint8_t brightness)
{
_bus->beginWrite();
_bus->writeC8D8(SH110X_SETCONTRAST, brightness);
_bus->endWrite();
} // setBrightness()
void Arduino_SH1106::drawBitmap(int16_t x, int16_t y, uint8_t *bitmap, int16_t w, int16_t h, uint16_t /* color */, uint16_t /* bg */)
{
// printf("SH1106::drawBitmap %d/%d w:%d h:%d\n", x, y, w, h);
// transfer the whole bitmap
for (uint8_t p = (y / 8); p < (h / 8); p++)
{
uint8_t *pptr = bitmap + (p * w); // page start pointer
// start page sequence
_bus->beginWrite();
// _bus->writeCommand(SH110X_SETPAGEADDR + p);
// _bus->write(); // set column
// _bus->write(SH110X_SETHIGHCOLUMN + 0);
uint8_t page_sequence[] = {
(uint8_t)(SH110X_SETPAGEADDR + p),
SH110X_SETLOWCOLUMN + 2,
SH110X_SETHIGHCOLUMN + 0};
_bus->writeCommandBytes(page_sequence, sizeof(page_sequence));
_bus->endWrite();
_bus->beginWrite();
_bus->writeBytes(pptr, w);
_bus->endWrite();
}
} // drawBitmap()
void Arduino_SH1106::drawIndexedBitmap(int16_t, int16_t, uint8_t *, uint16_t *, int16_t, int16_t, int16_t)
{
// println("SH1106::Not Implemented drawIndexedBitmap()");
}
void Arduino_SH1106::draw3bitRGBBitmap(int16_t, int16_t, uint8_t *, int16_t, int16_t)
{
// println("SH1106::Not Implemented draw3bitRGBBitmap()");
}
void Arduino_SH1106::draw16bitRGBBitmap(int16_t, int16_t, uint16_t *, int16_t, int16_t)
{
// println("SH1106::Not Implemented draw16bitRGBBitmap()");
}
void Arduino_SH1106::draw24bitRGBBitmap(int16_t, int16_t, uint8_t *, int16_t, int16_t)
{
// println("SH1106::Not Implemented draw24bitRGBBitmap()");
}
void Arduino_SH1106::invertDisplay(bool)
{
// println("SH1106::Not Implemented invertDisplay()");
}
void Arduino_SH1106::displayOn(void)
{
_bus->sendCommand(SH110X_DISPLAYON);
}
void Arduino_SH1106::displayOff(void)
{
_bus->sendCommand(SH110X_DISPLAYOFF);
}

View File

@@ -0,0 +1,80 @@
#pragma once
#include "../Arduino_GFX.h"
#include "../databus/Arduino_Wire.h"
/** SH1106 commands, See Datasheet:
* https://cdn.velleman.eu/downloads/29/infosheets/sh1106_datasheet.pdf
**/
#define SH110X_SETLOWCOLUMN 0x00
#define SH110X_SETHIGHCOLUMN 0x10
#define SH110X_MEMORYMODE 0x20
#define SH110X_COLUMNADDR 0x21
#define SH110X_PAGEADDR 0x22
#define SH110X_SETPUMPV 0x30
#define SH110X_SETSTARTLINE 0x40
#define SH110X_SETCONTRAST 0x81
#define SH110X_CHARGEPUMP 0x8D
#define SH110X_SEGREMAP 0xA0
#define SH110X_DISPLAYALLON_RESUME 0xA4
#define SH110X_DISPLAYALLON 0xA5
#define SH110X_NORMALDISPLAY 0xA6
#define SH110X_INVERTDISPLAY 0xA7
#define SH110X_SETMULTIPLEX 0xA8
#define SH110X_SETDCDCMODE 0xAD
#define SH110X_DISPLAYOFF 0xAE
#define SH110X_DISPLAYON 0xAF
#define SH110X_SETPAGEADDR 0xB0
#define SH110X_COMSCANINC 0xC0
#define SH110X_COMSCANDEC 0xC8
#define SH110X_SETDISPLAYOFFSET 0xD3
#define SH110X_SETDISPLAYCLOCKDIV 0xD5
#define SH110X_SETPRECHARGE 0xD9
#define SH110X_SETCOMPINS 0xDA
#define SH110X_SETVCOMDETECT 0xDB
#define SH110X_SETDISPSTARTLINE 0xDC
#define SH110X_READMODIFYWRITE 0xE0
#define SH110X_READMODIFYWRITEEND 0xEE
#define SH110X_NOP 0xE3
class Arduino_SH1106 : public Arduino_G
{
public:
Arduino_SH1106(Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, int16_t w = 128, int16_t h = 64);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void drawBitmap(int16_t x, int16_t y, uint8_t *bitmap, int16_t w, int16_t h, uint16_t color, uint16_t bg) override;
void drawIndexedBitmap(int16_t x, int16_t y, uint8_t *bitmap, uint16_t *color_index, int16_t w, int16_t h, int16_t x_skip = 0) override;
void draw3bitRGBBitmap(int16_t x, int16_t y, uint8_t *bitmap, int16_t w, int16_t h) override;
void draw16bitRGBBitmap(int16_t x, int16_t y, uint16_t *bitmap, int16_t w, int16_t h) override;
void draw24bitRGBBitmap(int16_t x, int16_t y, uint8_t *bitmap, int16_t w, int16_t h) override;
void invertDisplay(bool);
void displayOn();
void displayOff();
void setBrightness(uint8_t brightness);
protected:
Arduino_DataBus *_bus;
int8_t _rst;
int8_t _pages;
uint8_t _rotation;
uint8_t _contrast = 0x8F;
private:
};

View File

@@ -0,0 +1,162 @@
#include "Arduino_SH8601.h"
Arduino_SH8601::Arduino_SH8601(
Arduino_DataBus *bus, int8_t rst, uint8_t r, int16_t w, int16_t h,
uint8_t col_offset1, uint8_t row_offset1, uint8_t col_offset2, uint8_t row_offset2)
: Arduino_OLED(
bus, rst, r, w, h,
col_offset1, row_offset1, col_offset2, row_offset2)
{
}
bool Arduino_SH8601::begin(int32_t speed)
{
return Arduino_TFT::begin(speed);
}
void Arduino_SH8601::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
if ((x != _currentX) || (w != _currentW))
{
_currentX = x;
_currentW = w;
x += _xStart;
_bus->writeC8D16D16(SH8601_W_CASET, x, x + w - 1);
}
if ((y != _currentY) || (h != _currentH))
{
_currentY = y;
_currentH = h;
y += _yStart;
_bus->writeC8D16D16(SH8601_W_PASET, y, y + h - 1);
}
_bus->writeCommand(SH8601_W_RAMWR); // write to RAM
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_SH8601::setRotation(uint8_t r)
{
// SH8601 does not support rotation
Arduino_TFT::setRotation(r);
switch (_rotation)
{
case 1:
r = SH8601_MADCTL_COLOR_ORDER;
break;
case 2:
r = SH8601_MADCTL_COLOR_ORDER | SH8601_MADCTL_Y_AXIS_FLIP | SH8601_MADCTL_X_AXIS_FLIP;
break;
case 3:
r = SH8601_MADCTL_COLOR_ORDER;
break;
case 4:
r = SH8601_MADCTL_COLOR_ORDER | SH8601_MADCTL_X_AXIS_FLIP;
break;
case 5:
r = SH8601_MADCTL_COLOR_ORDER;
break;
case 6:
r = SH8601_MADCTL_COLOR_ORDER | SH8601_MADCTL_Y_AXIS_FLIP;
break;
case 7:
r = SH8601_MADCTL_COLOR_ORDER;
break;
default: // case 0:
r = SH8601_MADCTL_COLOR_ORDER;
break;
}
_bus->beginWrite();
_bus->writeC8D8(SH8601_W_MADCTL, r);
_bus->endWrite();
}
void Arduino_SH8601::invertDisplay(bool i)
{
_bus->sendCommand((_ips ^ i) ? SH8601_C_INVON : SH8601_C_INVOFF);
}
void Arduino_SH8601::displayOn(void)
{
_bus->sendCommand(SH8601_C_DISPON);
delay(SH8601_SLPIN_DELAY);
_bus->sendCommand(SH8601_C_SLPOUT);
// _bus->writeC8D8(SH8601_W_DEEPSTMODE, 0x00);
delay(SH8601_SLPOUT_DELAY);
}
void Arduino_SH8601::displayOff(void)
{
_bus->sendCommand(SH8601_C_DISPOFF);
delay(SH8601_SLPIN_DELAY);
_bus->sendCommand(SH8601_C_SLPIN);
// _bus->writeC8D8(SH8601_W_DEEPSTMODE, 0x01);
delay(SH8601_SLPIN_DELAY);
}
void Arduino_SH8601::setBrightness(uint8_t brightness)
{
_bus->beginWrite();
_bus->writeC8D8(SH8601_W_WDBRIGHTNESSVALNOR, brightness);
_bus->endWrite();
}
void Arduino_SH8601::setContrast(uint8_t contrast)
{
switch (contrast)
{
case SH8601_ContrastOff:
_bus->beginWrite();
_bus->writeC8D8(SH8601_W_WCE, 0x00);
_bus->endWrite();
break;
case SH8601_LowContrast:
_bus->beginWrite();
_bus->writeC8D8(SH8601_W_WCE, 0x05);
_bus->endWrite();
break;
case SH8601_MediumContrast:
_bus->beginWrite();
_bus->writeC8D8(SH8601_W_WCE, 0x06);
_bus->endWrite();
break;
case SH8601_HighContrast:
_bus->beginWrite();
_bus->writeC8D8(SH8601_W_WCE, 0x07);
_bus->endWrite();
break;
default:
break;
}
}
void Arduino_SH8601::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(10);
digitalWrite(_rst, LOW);
delay(SH8601_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(SH8601_RST_DELAY);
}
else
{
// Software Rest
_bus->sendCommand(SH8601_C_SWRESET);
delay(SH8601_RST_DELAY);
}
_bus->batchOperation(sh8601_init_operations, sizeof(sh8601_init_operations));
invertDisplay(false);
}

View File

@@ -0,0 +1,189 @@
#pragma once
#include "../Arduino_GFX.h"
#include "../Arduino_TFT.h"
#include "../Arduino_OLED.h"
#define SH8601_TFTWIDTH 480 ///< SH8601 max TFT width
#define SH8601_TFTHEIGHT 480 ///< SH8601 max TFT height
#define SH8601_RST_DELAY 200 ///< delay ms wait for reset finish
#define SH8601_SLPIN_DELAY 120 ///< delay ms wait for sleep in finish
#define SH8601_SLPOUT_DELAY 120 ///< delay ms wait for sleep out finish
// User Command
#define SH8601_C_NOP 0x00 // nop
#define SH8601_C_SWRESET 0x01 // Software Reset
#define SH8601_R_RDID 0x04 // Read Display Identification Information ID/1/2/3
#define SH8601_R_RDNERRORSDSI 0x05 // Read Number of Errors on DSI
#define SH8601_R_RDPOWERMODE 0x0A // Read Display Power Mode
#define SH8601_R_RDMADCTL 0x0B // Read Display MADCTL
#define SH8601_R_RDPIXFMT 0x0C // Read Display Pixel Format
#define SH8601_R_RDIMGFMT 0x0D // Read Display Image Mode
#define SH8601_R_RDSIGMODE 0x0E // Read Display Signal Mode
#define SH8601_R_RDSELFDIAG 0x0F // Read Display Self-Diagnostic Result
#define SH8601_C_SLPIN 0x10 // Sleep In
#define SH8601_C_SLPOUT 0x11 // Sleep Out
#define SH8601_C_PTLON 0x12 // Partial Display On
#define SH8601_C_NORON 0x13 // Normal Display mode on
#define SH8601_C_INVOFF 0x20 // Inversion Off
#define SH8601_C_INVON 0x21 // Inversion On
#define SH8601_C_ALLPOFF 0x22 // All pixels off
#define SH8601_C_ALLPON 0x23 // All pixels on
#define SH8601_C_DISPOFF 0x28 // Display off
#define SH8601_C_DISPON 0x29 // Display on
#define SH8601_W_CASET 0x2A // Column Address Set
#define SH8601_W_PASET 0x2B // Page Address Set
#define SH8601_W_RAMWR 0x2C // Memory Write Start
#define SH8601_W_PTLAR 0x30 // Partial Area Row Set
#define SH8601_W_PTLAC 0x31 // Partial Area Column Set
#define SH8601_C_TEAROFF 0x34 // Tearing effect off
#define SH8601_WC_TEARON 0x35 // Tearing effect on
#define SH8601_W_MADCTL 0x36 // Memory data access control
#define SH8601_C_IDLEOFF 0x38 // Idle Mode Off
#define SH8601_C_IDLEON 0x39 // Idle Mode On
#define SH8601_W_PIXFMT 0x3A // Write Display Pixel Format
#define SH8601_W_WRMC 0x3C // Memory Write Continue
#define SH8601_W_SETTSL 0x44 // Write Tearing Effect Scan Line
#define SH8601_R_GETSL 0x45 // Read Scan Line Number
#define SH8601_C_SPIROFF 0x46 // SPI read Off
#define SH8601_C_SPIRON 0x47 // SPI read On
#define SH8601_C_AODMOFF 0x48 // AOD Mode Off
#define SH8601_C_AODMON 0x49 // AOD Mode On
#define SH8601_W_WDBRIGHTNESSVALAOD 0x4A // Write Display Brightness Value in AOD Mode
#define SH8601_R_RDBRIGHTNESSVALAOD 0x4B // Read Display Brightness Value in AOD Mode
#define SH8601_W_DEEPSTMODE 0x4F // Deep Standby Mode On
#define SH8601_W_WDBRIGHTNESSVALNOR 0x51 // Write Display Brightness Value in Normal Mode
#define SH8601_R_RDBRIGHTNESSVALNOR 0x52 // Read display brightness value in Normal Mode
#define SH8601_W_WCTRLD1 0x53 // Write CTRL Display1
#define SH8601_R_RCTRLD1 0x54 // Read CTRL Display1
#define SH8601_W_WCTRLD2 0x55 // Write CTRL Display2
#define SH8601_R_RCTRLD2 0x56 // Read CTRL Display2
#define SH8601_W_WCE 0x58 // Write CE
#define SH8601_R_RCE 0x59 // Read CE
#define SH8601_W_WDBRIGHTNESSVALHBM 0x63 // Write Display Brightness Value in HBM Mode
#define SH8601_R_WDBRIGHTNESSVALHBM 0x64 // Read Display Brightness Value in HBM Mode
#define SH8601_W_WHBMCTL 0x66 // Write HBM Control
#define SH8601_W_COLORSET0 0x70 // Color Set 0
#define SH8601_W_COLORSET1 0x71 // Color Set 1
#define SH8601_W_COLORSET2 0x72 // Color Set 2
#define SH8601_W_COLORSET3 0x73 // Color Set 3
#define SH8601_W_COLORSET4 0x74 // Color Set 4
#define SH8601_W_COLORSET5 0x75 // Color Set 5
#define SH8601_W_COLORSET6 0x76 // Color Set 6
#define SH8601_W_COLORSET7 0x77 // Color Set 7
#define SH8601_W_COLORSET8 0x78 // Color Set 8
#define SH8601_W_COLORSET9 0x79 // Color Set 9
#define SH8601_W_COLORSET10 0x7A // Color Set 10
#define SH8601_W_COLORSET11 0x7B // Color Set 11
#define SH8601_W_COLORSET12 0x7C // Color Set 12
#define SH8601_W_COLORSET13 0x7D // Color Set 13
#define SH8601_W_COLORSET14 0x7E // Color Set 14
#define SH8601_W_COLORSET15 0x7F // Color Set 15
#define SH8601_W_COLOROPTION 0x80 // Color Option
#define SH8601_R_RDDBSTART 0xA1 // Read DDB start
#define SH8601_R_DDBCONTINUE 0xA8 // Read DDB Continue
#define SH8601_R_RFIRCHECKSUN 0xAA // Read First Checksum
#define SH8601_R_RCONTINUECHECKSUN 0xAF // Read Continue Checksum
#define SH8601_W_SPIMODECTL 0xC4 // SPI mode control
#define SH8601_R_RDID1 0xDA // Read ID1
#define SH8601_R_RDID2 0xDB // Read ID2
#define SH8601_R_RDID3 0xDC // Read ID3
// Flip
#define SH8601_MADCTL_X_AXIS_FLIP 0x02 // Flip Horizontal
#define SH8601_MADCTL_Y_AXIS_FLIP 0x05 // Flip Vertical
// Color Order
#define SH8601_MADCTL_RGB 0x00 // Red-Green-Blue pixel order
#define SH8601_MADCTL_BGR 0x08 // Blue-Green-Red pixel order
#define SH8601_MADCTL_COLOR_ORDER SH8601_MADCTL_RGB // RGB
enum
{
SH8601_ContrastOff = 0,
SH8601_LowContrast,
SH8601_MediumContrast,
SH8601_HighContrast
};
static const uint8_t sh8601_init_operations[] = {
BEGIN_WRITE,
WRITE_COMMAND_8, SH8601_C_SLPOUT,
END_WRITE,
DELAY, SH8601_SLPOUT_DELAY,
BEGIN_WRITE,
// WRITE_C8_D8, SH8601_WC_TEARON, 0x00,
WRITE_COMMAND_8, SH8601_C_NORON,
WRITE_COMMAND_8, SH8601_C_INVOFF,
// WRITE_COMMAND_8, SH8601_C_ALLPON,
// WRITE_C8_D8, SH8601_W_MADCTL, SH8601_MADCTL_COLOR_ORDER, // RGB/BGR
WRITE_C8_D8, SH8601_W_PIXFMT, 0x05, // Interface Pixel Format 16bit/pixel
// WRITE_C8_D8, SH8601_W_PIXFMT, 0x06, // Interface Pixel Format 18bit/pixel
// WRITE_C8_D8, SH8601_W_PIXFMT, 0x07, // Interface Pixel Format 24bit/pixel
WRITE_COMMAND_8, SH8601_C_DISPON,
// WRITE_COMMAND_8, SH8601_W_WDBRIGHTNESSVALNOR,
// WRITE_BYTES, 2,
// 0x03, 0xFF,
WRITE_C8_D8, SH8601_W_WCTRLD1, 0x28, // Brightness Control On and Display Dimming On
WRITE_C8_D8, SH8601_W_WDBRIGHTNESSVALNOR, 0xD0, // Brightness adjustment
// High contrast mode (Sunlight Readability Enhancement)
WRITE_C8_D8, SH8601_W_WCE, 0x00, // Off
// WRITE_C8_D8, SH8601_W_WCE, 0x05, // On Low
// WRITE_C8_D8, SH8601_W_WCE, 0x06, // On Medium
// WRITE_C8_D8, SH8601_W_WCE, 0x07, // On High
END_WRITE,
DELAY, 10};
class Arduino_SH8601 : public Arduino_OLED
{
public:
Arduino_SH8601(
Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0,
int16_t w = SH8601_TFTWIDTH, int16_t h = SH8601_TFTHEIGHT,
uint8_t col_offset1 = 0, uint8_t row_offset1 = 0, uint8_t col_offset2 = 0, uint8_t row_offset2 = 0);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void setRotation(uint8_t r) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
void setBrightness(uint8_t brightness) override;
void setContrast(uint8_t contrast) override;
protected:
void tftInit() override;
private:
};

View File

@@ -0,0 +1,84 @@
#include "Arduino_SPD2010.h"
#include "SPI.h"
Arduino_SPD2010::Arduino_SPD2010(Arduino_DataBus *bus, int8_t rst)
: Arduino_TFT(bus, rst, 0, false, SPD2010_TFTWIDTH, SPD2010_TFTHEIGHT, 0, 0, 0, 0)
{
}
bool Arduino_SPD2010::begin(int32_t speed)
{
_override_datamode = SPI_MODE3; // always use SPI_MODE3
return Arduino_TFT::begin(speed);
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_SPD2010::setRotation(uint8_t r)
{
Arduino_TFT::setRotation(r);
// not implemented
}
void Arduino_SPD2010::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
if ((x != _currentX) || (w != _currentW))
{
_currentX = x;
_currentW = w;
x += _xStart;
_bus->writeC8D16D16(SPD2010_CASET, x, x + w - 1);
}
if ((y != _currentY) || (h != _currentH))
{
_currentY = y;
_currentH = h;
y += _yStart;
_bus->writeC8D16D16(SPD2010_PASET, y, y + h - 1);
}
_bus->writeCommand(SPD2010_RAMWR); // write to RAM
}
void Arduino_SPD2010::invertDisplay(bool i)
{
_bus->sendCommand(i ? SPD2010_INVON : SPD2010_INVOFF);
}
void Arduino_SPD2010::displayOn(void)
{
_bus->sendCommand(SPD2010_SLPOUT);
delay(SPD2010_SLPOUT_DELAY);
}
void Arduino_SPD2010::displayOff(void)
{
_bus->sendCommand(SPD2010_SLPIN);
delay(SPD2010_SLPIN_DELAY);
}
// Companion code to the above tables. Reads and issues
// a series of LCD commands stored in PROGMEM byte array.
void Arduino_SPD2010::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(SPD2010_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(SPD2010_RST_DELAY);
}
_bus->batchOperation(spd2010_init_operations, sizeof(spd2010_init_operations));
invertDisplay(false);
}

View File

@@ -0,0 +1,474 @@
#pragma once
#include "../Arduino_GFX.h"
#include "../Arduino_TFT.h"
#define SPD2010_TFTWIDTH 412 ///< SPD2010 max TFT width
#define SPD2010_TFTHEIGHT 412 ///< SPD2010 max TFT height
#define SPD2010_RST_DELAY 120 ///< delay ms wait for reset finish
#define SPD2010_SLPIN_DELAY 120 ///< delay ms wait for sleep in finish
#define SPD2010_SLPOUT_DELAY 120 ///< delay ms wait for sleep out finish
#define SPD2010_SWRESET 0x01 ///< Software reset register
#define SPD2010_SLPIN 0x10 ///< Enter Sleep Mode
#define SPD2010_SLPOUT 0x11 ///< Sleep Out
#define SPD2010_INVOFF 0x20 ///< Display Inversion OFF
#define SPD2010_INVON 0x21 ///< Display Inversion ON
#define SPD2010_DISPOFF 0x28 ///< Display OFF
#define SPD2010_DISPON 0x29 ///< Display ON
#define SPD2010_CASET 0x2A ///< Column Address Set
#define SPD2010_PASET 0x2B ///< Page Address Set
#define SPD2010_RAMWR 0x2C ///< Memory Write
#define SPD2010_MADCTL 0x36
#define SPD2010_PIXFMT 0x3A // Interface Pixel Format
#define SPD2010_MADCTL_MY 0x80
#define SPD2010_MADCTL_MX 0x40
#define SPD2010_MADCTL_MV 0x20
#define SPD2010_MADCTL_ML 0x10
#define SPD2010_MADCTL_RGB 0x00
#define SPD2010_MADCTL_MH 0x04
#define SPD2010_MADCTL_BGR 0x08
static const uint8_t spd2010_init_operations[] = {
BEGIN_WRITE,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x00,
WRITE_COMMAND_8, SPD2010_SWRESET,
END_WRITE,
DELAY, SPD2010_RST_DELAY,
BEGIN_WRITE,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x10,
WRITE_C8_D8, 0x0C, 0x11,
WRITE_C8_D8, 0x10, 0x02,
WRITE_C8_D8, 0x11, 0x11,
WRITE_C8_D8, 0x15, 0x42,
WRITE_C8_D8, 0x16, 0x11,
WRITE_C8_D8, 0x1A, 0x02,
WRITE_C8_D8, 0x1B, 0x11,
WRITE_C8_D8, 0x61, 0x80,
WRITE_C8_D8, 0x62, 0x80,
WRITE_C8_D8, 0x54, 0x44,
WRITE_C8_D8, 0x58, 0x88,
WRITE_C8_D8, 0x5C, 0xcc,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x10,
WRITE_C8_D8, 0x20, 0x80,
WRITE_C8_D8, 0x21, 0x81,
WRITE_C8_D8, 0x22, 0x31,
WRITE_C8_D8, 0x23, 0x20,
WRITE_C8_D8, 0x24, 0x11,
WRITE_C8_D8, 0x25, 0x11,
WRITE_C8_D8, 0x26, 0x12,
WRITE_C8_D8, 0x27, 0x12,
WRITE_C8_D8, 0x30, 0x80,
WRITE_C8_D8, 0x31, 0x81,
WRITE_C8_D8, 0x32, 0x31,
WRITE_C8_D8, 0x33, 0x20,
WRITE_C8_D8, 0x34, 0x11,
WRITE_C8_D8, 0x35, 0x11,
WRITE_C8_D8, 0x36, 0x12,
WRITE_C8_D8, 0x37, 0x12,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x10,
WRITE_C8_D8, 0x41, 0x11,
WRITE_C8_D8, 0x42, 0x22,
WRITE_C8_D8, 0x43, 0x33,
WRITE_C8_D8, 0x49, 0x11,
WRITE_C8_D8, 0x4A, 0x22,
WRITE_C8_D8, 0x4B, 0x33,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x15,
WRITE_C8_D8, 0x00, 0x00,
WRITE_C8_D8, 0x01, 0x00,
WRITE_C8_D8, 0x02, 0x00,
WRITE_C8_D8, 0x03, 0x00,
WRITE_C8_D8, 0x04, 0x10,
WRITE_C8_D8, 0x05, 0x0C,
WRITE_C8_D8, 0x06, 0x23,
WRITE_C8_D8, 0x07, 0x22,
WRITE_C8_D8, 0x08, 0x21,
WRITE_C8_D8, 0x09, 0x20,
WRITE_C8_D8, 0x0A, 0x33,
WRITE_C8_D8, 0x0B, 0x32,
WRITE_C8_D8, 0x0C, 0x34,
WRITE_C8_D8, 0x0D, 0x35,
WRITE_C8_D8, 0x0E, 0x01,
WRITE_C8_D8, 0x0F, 0x01,
WRITE_C8_D8, 0x20, 0x00,
WRITE_C8_D8, 0x21, 0x00,
WRITE_C8_D8, 0x22, 0x00,
WRITE_C8_D8, 0x23, 0x00,
WRITE_C8_D8, 0x24, 0x0C,
WRITE_C8_D8, 0x25, 0x10,
WRITE_C8_D8, 0x26, 0x20,
WRITE_C8_D8, 0x27, 0x21,
WRITE_C8_D8, 0x28, 0x22,
WRITE_C8_D8, 0x29, 0x23,
WRITE_C8_D8, 0x2A, 0x33,
WRITE_C8_D8, 0x2B, 0x32,
WRITE_C8_D8, 0x2C, 0x34,
WRITE_C8_D8, 0x2D, 0x35,
WRITE_C8_D8, 0x2E, 0x01,
WRITE_C8_D8, 0x2F, 0x01,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x16,
WRITE_C8_D8, 0x00, 0x00,
WRITE_C8_D8, 0x01, 0x00,
WRITE_C8_D8, 0x02, 0x00,
WRITE_C8_D8, 0x03, 0x00,
WRITE_C8_D8, 0x04, 0x08,
WRITE_C8_D8, 0x05, 0x04,
WRITE_C8_D8, 0x06, 0x19,
WRITE_C8_D8, 0x07, 0x18,
WRITE_C8_D8, 0x08, 0x17,
WRITE_C8_D8, 0x09, 0x16,
WRITE_C8_D8, 0x0A, 0x33,
WRITE_C8_D8, 0x0B, 0x32,
WRITE_C8_D8, 0x0C, 0x34,
WRITE_C8_D8, 0x0D, 0x35,
WRITE_C8_D8, 0x0E, 0x01,
WRITE_C8_D8, 0x0F, 0x01,
WRITE_C8_D8, 0x20, 0x00,
WRITE_C8_D8, 0x21, 0x00,
WRITE_C8_D8, 0x22, 0x00,
WRITE_C8_D8, 0x23, 0x00,
WRITE_C8_D8, 0x24, 0x04,
WRITE_C8_D8, 0x25, 0x08,
WRITE_C8_D8, 0x26, 0x16,
WRITE_C8_D8, 0x27, 0x17,
WRITE_C8_D8, 0x28, 0x18,
WRITE_C8_D8, 0x29, 0x19,
WRITE_C8_D8, 0x2A, 0x33,
WRITE_C8_D8, 0x2B, 0x32,
WRITE_C8_D8, 0x2C, 0x34,
WRITE_C8_D8, 0x2D, 0x35,
WRITE_C8_D8, 0x2E, 0x01,
WRITE_C8_D8, 0x2F, 0x01,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x12,
WRITE_C8_D8, 0x00, 0x99,
WRITE_C8_D8, 0x2A, 0x28,
WRITE_C8_D8, 0x2B, 0x0f,
WRITE_C8_D8, 0x2C, 0x16,
WRITE_C8_D8, 0x2D, 0x28,
WRITE_C8_D8, 0x2E, 0x0f,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0xA0,
WRITE_C8_D8, 0x08, 0xdc,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x45,
WRITE_C8_D8, 0x01, 0x9C,
WRITE_C8_D8, 0x03, 0x9C,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x42,
WRITE_C8_D8, 0x05, 0x2c,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x11,
WRITE_C8_D8, 0x50, 0x01,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x00,
WRITE_C8_BYTES, 0x2A, 4, 0x00, 0x00, 0x01, 0x9B,
WRITE_C8_BYTES, 0x2B, 4, 0x00, 0x00, 0x01, 0x9B,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x40,
WRITE_C8_D8, 0x86, 0x00,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x00,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x12,
WRITE_C8_D8, 0x0D, 0x66,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x17,
WRITE_C8_D8, 0x39, 0x3c,
WRITE_C8_BYTES, 0xff, 3, 0x20, 0x10, 0x31,
WRITE_C8_D8, 0x38, 0x03,
WRITE_C8_D8, 0x39, 0xf0,
WRITE_C8_D8, 0x36, 0x03,
WRITE_C8_D8, 0x37, 0xe8,
WRITE_C8_D8, 0x34, 0x03,
WRITE_C8_D8, 0x35, 0xCF,
WRITE_C8_D8, 0x32, 0x03,
WRITE_C8_D8, 0x33, 0xBA,
WRITE_C8_D8, 0x30, 0x03,
WRITE_C8_D8, 0x31, 0xA2,
WRITE_C8_D8, 0x2e, 0x03,
WRITE_C8_D8, 0x2f, 0x95,
WRITE_C8_D8, 0x2c, 0x03,
WRITE_C8_D8, 0x2d, 0x7e,
WRITE_C8_D8, 0x2a, 0x03,
WRITE_C8_D8, 0x2b, 0x62,
WRITE_C8_D8, 0x28, 0x03,
WRITE_C8_D8, 0x29, 0x44,
WRITE_C8_D8, 0x26, 0x02,
WRITE_C8_D8, 0x27, 0xfc,
WRITE_C8_D8, 0x24, 0x02,
WRITE_C8_D8, 0x25, 0xd0,
WRITE_C8_D8, 0x22, 0x02,
WRITE_C8_D8, 0x23, 0x98,
WRITE_C8_D8, 0x20, 0x02,
WRITE_C8_D8, 0x21, 0x6f,
WRITE_C8_D8, 0x1e, 0x02,
WRITE_C8_D8, 0x1f, 0x32,
WRITE_C8_D8, 0x1c, 0x01,
WRITE_C8_D8, 0x1d, 0xf6,
WRITE_C8_D8, 0x1a, 0x01,
WRITE_C8_D8, 0x1b, 0xb8,
WRITE_C8_D8, 0x18, 0x01,
WRITE_C8_D8, 0x19, 0x6E,
WRITE_C8_D8, 0x16, 0x01,
WRITE_C8_D8, 0x17, 0x41,
WRITE_C8_D8, 0x14, 0x00,
WRITE_C8_D8, 0x15, 0xfd,
WRITE_C8_D8, 0x12, 0x00,
WRITE_C8_D8, 0x13, 0xCf,
WRITE_C8_D8, 0x10, 0x00,
WRITE_C8_D8, 0x11, 0x98,
WRITE_C8_D8, 0x0e, 0x00,
WRITE_C8_D8, 0x0f, 0x89,
WRITE_C8_D8, 0x0c, 0x00,
WRITE_C8_D8, 0x0d, 0x79,
WRITE_C8_D8, 0x0a, 0x00,
WRITE_C8_D8, 0x0b, 0x67,
WRITE_C8_D8, 0x08, 0x00,
WRITE_C8_D8, 0x09, 0x55,
WRITE_C8_D8, 0x06, 0x00,
WRITE_C8_D8, 0x07, 0x3F,
WRITE_C8_D8, 0x04, 0x00,
WRITE_C8_D8, 0x05, 0x28,
WRITE_C8_D8, 0x02, 0x00,
WRITE_C8_D8, 0x03, 0x0E,
WRITE_C8_BYTES, 0xff, 3, 0x20, 0x10, 0x00,
WRITE_C8_BYTES, 0xff, 3, 0x20, 0x10, 0x32,
WRITE_C8_D8, 0x38, 0x03,
WRITE_C8_D8, 0x39, 0xf0,
WRITE_C8_D8, 0x36, 0x03,
WRITE_C8_D8, 0x37, 0xe8,
WRITE_C8_D8, 0x34, 0x03,
WRITE_C8_D8, 0x35, 0xCF,
WRITE_C8_D8, 0x32, 0x03,
WRITE_C8_D8, 0x33, 0xBA,
WRITE_C8_D8, 0x30, 0x03,
WRITE_C8_D8, 0x31, 0xA2,
WRITE_C8_D8, 0x2e, 0x03,
WRITE_C8_D8, 0x2f, 0x95,
WRITE_C8_D8, 0x2c, 0x03,
WRITE_C8_D8, 0x2d, 0x7e,
WRITE_C8_D8, 0x2a, 0x03,
WRITE_C8_D8, 0x2b, 0x62,
WRITE_C8_D8, 0x28, 0x03,
WRITE_C8_D8, 0x29, 0x44,
WRITE_C8_D8, 0x26, 0x02,
WRITE_C8_D8, 0x27, 0xfc,
WRITE_C8_D8, 0x24, 0x02,
WRITE_C8_D8, 0x25, 0xd0,
WRITE_C8_D8, 0x22, 0x02,
WRITE_C8_D8, 0x23, 0x98,
WRITE_C8_D8, 0x20, 0x02,
WRITE_C8_D8, 0x21, 0x6f,
WRITE_C8_D8, 0x1e, 0x02,
WRITE_C8_D8, 0x1f, 0x32,
WRITE_C8_D8, 0x1c, 0x01,
WRITE_C8_D8, 0x1d, 0xf6,
WRITE_C8_D8, 0x1a, 0x01,
WRITE_C8_D8, 0x1b, 0xb8,
WRITE_C8_D8, 0x18, 0x01,
WRITE_C8_D8, 0x19, 0x6E,
WRITE_C8_D8, 0x16, 0x01,
WRITE_C8_D8, 0x17, 0x41,
WRITE_C8_D8, 0x14, 0x00,
WRITE_C8_D8, 0x15, 0xfd,
WRITE_C8_D8, 0x12, 0x00,
WRITE_C8_D8, 0x13, 0xCf,
WRITE_C8_D8, 0x10, 0x00,
WRITE_C8_D8, 0x11, 0x98,
WRITE_C8_D8, 0x0e, 0x00,
WRITE_C8_D8, 0x0f, 0x89,
WRITE_C8_D8, 0x0c, 0x00,
WRITE_C8_D8, 0x0d, 0x79,
WRITE_C8_D8, 0x0a, 0x00,
WRITE_C8_D8, 0x0b, 0x67,
WRITE_C8_D8, 0x08, 0x00,
WRITE_C8_D8, 0x09, 0x55,
WRITE_C8_D8, 0x06, 0x00,
WRITE_C8_D8, 0x07, 0x3F,
WRITE_C8_D8, 0x04, 0x00,
WRITE_C8_D8, 0x05, 0x28,
WRITE_C8_D8, 0x02, 0x00,
WRITE_C8_D8, 0x03, 0x0E,
WRITE_C8_BYTES, 0xff, 3, 0x20, 0x10, 0x00,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x11,
WRITE_C8_D8, 0x60, 0x01,
WRITE_C8_D8, 0x65, 0x03,
WRITE_C8_D8, 0x66, 0x38,
WRITE_C8_D8, 0x67, 0x04,
WRITE_C8_D8, 0x68, 0x34,
WRITE_C8_D8, 0x69, 0x03,
WRITE_C8_D8, 0x61, 0x03,
WRITE_C8_D8, 0x62, 0x38,
WRITE_C8_D8, 0x63, 0x04,
WRITE_C8_D8, 0x64, 0x34,
WRITE_C8_D8, 0x0A, 0x11,
WRITE_C8_D8, 0x0B, 0x20,
WRITE_C8_D8, 0x0c, 0x20,
WRITE_C8_D8, 0x55, 0x06,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x42,
WRITE_C8_D8, 0x05, 0x3D,
WRITE_C8_D8, 0x06, 0x03,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x00,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x12,
WRITE_C8_D8, 0x1F, 0xDC,
WRITE_C8_BYTES, 0xff, 3, 0x20, 0x10, 0x17,
WRITE_C8_D8, 0x11, 0xAA,
WRITE_C8_D8, 0x16, 0x12,
WRITE_C8_D8, 0x0B, 0xC3,
WRITE_C8_D8, 0x10, 0x0E,
WRITE_C8_D8, 0x14, 0xAA,
WRITE_C8_D8, 0x18, 0xA0,
WRITE_C8_D8, 0x1A, 0x80,
WRITE_C8_D8, 0x1F, 0x80,
WRITE_C8_BYTES, 0xff, 3, 0x20, 0x10, 0x11,
WRITE_C8_D8, 0x30, 0xEE,
WRITE_C8_BYTES, 0xff, 3, 0x20, 0x10, 0x12,
WRITE_C8_D8, 0x15, 0x0F,
WRITE_C8_BYTES, 0xff, 3, 0x20, 0x10, 0x2D,
WRITE_C8_D8, 0x01, 0x3E,
WRITE_C8_BYTES, 0xff, 3, 0x20, 0x10, 0x40,
WRITE_C8_D8, 0x83, 0xC4,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x12,
WRITE_C8_D8, 0x00, 0xCC,
WRITE_C8_D8, 0x36, 0xA0,
WRITE_C8_D8, 0x2A, 0x2D,
WRITE_C8_D8, 0x2B, 0x1e,
WRITE_C8_D8, 0x2C, 0x26,
WRITE_C8_D8, 0x2D, 0x2D,
WRITE_C8_D8, 0x2E, 0x1e,
WRITE_C8_D8, 0x1F, 0xE6,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0xA0,
WRITE_C8_D8, 0x08, 0xE6,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x12,
WRITE_C8_D8, 0x10, 0x0F,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x18,
WRITE_C8_D8, 0x01, 0x01,
WRITE_C8_D8, 0x00, 0x1E,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x43,
WRITE_C8_D8, 0x03, 0x04,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x18,
WRITE_C8_D8, 0x3A, 0x01,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x50,
WRITE_C8_D8, 0x05, 0x08,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x00,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x50,
WRITE_C8_D8, 0x00, 0xA6,
WRITE_C8_D8, 0x01, 0xA6,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x00,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x50,
WRITE_C8_D8, 0x08, 0x55,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x00,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x10,
WRITE_C8_D8, 0x0B, 0x43,
WRITE_C8_D8, 0x0C, 0x12,
WRITE_C8_D8, 0x10, 0x01,
WRITE_C8_D8, 0x11, 0x12,
WRITE_C8_D8, 0x15, 0x00,
WRITE_C8_D8, 0x16, 0x00,
WRITE_C8_D8, 0x1A, 0x00,
WRITE_C8_D8, 0x1B, 0x00,
WRITE_C8_D8, 0x61, 0x00,
WRITE_C8_D8, 0x62, 0x00,
WRITE_C8_D8, 0x51, 0x11,
WRITE_C8_D8, 0x55, 0x55,
WRITE_C8_D8, 0x58, 0x00,
WRITE_C8_D8, 0x5C, 0x00,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x10,
WRITE_C8_D8, 0x20, 0x81,
WRITE_C8_D8, 0x21, 0x82,
WRITE_C8_D8, 0x22, 0x72,
WRITE_C8_D8, 0x30, 0x00,
WRITE_C8_D8, 0x31, 0x00,
WRITE_C8_D8, 0x32, 0x00,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x10,
WRITE_C8_D8, 0x44, 0x44,
WRITE_C8_D8, 0x45, 0x55,
WRITE_C8_D8, 0x46, 0x66,
WRITE_C8_D8, 0x47, 0x77,
WRITE_C8_D8, 0x49, 0x00,
WRITE_C8_D8, 0x4A, 0x00,
WRITE_C8_D8, 0x4B, 0x00,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x17,
WRITE_C8_D8, 0x37, 0x00,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x15,
WRITE_C8_D8, 0x04, 0x08,
WRITE_C8_D8, 0x05, 0x04,
WRITE_C8_D8, 0x06, 0x1C,
WRITE_C8_D8, 0x07, 0x1A,
WRITE_C8_D8, 0x08, 0x18,
WRITE_C8_D8, 0x09, 0x16,
WRITE_C8_D8, 0x24, 0x05,
WRITE_C8_D8, 0x25, 0x09,
WRITE_C8_D8, 0x26, 0x17,
WRITE_C8_D8, 0x27, 0x19,
WRITE_C8_D8, 0x28, 0x1B,
WRITE_C8_D8, 0x29, 0x1D,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x16,
WRITE_C8_D8, 0x04, 0x09,
WRITE_C8_D8, 0x05, 0x05,
WRITE_C8_D8, 0x06, 0x1D,
WRITE_C8_D8, 0x07, 0x1B,
WRITE_C8_D8, 0x08, 0x19,
WRITE_C8_D8, 0x09, 0x17,
WRITE_C8_D8, 0x24, 0x04,
WRITE_C8_D8, 0x25, 0x08,
WRITE_C8_D8, 0x26, 0x16,
WRITE_C8_D8, 0x27, 0x18,
WRITE_C8_D8, 0x28, 0x1A,
WRITE_C8_D8, 0x29, 0x1C,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x18,
WRITE_C8_D8, 0x1F, 0x02,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x11,
WRITE_C8_D8, 0x15, 0x99,
WRITE_C8_D8, 0x16, 0x99,
WRITE_C8_D8, 0x1C, 0x88,
WRITE_C8_D8, 0x1D, 0x88,
WRITE_C8_D8, 0x1E, 0x88,
WRITE_C8_D8, 0x13, 0xf0,
WRITE_C8_D8, 0x14, 0x34,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x12,
WRITE_C8_D8, 0x12, 0x89,
WRITE_C8_D8, 0x06, 0x06,
WRITE_C8_D8, 0x18, 0x00,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x11,
WRITE_C8_D8, 0x0A, 0x00,
WRITE_C8_D8, 0x0B, 0xF0,
WRITE_C8_D8, 0x0c, 0xF0,
WRITE_C8_D8, 0x6A, 0x10,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x00,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x11,
WRITE_C8_D8, 0x08, 0x70,
WRITE_C8_D8, 0x09, 0x00,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x00,
WRITE_C8_D8, 0x35, 0x00,
WRITE_C8_D8, SPD2010_PIXFMT, 0x55,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x12,
WRITE_C8_D8, 0x21, 0x70,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x2D,
WRITE_C8_D8, 0x02, 0x00,
WRITE_C8_BYTES, 0xFF, 3, 0x20, 0x10, 0x00,
WRITE_COMMAND_8, SPD2010_SLPOUT,
WRITE_COMMAND_8, SPD2010_DISPON,
END_WRITE,
DELAY, SPD2010_SLPOUT_DELAY};
class Arduino_SPD2010 : public Arduino_TFT
{
public:
Arduino_SPD2010(Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void setRotation(uint8_t r) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h);
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
protected:
void tftInit() override;
private:
};

View File

@@ -0,0 +1,209 @@
/*
* start rewrite from:
* https://github.com/adafruit/Adafruit-GFX-Library.git
* https://github.com/gitcnd/LCDWIKI_SPI.git
*/
#include "Arduino_SSD1283A.h"
#include "SPI.h"
Arduino_SSD1283A::Arduino_SSD1283A(
Arduino_DataBus *bus, int8_t rst, uint8_t r, int16_t w, int16_t h,
uint8_t col_offset1, uint8_t row_offset1, uint8_t col_offset2, uint8_t row_offset2)
: Arduino_TFT(bus, rst, r, false, w, h, col_offset1, row_offset1, col_offset2, row_offset2)
{
}
bool Arduino_SSD1283A::begin(int32_t speed)
{
#if defined(ESP8266) || defined(ESP32)
if (speed == GFX_NOT_DEFINED)
{
speed = 27000000UL;
}
// Teensy 4.x
#elif defined(__IMXRT1052__) || defined(__IMXRT1062__)
if (speed == GFX_NOT_DEFINED)
{
speed = 27000000UL;
}
#endif
return Arduino_TFT::begin(speed);
}
// Companion code to the above tables. Reads and issues
// a series of LCD commands stored in PROGMEM byte array.
void Arduino_SSD1283A::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(SSD1283A_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(SSD1283A_RST_DELAY);
}
else
{
// Software Rest
}
// Initialization Sequence
_bus->beginWrite();
_bus->writeCommand16(SSD1283A_POWER_CONTROL_1);
_bus->write16(0x2F8E);
_bus->writeCommand16(SSD1283A_POWER_CONTROL_2);
_bus->write16(0x000C);
_bus->writeCommand16(SSD1283A_DISPLAY_CONTROL);
_bus->write16(0x0021);
_bus->writeCommand16(SSD1283A_VCOM_OTP_1);
_bus->write16(0x0006);
_bus->writeCommand16(SSD1283A_VCOM_OTP_1);
_bus->write16(0x0005);
_bus->writeCommand16(SSD1283A_FURTHER_BIAS_CURRENT_SETTING);
_bus->write16(0x057F);
_bus->writeCommand16(SSD1283A_VCOM_OTP_2);
_bus->write16(0x89A1);
_bus->writeCommand16(SSD1283A_OSCILLATOR);
_bus->write16(0x0001);
_bus->endWrite();
delay(100);
_bus->beginWrite();
_bus->writeCommand16(SSD1283A_VCOM_OTP_2);
_bus->write16(0x80B0);
_bus->endWrite();
delay(30);
_bus->beginWrite();
_bus->writeCommand16(SSD1283A_VCOM_OTP_2);
_bus->write16(0xFFFE);
_bus->writeCommand16(SSD1283A_DISPLAY_CONTROL);
_bus->write16(0x0223);
_bus->endWrite();
delay(30);
_bus->beginWrite();
_bus->writeCommand16(SSD1283A_DISPLAY_CONTROL);
_bus->write16(0x0233);
_bus->writeCommand16(SSD1283A_DRIVER_OUTPUT_CONTROL);
_bus->write16(0x2183);
_bus->writeCommand16(SSD1283A_ENTRY_MODE);
_bus->write16(0x6830);
_bus->writeCommand16(0x2F);
_bus->write16(0xFFFF);
_bus->writeCommand16(SSD1283A_OSCILLATOR_FREQUENCY);
_bus->write16(0x8000);
_bus->writeCommand16(SSD1283A_FURTHER_BIAS_CURRENT_SETTING);
_bus->write16(0x0570);
_bus->writeCommand16(SSD1283A_LCD_DRIVING_WAVEFORM_CONTROL);
_bus->write16(0x0300);
_bus->writeCommand16(SSD1283A_FRAME_CYCLE_CONTROL);
_bus->write16(0x580C);
_bus->writeCommand16(SSD1283A_POWER_CONTROL_3);
_bus->write16(0x0609);
_bus->writeCommand16(SSD1283A_POWER_CONTROL_4);
_bus->write16(0x3100);
_bus->endWrite();
}
void Arduino_SSD1283A::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
uint8_t v1 = 0, v2 = 0, v3 = 0, h1 = 0, h2 = 0, h3 = 0;
// TODO: it works, but should have better way
switch (_rotation)
{
case 1:
v1 = x + w - 1 + _xStart;
v2 = x + _xStart;
v3 = v2;
h1 = SSD1283A_TFTWIDTH - y - 1 + _yStart;
h2 = SSD1283A_TFTWIDTH - y - h + _yStart;
h3 = h1;
break;
case 2:
v1 = SSD1283A_TFTWIDTH - y - 1 + _yStart;
v2 = SSD1283A_TFTWIDTH - y - h + _yStart;
v3 = v1;
h1 = SSD1283A_TFTHEIGHT - x - 1 + _xStart;
h2 = SSD1283A_TFTHEIGHT - x - w + _xStart;
h3 = h1;
break;
case 3:
v1 = SSD1283A_TFTHEIGHT - x - 1 + _xStart;
v2 = SSD1283A_TFTHEIGHT - x - w + _xStart;
v3 = v1;
h1 = y + h - 1 + _yStart;
h2 = y + _yStart;
h3 = h2;
break;
default: // case 0:
v1 = y + h - 1 + _yStart;
v2 = y + _yStart;
v3 = v2;
h1 = x + w - 1 + _xStart;
h2 = x + _xStart;
h3 = h2;
break;
}
_bus->writeCommand(SSD1283A_HORIZONTAL_RAM_ADDRESS_POSITION);
_bus->write(h1);
_bus->write(h2);
_bus->writeCommand(SSD1283A_VERTICAL_RAM_ADDRESS_POSITION);
_bus->write(v1);
_bus->write(v2);
_bus->writeCommand(SSD1283A_RAM_ADDRESS_SET);
_bus->write(v3);
_bus->write(h3);
_bus->writeCommand(SSD1283A_WRITE_DATA_TO_GRAM);
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_SSD1283A::setRotation(uint8_t r)
{
Arduino_TFT::setRotation(r);
_bus->beginWrite();
switch (_rotation)
{
case 1:
_bus->writeCommand16(SSD1283A_ENTRY_MODE);
_bus->write16(0x6828);
break;
case 2:
_bus->writeCommand(SSD1283A_ENTRY_MODE);
_bus->write16(0x6800);
break;
case 3:
_bus->writeCommand(SSD1283A_ENTRY_MODE);
_bus->write16(0x6818);
break;
default: // case 0:
_bus->writeCommand16(SSD1283A_ENTRY_MODE);
_bus->write16(0x6830);
break;
}
_bus->endWrite();
}
void Arduino_SSD1283A::invertDisplay(bool)
{
// Not Implemented
}
void Arduino_SSD1283A::displayOn(void)
{
// Not Implemented
}
void Arduino_SSD1283A::displayOff(void)
{
// Not Implemented
}

View File

@@ -0,0 +1,81 @@
/*
* start rewrite from:
* https://github.com/adafruit/Adafruit-GFX-Library.git
* https://github.com/gitcnd/LCDWIKI_SPI.git
*/
#ifndef _ARDUINO_SSD1283A_H_
#define _ARDUINO_SSD1283A_H_
#include "../Arduino_GFX.h"
#include "../Arduino_TFT.h"
#define SSD1283A_TFTWIDTH 130 ///< SSD1283A max TFT width
#define SSD1283A_TFTHEIGHT 130 ///< SSD1283A max TFT height
#define SSD1283A_RST_DELAY 120
// http://www.lcdwiki.com/res/MSP1601/SSD1283A%20Datasheet.pdf
#define SSD1283A_OSCILLATOR 0x00
#define SSD1283A_DRIVER_OUTPUT_CONTROL 0x01
#define SSD1283A_LCD_DRIVING_WAVEFORM_CONTROL 0x02
#define SSD1283A_ENTRY_MODE 0x03
#define SSD1283A_COMPARE_REGISTER_1 0x04
#define SSD1283A_COMPARE_REGISTER_2 0x05
#define SSD1283A_DISPLAY_CONTROL 0x07
#define SSD1283A_FRAME_CYCLE_CONTROL 0x0B
#define SSD1283A_POWER_CONTROL_1 0x10
#define SSD1283A_POWER_CONTROL_2 0x11
#define SSD1283A_POWER_CONTROL_3 0x12
#define SSD1283A_POWER_CONTROL_4 0x13
#define SSD1283A_HORIZONTAL_PORCH 0x16
#define SSD1283A_VERTICAL_PORCH 0x17
#define SSD1283A_POWER_CONTROL_5 0x1E
#define SSD1283A_POWER_CONTROL_6 0x1F
#define SSD1283A_RAM_ADDRESS_SET 0x21
#define SSD1283A_WRITE_DATA_TO_GRAM 0x22
#define SSD1283A_READ_DATA_TO_GRAM 0x22
#define SSD1283A_RAM_WRITE_DATA_MASK_1 0x23
#define SSD1283A_RAM_WRITE_DATA_MASK_2 0x24
#define SSD1283A_VCOM_OTP_1 0x28
#define SSD1283A_VCOM_OTP_2 0x29
#define SSD1283A_GAMMA_CONTROL_01 0x30
#define SSD1283A_GAMMA_CONTROL_02 0x31
#define SSD1283A_GAMMA_CONTROL_03 0x32
#define SSD1283A_GAMMA_CONTROL_04 0x33
#define SSD1283A_GAMMA_CONTROL_05 0x34
#define SSD1283A_GAMMA_CONTROL_06 0x35
#define SSD1283A_GAMMA_CONTROL_07 0x36
#define SSD1283A_GAMMA_CONTROL_08 0x37
#define SSD1283A_GAMMA_CONTROL_09 0x38
#define SSD1283A_GAMMA_CONTROL_10 0x39
#define SSD1283A_GATE_SCAN_POSITION 0x40
#define SSD1283A_VERTICAL_SCROLL_CONTROL 0x41
#define SSD1283A_1ST_SCREEN_DRIVING_POSITION 0x42
#define SSD1283A_2ND_SCREEN_DRIVING_POSITION 0x43
#define SSD1283A_HORIZONTAL_RAM_ADDRESS_POSITION 0x44
#define SSD1283A_VERTICAL_RAM_ADDRESS_POSITION 0x45
#define SSD1283A_FURTHER_BIAS_CURRENT_SETTING 0x27
#define SSD1283A_OSCILLATOR_FREQUENCY 0x2C
class Arduino_SSD1283A : public Arduino_TFT
{
public:
Arduino_SSD1283A(
Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0,
int16_t w = SSD1283A_TFTWIDTH, int16_t h = SSD1283A_TFTHEIGHT,
uint8_t col_offset1 = 2, uint8_t row_offset1 = 2, uint8_t col_offset2 = 2, uint8_t row_offset2 = 2);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void setRotation(uint8_t r) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
protected:
void tftInit() override;
private:
};
#endif

View File

@@ -0,0 +1,173 @@
#include "Arduino_SSD1306.h"
Arduino_SSD1306::Arduino_SSD1306(Arduino_DataBus *bus, int8_t rst, int16_t w, int16_t h)
: Arduino_G(w, h), _bus(bus), _rst(rst)
{
_rotation = 0;
_pages = (h + 7) / 8;
}
bool Arduino_SSD1306::begin(int32_t speed)
{
if (speed != GFX_SKIP_DATABUS_BEGIN)
{
if (!_bus->begin(speed))
{
return false;
}
}
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(20);
digitalWrite(_rst, LOW);
delay(20);
digitalWrite(_rst, HIGH);
delay(20);
}
// display parameter default values
uint8_t comPins;
if ((WIDTH == 128) && (HEIGHT == 64))
{
comPins = 0x12;
_contrast = 0x9F;
_colStart = 0;
_colEnd = 128 - 1;
}
else if ((WIDTH == 128) && (HEIGHT == 32))
{
comPins = 0x02;
_contrast = 0x8F;
_colStart = 0;
_colEnd = 128 - 1;
}
else if ((WIDTH == 96) && (HEIGHT == 16))
{
comPins = 0x02;
_contrast = 0x10;
_colStart = 0;
_colEnd = 96 - 1;
}
else if ((WIDTH == 72) && (HEIGHT == 40))
{
comPins = 0x12;
_contrast = 0x82;
_colStart = 28;
_colEnd = 28 + 72 - 1;
}
else if ((WIDTH == 64) && (HEIGHT == 48))
{
comPins = 0x12;
_contrast = 0x82;
_colStart = 32;
_colEnd = 32 + 64 - 1;
}
else if ((WIDTH == 64) && (HEIGHT == 32))
{
comPins = 0x12;
_contrast = 0x82;
_colStart = 32;
_colEnd = 32 + 64 - 1;
}
else
{
// Other screen varieties -- TBD
comPins = 0x12;
_colStart = 0;
_colEnd = WIDTH - 1;
}
static const uint8_t init_sequence[] = {
BEGIN_WRITE,
WRITE_COMMAND_BYTES, 25,
SSD1306_DISPLAYOFF, // 0xAE
SSD1306_SETCONTRAST, _contrast, // 0x81, contrast
SSD1306_NORMALDISPLAY, // 0xA6
SSD1306_DEACTIVATE_SCROLL, // 0x2E
SSD1306_MEMORYMODE, 0x00, // 0x20, 00 Horizontal addressing mode
SSD1306_SEGREMAPINV, // 0xA1
SSD1306_SETMULTIPLEX, (uint8_t)(HEIGHT - 1), // 0xA8, nn
SSD1306_COMSCANDEC, // 0xC8
SSD1306_SETDISPLAYOFFSET, 0x00, // 0xD3, 00 no offset
SSD1306_SETCOMPINS, comPins, // 0xDA, nn
SSD1306_SETDISPLAYCLOCKDIV, 0x80, // 0xD5, 0x80
SSD1306_SETPRECHARGE, 0x22, // 0xd9, 0x22
SSD1306_SETVCOMDETECT, 0x40, // 0xDB, 0x40
SSD1306_CHARGEPUMP, 0x14, // 0x8D, 0x14
SSD1306_SETSTARTLINE | 0x0, // 0x40 line #0
SSD1306_DISPLAYALLON_RESUME, // 0xA4
END_WRITE,
DELAY, 100,
BEGIN_WRITE,
WRITE_COMMAND_8, SSD1306_DISPLAYON, // 0xAF
END_WRITE};
_bus->batchOperation(init_sequence, sizeof(init_sequence));
return true;
}
void Arduino_SSD1306::setBrightness(uint8_t brightness)
{
_bus->beginWrite();
_bus->writeC8D8(SSD1306_SETCONTRAST, brightness);
_bus->endWrite();
} // setBrightness()
void Arduino_SSD1306::drawBitmap(int16_t x, int16_t y, uint8_t *bitmap, int16_t w, int16_t h, uint16_t /* color */, uint16_t /* bg */)
{
// printf("SSD1306::drawBitmap %d/%d w:%d h:%d\n", x, y, w, h);
uint16_t count = w * ((h + 7) / 8);
// start page sequence
_bus->beginWrite();
uint8_t page_sequence[] = {
SSD1306_PAGEADDR, 0, 0xFF,
SSD1306_COLUMNADDR, _colStart, _colEnd};
_bus->writeCommandBytes(page_sequence, sizeof(page_sequence));
_bus->endWrite();
_bus->beginWrite();
_bus->writeBytes(bitmap, count);
_bus->endWrite();
} // drawBitmap()
void Arduino_SSD1306::drawIndexedBitmap(int16_t, int16_t, uint8_t *, uint16_t *, int16_t, int16_t, int16_t)
{
// println("SSD1306::Not Implemented drawIndexedBitmap()");
}
void Arduino_SSD1306::draw3bitRGBBitmap(int16_t, int16_t, uint8_t *, int16_t, int16_t)
{
// println("SSD1306::Not Implemented draw3bitRGBBitmap()");
}
void Arduino_SSD1306::draw16bitRGBBitmap(int16_t, int16_t, uint16_t *, int16_t, int16_t)
{
// println("SSD1306::Not Implemented draw16bitRGBBitmap()");
}
void Arduino_SSD1306::draw24bitRGBBitmap(int16_t, int16_t, uint8_t *, int16_t, int16_t)
{
// println("SSD1306::Not Implemented draw24bitRGBBitmap()");
}
void Arduino_SSD1306::invertDisplay(bool)
{
// println("SSD1306::Not Implemented invertDisplay()");
}
void Arduino_SSD1306::displayOn(void)
{
_bus->sendCommand(SSD1306_DISPLAYON);
}
void Arduino_SSD1306::displayOff(void)
{
_bus->sendCommand(SSD1306_DISPLAYOFF);
}

View File

@@ -0,0 +1,84 @@
#pragma once
#include "../Arduino_GFX.h"
#include "../databus/Arduino_Wire.h"
/** SSD1306 commands, See Datasheet:
* https://cdn-shop.adafruit.com/datasheets/SSD1306.pdf
**/
#define SSD1306_SETLOWCOLUMN 0x00
#define SSD1306_SETHIGHCOLUMN 0x10
#define SSD1306_MEMORYMODE 0x20
#define SSD1306_COLUMNADDR 0x21
#define SSD1306_PAGEADDR 0x22
#define SSD1306_RIGHT_HORIZONTAL_SCROLL 0x26
#define SSD1306_LEFT_HORIZONTAL_SCROLL 0x27
#define SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL 0x29
#define SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL 0x2A
#define SSD1306_DEACTIVATE_SCROLL 0x2E
#define SSD1306_ACTIVATE_SCROLL 0x2F
#define SSD1306_SETSTARTLINE 0x40
#define SSD1306_SETCONTRAST 0x81
#define SSD1306_CHARGEPUMP 0x8D
#define SSD1306_SEGREMAP 0xA0
#define SSD1306_SEGREMAPINV 0xA1
#define SSD1306_SET_VERTICAL_SCROLL_AREA 0xA3
#define SSD1306_DISPLAYALLON_RESUME 0xA4
#define SSD1306_DISPLAYALLON 0xA5
#define SSD1306_NORMALDISPLAY 0xA6
#define SSD1306_INVERSEDISPLAY 0xA7
#define SSD1306_SETMULTIPLEX 0xA8
#define SSD1306_DISPLAYOFF 0xAE
#define SSD1306_DISPLAYON 0xAF
#define SSD1306_COMSCANINC 0xC0
#define SSD1306_COMSCANDEC 0xC8
#define SSD1306_SETDISPLAYOFFSET 0xD3
#define SSD1306_SETDISPLAYCLOCKDIV 0xD5
#define SSD1306_SETPRECHARGE 0xD9
#define SSD1306_SETCOMPINS 0xDA
#define SSD1306_SETVCOMDETECT 0xDB
#define SSD1306_NOP 0xE3
class Arduino_SSD1306 : public Arduino_G
{
public:
Arduino_SSD1306(Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, int16_t w = 128, int16_t h = 64);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void drawBitmap(int16_t x, int16_t y, uint8_t *bitmap, int16_t w, int16_t h, uint16_t color, uint16_t bg) override;
void drawIndexedBitmap(int16_t x, int16_t y, uint8_t *bitmap, uint16_t *color_index, int16_t w, int16_t h, int16_t x_skip = 0) override;
void draw3bitRGBBitmap(int16_t x, int16_t y, uint8_t *bitmap, int16_t w, int16_t h) override;
void draw16bitRGBBitmap(int16_t x, int16_t y, uint16_t *bitmap, int16_t w, int16_t h) override;
void draw24bitRGBBitmap(int16_t x, int16_t y, uint8_t *bitmap, int16_t w, int16_t h) override;
void invertDisplay(bool);
void displayOn();
void displayOff();
void setBrightness(uint8_t brightness);
protected:
Arduino_DataBus *_bus;
int8_t _rst;
int8_t _pages;
uint8_t _rotation;
uint8_t _contrast;
uint8_t _colStart;
uint8_t _colEnd;
private:
};

View File

@@ -0,0 +1,148 @@
/*
* start rewrite from:
* https://github.com/adafruit/Adafruit-GFX-Library.git
*/
#include "Arduino_SSD1331.h"
#include "SPI.h"
Arduino_SSD1331::Arduino_SSD1331(
Arduino_DataBus *bus, int8_t rst, uint8_t r, int16_t w, int16_t h,
uint8_t col_offset1, uint8_t row_offset1, uint8_t col_offset2, uint8_t row_offset2)
: Arduino_TFT(bus, rst, r, false, w, h, col_offset1, row_offset1, col_offset2, row_offset2)
{
}
bool Arduino_SSD1331::begin(int32_t speed)
{
return Arduino_TFT::begin(speed);
}
// Companion code to the above tables. Reads and issues
// a series of LCD commands stored in PROGMEM byte array.
void Arduino_SSD1331::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(SSD1331_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(SSD1331_RST_DELAY);
}
else
{
// Software Rest
}
// Initialization Sequence
_bus->sendCommand(SSD1331_DISPLAYOFF); // 0xAE
_bus->sendCommand(SSD1331_STARTLINE); // 0xA1
_bus->sendCommand(0x0);
_bus->sendCommand(SSD1331_DISPLAYOFFSET); // 0xA2
_bus->sendCommand(0x0);
_bus->sendCommand(SSD1331_NORMALDISPLAY); // 0xA4
_bus->sendCommand(SSD1331_SETMULTIPLEX); // 0xA8
_bus->sendCommand(0x3F); // 0x3F 1/64 duty
_bus->sendCommand(SSD1331_SETMASTER); // 0xAD
_bus->sendCommand(0x8E);
_bus->sendCommand(SSD1331_POWERMODE); // 0xB0
_bus->sendCommand(0x0B);
_bus->sendCommand(SSD1331_PRECHARGE); // 0xB1
_bus->sendCommand(0x31);
_bus->sendCommand(SSD1331_CLOCKDIV); // 0xB3
_bus->sendCommand(0xF0); // 7:4 = Oscillator Frequency, 3:0 = CLK Div Ratio (A[3:0]+1 = 1..16)
_bus->sendCommand(SSD1331_PRECHARGEA); // 0x8A
_bus->sendCommand(0x64);
_bus->sendCommand(SSD1331_PRECHARGEB); // 0x8B
_bus->sendCommand(0x78);
_bus->sendCommand(SSD1331_PRECHARGEA); // 0x8C
_bus->sendCommand(0x64);
_bus->sendCommand(SSD1331_PRECHARGELEVEL); // 0xBB
_bus->sendCommand(0x3A);
_bus->sendCommand(SSD1331_VCOMH); // 0xBE
_bus->sendCommand(0x3E);
_bus->sendCommand(SSD1331_MASTERCURRENT); // 0x87
_bus->sendCommand(0x06);
_bus->sendCommand(SSD1331_CONTRASTA); // 0x81
_bus->sendCommand(0x91);
_bus->sendCommand(SSD1331_CONTRASTB); // 0x82
_bus->sendCommand(0x50);
_bus->sendCommand(SSD1331_CONTRASTC); // 0x83
_bus->sendCommand(0x7D);
_bus->sendCommand(SSD1331_DISPLAYON); //--turn on oled panel
}
void Arduino_SSD1331::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
if ((x != _currentX) || (w != _currentW))
{
uint8_t cmd = (_rotation & 0x01) ? SSD1331_SETROW : SSD1331_SETCOLUMN;
uint8_t x_start = x + _xStart, x_end = x + w - 1 + _xStart;
_bus->writeCommand(cmd); // Column addr set
_bus->writeCommand(x_start); // XSTART
_bus->writeCommand(x_end); // XEND
_currentX = x;
_currentW = w;
}
if ((y != _currentY) || (h != _currentH))
{
uint8_t cmd = (_rotation & 0x01) ? SSD1331_SETCOLUMN : SSD1331_SETROW;
uint8_t y_start = y + _yStart, y_end = y + h - 1 + _yStart;
_bus->writeCommand(cmd); // Row addr set
_bus->writeCommand(y_start); // YSTART
_bus->writeCommand(y_end); // YEND
_currentY = y;
_currentH = h;
}
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_SSD1331::setRotation(uint8_t r)
{
Arduino_TFT::setRotation(r);
switch (_rotation)
{
case 1:
r = 0b01110001;
break;
case 2:
r = 0b01100000;
break;
case 3:
r = 0b01100011;
break;
default: // case 0:
r = 0b01110010;
break;
}
_bus->beginWrite();
_bus->writeCommand(SSD1331_SETREMAP);
_bus->writeCommand(r);
_bus->endWrite();
}
void Arduino_SSD1331::invertDisplay(bool i)
{
_bus->sendCommand(i ? SSD1331_INVERTDISPLAY : SSD1331_NORMALDISPLAY);
}
void Arduino_SSD1331::displayOn(void)
{
_bus->sendCommand(SSD1331_DISPLAYALLON);
}
void Arduino_SSD1331::displayOff(void)
{
_bus->sendCommand(SSD1331_DISPLAYALLOFF);
}

View File

@@ -0,0 +1,66 @@
/*
* start rewrite from:
* https://github.com/adafruit/Adafruit-GFX-Library.git
*/
#ifndef _ARDUINO_SSD1331_H_
#define _ARDUINO_SSD1331_H_
#include "../Arduino_GFX.h"
#include "../Arduino_TFT.h"
#define SSD1331_TFTWIDTH 96 ///< SSD1331 max TFT width
#define SSD1331_TFTHEIGHT 64 ///< SSD1331 max TFT height
#define SSD1331_RST_DELAY 120
#define SSD1331_DRAWLINE 0x21
#define SSD1331_DRAWRECT 0x22
#define SSD1331_FILL 0x26
#define SSD1331_SETCOLUMN 0x15
#define SSD1331_SETROW 0x75
#define SSD1331_CONTRASTA 0x81
#define SSD1331_CONTRASTB 0x82
#define SSD1331_CONTRASTC 0x83
#define SSD1331_MASTERCURRENT 0x87
#define SSD1331_SETREMAP 0xA0
#define SSD1331_STARTLINE 0xA1
#define SSD1331_DISPLAYOFFSET 0xA2
#define SSD1331_NORMALDISPLAY 0xA4
#define SSD1331_DISPLAYALLON 0xA5
#define SSD1331_DISPLAYALLOFF 0xA6
#define SSD1331_INVERTDISPLAY 0xA7
#define SSD1331_SETMULTIPLEX 0xA8
#define SSD1331_SETMASTER 0xAD
#define SSD1331_DISPLAYOFF 0xAE
#define SSD1331_DISPLAYON 0xAF
#define SSD1331_POWERMODE 0xB0
#define SSD1331_PRECHARGE 0xB1
#define SSD1331_CLOCKDIV 0xB3
#define SSD1331_PRECHARGEA 0x8A
#define SSD1331_PRECHARGEB 0x8B
#define SSD1331_PRECHARGEC 0x8C
#define SSD1331_PRECHARGELEVEL 0xBB
#define SSD1331_VCOMH 0xBE
class Arduino_SSD1331 : public Arduino_TFT
{
public:
Arduino_SSD1331(
Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0,
int16_t w = SSD1331_TFTWIDTH, int16_t h = SSD1331_TFTHEIGHT,
uint8_t col_offset1 = 0, uint8_t row_offset1 = 0, uint8_t col_offset2 = 0, uint8_t row_offset2 = 0);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void setRotation(uint8_t r) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
protected:
void tftInit() override;
private:
};
#endif

View File

@@ -0,0 +1,140 @@
/*
* start rewrite from:
* https://github.com/adafruit/Adafruit-GFX-Library.git
* https://github.com/adafruit/Adafruit-SSD1351-library.git
*/
#include "Arduino_SSD1351.h"
#include "SPI.h"
Arduino_SSD1351::Arduino_SSD1351(
Arduino_DataBus *bus, int8_t rst, uint8_t r, int16_t w, int16_t h,
uint8_t col_offset1, uint8_t row_offset1, uint8_t col_offset2, uint8_t row_offset2)
: Arduino_TFT(bus, rst, r, false, w, h, col_offset1, row_offset1, col_offset2, row_offset2)
{
}
bool Arduino_SSD1351::begin(int32_t speed)
{
#if defined(ESP8266) || defined(ESP32)
if (speed == GFX_NOT_DEFINED)
{
speed = 16000000UL;
}
// Teensy 4.x
#elif defined(__IMXRT1052__) || defined(__IMXRT1062__)
if (speed == GFX_NOT_DEFINED)
{
speed = 16000000UL;
}
#endif
_override_datamode = SPI_MODE0; // always SPI_MODE0
return Arduino_TFT::begin(speed);
}
// Companion code to the above tables. Reads and issues
// a series of LCD commands stored in PROGMEM byte array.
void Arduino_SSD1351::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(SSD1351_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(SSD1351_RST_DELAY);
}
else
{
// Software Rest
}
_bus->sendCommand(SSD1351_COMMANDLOCK); // set command lock
_bus->sendData(0x12);
_bus->sendCommand(SSD1351_COMMANDLOCK); // set command lock
_bus->sendData(0xB1);
_bus->sendCommand(SSD1351_DISPLAYOFF); // Display off
_bus->sendCommand(SSD1351_DISPLAYOFFSET); // 0xA2
_bus->sendData(0x0);
_bus->sendCommand(SSD1351_NORMALDISPLAY); // 0xA6
_bus->sendCommand(SSD1351_DISPLAYON); // Main screen turn on
}
void Arduino_SSD1351::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
uint8_t cmd;
if ((x != _currentX) || (w != _currentW))
{
cmd = (_rotation & 0x01) ? SSD1351_SETROW : SSD1351_SETCOLUMN;
uint8_t x_start = x + _xStart, x_end = x + w - 1 + _xStart;
_bus->writeCommand(cmd); // Column addr set
_bus->write(x_start); // XSTART
_bus->write(x_end); // XEND
_currentX = x;
_currentW = w;
}
if ((y != _currentY) || (h != _currentH))
{
cmd = (_rotation & 0x01) ? SSD1351_SETCOLUMN : SSD1351_SETROW;
uint8_t y_start = y + _yStart, y_end = y + h - 1 + _yStart;
_bus->writeCommand(cmd); // Row addr set
_bus->write(y_start); // YSTART
_bus->write(y_end); // YEND
_currentY = y;
_currentH = h;
}
_bus->writeCommand(SSD1351_WRITERAM); // write to RAM
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_SSD1351::setRotation(uint8_t r)
{
Arduino_TFT::setRotation(r);
uint8_t startline = (_rotation < 2) ? HEIGHT : 0;
switch (_rotation)
{
case 1:
r = 0b01110111;
break;
case 2:
r = 0b01100110;
break;
case 3:
r = 0b01100101;
break;
default: // case 0:
r = 0b01110100;
break;
}
_bus->beginWrite();
_bus->writeC8D8(SSD1351_SETREMAP, r);
_bus->writeC8D8(SSD1351_STARTLINE, startline);
_bus->endWrite();
}
void Arduino_SSD1351::invertDisplay(bool i)
{
_bus->sendCommand(i ? SSD1351_INVERTDISPLAY : SSD1351_NORMALDISPLAY);
}
void Arduino_SSD1351::displayOn(void)
{
_bus->sendCommand(SSD1351_DISPLAYALLON);
}
void Arduino_SSD1351::displayOff(void)
{
_bus->sendCommand(SSD1351_DISPLAYALLOFF);
}

View File

@@ -0,0 +1,70 @@
/*
* start rewrite from:
* https://github.com/adafruit/Adafruit-GFX-Library.git
* https://github.com/adafruit/Adafruit-SSD1351-library.git
*/
#ifndef _ARDUINO_SSD1351_H_
#define _ARDUINO_SSD1351_H_
#include "../Arduino_GFX.h"
#include "../Arduino_TFT.h"
#define SSD1351_TFTWIDTH 128 ///< SSD1351 max TFT width
#define SSD1351_TFTHEIGHT 128 ///< SSD1351 max TFT height
#define SSD1351_RST_DELAY 120
#define SSD1351_SETCOLUMN 0x15
#define SSD1351_SETROW 0x75
#define SSD1351_WRITERAM 0x5C
#define SSD1351_READRAM 0x5D
#define SSD1351_SETREMAP 0xA0
#define SSD1351_STARTLINE 0xA1
#define SSD1351_DISPLAYOFFSET 0xA2
#define SSD1351_DISPLAYALLOFF 0xA4
#define SSD1351_DISPLAYALLON 0xA5
#define SSD1351_NORMALDISPLAY 0xA6
#define SSD1351_INVERTDISPLAY 0xA7
#define SSD1351_FUNCTIONSELECT 0xAB
#define SSD1351_DISPLAYOFF 0xAE
#define SSD1351_DISPLAYON 0xAF
#define SSD1351_PRECHARGE 0xB1
#define SSD1351_DISPLAYENHANCE 0xB2
#define SSD1351_CLOCKDIV 0xB3
#define SSD1351_SETVSL 0xB4
#define SSD1351_SETGPIO 0xB5
#define SSD1351_PRECHARGE2 0xB6
#define SSD1351_SETGRAY 0xB8
#define SSD1351_USELUT 0xB9
#define SSD1351_PRECHARGELEVEL 0xBB
#define SSD1351_VCOMH 0xBE
#define SSD1351_CONTRASTABC 0xC1
#define SSD1351_CONTRASTMASTER 0xC7
#define SSD1351_MUXRATIO 0xCA
#define SSD1351_COMMANDLOCK 0xFD
#define SSD1351_HORIZSCROLL 0x96
#define SSD1351_STOPSCROLL 0x9E
#define SSD1351_STARTSCROLL 0x9F
class Arduino_SSD1351 : public Arduino_TFT
{
public:
Arduino_SSD1351(
Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0,
int16_t w = SSD1351_TFTWIDTH, int16_t h = SSD1351_TFTHEIGHT,
uint8_t col_offset1 = 0, uint8_t row_offset1 = 0, uint8_t col_offset2 = 0, uint8_t row_offset2 = 0);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void setRotation(uint8_t r) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
protected:
void tftInit() override;
private:
};
#endif

View File

@@ -0,0 +1,138 @@
/*
* start rewrite from:
* https://github.com/adafruit/Adafruit-GFX-Library.git
*/
#include "Arduino_ST7735.h"
#include "SPI.h"
Arduino_ST7735::Arduino_ST7735(
Arduino_DataBus *bus, int8_t rst, uint8_t r,
bool ips, int16_t w, int16_t h,
uint8_t col_offset1, uint8_t row_offset1, uint8_t col_offset2, uint8_t row_offset2,
bool bgr)
: Arduino_TFT(bus, rst, r, ips, w, h, col_offset1, row_offset1, col_offset2, row_offset2), _bgr(bgr)
{
}
bool Arduino_ST7735::begin(int32_t speed)
{
#if defined(ESP8266) || defined(ESP32)
if (speed == GFX_NOT_DEFINED)
{
speed = 27000000UL; // ST7735 Maximum supported speed
}
// Teensy 4.x
#elif defined(__IMXRT1052__) || defined(__IMXRT1062__)
if (speed == GFX_NOT_DEFINED)
{
speed = 27000000UL; // ST7735 Maximum supported speed
}
#endif
_override_datamode = SPI_MODE0; // always use SPI_MODE0
return Arduino_TFT::begin(speed);
}
// Companion code to the above tables. Reads and issues
// a series of LCD commands stored in PROGMEM byte array.
void Arduino_ST7735::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(ST7735_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(ST7735_RST_DELAY);
}
else
{
// Software Rest
_bus->sendCommand(ST7735_SWRESET); // 1: Software reset
delay(ST7735_RST_DELAY);
}
_bus->batchOperation(st7735_init_operations, sizeof(st7735_init_operations));
invertDisplay(false);
}
void Arduino_ST7735::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
if ((x != _currentX) || (w != _currentW))
{
int16_t x_start = x + _xStart, x_end = x + w - 1 + _xStart;
_bus->writeCommand(ST7735_CASET); // Column addr set
_bus->write(x_start >> 8);
_bus->write(x_start & 0xFF); // XSTART
_bus->write(x_end >> 8);
_bus->write(x_end & 0xFF); // XEND
_currentX = x;
_currentW = w;
}
if ((y != _currentY) || (h != _currentH))
{
int16_t y_start = y + _yStart, y_end = y + h - 1 + _yStart;
_bus->writeCommand(ST7735_RASET); // Row addr set
_bus->write(y_start >> 8);
_bus->write(y_start & 0xFF); // YSTART
_bus->write(y_end >> 8);
_bus->write(y_end & 0xFF); // YEND
_currentY = y;
_currentH = h;
}
_bus->writeCommand(ST7735_RAMWR); // write to RAM
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_ST7735::setRotation(uint8_t r)
{
Arduino_TFT::setRotation(r);
switch (_rotation)
{
case 1:
r = ST7735_MADCTL_MY | ST7735_MADCTL_MV | (_bgr ? ST7735_MADCTL_BGR : ST7735_MADCTL_RGB);
break;
case 2:
r = (_bgr ? ST7735_MADCTL_BGR : ST7735_MADCTL_RGB);
break;
case 3:
r = ST7735_MADCTL_MX | ST7735_MADCTL_MV | (_bgr ? ST7735_MADCTL_BGR : ST7735_MADCTL_RGB);
break;
default: // case 0:
r = ST7735_MADCTL_MX | ST7735_MADCTL_MY | (_bgr ? ST7735_MADCTL_BGR : ST7735_MADCTL_RGB);
break;
}
_bus->beginWrite();
_bus->writeC8D8(ST7735_MADCTL, r);
_bus->endWrite();
}
void Arduino_ST7735::invertDisplay(bool i)
{
_bus->sendCommand((_ips ^ i) ? ST7735_INVON : ST7735_INVOFF);
}
void Arduino_ST7735::displayOn(void)
{
_bus->sendCommand(ST7735_SLPOUT);
delay(ST7735_SLPOUT_DELAY);
}
void Arduino_ST7735::displayOff(void)
{
_bus->sendCommand(ST7735_SLPIN);
delay(ST7735_SLPIN_DELAY);
}

View File

@@ -0,0 +1,133 @@
/*
* start rewrite from:
* https://github.com/adafruit/Adafruit-GFX-Library.git
*/
#ifndef _ARDUINO_ST7735_H_
#define _ARDUINO_ST7735_H_
#include "../Arduino_GFX.h"
#include "../Arduino_TFT.h"
#define ST7735_TFTWIDTH 128
#define ST7735_TFTHEIGHT 160
#define ST7735_RST_DELAY 50 ///< delay ms wait for reset finish
#define ST7735_SLPIN_DELAY 120 ///< delay ms wait for sleep in finish
#define ST7735_SLPOUT_DELAY 120 ///< delay ms wait for sleep out finish
#define ST7735_NOP 0x00
#define ST7735_SWRESET 0x01
#define ST7735_RDDID 0x04
#define ST7735_RDDST 0x09
#define ST7735_SLPIN 0x10
#define ST7735_SLPOUT 0x11
#define ST7735_PTLON 0x12
#define ST7735_NORON 0x13
#define ST7735_INVOFF 0x20
#define ST7735_INVON 0x21
#define ST7735_DISPOFF 0x28
#define ST7735_DISPON 0x29
#define ST7735_CASET 0x2A
#define ST7735_RASET 0x2B
#define ST7735_RAMWR 0x2C
#define ST7735_RAMRD 0x2E
#define ST7735_PTLAR 0x30
#define ST7735_COLMOD 0x3A
#define ST7735_MADCTL 0x36
#define ST7735_FRMCTR1 0xB1
#define ST7735_FRMCTR2 0xB2
#define ST7735_FRMCTR3 0xB3
#define ST7735_INVCTR 0xB4
#define ST7735_DISSET5 0xB6
#define ST7735_PWCTR1 0xC0
#define ST7735_PWCTR2 0xC1
#define ST7735_PWCTR3 0xC2
#define ST7735_PWCTR4 0xC3
#define ST7735_PWCTR5 0xC4
#define ST7735_VMCTR1 0xC5
#define ST7735_RDID1 0xDA
#define ST7735_RDID2 0xDB
#define ST7735_RDID3 0xDC
#define ST7735_RDID4 0xDD
#define ST7735_PWCTR6 0xFC
#define ST7735_GMCTRP1 0xE0
#define ST7735_GMCTRN1 0xE1
#define ST7735_MADCTL_MY 0x80
#define ST7735_MADCTL_MX 0x40
#define ST7735_MADCTL_MV 0x20
#define ST7735_MADCTL_ML 0x10
#define ST7735_MADCTL_RGB 0x00
#define ST7735_MADCTL_MH 0x04
#define ST7735_MADCTL_BGR 0x08
static const uint8_t st7735_init_operations[] = {
BEGIN_WRITE,
WRITE_COMMAND_8, ST7735_SLPOUT, // 2: Out of sleep mode, no args, w/delay
END_WRITE,
DELAY, ST7735_SLPOUT_DELAY,
BEGIN_WRITE,
WRITE_C8_D8, ST7735_COLMOD, 0x05, // 3: Set color mode, 16-bit color
WRITE_COMMAND_8, ST7735_GMCTRP1, // Gamma Adjustments (pos. polarity), 16 args:
WRITE_BYTES, 16,
0x09, 0x16, 0x09, 0x20, // (Not entirely necessary, but provides
0x21, 0x1B, 0x13, 0x19, // accurate colors)
0x17, 0x15, 0x1E, 0x2B,
0x04, 0x05, 0x02, 0x0E,
WRITE_COMMAND_8, ST7735_GMCTRN1, // Gamma Adjustments (neg. polarity), 16 args:
WRITE_BYTES, 16,
0x0B, 0x14, 0x08, 0x1E, // (Not entirely necessary, but provides
0x22, 0x1D, 0x18, 0x1E, // accurate colors)
0x1B, 0x1A, 0x24, 0x2B,
0x06, 0x06, 0x02, 0x0F,
END_WRITE,
DELAY, 10,
BEGIN_WRITE,
WRITE_COMMAND_8, ST7735_NORON, // 5: Normal display on, no args, w/delay
END_WRITE,
DELAY, 10,
BEGIN_WRITE,
WRITE_COMMAND_8, ST7735_DISPON, // 6: Main screen turn on, no args, w/delay
END_WRITE};
class Arduino_ST7735 : public Arduino_TFT
{
public:
Arduino_ST7735(
Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0,
bool ips = false, int16_t w = ST7735_TFTWIDTH, int16_t h = ST7735_TFTHEIGHT,
uint8_t col_offset1 = 0, uint8_t row_offset1 = 0, uint8_t col_offset2 = 0, uint8_t row_offset2 = 0,
bool bgr = true);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void setRotation(uint8_t r) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
protected:
void tftInit() override;
bool _bgr;
private:
};
#endif

View File

@@ -0,0 +1,131 @@
/*
* start rewrite from:
* https://github.com/adafruit/Adafruit-GFX-Library.git
* https://github.com/ananevilya/Arduino-ST7789-Library.git
*/
#include "Arduino_ST7789.h"
#include "SPI.h"
Arduino_ST7789::Arduino_ST7789(
Arduino_DataBus *bus, int8_t rst, uint8_t r,
bool ips, int16_t w, int16_t h,
uint8_t col_offset1, uint8_t row_offset1, uint8_t col_offset2, uint8_t row_offset2)
: Arduino_TFT(bus, rst, r, ips, w, h, col_offset1, row_offset1, col_offset2, row_offset2)
{
}
bool Arduino_ST7789::begin(int32_t speed)
{
#if defined(ESP32) || defined(ARDUINO_ARCH_NRF52840)
_override_datamode = SPI_MODE3;
#elif defined(ESP8266)
_override_datamode = SPI_MODE2;
#endif
return Arduino_TFT::begin(speed);
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_ST7789::setRotation(uint8_t r)
{
Arduino_TFT::setRotation(r);
switch (_rotation)
{
case 1:
r = ST7789_MADCTL_MX | ST7789_MADCTL_MV | ST7789_MADCTL_RGB;
break;
case 2:
r = ST7789_MADCTL_MX | ST7789_MADCTL_MY | ST7789_MADCTL_RGB;
break;
case 3:
r = ST7789_MADCTL_MY | ST7789_MADCTL_MV | ST7789_MADCTL_RGB;
break;
case 4:
r = ST7789_MADCTL_MX | ST7789_MADCTL_RGB;
break;
case 5:
r = ST7789_MADCTL_MX | ST7789_MADCTL_MY | ST7789_MADCTL_MV | ST7789_MADCTL_RGB;
break;
case 6:
r = ST7789_MADCTL_MY | ST7789_MADCTL_RGB;
break;
case 7:
r = ST7789_MADCTL_MV | ST7789_MADCTL_RGB;
break;
default: // case 0:
r = ST7789_MADCTL_RGB;
break;
}
_bus->beginWrite();
_bus->writeC8D8(ST7789_MADCTL, r);
_bus->endWrite();
}
void Arduino_ST7789::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
if ((x != _currentX) || (w != _currentW))
{
_currentX = x;
_currentW = w;
x += _xStart;
_bus->writeC8D16D16(ST7789_CASET, x, x + w - 1);
}
if ((y != _currentY) || (h != _currentH))
{
_currentY = y;
_currentH = h;
y += _yStart;
_bus->writeC8D16D16(ST7789_RASET, y, y + h - 1);
}
_bus->writeCommand(ST7789_RAMWR); // write to RAM
}
void Arduino_ST7789::invertDisplay(bool i)
{
_bus->sendCommand((_ips ^ i) ? ST7789_INVON : ST7789_INVOFF);
}
void Arduino_ST7789::displayOn(void)
{
_bus->sendCommand(ST7789_SLPOUT);
delay(ST7789_SLPOUT_DELAY);
}
void Arduino_ST7789::displayOff(void)
{
_bus->sendCommand(ST7789_SLPIN);
delay(ST7789_SLPIN_DELAY);
}
// Companion code to the above tables. Reads and issues
// a series of LCD commands stored in PROGMEM byte array.
void Arduino_ST7789::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(ST7789_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(ST7789_RST_DELAY);
}
// else
// {
// Software Rest
_bus->sendCommand(ST7789_SWRESET);
delay(ST7789_RST_DELAY);
// }
_bus->batchOperation(st7789_init_operations, sizeof(st7789_init_operations));
invertDisplay(false);
}

View File

@@ -0,0 +1,144 @@
#pragma once
/*
* start rewrite from:
* https://github.com/adafruit/Adafruit-GFX-Library.git
* https://github.com/ananevilya/Arduino-ST7789-Library.git
*/
#include "../Arduino_GFX.h"
#include "../Arduino_TFT.h"
#define ST7789_TFTWIDTH 240
#define ST7789_TFTHEIGHT 320
#define ST7789_RST_DELAY 120 ///< delay ms wait for reset finish
#define ST7789_SLPIN_DELAY 120 ///< delay ms wait for sleep in finish
#define ST7789_SLPOUT_DELAY 120 ///< delay ms wait for sleep out finish
#define ST7789_NOP 0x00
#define ST7789_SWRESET 0x01
#define ST7789_RDDID 0x04
#define ST7789_RDDST 0x09
#define ST7789_SLPIN 0x10
#define ST7789_SLPOUT 0x11
#define ST7789_PTLON 0x12
#define ST7789_NORON 0x13
#define ST7789_INVOFF 0x20
#define ST7789_INVON 0x21
#define ST7789_DISPOFF 0x28
#define ST7789_DISPON 0x29
#define ST7789_CASET 0x2A
#define ST7789_RASET 0x2B
#define ST7789_RAMWR 0x2C
#define ST7789_RAMRD 0x2E
#define ST7789_PTLAR 0x30
#define ST7789_COLMOD 0x3A
#define ST7789_MADCTL 0x36
#define ST7789_MADCTL_MY 0x80
#define ST7789_MADCTL_MX 0x40
#define ST7789_MADCTL_MV 0x20
#define ST7789_MADCTL_ML 0x10
#define ST7789_MADCTL_RGB 0x00
#define ST7789_RDID1 0xDA
#define ST7789_RDID2 0xDB
#define ST7789_RDID3 0xDC
#define ST7789_RDID4 0xDD
static const uint8_t st7789_init_operations[] = {
BEGIN_WRITE,
WRITE_COMMAND_8, ST7789_SLPOUT, // 2: Out of sleep mode, no args, w/delay
END_WRITE,
DELAY, ST7789_SLPOUT_DELAY,
BEGIN_WRITE,
WRITE_C8_D8, ST7789_COLMOD, 0x55, // 3: Set color mode, 16-bit color
WRITE_C8_D8, 0x36, 0x00,
WRITE_C8_BYTES, 0xB0, 2,
0x00, 0xF0, // 0xF0 MSB first, 0xF8 LSB first
WRITE_C8_BYTES, 0xB2, 5,
0x0C, 0x0C, 0x00, 0x33, 0x33,
WRITE_C8_D8, 0xB7, 0x35,
WRITE_C8_D8, 0xBB, 0x19,
WRITE_C8_D8, 0xC0, 0x2C,
WRITE_C8_D8, 0xC2, 0x01,
WRITE_C8_D8, 0xC3, 0x12,
WRITE_C8_D8, 0xC4, 0x20,
WRITE_C8_D8, 0xC6, 0x0F,
WRITE_C8_D16, 0xD0, 0xA4, 0xA1,
WRITE_C8_BYTES, 0xE0, 14,
0b11110000, // V63P3, V63P2, V63P1, V63P0, V0P3, V0P2, V0P1, V0P0
0b00001001, // 0, 0, V1P5, V1P4, V1P3, V1P2, V1P1, V1P0
0b00010011, // 0, 0, V2P5, V2P4, V2P3, V2P2, V2P1, V2P0
0b00010010, // 0, 0, 0, V4P4, V4P3, V4P2, V4P1, V4P0
0b00010010, // 0, 0, 0, V6P4, V6P3, V6P2, V6P1, V6P0
0b00101011, // 0, 0, J0P1, J0P0, V13P3, V13P2, V13P1, V13P0
0b00111100, // 0, V20P6, V20P5, V20P4, V20P3, V20P2, V20P1, V20P0
0b01000100, // 0, V36P2, V36P1, V36P0, 0, V27P2, V27P1, V27P0
0b01001011, // 0, V43P6, V43P5, V43P4, V43P3, V43P2, V43P1, V43P0
0b00011011, // 0, 0, J1P1, J1P0, V50P3, V50P2, V50P1, V50P0
0b00011000, // 0, 0, 0, V57P4, V57P3, V57P2, V57P1, V57P0
0b00010111, // 0, 0, 0, V59P4, V59P3, V59P2, V59P1, V59P0
0b00011101, // 0, 0, V61P5, V61P4, V61P3, V61P2, V61P1, V61P0
0b00100001, // 0, 0, V62P5, V62P4, V62P3, V62P2, V62P1, V62P0
WRITE_C8_BYTES, 0XE1, 14,
0b11110000, // V63P3, V63P2, V63P1, V63P0, V0P3, V0P2, V0P1, V0P0
0b00001001, // 0, 0, V1P5, V1P4, V1P3, V1P2, V1P1, V1P0
0b00010011, // 0, 0, V2P5, V2P4, V2P3, V2P2, V2P1, V2P0
0b00001100, // 0, 0, 0, V4N4, V4N3, V4N2, V4N1, V4N0
0b00001101, // 0, 0, 0, V6N4, V6N3, V6N2, V6N1, V6N0
0b00100111, // 0, 0, J0N1, J0N0, V13N3, V13N2, V13N1, V13N0
0b00111011, // 0, V20N6, V20N5, V20N4, V20N3, V20N2, V20N1, V20N0
0b01000100, // 0, V36N2, V36N1, V36N0, 0, V27N2, V27N1, V27N0
0b01001101, // 0, V43N6, V43N5, V43N4, V43N3, V43N2, V43N1, V43N0
0b00001011, // 0, 0, J1N1, J1N0, V50N3, V50N2, V50N1, V50N0
0b00010111, // 0, 0, 0, V57N4, V57N3, V57N2, V57N1, V57N0
0b00010111, // 0, 0, 0, V59N4, V59N3, V59N2, V59N1, V59N0
0b00011101, // 0, 0, V61N5, V61N4, V61N3, V61N2, V61N1, V61N0
0b00100001, // 0, 0, V62N5, V62N4, V62N3, V62N2, V62N1, V62N0
WRITE_COMMAND_8, ST7789_NORON, // 4: Normal display on, no args, w/delay
END_WRITE,
DELAY, 10,
BEGIN_WRITE,
WRITE_COMMAND_8, ST7789_DISPON, // 5: Main screen turn on, no args, w/delay
END_WRITE};
class Arduino_ST7789 : public Arduino_TFT
{
public:
Arduino_ST7789(
Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0,
bool ips = false, int16_t w = ST7789_TFTWIDTH, int16_t h = ST7789_TFTHEIGHT,
uint8_t col_offset1 = 0, uint8_t row_offset1 = 0, uint8_t col_offset2 = 0, uint8_t row_offset2 = 0);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void setRotation(uint8_t r) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
protected:
void tftInit() override;
private:
};

View File

@@ -0,0 +1,109 @@
#include "Arduino_ST77916.h"
Arduino_ST77916::Arduino_ST77916(
Arduino_DataBus *bus, int8_t rst, uint8_t r,
bool ips, int16_t w, int16_t h,
uint8_t col_offset1, uint8_t row_offset1, uint8_t col_offset2, uint8_t row_offset2,
const uint8_t *init_operations, size_t init_operations_len)
: Arduino_TFT(bus, rst, r, ips, w, h, col_offset1, row_offset1, col_offset2, row_offset2),
_init_operations(init_operations), _init_operations_len(init_operations_len)
{
}
bool Arduino_ST77916::begin(int32_t speed)
{
return Arduino_TFT::begin(speed);
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_ST77916::setRotation(uint8_t r)
{
Arduino_TFT::setRotation(r);
switch (_rotation)
{
case 1:
r = ST77916_MADCTL_MX | ST77916_MADCTL_MV | ST77916_MADCTL_RGB;
break;
case 2:
r = ST77916_MADCTL_MX | ST77916_MADCTL_MY | ST77916_MADCTL_RGB;
break;
case 3:
r = ST77916_MADCTL_MY | ST77916_MADCTL_MV | ST77916_MADCTL_RGB;
break;
default: // case 0:
r = ST77916_MADCTL_RGB;
break;
}
_bus->beginWrite();
_bus->writeC8D8(ST77916_MADCTL, r);
_bus->endWrite();
}
void Arduino_ST77916::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
if ((x != _currentX) || (w != _currentW))
{
_currentX = x;
_currentW = w;
x += _xStart;
_bus->writeC8D16D16(ST77916_CASET, x, x + w - 1);
}
if ((y != _currentY) || (h != _currentH))
{
_currentY = y;
_currentH = h;
y += _yStart;
_bus->writeC8D16D16(ST77916_RASET, y, y + h - 1);
}
_bus->writeCommand(ST77916_RAMWR); // write to RAM
}
void Arduino_ST77916::invertDisplay(bool i)
{
_bus->sendCommand((_ips ^ i) ? ST77916_INVON : ST77916_INVOFF);
}
void Arduino_ST77916::displayOn(void)
{
_bus->sendCommand(ST77916_SLPOUT);
delay(ST77916_SLPOUT_DELAY);
}
void Arduino_ST77916::displayOff(void)
{
_bus->sendCommand(ST77916_SLPIN);
delay(ST77916_SLPIN_DELAY);
}
// Companion code to the above tables. Reads and issues
// a series of LCD commands stored in PROGMEM byte array.
void Arduino_ST77916::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(ST77916_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(ST77916_RST_DELAY);
}
else
{
// Software Rest
_bus->sendCommand(ST77916_SWRESET);
delay(ST77916_RST_DELAY);
}
_bus->batchOperation(_init_operations, _init_operations_len);
invertDisplay(false);
}

View File

@@ -0,0 +1,569 @@
#ifndef _ARDUINO_ST77916_H_
#define _ARDUINO_ST77916_H_
#include "../Arduino_GFX.h"
#include "../Arduino_TFT.h"
#define ST77916_TFTWIDTH 360
#define ST77916_TFTHEIGHT 360
#define ST77916_RST_DELAY 120 ///< delay ms wait for reset finish
#define ST77916_SLPIN_DELAY 120 ///< delay ms wait for sleep in finish
#define ST77916_SLPOUT_DELAY 120 ///< delay ms wait for sleep out finish
#define ST77916_NOP 0x00
#define ST77916_SWRESET 0x01
#define ST77916_RDDID 0x04
#define ST77916_RDDST 0x09
#define ST77916_SLPIN 0x10
#define ST77916_SLPOUT 0x11
#define ST77916_PTLON 0x12
#define ST77916_NORON 0x13
#define ST77916_INVOFF 0x20
#define ST77916_INVON 0x21
#define ST77916_DISPOFF 0x28
#define ST77916_DISPON 0x29
#define ST77916_CASET 0x2A
#define ST77916_RASET 0x2B
#define ST77916_RAMWR 0x2C
#define ST77916_RAMRD 0x2E
#define ST77916_PTLAR 0x30
#define ST77916_COLMOD 0x3A
#define ST77916_MADCTL 0x36
#define ST77916_MADCTL_MY 0x80
#define ST77916_MADCTL_MX 0x40
#define ST77916_MADCTL_MV 0x20
#define ST77916_MADCTL_ML 0x10
#define ST77916_MADCTL_RGB 0x00
#define ST77916_MADCTL_BGR 0x08
#define ST77916_MADCTL_MH 0x04
#define ST77916_RDID1 0xDA
#define ST77916_RDID2 0xDB
#define ST77916_RDID3 0xDC
#define ST77916_RDID4 0xDD
static const uint8_t st77916_150_init_operations[] = {
BEGIN_WRITE,
WRITE_C8_D8, 0xF0, 0x28,
WRITE_C8_D8, 0xF2, 0x28,
WRITE_C8_D8, 0x73, 0xF0,
WRITE_C8_D8, 0x7C, 0xD1,
WRITE_C8_D8, 0x83, 0xE0,
WRITE_C8_D8, 0x84, 0x61,
WRITE_C8_D8, 0xF2, 0x82,
WRITE_C8_D8, 0xF0, 0x00,
WRITE_C8_D8, 0xF0, 0x01,
WRITE_C8_D8, 0xF1, 0x01,
WRITE_C8_D8, 0xB0, 0x69,
WRITE_C8_D8, 0xB1, 0x4A,
WRITE_C8_D8, 0xB2, 0x2F,
WRITE_C8_D8, 0xB3, 0x01,
WRITE_C8_D8, 0xB4, 0x69,
WRITE_C8_D8, 0xB5, 0x45,
WRITE_C8_D8, 0xB6, 0xAB,
WRITE_C8_D8, 0xB7, 0x41,
WRITE_C8_D8, 0xB8, 0x86,
WRITE_C8_D8, 0xB9, 0x15,
WRITE_C8_D8, 0xBA, 0x00,
WRITE_C8_D8, 0xBB, 0x08,
WRITE_C8_D8, 0xBC, 0x08,
WRITE_C8_D8, 0xBD, 0x00,
WRITE_C8_D8, 0xBE, 0x00,
WRITE_C8_D8, 0xBF, 0x07,
WRITE_C8_D8, 0xC0, 0x80,
WRITE_C8_D8, 0xC1, 0x10,
WRITE_C8_D8, 0xC2, 0x37,
WRITE_C8_D8, 0xC3, 0x80,
WRITE_C8_D8, 0xC4, 0x10,
WRITE_C8_D8, 0xC5, 0x37,
WRITE_C8_D8, 0xC6, 0xA9,
WRITE_C8_D8, 0xC7, 0x41,
WRITE_C8_D8, 0xC8, 0x01,
WRITE_C8_D8, 0xC9, 0xA9,
WRITE_C8_D8, 0xCA, 0x41,
WRITE_C8_D8, 0xCB, 0x01,
WRITE_C8_D8, 0xCC, 0x7F,
WRITE_C8_D8, 0xCD, 0x7F,
WRITE_C8_D8, 0xCE, 0xFF,
WRITE_C8_D8, 0xD0, 0x91,
WRITE_C8_D8, 0xD1, 0x68,
WRITE_C8_D8, 0xD2, 0x68,
WRITE_C8_D16, 0xF5, 0x00, 0xA5,
WRITE_C8_D8, 0xF1, 0x10,
WRITE_C8_D8, 0xF0, 0x00,
WRITE_C8_D8, 0xF0, 0x02,
WRITE_COMMAND_8, 0xE0,
WRITE_BYTES, 14,
0xF0, 0x10, 0x18, 0x0D,
0x0C, 0x38, 0x3E, 0x44,
0x51, 0x39, 0x15, 0x15,
0x30, 0x34,
WRITE_COMMAND_8, 0xE1,
WRITE_BYTES, 14,
0xF0, 0x0F, 0x17, 0x0D,
0x0B, 0x07, 0x3E, 0x33,
0x51, 0x39, 0x15, 0x15,
0x30, 0x34,
WRITE_C8_D8, 0xF0, 0x10,
WRITE_C8_D8, 0xF3, 0x10,
WRITE_C8_D8, 0xE0, 0x08,
WRITE_C8_D8, 0xE1, 0x00,
WRITE_C8_D8, 0xE2, 0x00,
WRITE_C8_D8, 0xE3, 0x00,
WRITE_C8_D8, 0xE4, 0xE0,
WRITE_C8_D8, 0xE5, 0x06,
WRITE_C8_D8, 0xE6, 0x21,
WRITE_C8_D8, 0xE7, 0x03,
WRITE_C8_D8, 0xE8, 0x05,
WRITE_C8_D8, 0xE9, 0x02,
WRITE_C8_D8, 0xEA, 0xE9,
WRITE_C8_D8, 0xEB, 0x00,
WRITE_C8_D8, 0xEC, 0x00,
WRITE_C8_D8, 0xED, 0x14,
WRITE_C8_D8, 0xEE, 0xFF,
WRITE_C8_D8, 0xEF, 0x00,
WRITE_C8_D8, 0xF8, 0xFF,
WRITE_C8_D8, 0xF9, 0x00,
WRITE_C8_D8, 0xFA, 0x00,
WRITE_C8_D8, 0xFB, 0x30,
WRITE_C8_D8, 0xFC, 0x00,
WRITE_C8_D8, 0xFD, 0x00,
WRITE_C8_D8, 0xFE, 0x00,
WRITE_C8_D8, 0xFF, 0x00,
WRITE_C8_D8, 0x60, 0x40,
WRITE_C8_D8, 0x61, 0x05,
WRITE_C8_D8, 0x62, 0x00,
WRITE_C8_D8, 0x63, 0x42,
WRITE_C8_D8, 0x64, 0xDA,
WRITE_C8_D8, 0x65, 0x00,
WRITE_C8_D8, 0x66, 0x00,
WRITE_C8_D8, 0x67, 0x00,
WRITE_C8_D8, 0x68, 0x00,
WRITE_C8_D8, 0x69, 0x00,
WRITE_C8_D8, 0x6A, 0x00,
WRITE_C8_D8, 0x6B, 0x00,
WRITE_C8_D8, 0x70, 0x40,
WRITE_C8_D8, 0x71, 0x04,
WRITE_C8_D8, 0x72, 0x00,
WRITE_C8_D8, 0x73, 0x42,
WRITE_C8_D8, 0x74, 0xD9,
WRITE_C8_D8, 0x75, 0x00,
WRITE_C8_D8, 0x76, 0x00,
WRITE_C8_D8, 0x77, 0x00,
WRITE_C8_D8, 0x78, 0x00,
WRITE_C8_D8, 0x79, 0x00,
WRITE_C8_D8, 0x7A, 0x00,
WRITE_C8_D8, 0x7B, 0x00,
WRITE_C8_D8, 0x80, 0x48,
WRITE_C8_D8, 0x81, 0x00,
WRITE_C8_D8, 0x82, 0x07,
WRITE_C8_D8, 0x83, 0x02,
WRITE_C8_D8, 0x84, 0xD7,
WRITE_C8_D8, 0x85, 0x04,
WRITE_C8_D8, 0x86, 0x00,
WRITE_C8_D8, 0x87, 0x00,
WRITE_C8_D8, 0x88, 0x48,
WRITE_C8_D8, 0x89, 0x00,
WRITE_C8_D8, 0x8A, 0x09,
WRITE_C8_D8, 0x8B, 0x02,
WRITE_C8_D8, 0x8C, 0xD9,
WRITE_C8_D8, 0x8D, 0x04,
WRITE_C8_D8, 0x8E, 0x00,
WRITE_C8_D8, 0x8F, 0x00,
WRITE_C8_D8, 0x90, 0x48,
WRITE_C8_D8, 0x91, 0x00,
WRITE_C8_D8, 0x92, 0x0B,
WRITE_C8_D8, 0x93, 0x02,
WRITE_C8_D8, 0x94, 0xDB,
WRITE_C8_D8, 0x95, 0x04,
WRITE_C8_D8, 0x96, 0x00,
WRITE_C8_D8, 0x97, 0x00,
WRITE_C8_D8, 0x98, 0x48,
WRITE_C8_D8, 0x99, 0x00,
WRITE_C8_D8, 0x9A, 0x0D,
WRITE_C8_D8, 0x9B, 0x02,
WRITE_C8_D8, 0x9C, 0xDD,
WRITE_C8_D8, 0x9D, 0x04,
WRITE_C8_D8, 0x9E, 0x00,
WRITE_C8_D8, 0x9F, 0x00,
WRITE_C8_D8, 0xA0, 0x48,
WRITE_C8_D8, 0xA1, 0x00,
WRITE_C8_D8, 0xA2, 0x06,
WRITE_C8_D8, 0xA3, 0x02,
WRITE_C8_D8, 0xA4, 0xD6,
WRITE_C8_D8, 0xA5, 0x04,
WRITE_C8_D8, 0xA6, 0x00,
WRITE_C8_D8, 0xA7, 0x00,
WRITE_C8_D8, 0xA8, 0x48,
WRITE_C8_D8, 0xA9, 0x00,
WRITE_C8_D8, 0xAA, 0x08,
WRITE_C8_D8, 0xAB, 0x02,
WRITE_C8_D8, 0xAC, 0xD8,
WRITE_C8_D8, 0xAD, 0x04,
WRITE_C8_D8, 0xAE, 0x00,
WRITE_C8_D8, 0xAF, 0x00,
WRITE_C8_D8, 0xB0, 0x48,
WRITE_C8_D8, 0xB1, 0x00,
WRITE_C8_D8, 0xB2, 0x0A,
WRITE_C8_D8, 0xB3, 0x02,
WRITE_C8_D8, 0xB4, 0xDA,
WRITE_C8_D8, 0xB5, 0x04,
WRITE_C8_D8, 0xB6, 0x00,
WRITE_C8_D8, 0xB7, 0x00,
WRITE_C8_D8, 0xB8, 0x48,
WRITE_C8_D8, 0xB9, 0x00,
WRITE_C8_D8, 0xBA, 0x0C,
WRITE_C8_D8, 0xBB, 0x02,
WRITE_C8_D8, 0xBC, 0xDC,
WRITE_C8_D8, 0xBD, 0x04,
WRITE_C8_D8, 0xBE, 0x00,
WRITE_C8_D8, 0xBF, 0x00,
WRITE_C8_D8, 0xC0, 0x10,
WRITE_C8_D8, 0xC1, 0x47,
WRITE_C8_D8, 0xC2, 0x56,
WRITE_C8_D8, 0xC3, 0x65,
WRITE_C8_D8, 0xC4, 0x74,
WRITE_C8_D8, 0xC5, 0x88,
WRITE_C8_D8, 0xC6, 0x99,
WRITE_C8_D8, 0xC7, 0x01,
WRITE_C8_D8, 0xC8, 0xBB,
WRITE_C8_D8, 0xC9, 0xAA,
WRITE_C8_D8, 0xD0, 0x10,
WRITE_C8_D8, 0xD1, 0x47,
WRITE_C8_D8, 0xD2, 0x56,
WRITE_C8_D8, 0xD3, 0x65,
WRITE_C8_D8, 0xD4, 0x74,
WRITE_C8_D8, 0xD5, 0x88,
WRITE_C8_D8, 0xD6, 0x99,
WRITE_C8_D8, 0xD7, 0x01,
WRITE_C8_D8, 0xD8, 0xBB,
WRITE_C8_D8, 0xD9, 0xAA,
WRITE_C8_D8, 0xF3, 0x01,
WRITE_C8_D8, 0xF0, 0x00,
WRITE_C8_D8, 0x3A, 0x05,
WRITE_C8_D8, 0x35, 0x00,
WRITE_COMMAND_8, 0x21,
WRITE_COMMAND_8, 0x11,
END_WRITE,
DELAY, ST77916_SLPOUT_DELAY,
BEGIN_WRITE,
WRITE_COMMAND_8, 0x29,
WRITE_COMMAND_8, 0x2c,
END_WRITE};
static const uint8_t st77916_180_init_operations[] = {
BEGIN_WRITE,
WRITE_C8_D8, 0xF0, 0x08,
WRITE_C8_D8, 0xF2, 0x08,
WRITE_C8_D8, 0x9B, 0x51,
WRITE_C8_D8, 0x86, 0x53,
WRITE_C8_D8, 0xF2, 0x80,
WRITE_C8_D8, 0xF0, 0x00,
WRITE_C8_D8, 0xF0, 0x01,
WRITE_C8_D8, 0xF1, 0x01,
WRITE_C8_D8, 0xB0, 0x54,
WRITE_C8_D8, 0xB1, 0x3F,
WRITE_C8_D8, 0xB2, 0x2A,
WRITE_C8_D8, 0xB4, 0x46,
WRITE_C8_D8, 0xB5, 0x34,
WRITE_C8_D8, 0xB6, 0xD5,
WRITE_C8_D8, 0xB7, 0x30,
WRITE_C8_D8, 0xBA, 0x00,
WRITE_C8_D8, 0xBB, 0x08,
WRITE_C8_D8, 0xBC, 0x08,
WRITE_C8_D8, 0xBD, 0x00,
WRITE_C8_D8, 0xC0, 0x80,
WRITE_C8_D8, 0xC1, 0x10,
WRITE_C8_D8, 0xC2, 0x37,
WRITE_C8_D8, 0xC3, 0x80,
WRITE_C8_D8, 0xC4, 0x10,
WRITE_C8_D8, 0xC5, 0x37,
WRITE_C8_D8, 0xC6, 0xA9,
WRITE_C8_D8, 0xC7, 0x41,
WRITE_C8_D8, 0xC8, 0x51,
WRITE_C8_D8, 0xC9, 0xA9,
WRITE_C8_D8, 0xCA, 0x41,
WRITE_C8_D8, 0xCB, 0x51,
WRITE_C8_D8, 0xD0, 0x91,
WRITE_C8_D8, 0xD1, 0x68,
WRITE_C8_D8, 0xD2, 0x69,
WRITE_C8_D16, 0xF5, 0x00, 0xA5,
WRITE_C8_D8, 0xDD, 0x3F,
WRITE_C8_D8, 0xDE, 0x3F,
WRITE_C8_D8, 0xF1, 0x10,
WRITE_C8_D8, 0xF0, 0x00,
WRITE_C8_D8, 0xF0, 0x02,
WRITE_COMMAND_8, 0xE0,
WRITE_BYTES, 14,
0x70, 0x09, 0x12, 0x0C,
0x0B, 0x27, 0x38, 0x54,
0x4E, 0x19, 0x15, 0x15,
0x2C, 0x2F,
WRITE_COMMAND_8, 0xE1,
WRITE_BYTES, 14,
0x70, 0x08, 0x11, 0x0C,
0x0B, 0x27, 0x38, 0x43,
0x4C, 0x18, 0x14, 0x14,
0x2B, 0x2D,
WRITE_C8_D8, 0xF0, 0x10,
WRITE_C8_D8, 0xF3, 0x10,
WRITE_C8_D8, 0xE0, 0x08,
WRITE_C8_D8, 0xE1, 0x00,
WRITE_C8_D8, 0xE2, 0x00,
WRITE_C8_D8, 0xE3, 0x00,
WRITE_C8_D8, 0xE4, 0xE0,
WRITE_C8_D8, 0xE5, 0x06,
WRITE_C8_D8, 0xE6, 0x21,
WRITE_C8_D8, 0xE7, 0x00,
WRITE_C8_D8, 0xE8, 0x05,
WRITE_C8_D8, 0xE9, 0x82,
WRITE_C8_D8, 0xEA, 0xDF,
WRITE_C8_D8, 0xEB, 0x89,
WRITE_C8_D8, 0xEC, 0x20,
WRITE_C8_D8, 0xED, 0x14,
WRITE_C8_D8, 0xEE, 0xFF,
WRITE_C8_D8, 0xEF, 0x00,
WRITE_C8_D8, 0xF8, 0xFF,
WRITE_C8_D8, 0xF9, 0x00,
WRITE_C8_D8, 0xFA, 0x00,
WRITE_C8_D8, 0xFB, 0x30,
WRITE_C8_D8, 0xFC, 0x00,
WRITE_C8_D8, 0xFD, 0x00,
WRITE_C8_D8, 0xFE, 0x00,
WRITE_C8_D8, 0xFF, 0x00,
WRITE_C8_D8, 0x60, 0x42,
WRITE_C8_D8, 0x61, 0xE0,
WRITE_C8_D8, 0x62, 0x40,
WRITE_C8_D8, 0x63, 0x40,
WRITE_C8_D8, 0x64, 0x02,
WRITE_C8_D8, 0x65, 0x00,
WRITE_C8_D8, 0x66, 0x40,
WRITE_C8_D8, 0x67, 0x03,
WRITE_C8_D8, 0x68, 0x00,
WRITE_C8_D8, 0x69, 0x00,
WRITE_C8_D8, 0x6A, 0x00,
WRITE_C8_D8, 0x6B, 0x00,
WRITE_C8_D8, 0x70, 0x42,
WRITE_C8_D8, 0x71, 0xE0,
WRITE_C8_D8, 0x72, 0x40,
WRITE_C8_D8, 0x73, 0x40,
WRITE_C8_D8, 0x74, 0x02,
WRITE_C8_D8, 0x75, 0x00,
WRITE_C8_D8, 0x76, 0x40,
WRITE_C8_D8, 0x77, 0x03,
WRITE_C8_D8, 0x78, 0x00,
WRITE_C8_D8, 0x79, 0x00,
WRITE_C8_D8, 0x7A, 0x00,
WRITE_C8_D8, 0x7B, 0x00,
WRITE_C8_D8, 0x80, 0x48,
WRITE_C8_D8, 0x81, 0x00,
WRITE_C8_D8, 0x82, 0x05,
WRITE_C8_D8, 0x83, 0x02,
WRITE_C8_D8, 0x84, 0xDD,
WRITE_C8_D8, 0x85, 0x00,
WRITE_C8_D8, 0x86, 0x00,
WRITE_C8_D8, 0x87, 0x00,
WRITE_C8_D8, 0x88, 0x48,
WRITE_C8_D8, 0x89, 0x00,
WRITE_C8_D8, 0x8A, 0x07,
WRITE_C8_D8, 0x8B, 0x02,
WRITE_C8_D8, 0x8C, 0xDF,
WRITE_C8_D8, 0x8D, 0x00,
WRITE_C8_D8, 0x8E, 0x00,
WRITE_C8_D8, 0x8F, 0x00,
WRITE_C8_D8, 0x90, 0x48,
WRITE_C8_D8, 0x91, 0x00,
WRITE_C8_D8, 0x92, 0x09,
WRITE_C8_D8, 0x93, 0x02,
WRITE_C8_D8, 0x94, 0xE1,
WRITE_C8_D8, 0x95, 0x00,
WRITE_C8_D8, 0x96, 0x00,
WRITE_C8_D8, 0x97, 0x00,
WRITE_C8_D8, 0x98, 0x48,
WRITE_C8_D8, 0x99, 0x00,
WRITE_C8_D8, 0x9A, 0x0B,
WRITE_C8_D8, 0x9B, 0x02,
WRITE_C8_D8, 0x9C, 0xE3,
WRITE_C8_D8, 0x9D, 0x00,
WRITE_C8_D8, 0x9E, 0x00,
WRITE_C8_D8, 0x9F, 0x00,
WRITE_C8_D8, 0xA0, 0x48,
WRITE_C8_D8, 0xA1, 0x00,
WRITE_C8_D8, 0xA2, 0x04,
WRITE_C8_D8, 0xA3, 0x02,
WRITE_C8_D8, 0xA4, 0xDC,
WRITE_C8_D8, 0xA5, 0x00,
WRITE_C8_D8, 0xA6, 0x00,
WRITE_C8_D8, 0xA7, 0x00,
WRITE_C8_D8, 0xA8, 0x48,
WRITE_C8_D8, 0xA9, 0x00,
WRITE_C8_D8, 0xAA, 0x06,
WRITE_C8_D8, 0xAB, 0x02,
WRITE_C8_D8, 0xAC, 0xDE,
WRITE_C8_D8, 0xAD, 0x00,
WRITE_C8_D8, 0xAE, 0x00,
WRITE_C8_D8, 0xAF, 0x00,
WRITE_C8_D8, 0xB0, 0x48,
WRITE_C8_D8, 0xB1, 0x00,
WRITE_C8_D8, 0xB2, 0x08,
WRITE_C8_D8, 0xB3, 0x02,
WRITE_C8_D8, 0xB4, 0xE0,
WRITE_C8_D8, 0xB5, 0x00,
WRITE_C8_D8, 0xB6, 0x00,
WRITE_C8_D8, 0xB7, 0x00,
WRITE_C8_D8, 0xB8, 0x48,
WRITE_C8_D8, 0xB9, 0x00,
WRITE_C8_D8, 0xBA, 0x0A,
WRITE_C8_D8, 0xBB, 0x02,
WRITE_C8_D8, 0xBC, 0xE2,
WRITE_C8_D8, 0xBD, 0x00,
WRITE_C8_D8, 0xBE, 0x00,
WRITE_C8_D8, 0xBF, 0x00,
WRITE_C8_D8, 0xC0, 0x12,
WRITE_C8_D8, 0xC1, 0xAA,
WRITE_C8_D8, 0xC2, 0x65,
WRITE_C8_D8, 0xC3, 0x74,
WRITE_C8_D8, 0xC4, 0x47,
WRITE_C8_D8, 0xC5, 0x56,
WRITE_C8_D8, 0xC6, 0x00,
WRITE_C8_D8, 0xC7, 0x88,
WRITE_C8_D8, 0xC8, 0x99,
WRITE_C8_D8, 0xC9, 0x33,
WRITE_C8_D8, 0xD0, 0x21,
WRITE_C8_D8, 0xD1, 0xAA,
WRITE_C8_D8, 0xD2, 0x65,
WRITE_C8_D8, 0xD3, 0x74,
WRITE_C8_D8, 0xD4, 0x47,
WRITE_C8_D8, 0xD5, 0x56,
WRITE_C8_D8, 0xD6, 0x00,
WRITE_C8_D8, 0xD7, 0x88,
WRITE_C8_D8, 0xD8, 0x99,
WRITE_C8_D8, 0xD9, 0x33,
WRITE_C8_D8, 0xF3, 0x01,
WRITE_C8_D8, 0xF0, 0x00,
WRITE_C8_D8, 0xF0, 0x01,
WRITE_C8_D8, 0xF1, 0x01,
WRITE_C8_D8, 0xA0, 0x0B,
WRITE_C8_D8, 0xA3, 0x2A,
WRITE_C8_D8, 0xA5, 0xC3,
END_WRITE,
DELAY, 1,
BEGIN_WRITE,
WRITE_C8_D8, 0xA3, 0x2B,
WRITE_C8_D8, 0xA5, 0xC3,
END_WRITE,
DELAY, 1,
BEGIN_WRITE,
WRITE_C8_D8, 0xA3, 0x2C,
WRITE_C8_D8, 0xA5, 0xC3,
END_WRITE,
DELAY, 1,
BEGIN_WRITE,
WRITE_C8_D8, 0xA3, 0x2D,
WRITE_C8_D8, 0xA5, 0xC3,
END_WRITE,
DELAY, 1,
BEGIN_WRITE,
WRITE_C8_D8, 0xA3, 0x2E,
WRITE_C8_D8, 0xA5, 0xC3,
END_WRITE,
DELAY, 1,
BEGIN_WRITE,
WRITE_C8_D8, 0xA3, 0x2F,
WRITE_C8_D8, 0xA5, 0xC3,
END_WRITE,
DELAY, 1,
BEGIN_WRITE,
WRITE_C8_D8, 0xA3, 0x30,
WRITE_C8_D8, 0xA5, 0xC3,
END_WRITE,
DELAY, 1,
BEGIN_WRITE,
WRITE_C8_D8, 0xA3, 0x31,
WRITE_C8_D8, 0xA5, 0xC3,
END_WRITE,
DELAY, 1,
BEGIN_WRITE,
WRITE_C8_D8, 0xA3, 0x32,
WRITE_C8_D8, 0xA5, 0xC3,
END_WRITE,
DELAY, 1,
BEGIN_WRITE,
WRITE_C8_D8, 0xA3, 0x33,
WRITE_C8_D8, 0xA5, 0xC3,
END_WRITE,
DELAY, 1,
BEGIN_WRITE,
WRITE_C8_D8, 0xA0, 0x09,
WRITE_C8_D8, 0xF1, 0x10,
WRITE_C8_D8, 0xF0, 0x00,
WRITE_COMMAND_8, 0x2A,
WRITE_BYTES, 4,
0x00, 0x00, 0x01, 0x67,
WRITE_COMMAND_8, 0x2B,
WRITE_BYTES, 4,
0x01, 0x68, 0x01, 0x68,
WRITE_C8_D8, 0x4D, 0x00,
WRITE_C8_D8, 0x4E, 0x00,
WRITE_C8_D8, 0x4F, 0x00,
WRITE_C8_D8, 0x4C, 0x01,
END_WRITE,
DELAY, 10,
BEGIN_WRITE,
WRITE_C8_D8, 0x4C, 0x00,
WRITE_COMMAND_8, 0x2A,
WRITE_BYTES, 4,
0x00, 0x00, 0x01, 0x67,
WRITE_C8_D8, 0x4C, 0x00,
WRITE_COMMAND_8, 0x2B,
WRITE_BYTES, 4,
0x00, 0x00, 0x01, 0x67,
WRITE_C8_D8, 0x21, 0x00,
WRITE_C8_D8, 0x3A, 0x55, // color=16
WRITE_C8_D8, 0x11, 0x00,
END_WRITE,
DELAY, ST77916_SLPOUT_DELAY,
BEGIN_WRITE,
WRITE_C8_D8, 0x29, 0x00,
END_WRITE};
class Arduino_ST77916 : public Arduino_TFT
{
public:
Arduino_ST77916(
Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0,
bool ips = false, int16_t w = ST77916_TFTWIDTH, int16_t h = ST77916_TFTHEIGHT,
uint8_t col_offset1 = 0, uint8_t row_offset1 = 0, uint8_t col_offset2 = 0, uint8_t row_offset2 = 0,
const uint8_t *init_operations = st77916_180_init_operations, size_t init_operations_len = sizeof(st77916_180_init_operations));
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void setRotation(uint8_t r) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
protected:
void tftInit() override;
private:
const uint8_t *_init_operations;
size_t _init_operations_len;
};
#endif

View File

@@ -0,0 +1,132 @@
/*
* start rewrite from:
* https://github.com/adafruit/Adafruit-GFX-Library.git
*/
#include "Arduino_ST7796.h"
#include "SPI.h"
Arduino_ST7796::Arduino_ST7796(
Arduino_DataBus *bus, int8_t rst, uint8_t r,
bool ips, int16_t w, int16_t h,
uint8_t col_offset1, uint8_t row_offset1, uint8_t col_offset2, uint8_t row_offset2)
: Arduino_TFT(bus, rst, r, ips, w, h, col_offset1, row_offset1, col_offset2, row_offset2)
{
}
bool Arduino_ST7796::begin(int32_t speed)
{
#if defined(ESP32) || defined(ARDUINO_ARCH_NRF52840)
_override_datamode = SPI_MODE3;
#elif defined(ESP8266)
_override_datamode = SPI_MODE2;
#elif defined(__AVR__)
_override_datamode = SPI_MODE0;
#endif
return Arduino_TFT::begin(speed);
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_ST7796::setRotation(uint8_t r)
{
Arduino_TFT::setRotation(r);
switch (_rotation)
{
case 1:
r = ST7796_MADCTL_MX | ST7796_MADCTL_MV | ST7796_MADCTL_BGR;
break;
case 2:
r = ST7796_MADCTL_MX | ST7796_MADCTL_MY | ST7796_MADCTL_BGR;
break;
case 3:
r = ST7796_MADCTL_MY | ST7796_MADCTL_MV | ST7796_MADCTL_BGR;
break;
case 4:
r = ST7796_MADCTL_MX | ST7796_MADCTL_BGR;
break;
case 5:
r = ST7796_MADCTL_MX | ST7796_MADCTL_MY | ST7796_MADCTL_MV | ST7796_MADCTL_BGR;
break;
case 6:
r = ST7796_MADCTL_MY | ST7796_MADCTL_BGR;
break;
case 7:
r = ST7796_MADCTL_MV | ST7796_MADCTL_BGR;
break;
default: // case 0:
r = ST7796_MADCTL_BGR;
break;
}
_bus->beginWrite();
_bus->writeC8D8(ST7796_MADCTL, r);
_bus->endWrite();
}
void Arduino_ST7796::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
{
if ((x != _currentX) || (w != _currentW))
{
_currentX = x;
_currentW = w;
x += _xStart;
_bus->writeC8D16D16(ST7796_CASET, x, x + w - 1);
}
if ((y != _currentY) || (h != _currentH))
{
_currentY = y;
_currentH = h;
y += _yStart;
_bus->writeC8D16D16(ST7796_RASET, y, y + h - 1);
}
_bus->writeCommand(ST7796_RAMWR); // write to RAM
}
void Arduino_ST7796::invertDisplay(bool i)
{
_bus->sendCommand((_ips ^ i) ? ST7796_INVON : ST7796_INVOFF);
}
void Arduino_ST7796::displayOn(void)
{
_bus->sendCommand(ST7796_SLPOUT);
delay(ST7796_SLPOUT_DELAY);
}
void Arduino_ST7796::displayOff(void)
{
_bus->sendCommand(ST7796_SLPIN);
delay(ST7796_SLPIN_DELAY);
}
// Companion code to the above tables. Reads and issues
// a series of LCD commands stored in PROGMEM byte array.
void Arduino_ST7796::tftInit()
{
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(ST7796_RST_DELAY);
digitalWrite(_rst, HIGH);
delay(ST7796_RST_DELAY);
}
else
{
// Software Rest
_bus->sendCommand(ST7796_SWRESET);
delay(ST7796_RST_DELAY);
}
_bus->batchOperation(st7796_init_operations, sizeof(st7796_init_operations));
invertDisplay(false);
}

View File

@@ -0,0 +1,126 @@
/*
* start rewrite from:
* https://github.com/adafruit/Adafruit-GFX-Library.git
*/
#ifndef _ARDUINO_ST7796_H_
#define _ARDUINO_ST7796_H_
#include "../Arduino_GFX.h"
#include "../Arduino_TFT.h"
#define ST7796_TFTWIDTH 320
#define ST7796_TFTHEIGHT 480
#define ST7796_RST_DELAY 120 ///< delay ms wait for reset finish
#define ST7796_SLPIN_DELAY 120 ///< delay ms wait for sleep in finish
#define ST7796_SLPOUT_DELAY 120 ///< delay ms wait for sleep out finish
#define ST7796_NOP 0x00
#define ST7796_SWRESET 0x01
#define ST7796_RDDID 0x04
#define ST7796_RDDST 0x09
#define ST7796_SLPIN 0x10
#define ST7796_SLPOUT 0x11
#define ST7796_PTLON 0x12
#define ST7796_NORON 0x13
#define ST7796_INVOFF 0x20
#define ST7796_INVON 0x21
#define ST7796_DISPOFF 0x28
#define ST7796_DISPON 0x29
#define ST7796_CASET 0x2A
#define ST7796_RASET 0x2B
#define ST7796_RAMWR 0x2C
#define ST7796_RAMRD 0x2E
#define ST7796_PTLAR 0x30
#define ST7796_COLMOD 0x3A
#define ST7796_MADCTL 0x36
#define ST7796_MADCTL_MY 0x80
#define ST7796_MADCTL_MX 0x40
#define ST7796_MADCTL_MV 0x20
#define ST7796_MADCTL_ML 0x10
#define ST7796_MADCTL_RGB 0x00
#define ST7796_MADCTL_BGR 0x08
#define ST7796_MADCTL_MH 0x04
#define ST7796_RDID1 0xDA
#define ST7796_RDID2 0xDB
#define ST7796_RDID3 0xDC
#define ST7796_RDID4 0xDD
static const uint8_t st7796_init_operations[] = {
BEGIN_WRITE,
WRITE_C8_D8, ST7796_COLMOD, 0x55, // 0x66,
WRITE_C8_D8, 0xF0, 0xC3, // Command Set Control
WRITE_C8_D8, 0xF0, 0x96,
WRITE_C8_D8, 0xB4, 0x01,
WRITE_COMMAND_8, 0xB6,
WRITE_BYTES, 3, 0x80, 0x22, 0x3B,
WRITE_COMMAND_8, 0xE8,
WRITE_BYTES, 8,
0x40, 0x8A, 0x00, 0x00, 0x29,
0x19, 0xA5, 0x33,
WRITE_C8_D8, 0xC1, 0x06,
WRITE_C8_D8, 0xC2, 0xA7,
WRITE_C8_D8, 0xC5, 0x18,
WRITE_COMMAND_8, 0xE0,
WRITE_BYTES, 14,
0xF0, 0x09, 0x0B, 0x06, 0x04,
0x15, 0x2F, 0x54, 0x42, 0x3C,
0x17, 0x14, 0x18, 0x1B,
WRITE_COMMAND_8, 0xE1,
WRITE_BYTES, 14,
0xE0, 0x09, 0x0B, 0x06, 0x04,
0x03, 0x2B, 0x43, 0x42, 0x3B,
0x16, 0x14, 0x17, 0x1B,
WRITE_C8_D8, 0xF0, 0x3C,
WRITE_C8_D8, 0xF0, 0x69,
WRITE_COMMAND_8, ST7796_SLPOUT,
END_WRITE,
DELAY, ST7796_SLPOUT_DELAY,
BEGIN_WRITE,
WRITE_COMMAND_8, 0x38,
WRITE_COMMAND_8, ST7796_DISPON,
END_WRITE,
DELAY, ST7796_SLPOUT_DELAY};
class Arduino_ST7796 : public Arduino_TFT
{
public:
Arduino_ST7796(
Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0,
bool ips = false, int16_t w = ST7796_TFTWIDTH, int16_t h = ST7796_TFTHEIGHT,
uint8_t col_offset1 = 0, uint8_t row_offset1 = 0, uint8_t col_offset2 = 0, uint8_t row_offset2 = 0);
bool begin(int32_t speed = GFX_NOT_DEFINED) override;
void setRotation(uint8_t r) override;
void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
void invertDisplay(bool) override;
void displayOn() override;
void displayOff() override;
protected:
void tftInit() override;
private:
};
#endif

Some files were not shown because too many files have changed in this diff Show More