Update GFX Library

This commit is contained in:
lewishe 2024-01-15 10:04:06 +08:00
parent 330baf44ad
commit 98ab7c9374
305 changed files with 76859 additions and 8707 deletions

View File

@ -1,235 +0,0 @@
/*******************************************************************************
* Touch libraries:
* FT6X36: https://github.com/strange-v/FT6X36.git
* GT911: https://github.com/TAMCTec/gt911-arduino.git
* XPT2046: https://github.com/PaulStoffregen/XPT2046_Touchscreen.git
******************************************************************************/
/* uncomment for FT6X36 */
// #define TOUCH_FT6X36
// #define TOUCH_FT6X36_SCL 19
// #define TOUCH_FT6X36_SDA 18
// #define TOUCH_FT6X36_INT 39
/* uncomment for GT911 */
// #define TOUCH_GT911
// #define TOUCH_GT911_SCL 41
// #define TOUCH_GT911_SDA 40
// #define TOUCH_GT911_INT -1
// #define TOUCH_GT911_RST -1
// #define TOUCH_GT911_ROTATION ROTATION_NORMAL
/* uncomment for XPT2046 */
// #define TOUCH_XPT2046
// #define TOUCH_XPT2046_SCK 12
// #define TOUCH_XPT2046_MISO 13
// #define TOUCH_XPT2046_MOSI 11
// #define TOUCH_XPT2046_CS 10
// #define TOUCH_XPT2046_INT 18
// #define TOUCH_XPT2046_ROTATION 0
// #define TOUCH_XPT2046_SAMPLES 50
// Please fill below values from Arduino_GFX Example - TouchCalibration
bool touch_swap_xy = false;
int16_t touch_map_x1 = -1;
int16_t touch_map_x2 = -1;
int16_t touch_map_y1 = -1;
int16_t touch_map_y2 = -1;
int16_t touch_max_x = 0, touch_max_y = 0;
int16_t touch_raw_x = 0, touch_raw_y = 0;
int16_t touch_last_x = 0, touch_last_y = 0;
#if defined(TOUCH_FT6X36)
#include <Wire.h>
#include <FT6X36.h>
FT6X36 ts(&Wire, TOUCH_FT6X36_INT);
bool touch_touched_flag = true, touch_released_flag = true;
#elif defined(TOUCH_GT911)
#include <Wire.h>
#include <TAMC_GT911.h>
TAMC_GT911 ts = TAMC_GT911(TOUCH_GT911_SDA, TOUCH_GT911_SCL, TOUCH_GT911_INT, TOUCH_GT911_RST, max(touch_map_x1, touch_map_x2), max(touch_map_y1, touch_map_y2));
#elif defined(TOUCH_XPT2046)
#include <XPT2046_Touchscreen.h>
#include <SPI.h>
XPT2046_Touchscreen ts(TOUCH_XPT2046_CS, TOUCH_XPT2046_INT);
#endif
#if defined(TOUCH_FT6X36)
void touch(TPoint p, TEvent e)
{
if (e != TEvent::Tap && e != TEvent::DragStart && e != TEvent::DragMove && e != TEvent::DragEnd)
{
return;
}
// translation logic depends on screen rotation
touch_raw_x = p.x;
touch_raw_y = p.y;
if (touch_swap_xy)
{
touch_last_x = map(touch_raw_y, touch_map_x1, touch_map_x2, 0, touch_max_x);
touch_last_y = map(touch_raw_x, touch_map_y1, touch_map_y2, 0, touch_max_y);
}
else
{
touch_last_x = map(touch_raw_x, touch_map_x1, touch_map_x2, 0, touch_max_x);
touch_last_y = map(touch_raw_y, touch_map_y1, touch_map_y2, 0, touch_max_y);
}
switch (e)
{
case TEvent::Tap:
Serial.println("Tap");
touch_touched_flag = true;
touch_released_flag = true;
break;
case TEvent::DragStart:
Serial.println("DragStart");
touch_touched_flag = true;
break;
case TEvent::DragMove:
Serial.println("DragMove");
touch_touched_flag = true;
break;
case TEvent::DragEnd:
Serial.println("DragEnd");
touch_released_flag = true;
break;
default:
Serial.println("UNKNOWN");
break;
}
}
#endif
void touch_init(int max_x, int max_y)
{
touch_max_x = max_x;
touch_max_y = max_y;
#if defined(TOUCH_FT6X36)
Wire.begin(TOUCH_FT6X36_SDA, TOUCH_FT6X36_SCL);
ts.begin();
ts.registerTouchHandler(touch);
#elif defined(TOUCH_GT911)
Wire.begin(TOUCH_GT911_SDA, TOUCH_GT911_SCL);
ts.begin();
ts.setRotation(TOUCH_GT911_ROTATION);
#elif defined(TOUCH_XPT2046)
SPI.begin(TOUCH_XPT2046_SCK, TOUCH_XPT2046_MISO, TOUCH_XPT2046_MOSI, TOUCH_XPT2046_CS);
ts.begin();
ts.setRotation(TOUCH_XPT2046_ROTATION);
#endif
}
bool touch_has_signal()
{
#if defined(TOUCH_FT6X36)
ts.loop();
return touch_touched_flag || touch_released_flag;
#elif defined(TOUCH_GT911)
return true;
#elif defined(TOUCH_XPT2046)
return ts.tirqTouched();
#else
return false;
#endif
}
bool touch_touched()
{
#if defined(TOUCH_FT6X36)
if (touch_touched_flag)
{
touch_touched_flag = false;
return true;
}
#elif defined(TOUCH_GT911)
ts.read();
if (ts.isTouched)
{
touch_raw_x = ts.points[0].x;
touch_raw_y = ts.points[0].y;
if (touch_swap_xy)
{
touch_last_x = map(touch_raw_y, touch_map_x1, touch_map_x2, 0, touch_max_x);
touch_last_y = map(touch_raw_x, touch_map_y1, touch_map_y2, 0, touch_max_y);
}
else
{
touch_last_x = map(touch_raw_x, touch_map_x1, touch_map_x2, 0, touch_max_x);
touch_last_y = map(touch_raw_y, touch_map_y1, touch_map_y2, 0, touch_max_y);
}
return true;
}
#elif defined(TOUCH_XPT2046)
if (ts.touched())
{
TS_Point p = ts.getPoint();
touch_raw_x = p.x;
touch_raw_y = p.y;
int max_z = p.z;
int count = 0;
while ((ts.touched()) && (count < TOUCH_XPT2046_SAMPLES))
{
count++;
TS_Point p = ts.getPoint();
if (p.z > max_z)
{
touch_raw_x = p.x;
touch_raw_y = p.y;
max_z = p.z;
}
// Serial.printf("touch_raw_x: %d, touch_raw_y: %d, p.z: %d\n", touch_raw_x, touch_raw_y, p.z);
}
if (touch_swap_xy)
{
touch_last_x = map(touch_raw_y, touch_map_x1, touch_map_x2, 0, touch_max_x);
touch_last_y = map(touch_raw_x, touch_map_y1, touch_map_y2, 0, touch_max_y);
}
else
{
touch_last_x = map(touch_raw_x, touch_map_x1, touch_map_x2, 0, touch_max_x);
touch_last_y = map(touch_raw_y, touch_map_y1, touch_map_y2, 0, touch_max_y);
}
return true;
}
#endif
return false;
}
bool touch_released()
{
#if defined(TOUCH_FT6X36)
if (touch_released_flag)
{
touch_released_flag = false;
return true;
}
else
{
return false;
}
#elif defined(TOUCH_GT911)
return true;
#elif defined(TOUCH_XPT2046)
return true;
#else
return false;
#endif
}

View File

@ -1,382 +0,0 @@
/*
Arduino Watch Lite Version
You may find full version at: https://github.com/moononournation/ArduinoWatch
*/
/*******************************************************************************
* Start of Arduino_GFX setting
*
* Arduino_GFX try to find the settings depends on selected board in Arduino IDE
* Or you can define the display dev kit not in the board list
* Defalult pin list for non display dev kit:
* Arduino Nano, Micro and more: CS: 9, DC: 8, RST: 7, BL: 6, SCK: 13, MOSI: 11, MISO: 12
* ESP32 various dev board : CS: 5, DC: 27, RST: 33, BL: 22, SCK: 18, MOSI: 23, MISO: nil
* ESP32-C3 various dev board : CS: 7, DC: 2, RST: 1, BL: 3, SCK: 4, MOSI: 6, MISO: nil
* ESP32-S2 various dev board : CS: 34, DC: 35, RST: 33, BL: 21, SCK: 36, MOSI: 35, MISO: nil
* ESP32-S3 various dev board : CS: 40, DC: 41, RST: 42, BL: 48, SCK: 36, MOSI: 35, MISO: nil
* ESP8266 various dev board : CS: 15, DC: 4, RST: 2, BL: 5, SCK: 14, MOSI: 13, MISO: 12
* Raspberry Pi Pico dev board : CS: 17, DC: 27, RST: 26, BL: 28, SCK: 18, MOSI: 19, MISO: 16
* RTL8720 BW16 old patch core : CS: 18, DC: 17, RST: 2, BL: 23, SCK: 19, MOSI: 21, MISO: 20
* RTL8720_BW16 Official core : CS: 9, DC: 8, RST: 6, BL: 3, SCK: 10, MOSI: 12, MISO: 11
* RTL8722 dev board : CS: 18, DC: 17, RST: 22, BL: 23, SCK: 13, MOSI: 11, MISO: 12
* RTL8722_mini dev board : CS: 12, DC: 14, RST: 15, BL: 13, SCK: 11, MOSI: 9, MISO: 10
* Seeeduino XIAO dev board : CS: 3, DC: 2, RST: 1, BL: 0, SCK: 8, MOSI: 10, MISO: 9
* Teensy 4.1 dev board : CS: 39, DC: 41, RST: 40, BL: 22, SCK: 13, MOSI: 11, MISO: 12
******************************************************************************/
#include <Arduino_GFX_Library.h>
#define GFX_BL DF_GFX_BL // default backlight pin, you may replace DF_GFX_BL to actual backlight pin
/* More dev device declaration: https://github.com/moononournation/Arduino_GFX/wiki/Dev-Device-Declaration */
#if defined(DISPLAY_DEV_KIT)
Arduino_GFX *gfx = create_default_Arduino_GFX();
#else /* !defined(DISPLAY_DEV_KIT) */
/* More data bus class: https://github.com/moononournation/Arduino_GFX/wiki/Data-Bus-Class */
Arduino_DataBus *bus = create_default_Arduino_DataBus();
/* More display class: https://github.com/moononournation/Arduino_GFX/wiki/Display-Class */
Arduino_GFX *gfx = new Arduino_ILI9341(bus, DF_GFX_RST, 0 /* rotation */, false /* IPS */);
#endif /* !defined(DISPLAY_DEV_KIT) */
/*******************************************************************************
* End of Arduino_GFX setting
******************************************************************************/
#define BACKGROUND BLACK
#define MARK_COLOR WHITE
#define SUBMARK_COLOR DARKGREY // LIGHTGREY
#define HOUR_COLOR WHITE
#define MINUTE_COLOR BLUE // LIGHTGREY
#define SECOND_COLOR RED
#define SIXTIETH 0.016666667
#define TWELFTH 0.08333333
#define SIXTIETH_RADIAN 0.10471976
#define TWELFTH_RADIAN 0.52359878
#define RIGHT_ANGLE_RADIAN 1.5707963
static uint8_t conv2d(const char *p)
{
uint8_t v = 0;
return (10 * (*p - '0')) + (*++p - '0');
}
static int16_t w, h, center;
static int16_t hHandLen, mHandLen, sHandLen, markLen;
static float sdeg, mdeg, hdeg;
static int16_t osx = 0, osy = 0, omx = 0, omy = 0, ohx = 0, ohy = 0; // Saved H, M, S x & y coords
static int16_t nsx, nsy, nmx, nmy, nhx, nhy; // H, M, S x & y coords
static int16_t xMin, yMin, xMax, yMax; // redraw range
static int16_t hh, mm, ss;
static unsigned long targetTime; // next action time
static int16_t *cached_points;
static uint16_t cached_points_idx = 0;
static int16_t *last_cached_point;
void setup(void)
{
gfx->begin();
gfx->fillScreen(BACKGROUND);
#ifdef GFX_BL
pinMode(GFX_BL, OUTPUT);
digitalWrite(GFX_BL, HIGH);
#endif
// init LCD constant
w = gfx->width();
h = gfx->height();
if (w < h)
{
center = w / 2;
}
else
{
center = h / 2;
}
hHandLen = center * 3 / 8;
mHandLen = center * 2 / 3;
sHandLen = center * 5 / 6;
markLen = sHandLen / 6;
cached_points = (int16_t *)malloc((hHandLen + 1 + mHandLen + 1 + sHandLen + 1) * 2 * 2);
// Draw 60 clock marks
draw_round_clock_mark(
// draw_square_clock_mark(
center - markLen, center,
center - (markLen * 2 / 3), center,
center - (markLen / 2), center);
hh = conv2d(__TIME__);
mm = conv2d(__TIME__ + 3);
ss = conv2d(__TIME__ + 6);
targetTime = ((millis() / 1000) + 1) * 1000;
}
void loop()
{
unsigned long cur_millis = millis();
if (cur_millis >= targetTime)
{
targetTime += 1000;
ss++; // Advance second
if (ss == 60)
{
ss = 0;
mm++; // Advance minute
if (mm > 59)
{
mm = 0;
hh++; // Advance hour
if (hh > 23)
{
hh = 0;
}
}
}
}
// Pre-compute hand degrees, x & y coords for a fast screen update
sdeg = SIXTIETH_RADIAN * ((0.001 * (cur_millis % 1000)) + ss); // 0-59 (includes millis)
nsx = cos(sdeg - RIGHT_ANGLE_RADIAN) * sHandLen + center;
nsy = sin(sdeg - RIGHT_ANGLE_RADIAN) * sHandLen + center;
if ((nsx != osx) || (nsy != osy))
{
mdeg = (SIXTIETH * sdeg) + (SIXTIETH_RADIAN * mm); // 0-59 (includes seconds)
hdeg = (TWELFTH * mdeg) + (TWELFTH_RADIAN * hh); // 0-11 (includes minutes)
mdeg -= RIGHT_ANGLE_RADIAN;
hdeg -= RIGHT_ANGLE_RADIAN;
nmx = cos(mdeg) * mHandLen + center;
nmy = sin(mdeg) * mHandLen + center;
nhx = cos(hdeg) * hHandLen + center;
nhy = sin(hdeg) * hHandLen + center;
// redraw hands
redraw_hands_cached_draw_and_erase();
ohx = nhx;
ohy = nhy;
omx = nmx;
omy = nmy;
osx = nsx;
osy = nsy;
delay(1);
}
}
void draw_round_clock_mark(int16_t innerR1, int16_t outerR1, int16_t innerR2, int16_t outerR2, int16_t innerR3, int16_t outerR3)
{
float x, y;
int16_t x0, x1, y0, y1, innerR, outerR;
uint16_t c;
for (uint8_t i = 0; i < 60; i++)
{
if ((i % 15) == 0)
{
innerR = innerR1;
outerR = outerR1;
c = MARK_COLOR;
}
else if ((i % 5) == 0)
{
innerR = innerR2;
outerR = outerR2;
c = MARK_COLOR;
}
else
{
innerR = innerR3;
outerR = outerR3;
c = SUBMARK_COLOR;
}
mdeg = (SIXTIETH_RADIAN * i) - RIGHT_ANGLE_RADIAN;
x = cos(mdeg);
y = sin(mdeg);
x0 = x * outerR + center;
y0 = y * outerR + center;
x1 = x * innerR + center;
y1 = y * innerR + center;
gfx->drawLine(x0, y0, x1, y1, c);
}
}
void draw_square_clock_mark(int16_t innerR1, int16_t outerR1, int16_t innerR2, int16_t outerR2, int16_t innerR3, int16_t outerR3)
{
float x, y;
int16_t x0, x1, y0, y1, innerR, outerR;
uint16_t c;
for (uint8_t i = 0; i < 60; i++)
{
if ((i % 15) == 0)
{
innerR = innerR1;
outerR = outerR1;
c = MARK_COLOR;
}
else if ((i % 5) == 0)
{
innerR = innerR2;
outerR = outerR2;
c = MARK_COLOR;
}
else
{
innerR = innerR3;
outerR = outerR3;
c = SUBMARK_COLOR;
}
if ((i >= 53) || (i < 8))
{
x = tan(SIXTIETH_RADIAN * i);
x0 = center + (x * outerR);
y0 = center + (1 - outerR);
x1 = center + (x * innerR);
y1 = center + (1 - innerR);
}
else if (i < 23)
{
y = tan((SIXTIETH_RADIAN * i) - RIGHT_ANGLE_RADIAN);
x0 = center + (outerR);
y0 = center + (y * outerR);
x1 = center + (innerR);
y1 = center + (y * innerR);
}
else if (i < 38)
{
x = tan(SIXTIETH_RADIAN * i);
x0 = center - (x * outerR);
y0 = center + (outerR);
x1 = center - (x * innerR);
y1 = center + (innerR);
}
else if (i < 53)
{
y = tan((SIXTIETH_RADIAN * i) - RIGHT_ANGLE_RADIAN);
x0 = center + (1 - outerR);
y0 = center - (y * outerR);
x1 = center + (1 - innerR);
y1 = center - (y * innerR);
}
gfx->drawLine(x0, y0, x1, y1, c);
}
}
void redraw_hands_cached_draw_and_erase()
{
gfx->startWrite();
draw_and_erase_cached_line(center, center, nsx, nsy, SECOND_COLOR, cached_points, sHandLen + 1, false, false);
draw_and_erase_cached_line(center, center, nhx, nhy, HOUR_COLOR, cached_points + ((sHandLen + 1) * 2), hHandLen + 1, true, false);
draw_and_erase_cached_line(center, center, nmx, nmy, MINUTE_COLOR, cached_points + ((sHandLen + 1 + hHandLen + 1) * 2), mHandLen + 1, true, true);
gfx->endWrite();
}
void draw_and_erase_cached_line(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t color, int16_t *cache, int16_t cache_len, bool cross_check_second, bool cross_check_hour)
{
#if defined(ESP8266)
yield();
#endif
bool steep = _diff(y1, y0) > _diff(x1, x0);
if (steep)
{
_swap_int16_t(x0, y0);
_swap_int16_t(x1, y1);
}
int16_t dx, dy;
dx = _diff(x1, x0);
dy = _diff(y1, y0);
int16_t err = dx / 2;
int8_t xstep = (x0 < x1) ? 1 : -1;
int8_t ystep = (y0 < y1) ? 1 : -1;
x1 += xstep;
int16_t x, y, ox, oy;
for (uint16_t i = 0; i <= dx; i++)
{
if (steep)
{
x = y0;
y = x0;
}
else
{
x = x0;
y = y0;
}
ox = *(cache + (i * 2));
oy = *(cache + (i * 2) + 1);
if ((x == ox) && (y == oy))
{
if (cross_check_second || cross_check_hour)
{
write_cache_pixel(x, y, color, cross_check_second, cross_check_hour);
}
}
else
{
write_cache_pixel(x, y, color, cross_check_second, cross_check_hour);
if ((ox > 0) || (oy > 0))
{
write_cache_pixel(ox, oy, BACKGROUND, cross_check_second, cross_check_hour);
}
*(cache + (i * 2)) = x;
*(cache + (i * 2) + 1) = y;
}
if (err < dy)
{
y0 += ystep;
err += dx;
}
err -= dy;
x0 += xstep;
}
for (uint16_t i = dx + 1; i < cache_len; i++)
{
ox = *(cache + (i * 2));
oy = *(cache + (i * 2) + 1);
if ((ox > 0) || (oy > 0))
{
write_cache_pixel(ox, oy, BACKGROUND, cross_check_second, cross_check_hour);
}
*(cache + (i * 2)) = 0;
*(cache + (i * 2) + 1) = 0;
}
}
void write_cache_pixel(int16_t x, int16_t y, int16_t color, bool cross_check_second, bool cross_check_hour)
{
int16_t *cache = cached_points;
if (cross_check_second)
{
for (uint16_t i = 0; i <= sHandLen; i++)
{
if ((x == *(cache++)) && (y == *(cache)))
{
return;
}
cache++;
}
}
if (cross_check_hour)
{
cache = cached_points + ((sHandLen + 1) * 2);
for (uint16_t i = 0; i <= hHandLen; i++)
{
if ((x == *(cache++)) && (y == *(cache)))
{
return;
}
cache++;
}
}
gfx->writePixel(x, y, color);
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 773 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 89 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 868 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

View File

@ -1,235 +0,0 @@
/*******************************************************************************
* Touch libraries:
* FT6X36: https://github.com/strange-v/FT6X36.git
* GT911: https://github.com/TAMCTec/gt911-arduino.git
* XPT2046: https://github.com/PaulStoffregen/XPT2046_Touchscreen.git
******************************************************************************/
/* uncomment for FT6X36 */
// #define TOUCH_FT6X36
// #define TOUCH_FT6X36_SCL 19
// #define TOUCH_FT6X36_SDA 18
// #define TOUCH_FT6X36_INT 39
/* uncomment for GT911 */
// #define TOUCH_GT911
// #define TOUCH_GT911_SCL 41
// #define TOUCH_GT911_SDA 40
// #define TOUCH_GT911_INT -1
// #define TOUCH_GT911_RST -1
// #define TOUCH_GT911_ROTATION ROTATION_NORMAL
/* uncomment for XPT2046 */
// #define TOUCH_XPT2046
// #define TOUCH_XPT2046_SCK 12
// #define TOUCH_XPT2046_MISO 13
// #define TOUCH_XPT2046_MOSI 11
// #define TOUCH_XPT2046_CS 10
// #define TOUCH_XPT2046_INT 18
// #define TOUCH_XPT2046_ROTATION 0
// #define TOUCH_XPT2046_SAMPLES 50
// Please fill below values from Arduino_GFX Example - TouchCalibration
bool touch_swap_xy = false;
int16_t touch_map_x1 = -1;
int16_t touch_map_x2 = -1;
int16_t touch_map_y1 = -1;
int16_t touch_map_y2 = -1;
int16_t touch_max_x = 0, touch_max_y = 0;
int16_t touch_raw_x = 0, touch_raw_y = 0;
int16_t touch_last_x = 0, touch_last_y = 0;
#if defined(TOUCH_FT6X36)
#include <Wire.h>
#include <FT6X36.h>
FT6X36 ts(&Wire, TOUCH_FT6X36_INT);
bool touch_touched_flag = true, touch_released_flag = true;
#elif defined(TOUCH_GT911)
#include <Wire.h>
#include <TAMC_GT911.h>
TAMC_GT911 ts = TAMC_GT911(TOUCH_GT911_SDA, TOUCH_GT911_SCL, TOUCH_GT911_INT, TOUCH_GT911_RST, max(touch_map_x1, touch_map_x2), max(touch_map_y1, touch_map_y2));
#elif defined(TOUCH_XPT2046)
#include <XPT2046_Touchscreen.h>
#include <SPI.h>
XPT2046_Touchscreen ts(TOUCH_XPT2046_CS, TOUCH_XPT2046_INT);
#endif
#if defined(TOUCH_FT6X36)
void touch(TPoint p, TEvent e)
{
if (e != TEvent::Tap && e != TEvent::DragStart && e != TEvent::DragMove && e != TEvent::DragEnd)
{
return;
}
// translation logic depends on screen rotation
touch_raw_x = p.x;
touch_raw_y = p.y;
if (touch_swap_xy)
{
touch_last_x = map(touch_raw_y, touch_map_x1, touch_map_x2, 0, touch_max_x);
touch_last_y = map(touch_raw_x, touch_map_y1, touch_map_y2, 0, touch_max_y);
}
else
{
touch_last_x = map(touch_raw_x, touch_map_x1, touch_map_x2, 0, touch_max_x);
touch_last_y = map(touch_raw_y, touch_map_y1, touch_map_y2, 0, touch_max_y);
}
switch (e)
{
case TEvent::Tap:
Serial.println("Tap");
touch_touched_flag = true;
touch_released_flag = true;
break;
case TEvent::DragStart:
Serial.println("DragStart");
touch_touched_flag = true;
break;
case TEvent::DragMove:
Serial.println("DragMove");
touch_touched_flag = true;
break;
case TEvent::DragEnd:
Serial.println("DragEnd");
touch_released_flag = true;
break;
default:
Serial.println("UNKNOWN");
break;
}
}
#endif
void touch_init(int max_x, int max_y)
{
touch_max_x = max_x;
touch_max_y = max_y;
#if defined(TOUCH_FT6X36)
Wire.begin(TOUCH_FT6X36_SDA, TOUCH_FT6X36_SCL);
ts.begin();
ts.registerTouchHandler(touch);
#elif defined(TOUCH_GT911)
Wire.begin(TOUCH_GT911_SDA, TOUCH_GT911_SCL);
ts.begin();
ts.setRotation(TOUCH_GT911_ROTATION);
#elif defined(TOUCH_XPT2046)
SPI.begin(TOUCH_XPT2046_SCK, TOUCH_XPT2046_MISO, TOUCH_XPT2046_MOSI, TOUCH_XPT2046_CS);
ts.begin();
ts.setRotation(TOUCH_XPT2046_ROTATION);
#endif
}
bool touch_has_signal()
{
#if defined(TOUCH_FT6X36)
ts.loop();
return touch_touched_flag || touch_released_flag;
#elif defined(TOUCH_GT911)
return true;
#elif defined(TOUCH_XPT2046)
return ts.tirqTouched();
#else
return false;
#endif
}
bool touch_touched()
{
#if defined(TOUCH_FT6X36)
if (touch_touched_flag)
{
touch_touched_flag = false;
return true;
}
#elif defined(TOUCH_GT911)
ts.read();
if (ts.isTouched)
{
touch_raw_x = ts.points[0].x;
touch_raw_y = ts.points[0].y;
if (touch_swap_xy)
{
touch_last_x = map(touch_raw_y, touch_map_x1, touch_map_x2, 0, touch_max_x);
touch_last_y = map(touch_raw_x, touch_map_y1, touch_map_y2, 0, touch_max_y);
}
else
{
touch_last_x = map(touch_raw_x, touch_map_x1, touch_map_x2, 0, touch_max_x);
touch_last_y = map(touch_raw_y, touch_map_y1, touch_map_y2, 0, touch_max_y);
}
return true;
}
#elif defined(TOUCH_XPT2046)
if (ts.touched())
{
TS_Point p = ts.getPoint();
touch_raw_x = p.x;
touch_raw_y = p.y;
int max_z = p.z;
int count = 0;
while ((ts.touched()) && (count < TOUCH_XPT2046_SAMPLES))
{
count++;
TS_Point p = ts.getPoint();
if (p.z > max_z)
{
touch_raw_x = p.x;
touch_raw_y = p.y;
max_z = p.z;
}
// Serial.printf("touch_raw_x: %d, touch_raw_y: %d, p.z: %d\n", touch_raw_x, touch_raw_y, p.z);
}
if (touch_swap_xy)
{
touch_last_x = map(touch_raw_y, touch_map_x1, touch_map_x2, 0, touch_max_x);
touch_last_y = map(touch_raw_x, touch_map_y1, touch_map_y2, 0, touch_max_y);
}
else
{
touch_last_x = map(touch_raw_x, touch_map_x1, touch_map_x2, 0, touch_max_x);
touch_last_y = map(touch_raw_y, touch_map_y1, touch_map_y2, 0, touch_max_y);
}
return true;
}
#endif
return false;
}
bool touch_released()
{
#if defined(TOUCH_FT6X36)
if (touch_released_flag)
{
touch_released_flag = false;
return true;
}
else
{
return false;
}
#elif defined(TOUCH_GT911)
return true;
#elif defined(TOUCH_XPT2046)
return true;
#else
return false;
#endif
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

File diff suppressed because it is too large Load Diff

View File

@ -1,235 +0,0 @@
/*******************************************************************************
* Touch libraries:
* FT6X36: https://github.com/strange-v/FT6X36.git
* GT911: https://github.com/TAMCTec/gt911-arduino.git
* XPT2046: https://github.com/PaulStoffregen/XPT2046_Touchscreen.git
******************************************************************************/
/* uncomment for FT6X36 */
// #define TOUCH_FT6X36
// #define TOUCH_FT6X36_SCL 19
// #define TOUCH_FT6X36_SDA 18
// #define TOUCH_FT6X36_INT 39
/* uncomment for GT911 */
// #define TOUCH_GT911
// #define TOUCH_GT911_SCL 41
// #define TOUCH_GT911_SDA 40
// #define TOUCH_GT911_INT -1
// #define TOUCH_GT911_RST -1
// #define TOUCH_GT911_ROTATION ROTATION_NORMAL
/* uncomment for XPT2046 */
// #define TOUCH_XPT2046
// #define TOUCH_XPT2046_SCK 12
// #define TOUCH_XPT2046_MISO 13
// #define TOUCH_XPT2046_MOSI 11
// #define TOUCH_XPT2046_CS 10
// #define TOUCH_XPT2046_INT 18
// #define TOUCH_XPT2046_ROTATION 0
// #define TOUCH_XPT2046_SAMPLES 50
// Please fill below values from Arduino_GFX Example - TouchCalibration
bool touch_swap_xy = false;
int16_t touch_map_x1 = -1;
int16_t touch_map_x2 = -1;
int16_t touch_map_y1 = -1;
int16_t touch_map_y2 = -1;
int16_t touch_max_x = 0, touch_max_y = 0;
int16_t touch_raw_x = 0, touch_raw_y = 0;
int16_t touch_last_x = 0, touch_last_y = 0;
#if defined(TOUCH_FT6X36)
#include <Wire.h>
#include <FT6X36.h>
FT6X36 ts(&Wire, TOUCH_FT6X36_INT);
bool touch_touched_flag = true, touch_released_flag = true;
#elif defined(TOUCH_GT911)
#include <Wire.h>
#include <TAMC_GT911.h>
TAMC_GT911 ts = TAMC_GT911(TOUCH_GT911_SDA, TOUCH_GT911_SCL, TOUCH_GT911_INT, TOUCH_GT911_RST, max(touch_map_x1, touch_map_x2), max(touch_map_y1, touch_map_y2));
#elif defined(TOUCH_XPT2046)
#include <XPT2046_Touchscreen.h>
#include <SPI.h>
XPT2046_Touchscreen ts(TOUCH_XPT2046_CS, TOUCH_XPT2046_INT);
#endif
#if defined(TOUCH_FT6X36)
void touch(TPoint p, TEvent e)
{
if (e != TEvent::Tap && e != TEvent::DragStart && e != TEvent::DragMove && e != TEvent::DragEnd)
{
return;
}
// translation logic depends on screen rotation
touch_raw_x = p.x;
touch_raw_y = p.y;
if (touch_swap_xy)
{
touch_last_x = map(touch_raw_y, touch_map_x1, touch_map_x2, 0, touch_max_x);
touch_last_y = map(touch_raw_x, touch_map_y1, touch_map_y2, 0, touch_max_y);
}
else
{
touch_last_x = map(touch_raw_x, touch_map_x1, touch_map_x2, 0, touch_max_x);
touch_last_y = map(touch_raw_y, touch_map_y1, touch_map_y2, 0, touch_max_y);
}
switch (e)
{
case TEvent::Tap:
Serial.println("Tap");
touch_touched_flag = true;
touch_released_flag = true;
break;
case TEvent::DragStart:
Serial.println("DragStart");
touch_touched_flag = true;
break;
case TEvent::DragMove:
Serial.println("DragMove");
touch_touched_flag = true;
break;
case TEvent::DragEnd:
Serial.println("DragEnd");
touch_released_flag = true;
break;
default:
Serial.println("UNKNOWN");
break;
}
}
#endif
void touch_init(int max_x, int max_y)
{
touch_max_x = max_x;
touch_max_y = max_y;
#if defined(TOUCH_FT6X36)
Wire.begin(TOUCH_FT6X36_SDA, TOUCH_FT6X36_SCL);
ts.begin();
ts.registerTouchHandler(touch);
#elif defined(TOUCH_GT911)
Wire.begin(TOUCH_GT911_SDA, TOUCH_GT911_SCL);
ts.begin();
ts.setRotation(TOUCH_GT911_ROTATION);
#elif defined(TOUCH_XPT2046)
SPI.begin(TOUCH_XPT2046_SCK, TOUCH_XPT2046_MISO, TOUCH_XPT2046_MOSI, TOUCH_XPT2046_CS);
ts.begin();
ts.setRotation(TOUCH_XPT2046_ROTATION);
#endif
}
bool touch_has_signal()
{
#if defined(TOUCH_FT6X36)
ts.loop();
return touch_touched_flag || touch_released_flag;
#elif defined(TOUCH_GT911)
return true;
#elif defined(TOUCH_XPT2046)
return ts.tirqTouched();
#else
return false;
#endif
}
bool touch_touched()
{
#if defined(TOUCH_FT6X36)
if (touch_touched_flag)
{
touch_touched_flag = false;
return true;
}
#elif defined(TOUCH_GT911)
ts.read();
if (ts.isTouched)
{
touch_raw_x = ts.points[0].x;
touch_raw_y = ts.points[0].y;
if (touch_swap_xy)
{
touch_last_x = map(touch_raw_y, touch_map_x1, touch_map_x2, 0, touch_max_x);
touch_last_y = map(touch_raw_x, touch_map_y1, touch_map_y2, 0, touch_max_y);
}
else
{
touch_last_x = map(touch_raw_x, touch_map_x1, touch_map_x2, 0, touch_max_x);
touch_last_y = map(touch_raw_y, touch_map_y1, touch_map_y2, 0, touch_max_y);
}
return true;
}
#elif defined(TOUCH_XPT2046)
if (ts.touched())
{
TS_Point p = ts.getPoint();
touch_raw_x = p.x;
touch_raw_y = p.y;
int max_z = p.z;
int count = 0;
while ((ts.touched()) && (count < TOUCH_XPT2046_SAMPLES))
{
count++;
TS_Point p = ts.getPoint();
if (p.z > max_z)
{
touch_raw_x = p.x;
touch_raw_y = p.y;
max_z = p.z;
}
// Serial.printf("touch_raw_x: %d, touch_raw_y: %d, p.z: %d\n", touch_raw_x, touch_raw_y, p.z);
}
if (touch_swap_xy)
{
touch_last_x = map(touch_raw_y, touch_map_x1, touch_map_x2, 0, touch_max_x);
touch_last_y = map(touch_raw_x, touch_map_y1, touch_map_y2, 0, touch_max_y);
}
else
{
touch_last_x = map(touch_raw_x, touch_map_x1, touch_map_x2, 0, touch_max_x);
touch_last_y = map(touch_raw_y, touch_map_y1, touch_map_y2, 0, touch_max_y);
}
return true;
}
#endif
return false;
}
bool touch_released()
{
#if defined(TOUCH_FT6X36)
if (touch_released_flag)
{
touch_released_flag = false;
return true;
}
else
{
return false;
}
#elif defined(TOUCH_GT911)
return true;
#elif defined(TOUCH_XPT2046)
return true;
#else
return false;
#endif
}

View File

@ -1,156 +0,0 @@
/*******************************************************************************
* U8g2 latest unifont-14.0.02 all glyphs example
* Please note this font is 2,250,360 in size and cannot fit in many platform.
* This font is generated by U8g2 tools:
* u8g2/tools/font/bdfconv/./bdfconv -v -f 1 -b 1 -m "0-1114111" unifont_jp-14.0.02.bdf -o u8g2_font_unifont_h_utf8.h -n u8g2_font_unifont_h_utf8
* Hello world in multiple languages
* https://codegolf.stackexchange.com/questions/146544/hello-world-in-multiple-languages
******************************************************************************/
/*******************************************************************************
* Start of Arduino_GFX setting
*
* Arduino_GFX try to find the settings depends on selected board in Arduino IDE
* Or you can define the display dev kit not in the board list
* Defalult pin list for non display dev kit:
* Arduino Nano, Micro and more: CS: 9, DC: 8, RST: 7, BL: 6, SCK: 13, MOSI: 11, MISO: 12
* ESP32 various dev board : CS: 5, DC: 27, RST: 33, BL: 22, SCK: 18, MOSI: 23, MISO: nil
* ESP32-C3 various dev board : CS: 7, DC: 2, RST: 1, BL: 3, SCK: 4, MOSI: 6, MISO: nil
* ESP32-S2 various dev board : CS: 34, DC: 35, RST: 33, BL: 21, SCK: 36, MOSI: 35, MISO: nil
* ESP32-S3 various dev board : CS: 40, DC: 41, RST: 42, BL: 48, SCK: 36, MOSI: 35, MISO: nil
* ESP8266 various dev board : CS: 15, DC: 4, RST: 2, BL: 5, SCK: 14, MOSI: 13, MISO: 12
* Raspberry Pi Pico dev board : CS: 17, DC: 27, RST: 26, BL: 28, SCK: 18, MOSI: 19, MISO: 16
* RTL8720 BW16 old patch core : CS: 18, DC: 17, RST: 2, BL: 23, SCK: 19, MOSI: 21, MISO: 20
* RTL8720_BW16 Official core : CS: 9, DC: 8, RST: 6, BL: 3, SCK: 10, MOSI: 12, MISO: 11
* RTL8722 dev board : CS: 18, DC: 17, RST: 22, BL: 23, SCK: 13, MOSI: 11, MISO: 12
* RTL8722_mini dev board : CS: 12, DC: 14, RST: 15, BL: 13, SCK: 11, MOSI: 9, MISO: 10
* Seeeduino XIAO dev board : CS: 3, DC: 2, RST: 1, BL: 0, SCK: 8, MOSI: 10, MISO: 9
* Teensy 4.1 dev board : CS: 39, DC: 41, RST: 40, BL: 22, SCK: 13, MOSI: 11, MISO: 12
******************************************************************************/
#include <U8g2lib.h>
#include <Arduino_GFX_Library.h>
#define GFX_BL DF_GFX_BL // default backlight pin, you may replace DF_GFX_BL to actual backlight pin
/* More dev device declaration: https://github.com/moononournation/Arduino_GFX/wiki/Dev-Device-Declaration */
#if defined(DISPLAY_DEV_KIT)
Arduino_GFX *gfx = create_default_Arduino_GFX();
#else /* !defined(DISPLAY_DEV_KIT) */
/* More data bus class: https://github.com/moononournation/Arduino_GFX/wiki/Data-Bus-Class */
Arduino_DataBus *bus = create_default_Arduino_DataBus();
/* More display class: https://github.com/moononournation/Arduino_GFX/wiki/Display-Class */
Arduino_GFX *gfx = new Arduino_ILI9341(bus, DF_GFX_RST, 3 /* rotation */, false /* IPS */);
#endif /* !defined(DISPLAY_DEV_KIT) */
/*******************************************************************************
* End of Arduino_GFX setting
******************************************************************************/
/* more fonts at: https://github.com/moononournation/ArduinoFreeFontFile.git */
String helloWorldStrings[] = {
"Hello Wêreld!", // Afrikaans
"Përshendetje Botë!", // Albanian
"ሰላም ልዑል!", // Amharic
"مرحبا بالعالم!", // Arabic
"Բարեւ աշխարհ!", // Armenian
"Kaixo Mundua!", // Basque
"Прывітанне Сусвет!", // Belarussian
"ওহে বিশ্ব!", // Bengali
"Здравей свят!", // Bulgarian
"Hola món!", // Catalan
"Moni Dziko Lapansi!", // Chichewa
"世界你好!", // Chinese
"Pozdrav svijete!", // Croatian
"Ahoj světe!", // Czech
"Hej Verden!", // Danish
"Hallo Wereld!", // Dutch
"Hello World!", // English
"Tere maailm!", // Estonian
"Hei maailma!", // Finnish
"Bonjour monde!", // French
"Hallo wrâld!", // Frisian
"გამარჯობა მსოფლიო!", // Georgian
"Hallo Welt!", // German
"Γειά σου Κόσμε!", // Greek
"Sannu Duniya!", // Hausa
"שלום עולם!", // Hebrew
"नमस्ते दुनिया!", // Hindi
"Helló Világ!", // Hungarian
"Halló heimur!", // Icelandic
"Ndewo Ụwa!", // Igbo
"Halo Dunia!", // Indonesian
"Ciao mondo!", // Italian
"こんにちは世界!", // Japanese
"Сәлем Әлем!", // Kazakh
"សួស្តី​ពិភពលោក!", // Khmer
"Салам дүйнө!", // Kyrgyz
"ສະ​ບາຍ​ດີ​ຊາວ​ໂລກ!", // Lao
"Sveika pasaule!", // Latvian
"Labas pasauli!", // Lithuanian
"Moien Welt!", // Luxemburgish
"Здраво свету!", // Macedonian
"Hai dunia!", // Malay
"ഹലോ വേൾഡ്!", // Malayalam
"Сайн уу дэлхий!", // Mongolian
"မင်္ဂလာပါကမ္ဘာလောက!", // Myanmar
"नमस्कार संसार!", // Nepali
"Hei Verden!", // Norwegian
"سلام نړی!", // Pashto
"سلام دنیا!", // Persian
"Witaj świecie!", // Polish
"Olá Mundo!", // Portuguese
"ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ!", // Punjabi
"Salut Lume!", // Romanian
"Привет мир!", // Russian
"Hàlo a Shaoghail!", // Scots Gaelic
"Здраво Свете!", // Serbian
"Lefatše Lumela!", // Sesotho
"හෙලෝ වර්ල්ඩ්!", // Sinhala
"Pozdravljen svet!", // Slovenian
"¡Hola Mundo!", // Spanish, Leading '¡' optional
"Halo Dunya!", // Sundanese
"Salamu Dunia!", // Swahili
"Hej världen!", // Swedish
"Салом Ҷаҳон!", // Tajik
"สวัสดีชาวโลก!", // Thai
"Selam Dünya!", // Turkish
"Привіт Світ!", // Ukrainian
"Salom Dunyo!", // Uzbek
"Chào thế giới!", // Vietnamese
"Helo Byd!", // Welsh
"Molo Lizwe!", // Xhosa
"העלא וועלט!", // Yiddish
"Mo ki O Ile Aiye!", // Yoruba
"Sawubona Mhlaba!" // Zulu
};
void setup(void)
{
gfx->begin();
gfx->fillScreen(BLACK);
gfx->setUTF8Print(true); // enable UTF8 support for the Arduino print() function
#ifdef GFX_BL
pinMode(GFX_BL, OUTPUT);
digitalWrite(GFX_BL, HIGH);
#endif
gfx->setCursor(0, 14);
gfx->setFont(u8g2_font_unifont_h_utf8);
gfx->println("Hello world in multiple languages");
delay(2000); // 2 seconds
}
void loop()
{
gfx->setCursor(random(gfx->width() / 4), random(gfx->height() - 32) + 16);
gfx->setTextColor(random(0xffff), random(0xffff));
gfx->setTextSize(random(2) + 2 /* x scale */, random(2) + 2 /* y scale */);
gfx->println(helloWorldStrings[random(74)]);
delay(500); // 0.5 second
}

View File

@ -1,7 +0,0 @@
name=GFX Library for Arduino
version=1.3.0
author=Moon On Our Nation <moononournation@gmail.com>
maintainer=Moon On Our Nation <moononournation@gmail.com>
sentence=Arduino_GFX is a GFX library for various color displays with various data bus interfaces
paragraph=Arduino_GFX is a Arduino graphics library. Currently support GC9A01 round display, GC9106, GC9107, GC9503V, HX8347C, HX8347D, HX8352C, HX8357A, HX8357B, HX8369A, ILI6485, ILI9225, ILI9331, ILI9341, ILI9342(M5Stack), ILI9481, ILI9486, ILI9488, ILI9806, JBT6K71, NT35310, NT35510, NT39125, NV3041A, R61529, SEPS525, SSD1283A, SSD1331, SSD1351, ST7701, ST7735, ST7789, ST7796 and virtually all Raspberry Pi DPI display. Currently support software SPI (8-bit and 9-bit), hardware SPI (8-bit, ESP32 also support 9-bit), 8-bit parallel interface(AVR, ESP32, RPi Pico, RTL8720, STM32), 16-bit parallel interface(ESP32 and RPi Pico) and RGB Panel interface(ESP32S3).
url=https://github.com/moononournation/Arduino_GFX

View File

@ -1,16 +0,0 @@
#if !defined(LITTLE_FOOT_PRINT)
#include "Arduino_G.h"
/**************************************************************************/
/*!
@brief Instatiate a GFX context for graphics! Can only be done by a superclass
@param w Display width, in pixels
@param h Display height, in pixels
*/
/**************************************************************************/
Arduino_G::Arduino_G(int16_t w, int16_t h) : WIDTH(w), HEIGHT(h)
{
}
#endif // !defined(LITTLE_FOOT_PRINT)

View File

@ -1,34 +0,0 @@
#include "Arduino_GFX_Library.h"
Arduino_DataBus *create_default_Arduino_DataBus()
{
#if defined(ARDUINO_ARCH_NRF52840)
return new Arduino_NRFXSPI(DF_GFX_DC, DF_GFX_CS, DF_GFX_SCK, DF_GFX_MOSI, DF_GFX_MISO);
#elif defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_RASPBERRY_PI_PICO_W)
return new Arduino_RPiPicoSPI(DF_GFX_DC, DF_GFX_CS, DF_GFX_SCK, DF_GFX_MOSI, DF_GFX_MISO, spi0);
#elif defined(ESP32)
return new Arduino_ESP32SPI(DF_GFX_DC, DF_GFX_CS, DF_GFX_SCK, DF_GFX_MOSI, DF_GFX_MISO);
#elif defined(ESP8266)
return new Arduino_ESP8266SPI(DF_GFX_DC, DF_GFX_CS);
#else
return new Arduino_HWSPI(DF_GFX_DC, DF_GFX_CS);
#endif
}
Arduino_GFX *create_default_Arduino_GFX()
{
Arduino_DataBus *bus = create_default_Arduino_DataBus();
#if defined(WIO_TERMINAL)
return new Arduino_ILI9341(bus, DF_GFX_RST, 1 /* rotation */);
#elif defined(ESP32_S3_BOX)
return new Arduino_ILI9342(bus, DF_GFX_RST, 0 /* rotation */);
#elif defined(M5STACK_CORE)
return new Arduino_ILI9342(bus, DF_GFX_RST, 2 /* rotation */);
#elif defined(ODROID_GO)
return new Arduino_ILI9341(bus, DF_GFX_RST, 3 /* rotation */);
#elif defined(TTGO_T_WATCH)
return new Arduino_ST7789(bus, DF_GFX_RST, 0 /* rotation */, true /* IPS */, 240, 240, 0, 80);
#else
return new Arduino_ILI9341(bus, DF_GFX_RST, 0 /* rotation */);
#endif
}

View File

@ -1,250 +0,0 @@
#include "../Arduino_DataBus.h"
#if !defined(LITTLE_FOOT_PRINT)
#include "../Arduino_GFX.h"
#include "Arduino_Canvas.h"
Arduino_Canvas::Arduino_Canvas(
int16_t w, int16_t h, Arduino_G *output, int16_t output_x, int16_t output_y)
: Arduino_GFX(w, h), _output(output), _output_x(output_x), _output_y(output_y)
{
}
void Arduino_Canvas::begin(int32_t speed)
{
_output->begin(speed);
size_t s = _width * _height * 2;
#if defined(ESP32)
if (psramFound())
{
_framebuffer = (uint16_t *)ps_malloc(s);
}
else
{
_framebuffer = (uint16_t *)malloc(s);
if (!_framebuffer)
{
// hack for allocate memory over 63,360 pixels
s /= 2;
_framebuffer = (uint16_t *)malloc(s);
uint16_t *tmp = (uint16_t *)malloc(s);
UNUSED(tmp);
log_v("_framebuffer delta: %d", tmp - _framebuffer);
}
}
#else
_framebuffer = (uint16_t *)malloc(s);
#endif
if (!_framebuffer)
{
Serial.println(F("_framebuffer allocation failed."));
}
}
void Arduino_Canvas::writePixelPreclipped(int16_t x, int16_t y, uint16_t color)
{
_framebuffer[((int32_t)y * _width) + x] = color;
}
void Arduino_Canvas::writeFastVLine(int16_t x, int16_t y,
int16_t h, uint16_t color)
{
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
uint16_t *fb = _framebuffer + ((int32_t)y * _width) + x;
while (h--)
{
*fb = color;
fb += _width;
}
}
}
}
}
void Arduino_Canvas::writeFastHLine(int16_t x, int16_t y,
int16_t w, uint16_t color)
{
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
uint16_t *fb = _framebuffer + ((int32_t)y * _width) + x;
while (w--)
{
*(fb++) = color;
}
}
}
}
}
void Arduino_Canvas::writeFillRectPreclipped(int16_t x, int16_t y,
int16_t w, int16_t h, uint16_t color)
{
uint16_t *row = _framebuffer;
row += y * _width;
row += x;
for (int j = 0; j < h; j++)
{
for (int i = 0; i < w; i++)
{
row[i] = color;
}
row += _width;
}
}
void Arduino_Canvas::draw16bitRGBBitmap(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
{
int16_t xskip = 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)
{
xskip = (x + w - 1) - _max_x;
w -= xskip;
}
if (x < 0)
{
bitmap -= x;
xskip -= x;
w += x;
x = 0;
}
uint16_t *row = _framebuffer;
row += y * _width;
row += x;
for (int j = 0; j < h; j++)
{
for (int i = 0; i < w; i++)
{
row[i] = *bitmap++;
}
bitmap += xskip;
row += _width;
}
}
}
void Arduino_Canvas::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
{
int16_t xskip = 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)
{
xskip = (x + w - 1) - _max_x;
w -= xskip;
}
if (x < 0)
{
bitmap -= x;
xskip -= x;
w += x;
x = 0;
}
uint16_t *row = _framebuffer;
row += y * _width;
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 += xskip;
row += _width;
}
}
}
void Arduino_Canvas::flush()
{
_output->draw16bitRGBBitmap(_output_x, _output_y, _framebuffer, _width, _height);
}
#endif // !defined(LITTLE_FOOT_PRINT)

View File

@ -1,57 +0,0 @@
#include "../Arduino_DataBus.h"
#if !defined(LITTLE_FOOT_PRINT)
#include "../Arduino_GFX.h"
#include "Arduino_Canvas_3bit.h"
Arduino_Canvas_3bit::Arduino_Canvas_3bit(int16_t w, int16_t h, Arduino_G *output, int16_t output_x, int16_t output_y)
: Arduino_GFX(w, h), _output(output), _output_x(output_x), _output_y(output_y)
{
}
void Arduino_Canvas_3bit::begin(int32_t speed)
{
_output->begin(speed);
size_t s = (_width * _height + 1) / 2;
#if defined(ESP32)
if (psramFound())
{
_framebuffer = (uint8_t *)ps_malloc(s);
}
else
{
_framebuffer = (uint8_t *)malloc(s);
}
#else
_framebuffer = (uint8_t *)malloc(s);
#endif
if (!_framebuffer)
{
Serial.println(F("_framebuffer allocation failed."));
}
}
void Arduino_Canvas_3bit::writePixelPreclipped(int16_t x, int16_t y, uint16_t color)
{
int32_t pos = x + (y * _width);
int32_t idx = pos >> 1;
uint8_t c = (((color & 0b1000000000000000) ? 0b100 : 0) |
((color & 0b0000010000000000) ? 0b010 : 0) |
((color & 0b0000000000010000) ? 0b001 : 0));
if (pos & 1)
{
_framebuffer[idx] = (_framebuffer[idx] & 0b00111000) | c;
}
else
{
_framebuffer[idx] = (_framebuffer[idx] & 0b00000111) | (c << 3);
}
}
void Arduino_Canvas_3bit::flush()
{
_output->draw3bitRGBBitmap(_output_x, _output_y, _framebuffer, _width, _height);
}
#endif // !defined(LITTLE_FOOT_PRINT)

View File

@ -1,182 +0,0 @@
#include "../Arduino_DataBus.h"
#if !defined(LITTLE_FOOT_PRINT)
#include "../Arduino_GFX.h"
#include "Arduino_Canvas_Indexed.h"
Arduino_Canvas_Indexed::Arduino_Canvas_Indexed(int16_t w, int16_t h, Arduino_G *output, int16_t output_x, int16_t output_y, uint8_t mask_level)
: Arduino_GFX(w, h), _output(output), _output_x(output_x), _output_y(output_y)
{
if (mask_level >= MAXMASKLEVEL)
{
mask_level = MAXMASKLEVEL - 1;
}
_current_mask_level = mask_level;
_color_mask = mask_level_list[_current_mask_level];
}
void Arduino_Canvas_Indexed::begin(int32_t speed)
{
_output->begin(speed);
size_t s = _width * _height;
#if defined(ESP32)
if (psramFound())
{
_framebuffer = (uint8_t *)ps_malloc(s);
}
else
{
_framebuffer = (uint8_t *)malloc(s);
}
#else
_framebuffer = (uint8_t *)malloc(s);
#endif
if (!_framebuffer)
{
Serial.println(F("_framebuffer allocation failed."));
}
}
void Arduino_Canvas_Indexed::writePixelPreclipped(int16_t x, int16_t y, uint16_t color)
{
_framebuffer[((int32_t)y * _width) + x] = get_color_index(color);
}
void Arduino_Canvas_Indexed::writeFastVLine(int16_t x, int16_t y,
int16_t h, uint16_t color)
{
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
uint8_t idx = get_color_index(color);
uint8_t *fb = _framebuffer + ((int32_t)y * _width) + x;
while (h--)
{
*fb = idx;
fb += _width;
}
}
}
}
}
void Arduino_Canvas_Indexed::writeFastHLine(int16_t x, int16_t y,
int16_t w, uint16_t color)
{
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
uint8_t idx = get_color_index(color);
uint8_t *fb = _framebuffer + ((int32_t)y * _width) + x;
while (w--)
{
*(fb++) = idx;
}
}
}
}
}
void Arduino_Canvas_Indexed::flush()
{
_output->drawIndexedBitmap(_output_x, _output_y, _framebuffer, _color_index, _width, _height);
}
uint8_t Arduino_Canvas_Indexed::get_color_index(uint16_t color)
{
color &= _color_mask;
for (uint8_t i = 0; i < _indexed_size; i++)
{
if (_color_index[i] == color)
{
return i;
}
}
if (_indexed_size == (COLOR_IDX_SIZE - 1)) // overflowed
{
raise_mask_level();
}
_color_index[_indexed_size] = color;
// Serial.print("color_index[");
// Serial.print(_indexed_size);
// Serial.print("] = ");
// Serial.println(color);
return _indexed_size++;
}
uint16_t Arduino_Canvas_Indexed::get_index_color(uint8_t idx)
{
return _color_index[idx];
}
void Arduino_Canvas_Indexed::raise_mask_level()
{
if ((_current_mask_level + 1) < MAXMASKLEVEL)
{
int32_t buffer_size = _width * _height;
uint8_t old_indexed_size = _indexed_size;
uint8_t new_color;
_indexed_size = 0;
_color_mask = mask_level_list[++_current_mask_level];
Serial.print("Raised mask level: ");
Serial.println(_current_mask_level);
// update _framebuffer color index, it is a time consuming job
for (uint8_t old_color = 0; old_color < old_indexed_size; old_color++)
{
new_color = get_color_index(_color_index[old_color]);
for (int32_t i = 0; i < buffer_size; i++)
{
if (_framebuffer[i] == old_color)
{
_framebuffer[i] = new_color;
}
}
}
}
}
#endif // !defined(LITTLE_FOOT_PRINT)

View File

@ -1,54 +0,0 @@
#include "../Arduino_DataBus.h"
#if !defined(LITTLE_FOOT_PRINT)
#include "../Arduino_GFX.h"
#include "Arduino_Canvas_Mono.h"
Arduino_Canvas_Mono::Arduino_Canvas_Mono(int16_t w, int16_t h, Arduino_G *output, int16_t output_x, int16_t output_y)
: Arduino_GFX(w, h), _output(output), _output_x(output_x), _output_y(output_y)
{
}
void Arduino_Canvas_Mono::begin(int32_t speed)
{
_output->begin(speed);
size_t s = (_width + 7) / 8 * _height;
#if defined(ESP32)
if (psramFound())
{
_framebuffer = (uint8_t *)ps_malloc(s);
}
else
{
_framebuffer = (uint8_t *)malloc(s);
}
#else
_framebuffer = (uint8_t *)malloc(s);
#endif
if (!_framebuffer)
{
Serial.println(F("_framebuffer allocation failed."));
}
}
void Arduino_Canvas_Mono::writePixelPreclipped(int16_t x, int16_t y, uint16_t color)
{
int16_t w = (_width + 7) / 8;
int32_t pos = y * w + x / 8;
if (color & 0b1000010000010000)
{
_framebuffer[pos] |= 0x80 >> (x & 7);
}
else
{
_framebuffer[pos] &= ~(0x80 >> (x & 7));
}
}
void Arduino_Canvas_Mono::flush()
{
_output->drawBitmap(_output_x, _output_y, _framebuffer, _width, _height, WHITE, BLACK);
}
#endif // !defined(LITTLE_FOOT_PRINT)

View File

@ -1,283 +0,0 @@
/*
* start rewrite from:
* https://github.com/lovyan03/LovyanGFX/blob/master/src/lgfx/v0/platforms/LGFX_PARALLEL_ESP32.hpp
*/
#include "Arduino_ESP32LCD8.h"
#if defined(ESP32) && (CONFIG_IDF_TARGET_ESP32S3)
#define WAIT_LCD_NOT_BUSY while (LCD_CAM.lcd_user.val & LCD_CAM_LCD_START)
Arduino_ESP32LCD8::Arduino_ESP32LCD8(
int8_t dc, int8_t cs, int8_t wr, int8_t rd,
int8_t d0, int8_t d1, int8_t d2, int8_t d3, int8_t d4, int8_t d5, int8_t d6, int8_t d7)
: _dc(dc), _cs(cs), _wr(wr), _rd(rd),
_d0(d0), _d1(d1), _d2(d2), _d3(d3), _d4(d4), _d5(d5), _d6(d6), _d7(d7)
{
}
void Arduino_ESP32LCD8::begin(int32_t speed, int8_t dataMode)
{
if (speed == GFX_NOT_DEFINED)
{
_speed = 24000000UL;
}
else
{
_speed = speed;
}
pinMode(_dc, OUTPUT);
digitalWrite(_dc, HIGH);
if (_cs != GFX_NOT_DEFINED)
{
pinMode(_cs, OUTPUT);
digitalWrite(_cs, HIGH); // disable chip select
}
if (_cs >= 32)
{
_csPinMask = digitalPinToBitMask(_cs);
_csPortSet = (PORTreg_t)&GPIO.out1_w1ts.val;
_csPortClr = (PORTreg_t)&GPIO.out1_w1tc.val;
}
else if (_cs != GFX_NOT_DEFINED)
{
_csPinMask = digitalPinToBitMask(_cs);
_csPortSet = (PORTreg_t)&GPIO.out_w1ts;
_csPortClr = (PORTreg_t)&GPIO.out_w1tc;
}
pinMode(_wr, OUTPUT);
digitalWrite(_wr, HIGH);
if (_rd != GFX_NOT_DEFINED)
{
pinMode(_rd, OUTPUT);
digitalWrite(_rd, HIGH);
}
esp_lcd_i80_bus_config_t bus_config = {
.dc_gpio_num = _dc,
.wr_gpio_num = _wr,
.clk_src = LCD_CLK_SRC_PLL160M,
.data_gpio_nums = {
_d0, _d1, _d2, _d3, _d4, _d5, _d6, _d7},
.bus_width = 8,
.max_transfer_bytes = 2};
esp_lcd_new_i80_bus(&bus_config, &_i80_bus);
uint32_t diff = INT32_MAX;
uint32_t div_n = 256;
uint32_t div_a = 63;
uint32_t div_b = 62;
uint32_t clkcnt = 64;
uint32_t start_cnt = std::min<uint32_t>(64u, (F_CPU / (_speed * 2) + 1));
uint32_t end_cnt = std::max<uint32_t>(2u, F_CPU / 256u / _speed);
if (start_cnt <= 2)
{
end_cnt = 1;
}
for (uint32_t cnt = start_cnt; diff && cnt >= end_cnt; --cnt)
{
float fdiv = (float)F_CPU / cnt / _speed;
uint32_t n = std::max<uint32_t>(2u, (uint32_t)fdiv);
fdiv -= n;
for (uint32_t a = 63; diff && a > 0; --a)
{
uint32_t b = roundf(fdiv * a);
if (a == b && n == 256)
{
break;
}
uint32_t freq = F_CPU / ((n * cnt) + (float)(b * cnt) / (float)a);
uint32_t d = abs(_speed - (int)freq);
if (diff <= d)
{
continue;
}
diff = d;
clkcnt = cnt;
div_n = n;
div_b = b;
div_a = a;
if (b == 0 || a == b)
{
break;
}
}
}
if (div_a == div_b)
{
div_b = 0;
div_n += 1;
}
lcd_cam_lcd_clock_reg_t lcd_clock;
lcd_clock.lcd_clkcnt_n = std::max(1u, clkcnt - 1);
lcd_clock.lcd_clk_equ_sysclk = (clkcnt == 1);
lcd_clock.lcd_ck_idle_edge = true;
lcd_clock.lcd_ck_out_edge = false;
lcd_clock.lcd_clkm_div_num = div_n;
lcd_clock.lcd_clkm_div_b = div_b;
lcd_clock.lcd_clkm_div_a = div_a;
lcd_clock.lcd_clk_sel = 2; // clock_select: 1=XTAL CLOCK / 2=240MHz / 3=160MHz
lcd_clock.clk_en = true;
LCD_CAM.lcd_clock.val = lcd_clock.val;
}
void Arduino_ESP32LCD8::beginWrite()
{
CS_LOW();
LCD_CAM.lcd_misc.val = LCD_CAM_LCD_CD_IDLE_EDGE;
LCD_CAM.lcd_user.val = 0;
LCD_CAM.lcd_user.val = LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE_REG;
}
void Arduino_ESP32LCD8::endWrite()
{
WAIT_LCD_NOT_BUSY;
CS_HIGH();
}
void Arduino_ESP32LCD8::writeCommand(uint8_t c)
{
WRITECOMMAND(c);
}
void Arduino_ESP32LCD8::writeCommand16(uint16_t c)
{
WRITECOMMAND16(c);
}
void Arduino_ESP32LCD8::write(uint8_t d)
{
WRITE(d);
}
void Arduino_ESP32LCD8::write16(uint16_t d)
{
WRITE16(d);
}
void Arduino_ESP32LCD8::writeRepeat(uint16_t p, uint32_t len)
{
while (len--)
{
WRITE16(p);
}
}
void Arduino_ESP32LCD8::writePixels(uint16_t *data, uint32_t len)
{
LCD_CAM.lcd_misc.val = LCD_CAM_LCD_CD_IDLE_EDGE;
while (len--)
{
_data16.value = *data++;
LCD_CAM.lcd_cmd_val.lcd_cmd_value = _data16.msb;
WAIT_LCD_NOT_BUSY;
LCD_CAM.lcd_user.val = LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE_REG | LCD_CAM_LCD_START;
LCD_CAM.lcd_cmd_val.lcd_cmd_value = _data16.lsb;
WAIT_LCD_NOT_BUSY;
LCD_CAM.lcd_user.val = LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE_REG | LCD_CAM_LCD_START;
}
}
void Arduino_ESP32LCD8::writeBytes(uint8_t *data, uint32_t len)
{
LCD_CAM.lcd_misc.val = LCD_CAM_LCD_CD_IDLE_EDGE;
while (len--)
{
LCD_CAM.lcd_cmd_val.lcd_cmd_value = *data++;
WAIT_LCD_NOT_BUSY;
LCD_CAM.lcd_user.val = LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE_REG | LCD_CAM_LCD_START;
}
}
void Arduino_ESP32LCD8::writePattern(uint8_t *data, uint8_t len, uint32_t repeat)
{
while (repeat--)
{
writeBytes(data, len);
}
}
void Arduino_ESP32LCD8::writeIndexedPixels(uint8_t *data, uint16_t *idx, uint32_t len)
{
while (len--)
{
WRITE16(idx[*data++]);
}
}
void Arduino_ESP32LCD8::writeIndexedPixelsDouble(uint8_t *data, uint16_t *idx, uint32_t len)
{
while (len--)
{
WRITE16(idx[*data]);
WRITE16(idx[*data++]);
}
}
INLINE void Arduino_ESP32LCD8::WRITECOMMAND(uint8_t c)
{
LCD_CAM.lcd_misc.val = LCD_CAM_LCD_CD_IDLE_EDGE | LCD_CAM_LCD_CD_CMD_SET;
LCD_CAM.lcd_cmd_val.lcd_cmd_value = c;
WAIT_LCD_NOT_BUSY;
LCD_CAM.lcd_user.val = LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE_REG | LCD_CAM_LCD_START;
}
INLINE void Arduino_ESP32LCD8::WRITECOMMAND16(uint16_t c)
{
_data16.value = c;
LCD_CAM.lcd_misc.val = LCD_CAM_LCD_CD_IDLE_EDGE | LCD_CAM_LCD_CD_CMD_SET;
LCD_CAM.lcd_cmd_val.lcd_cmd_value = _data16.msb;
WAIT_LCD_NOT_BUSY;
LCD_CAM.lcd_user.val = LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE_REG | LCD_CAM_LCD_START;
LCD_CAM.lcd_cmd_val.lcd_cmd_value = _data16.lsb;
WAIT_LCD_NOT_BUSY;
LCD_CAM.lcd_user.val = LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE_REG | LCD_CAM_LCD_START;
}
INLINE void Arduino_ESP32LCD8::WRITE(uint8_t d)
{
LCD_CAM.lcd_misc.val = LCD_CAM_LCD_CD_IDLE_EDGE;
LCD_CAM.lcd_cmd_val.lcd_cmd_value = d;
WAIT_LCD_NOT_BUSY;
LCD_CAM.lcd_user.val = LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE_REG | LCD_CAM_LCD_START;
}
INLINE void Arduino_ESP32LCD8::WRITE16(uint16_t d)
{
_data16.value = d;
LCD_CAM.lcd_misc.val = LCD_CAM_LCD_CD_IDLE_EDGE;
LCD_CAM.lcd_cmd_val.lcd_cmd_value = _data16.msb;
WAIT_LCD_NOT_BUSY;
LCD_CAM.lcd_user.val = LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE_REG | LCD_CAM_LCD_START;
LCD_CAM.lcd_cmd_val.lcd_cmd_value = _data16.lsb;
WAIT_LCD_NOT_BUSY;
LCD_CAM.lcd_user.val = LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE_REG | LCD_CAM_LCD_START;
}
/******** low level bit twiddling **********/
INLINE void Arduino_ESP32LCD8::CS_HIGH(void)
{
if (_cs != GFX_NOT_DEFINED)
{
*_csPortSet = _csPinMask;
}
}
INLINE void Arduino_ESP32LCD8::CS_LOW(void)
{
if (_cs != GFX_NOT_DEFINED)
{
*_csPortClr = _csPinMask;
}
}
#endif // #if defined(ESP32) && (CONFIG_IDF_TARGET_ESP32S3)

View File

@ -1,293 +0,0 @@
#include "Arduino_ESP32RGBPanel.h"
#if defined(ESP32) && (CONFIG_IDF_TARGET_ESP32S3)
Arduino_ESP32RGBPanel::Arduino_ESP32RGBPanel(
int8_t cs, int8_t sck, int8_t sda,
int8_t de, int8_t vsync, int8_t hsync, int8_t pclk,
int8_t r0, int8_t r1, int8_t r2, int8_t r3, int8_t r4,
int8_t g0, int8_t g1, int8_t g2, int8_t g3, int8_t g4, int8_t g5,
int8_t b0, int8_t b1, int8_t b2, int8_t b3, int8_t b4,
bool useBigEndian)
: _cs(cs), _sck(sck), _sda(sda),
_de(de), _vsync(vsync), _hsync(hsync), _pclk(pclk),
_r0(r0), _r1(r1), _r2(r2), _r3(r3), _r4(r4),
_g0(g0), _g1(g1), _g2(g2), _g3(g3), _g4(g4), _g5(g5),
_b0(b0), _b1(b1), _b2(b2), _b3(b3), _b4(b4),
_useBigEndian(useBigEndian)
{
}
void Arduino_ESP32RGBPanel::begin(int32_t speed, int8_t dataMode)
{
if (speed == GFX_NOT_DEFINED)
{
#ifdef CONFIG_SPIRAM_MODE_QUAD
_speed = 6000000L;
#else
_speed = 12000000L;
#endif
}
else
{
_speed = speed;
}
UNUSED(dataMode);
if (_cs != GFX_NOT_DEFINED)
{
pinMode(_cs, OUTPUT);
digitalWrite(_cs, HIGH); // disable chip select
}
if (_cs >= 32)
{
_csPinMask = digitalPinToBitMask(_cs);
_csPortSet = (PORTreg_t)&GPIO.out1_w1ts.val;
_csPortClr = (PORTreg_t)&GPIO.out1_w1tc.val;
}
else
{
_csPinMask = digitalPinToBitMask(_cs);
_csPortSet = (PORTreg_t)&GPIO.out_w1ts;
_csPortClr = (PORTreg_t)&GPIO.out_w1tc;
}
if (_sck != GFX_NOT_DEFINED)
{
pinMode(_sck, OUTPUT);
digitalWrite(_sck, LOW);
}
if (_sck >= 32)
{
_sckPinMask = digitalPinToBitMask(_sck);
_sckPortSet = (PORTreg_t)&GPIO.out1_w1ts.val;
_sckPortClr = (PORTreg_t)&GPIO.out1_w1tc.val;
}
else
{
_sckPinMask = digitalPinToBitMask(_sck);
_sckPortSet = (PORTreg_t)&GPIO.out_w1ts;
_sckPortClr = (PORTreg_t)&GPIO.out_w1tc;
}
if (_sda != GFX_NOT_DEFINED)
{
pinMode(_sda, OUTPUT);
digitalWrite(_sda, LOW);
}
if (_sda >= 32)
{
_sdaPinMask = digitalPinToBitMask(_sda);
_sdaPortSet = (PORTreg_t)&GPIO.out1_w1ts.val;
_sdaPortClr = (PORTreg_t)&GPIO.out1_w1tc.val;
}
else
{
_sdaPinMask = digitalPinToBitMask(_sda);
_sdaPortSet = (PORTreg_t)&GPIO.out_w1ts;
_sdaPortClr = (PORTreg_t)&GPIO.out_w1tc;
}
}
void Arduino_ESP32RGBPanel::beginWrite()
{
CS_LOW();
}
void Arduino_ESP32RGBPanel::endWrite()
{
CS_HIGH();
}
void Arduino_ESP32RGBPanel::writeCommand(uint8_t c)
{
// D/C bit, command
SDA_LOW();
SCK_HIGH();
SCK_LOW();
uint8_t bit = 0x80;
while (bit)
{
if (c & bit)
{
SDA_HIGH();
}
else
{
SDA_LOW();
}
SCK_HIGH();
bit >>= 1;
SCK_LOW();
}
}
void Arduino_ESP32RGBPanel::writeCommand16(uint16_t)
{
}
void Arduino_ESP32RGBPanel::write(uint8_t d)
{
// D/C bit, data
SDA_HIGH();
SCK_HIGH();
SCK_LOW();
uint8_t bit = 0x80;
while (bit)
{
if (d & bit)
{
SDA_HIGH();
}
else
{
SDA_LOW();
}
SCK_HIGH();
bit >>= 1;
SCK_LOW();
}
}
void Arduino_ESP32RGBPanel::write16(uint16_t)
{
}
void Arduino_ESP32RGBPanel::writeRepeat(uint16_t p, uint32_t len)
{
}
void Arduino_ESP32RGBPanel::writePixels(uint16_t *data, uint32_t len)
{
}
void Arduino_ESP32RGBPanel::writeBytes(uint8_t *data, uint32_t len)
{
}
void Arduino_ESP32RGBPanel::writePattern(uint8_t *data, uint8_t len, uint32_t repeat)
{
}
uint16_t *Arduino_ESP32RGBPanel::getFrameBuffer(
uint16_t w, uint16_t h,
uint16_t hsync_pulse_width, uint16_t hsync_back_porch, uint16_t hsync_front_porch, uint16_t hsync_polarity,
uint16_t vsync_pulse_width, uint16_t vsync_back_porch, uint16_t vsync_front_porch, uint16_t vsync_polarity,
uint16_t pclk_active_neg, int32_t prefer_speed)
{
esp_lcd_rgb_panel_config_t *_panel_config = (esp_lcd_rgb_panel_config_t *)heap_caps_calloc(1, sizeof(esp_lcd_rgb_panel_config_t), MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL);
_panel_config->clk_src = LCD_CLK_SRC_PLL160M;
_panel_config->timings.pclk_hz = (prefer_speed == GFX_NOT_DEFINED) ? _speed : prefer_speed;
_panel_config->timings.h_res = w;
_panel_config->timings.v_res = h;
// The following parameters should refer to LCD spec
_panel_config->timings.hsync_pulse_width = hsync_pulse_width;
_panel_config->timings.hsync_back_porch = hsync_back_porch;
_panel_config->timings.hsync_front_porch = hsync_front_porch;
_panel_config->timings.vsync_pulse_width = vsync_pulse_width;
_panel_config->timings.vsync_back_porch = vsync_back_porch;
_panel_config->timings.vsync_front_porch = vsync_front_porch;
_panel_config->timings.flags.hsync_idle_low = (hsync_polarity == 0) ? 1 : 0;
_panel_config->timings.flags.vsync_idle_low = (vsync_polarity == 0) ? 1 : 0;
_panel_config->timings.flags.de_idle_high = 0;
_panel_config->timings.flags.pclk_active_neg = pclk_active_neg;
_panel_config->timings.flags.pclk_idle_high = 0;
_panel_config->data_width = 16; // RGB565 in parallel mode, thus 16bit in width
_panel_config->sram_trans_align = 8;
_panel_config->psram_trans_align = 64;
_panel_config->hsync_gpio_num = _hsync;
_panel_config->vsync_gpio_num = _vsync;
_panel_config->de_gpio_num = _de;
_panel_config->pclk_gpio_num = _pclk;
if (_useBigEndian)
{
_panel_config->data_gpio_nums[0] = _g3;
_panel_config->data_gpio_nums[1] = _g4;
_panel_config->data_gpio_nums[2] = _g5;
_panel_config->data_gpio_nums[3] = _r0;
_panel_config->data_gpio_nums[4] = _r1;
_panel_config->data_gpio_nums[5] = _r2;
_panel_config->data_gpio_nums[6] = _r3;
_panel_config->data_gpio_nums[7] = _r4;
_panel_config->data_gpio_nums[8] = _b0;
_panel_config->data_gpio_nums[9] = _b1;
_panel_config->data_gpio_nums[10] = _b2;
_panel_config->data_gpio_nums[11] = _b3;
_panel_config->data_gpio_nums[12] = _b4;
_panel_config->data_gpio_nums[13] = _g0;
_panel_config->data_gpio_nums[14] = _g1;
_panel_config->data_gpio_nums[15] = _g2;
}
else
{
_panel_config->data_gpio_nums[0] = _b0;
_panel_config->data_gpio_nums[1] = _b1;
_panel_config->data_gpio_nums[2] = _b2;
_panel_config->data_gpio_nums[3] = _b3;
_panel_config->data_gpio_nums[4] = _b4;
_panel_config->data_gpio_nums[5] = _g0;
_panel_config->data_gpio_nums[6] = _g1;
_panel_config->data_gpio_nums[7] = _g2;
_panel_config->data_gpio_nums[8] = _g3;
_panel_config->data_gpio_nums[9] = _g4;
_panel_config->data_gpio_nums[10] = _g5;
_panel_config->data_gpio_nums[11] = _r0;
_panel_config->data_gpio_nums[12] = _r1;
_panel_config->data_gpio_nums[13] = _r2;
_panel_config->data_gpio_nums[14] = _r3;
_panel_config->data_gpio_nums[15] = _r4;
}
_panel_config->disp_gpio_num = GPIO_NUM_NC;
_panel_config->flags.disp_active_low = 0;
_panel_config->flags.relax_on_idle = 0;
_panel_config->flags.fb_in_psram = 1; // allocate frame buffer in PSRAM
ESP_ERROR_CHECK(esp_lcd_new_rgb_panel(_panel_config, &_panel_handle));
ESP_ERROR_CHECK(esp_lcd_panel_reset(_panel_handle));
ESP_ERROR_CHECK(esp_lcd_panel_init(_panel_handle));
uint16_t color = random(0xffff);
ESP_ERROR_CHECK(_panel_handle->draw_bitmap(_panel_handle, 0, 0, 1, 1, &color));
_rgb_panel = __containerof(_panel_handle, esp_rgb_panel_t, base);
return (uint16_t *)_rgb_panel->fb;
}
INLINE void Arduino_ESP32RGBPanel::CS_HIGH(void)
{
*_csPortSet = _csPinMask;
}
INLINE void Arduino_ESP32RGBPanel::CS_LOW(void)
{
*_csPortClr = _csPinMask;
}
INLINE void Arduino_ESP32RGBPanel::SCK_HIGH(void)
{
*_sckPortSet = _sckPinMask;
}
INLINE void Arduino_ESP32RGBPanel::SCK_LOW(void)
{
*_sckPortClr = _sckPinMask;
}
INLINE void Arduino_ESP32RGBPanel::SDA_HIGH(void)
{
*_sdaPortSet = _sdaPinMask;
}
INLINE void Arduino_ESP32RGBPanel::SDA_LOW(void)
{
*_sdaPortClr = _sdaPinMask;
}
#endif // #if defined(ESP32) && (CONFIG_IDF_TARGET_ESP32S3)

View File

@ -1,283 +0,0 @@
#include "../Arduino_DataBus.h"
#if defined(ESP32) && (CONFIG_IDF_TARGET_ESP32S3)
#include "../Arduino_GFX.h"
#include "Arduino_GC9503V_RGBPanel.h"
Arduino_GC9503V_RGBPanel::Arduino_GC9503V_RGBPanel(
Arduino_ESP32RGBPanel *bus, int8_t rst, int16_t w, int16_t h,
const uint8_t *init_operations, size_t init_operations_len)
: Arduino_GFX(w, h), _bus(bus), _rst(rst),
_init_operations(init_operations), _init_operations_len(init_operations_len)
{
}
void Arduino_GC9503V_RGBPanel::begin(int32_t speed)
{
_bus->begin(speed);
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(120);
digitalWrite(_rst, HIGH);
delay(120);
}
else
{
// Software Rest
_bus->sendCommand(0x01);
delay(120);
}
_bus->batchOperation(_init_operations, _init_operations_len);
_framebuffer = _bus->getFrameBuffer(_width, _height);
}
void Arduino_GC9503V_RGBPanel::writePixelPreclipped(int16_t x, int16_t y, uint16_t color)
{
uint16_t *fb = _framebuffer;
fb += (int32_t)y * _width;
fb += x;
*fb = color;
Cache_WriteBack_Addr((uint32_t)fb, 2);
}
void Arduino_GC9503V_RGBPanel::writeFastVLine(int16_t x, int16_t y,
int16_t h, uint16_t color)
{
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
uint16_t *fb = _framebuffer + ((int32_t)y * _width) + x;
while (h--)
{
*fb = color;
Cache_WriteBack_Addr((uint32_t)fb, 2);
fb += _width;
}
}
}
}
}
void Arduino_GC9503V_RGBPanel::writeFastHLine(int16_t x, int16_t y,
int16_t w, uint16_t color)
{
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
uint16_t *fb = _framebuffer + ((int32_t)y * _width) + x;
uint32_t cachePos = (uint32_t)fb;
int16_t writeSize = w * 2;
while (w--)
{
*(fb++) = color;
}
Cache_WriteBack_Addr(cachePos, writeSize);
}
}
}
}
void Arduino_GC9503V_RGBPanel::writeFillRectPreclipped(int16_t x, int16_t y,
int16_t w, int16_t h, uint16_t color)
{
uint16_t *row = _framebuffer;
row += y * _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 += _width;
}
Cache_WriteBack_Addr(cachePos, _width * h * 2);
}
void Arduino_GC9503V_RGBPanel::draw16bitRGBBitmap(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
{
int16_t xskip = 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)
{
xskip = (x + w - 1) - _max_x;
w -= xskip;
}
if (x < 0)
{
bitmap -= x;
xskip -= x;
w += x;
x = 0;
}
uint16_t *row = _framebuffer;
row += y * _width;
uint32_t cachePos = (uint32_t)row;
row += x;
if (((_width & 1) == 0) && ((xskip & 1) == 0) && ((w & 1) == 0))
{
uint32_t *row2 = (uint32_t *)row;
uint32_t *bitmap2 = (uint32_t *)bitmap;
int16_t _width2 = _width >> 1;
int16_t xskip2 = xskip >> 1;
int16_t w2 = w >> 1;
for (int16_t j = 0; j < h; j++)
{
for (int16_t i = 0; i < w2; i++)
{
row2[i] = *bitmap2++;
}
bitmap2 += xskip2;
row2 += _width2;
}
}
else
{
for (int j = 0; j < h; j++)
{
for (int i = 0; i < w; i++)
{
row[i] = *bitmap++;
}
bitmap += xskip;
row += _width;
}
}
Cache_WriteBack_Addr(cachePos, _width * h * 2);
}
}
void Arduino_GC9503V_RGBPanel::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
{
int16_t xskip = 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)
{
xskip = (x + w - 1) - _max_x;
w -= xskip;
}
if (x < 0)
{
bitmap -= x;
xskip -= x;
w += x;
x = 0;
}
uint16_t *row = _framebuffer;
row += y * _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 += xskip;
row += _width;
}
Cache_WriteBack_Addr(cachePos, _width * h * 2);
}
}
uint16_t *Arduino_GC9503V_RGBPanel::getFramebuffer()
{
return _framebuffer;
}
#endif // #if defined(ESP32) && (CONFIG_IDF_TARGET_ESP32S3)

View File

@ -1,248 +0,0 @@
#include "../Arduino_DataBus.h"
#if defined(ESP32) && (CONFIG_IDF_TARGET_ESP32S3)
#ifndef _ARDUINO_GC9503V_RGBPANEL_H_
#define _ARDUINO_GC9503V_RGBPANEL_H_
#include "../Arduino_GFX.h"
#include "../databus/Arduino_ESP32RGBPanel.h"
#define ST7701_TFTWIDTH 480
#define ST7701_TFTHEIGHT 864
static const uint8_t gc9503v_type1_init_operations[] = {
BEGIN_WRITE,
WRITE_COMMAND_8, 0xF0,
WRITE_BYTES, 5, 0x55, 0xAA, 0x52, 0x08, 0x00,
WRITE_C8_D16, 0xF6, 0x5A, 0x87,
WRITE_C8_D8, 0xC1, 0x3F,
WRITE_C8_D8, 0xC2, 0x0E,
WRITE_C8_D8, 0xC6, 0xF8,
WRITE_C8_D8, 0xC9, 0x10,
WRITE_C8_D8, 0xCD, 0x25,
WRITE_C8_D8, 0xF8, 0x8A,
WRITE_C8_D8, 0xAC, 0x45,
WRITE_C8_D8, 0xA0, 0xDD,
WRITE_C8_D8, 0xA7, 0x47,
WRITE_COMMAND_8, 0xFA,
WRITE_BYTES, 4, 0x00, 0x00, 0x00, 0x04,
WRITE_C8_D8, 0xA3, 0xEE,
WRITE_COMMAND_8, 0xFD,
WRITE_BYTES, 3, 0x28, 0x28, 0x00,
WRITE_C8_D8, 0x71, 0x48,
WRITE_C8_D8, 0x72, 0x48,
WRITE_C8_D16, 0x73, 0x00, 0x44,
WRITE_C8_D8, 0x97, 0xEE,
WRITE_C8_D8, 0x83, 0x93,
WRITE_C8_D8, 0x9A, 0x72,
WRITE_C8_D8, 0x9B, 0x5a,
WRITE_C8_D16, 0x82, 0x2c, 0x2c,
WRITE_C8_D8, 0xB1, 0x10,
WRITE_COMMAND_8, 0x6D,
WRITE_BYTES, 32,
0x00, 0x1F, 0x19, 0x1A,
0x10, 0x0e, 0x0c, 0x0a,
0x02, 0x07, 0x1E, 0x1E,
0x1E, 0x1E, 0x1E, 0x1E,
0x1E, 0x1E, 0x1E, 0x1E,
0x1E, 0x1E, 0x08, 0x01,
0x09, 0x0b, 0x0D, 0x0F,
0x1a, 0x19, 0x1f, 0x00,
WRITE_COMMAND_8, 0x64,
WRITE_BYTES, 16,
0x38, 0x05, 0x01, 0xdb,
0x03, 0x03, 0x38, 0x04,
0x01, 0xdc, 0x03, 0x03,
0x7A, 0x7A, 0x7A, 0x7A,
WRITE_COMMAND_8, 0x65,
WRITE_BYTES, 16,
0x38, 0x03, 0x01, 0xdd,
0x03, 0x03, 0x38, 0x02,
0x01, 0xde, 0x03, 0x03,
0x7A, 0x7A, 0x7A, 0x7A,
WRITE_COMMAND_8, 0x66,
WRITE_BYTES, 16,
0x38, 0x01, 0x01, 0xdf,
0x03, 0x03, 0x38, 0x00,
0x01, 0xe0, 0x03, 0x03,
0x7A, 0x7A, 0x7A, 0x7A,
WRITE_COMMAND_8, 0x67,
WRITE_BYTES, 16,
0x30, 0x01, 0x01, 0xe1,
0x03, 0x03, 0x30, 0x02,
0x01, 0xe2, 0x03, 0x03,
0x7A, 0x7A, 0x7A, 0x7A,
WRITE_COMMAND_8, 0x68,
WRITE_BYTES, 13,
0x00, 0x08, 0x15, 0x08,
0x15, 0x7A, 0x7A, 0x08,
0x15, 0x08, 0x15, 0x7A,
0x7A,
WRITE_COMMAND_8, 0x60,
WRITE_BYTES, 8,
0x38, 0x08, 0x7A, 0x7A,
0x38, 0x09, 0x7A, 0x7A,
WRITE_COMMAND_8, 0x63,
WRITE_BYTES, 8,
0x31, 0xe4, 0x7A, 0x7A,
0x31, 0xe5, 0x7A, 0x7A,
WRITE_C8_D8, 0x6B, 0x07,
WRITE_C8_D16, 0x7A, 0x08, 0x13,
WRITE_C8_D16, 0x7B, 0x08, 0x13,
WRITE_COMMAND_8, 0xD1,
WRITE_BYTES, 52,
0x00, 0x00, 0x00, 0x04,
0x00, 0x12, 0x00, 0x18,
0x00, 0x21, 0x00, 0x2a,
0x00, 0x35, 0x00, 0x47,
0x00, 0x56, 0x00, 0x90,
0x00, 0xe5, 0x01, 0x68,
0x01, 0xd5, 0x01, 0xd7,
0x02, 0x36, 0x02, 0xa6,
0x02, 0xee, 0x03, 0x48,
0x03, 0xa0, 0x03, 0xba,
0x03, 0xc5, 0x03, 0xd0,
0x03, 0xE0, 0x03, 0xea,
0x03, 0xFa, 0x03, 0xFF,
WRITE_COMMAND_8, 0xD2,
WRITE_BYTES, 52,
0x00, 0x00, 0x00, 0x04,
0x00, 0x12, 0x00, 0x18,
0x00, 0x21, 0x00, 0x2a,
0x00, 0x35, 0x00, 0x47,
0x00, 0x56, 0x00, 0x90,
0x00, 0xe5, 0x01, 0x68,
0x01, 0xd5, 0x01, 0xd7,
0x02, 0x36, 0x02, 0xa6,
0x02, 0xee, 0x03, 0x48,
0x03, 0xa0, 0x03, 0xba,
0x03, 0xc5, 0x03, 0xd0,
0x03, 0xE0, 0x03, 0xea,
0x03, 0xFa, 0x03, 0xFF,
WRITE_COMMAND_8, 0xD3,
WRITE_BYTES, 52,
0x00, 0x00, 0x00, 0x04,
0x00, 0x12, 0x00, 0x18,
0x00, 0x21, 0x00, 0x2a,
0x00, 0x35, 0x00, 0x47,
0x00, 0x56, 0x00, 0x90,
0x00, 0xe5, 0x01, 0x68,
0x01, 0xd5, 0x01, 0xd7,
0x02, 0x36, 0x02, 0xa6,
0x02, 0xee, 0x03, 0x48,
0x03, 0xa0, 0x03, 0xba,
0x03, 0xc5, 0x03, 0xd0,
0x03, 0xE0, 0x03, 0xea,
0x03, 0xFa, 0x03, 0xFF,
WRITE_COMMAND_8, 0xD4,
WRITE_BYTES, 52,
0x00, 0x00, 0x00, 0x04,
0x00, 0x12, 0x00, 0x18,
0x00, 0x21, 0x00, 0x2a,
0x00, 0x35, 0x00, 0x47,
0x00, 0x56, 0x00, 0x90,
0x00, 0xe5, 0x01, 0x68,
0x01, 0xd5, 0x01, 0xd7,
0x02, 0x36, 0x02, 0xa6,
0x02, 0xee, 0x03, 0x48,
0x03, 0xa0, 0x03, 0xba,
0x03, 0xc5, 0x03, 0xd0,
0x03, 0xE0, 0x03, 0xea,
0x03, 0xFa, 0x03, 0xFF,
WRITE_COMMAND_8, 0xD5,
WRITE_BYTES, 52,
0x00, 0x00, 0x00, 0x04,
0x00, 0x12, 0x00, 0x18,
0x00, 0x21, 0x00, 0x2a,
0x00, 0x35, 0x00, 0x47,
0x00, 0x56, 0x00, 0x90,
0x00, 0xe5, 0x01, 0x68,
0x01, 0xd5, 0x01, 0xd7,
0x02, 0x36, 0x02, 0xa6,
0x02, 0xee, 0x03, 0x48,
0x03, 0xa0, 0x03, 0xba,
0x03, 0xc5, 0x03, 0xd0,
0x03, 0xE0, 0x03, 0xea,
0x03, 0xFa, 0x03, 0xFF,
WRITE_COMMAND_8, 0xD6,
WRITE_BYTES, 52,
0x00, 0x00, 0x00, 0x04,
0x00, 0x12, 0x00, 0x18,
0x00, 0x21, 0x00, 0x2a,
0x00, 0x35, 0x00, 0x47,
0x00, 0x56, 0x00, 0x90,
0x00, 0xe5, 0x01, 0x68,
0x01, 0xd5, 0x01, 0xd7,
0x02, 0x36, 0x02, 0xa6,
0x02, 0xee, 0x03, 0x48,
0x03, 0xa0, 0x03, 0xba,
0x03, 0xc5, 0x03, 0xd0,
0x03, 0xE0, 0x03, 0xea,
0x03, 0xFa, 0x03, 0xFF,
WRITE_C8_D8, 0x3a, 0x66,
WRITE_COMMAND_8, 0x11,
END_WRITE,
DELAY, 200,
BEGIN_WRITE,
WRITE_COMMAND_8, 0x29,
END_WRITE};
class Arduino_GC9503V_RGBPanel : public Arduino_GFX
{
public:
Arduino_GC9503V_RGBPanel(
Arduino_ESP32RGBPanel *bus, int8_t rst = GFX_NOT_DEFINED, int16_t w = ST7701_TFTWIDTH, int16_t h = ST7701_TFTHEIGHT,
const uint8_t *init_operations = gc9503v_type1_init_operations,
size_t init_operations_len = sizeof(gc9503v_type1_init_operations));
void 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 writeFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color) override;
void writeFillRectPreclipped(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) 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;
uint16_t *getFramebuffer();
protected:
uint16_t *_framebuffer;
Arduino_ESP32RGBPanel *_bus;
int8_t _rst;
const uint8_t *_init_operations;
size_t _init_operations_len;
private:
};
#endif // _ARDUINO_GC9503V_RGBPANEL_H_
#endif // #if defined(ESP32) && (CONFIG_IDF_TARGET_ESP32S3)

View File

@ -1,306 +0,0 @@
#include "../Arduino_DataBus.h"
#if defined(ESP32) && (CONFIG_IDF_TARGET_ESP32S3)
#include "../Arduino_GFX.h"
#include "Arduino_RPi_DPI_RGBPanel.h"
Arduino_RPi_DPI_RGBPanel::Arduino_RPi_DPI_RGBPanel(
Arduino_ESP32RGBPanel *bus,
int16_t w, uint16_t hsync_polarity, uint16_t hsync_front_porch, uint16_t hsync_pulse_width, uint16_t hsync_back_porch,
int16_t h, uint16_t vsync_polarity, uint16_t vsync_front_porch, uint16_t vsync_pulse_width, uint16_t vsync_back_porch,
uint16_t pclk_active_neg, int32_t prefer_speed, bool auto_flush)
: Arduino_GFX(w, h), _bus(bus),
_hsync_polarity(hsync_polarity), _hsync_front_porch(hsync_front_porch), _hsync_pulse_width(hsync_pulse_width), _hsync_back_porch(hsync_back_porch),
_vsync_polarity(vsync_polarity), _vsync_front_porch(vsync_front_porch), _vsync_pulse_width(vsync_pulse_width), _vsync_back_porch(vsync_back_porch),
_pclk_active_neg(pclk_active_neg), _prefer_speed(prefer_speed), _auto_flush(auto_flush)
{
_framebuffer_size = w * h * 2;
}
void Arduino_RPi_DPI_RGBPanel::begin(int32_t speed)
{
_bus->begin(speed);
_framebuffer = _bus->getFrameBuffer(
_width, _height,
_hsync_pulse_width, _hsync_back_porch, _hsync_front_porch, _hsync_polarity,
_vsync_pulse_width, _vsync_back_porch, _vsync_front_porch, _vsync_polarity,
_pclk_active_neg, _prefer_speed);
}
void Arduino_RPi_DPI_RGBPanel::writePixelPreclipped(int16_t x, int16_t y, uint16_t color)
{
uint16_t *fb = _framebuffer;
fb += (int32_t)y * _width;
fb += x;
*fb = color;
if (_auto_flush)
{
Cache_WriteBack_Addr((uint32_t)fb, 2);
}
}
void Arduino_RPi_DPI_RGBPanel::writeFastVLine(int16_t x, int16_t y,
int16_t h, uint16_t color)
{
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
uint16_t *fb = _framebuffer + ((int32_t)y * _width) + x;
if (_auto_flush)
{
while (h--)
{
*fb = color;
Cache_WriteBack_Addr((uint32_t)fb, 2);
fb += _width;
}
}
else
{
while (h--)
{
*fb = color;
fb += _width;
}
}
}
}
}
}
void Arduino_RPi_DPI_RGBPanel::writeFastHLine(int16_t x, int16_t y,
int16_t w, uint16_t color)
{
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
uint16_t *fb = _framebuffer + ((int32_t)y * _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_RPi_DPI_RGBPanel::writeFillRectPreclipped(int16_t x, int16_t y,
int16_t w, int16_t h, uint16_t color)
{
uint16_t *row = _framebuffer;
row += y * _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 += _width;
}
if (_auto_flush)
{
Cache_WriteBack_Addr(cachePos, _width * h * 2);
}
}
void Arduino_RPi_DPI_RGBPanel::draw16bitRGBBitmap(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
{
int16_t xskip = 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)
{
xskip = (x + w - 1) - _max_x;
w -= xskip;
}
if (x < 0)
{
bitmap -= x;
xskip -= x;
w += x;
x = 0;
}
uint16_t *row = _framebuffer;
row += y * _width;
uint32_t cachePos = (uint32_t)row;
row += x;
if (((_width & 1) == 0) && ((xskip & 1) == 0) && ((w & 1) == 0))
{
uint32_t *row2 = (uint32_t *)row;
uint32_t *bitmap2 = (uint32_t *)bitmap;
int16_t _width2 = _width >> 1;
int16_t xskip2 = xskip >> 1;
int16_t w2 = w >> 1;
for (int16_t j = 0; j < h; j++)
{
for (int16_t i = 0; i < w2; i++)
{
row2[i] = *bitmap2++;
}
bitmap2 += xskip2;
row2 += _width2;
}
}
else
{
for (int j = 0; j < h; j++)
{
for (int i = 0; i < w; i++)
{
row[i] = *bitmap++;
}
bitmap += xskip;
row += _width;
}
}
if (_auto_flush)
{
Cache_WriteBack_Addr(cachePos, _width * h * 2);
}
}
}
void Arduino_RPi_DPI_RGBPanel::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
{
int16_t xskip = 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)
{
xskip = (x + w - 1) - _max_x;
w -= xskip;
}
if (x < 0)
{
bitmap -= x;
xskip -= x;
w += x;
x = 0;
}
uint16_t *row = _framebuffer;
row += y * _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 += xskip;
row += _width;
}
if (_auto_flush)
{
Cache_WriteBack_Addr(cachePos, _width * h * 2);
}
}
}
void Arduino_RPi_DPI_RGBPanel::flush(void)
{
if (!_auto_flush)
{
Cache_WriteBack_Addr((uint32_t)_framebuffer, _framebuffer_size);
}
}
uint16_t *Arduino_RPi_DPI_RGBPanel::getFramebuffer()
{
return _framebuffer;
}
#endif // #if defined(ESP32) && (CONFIG_IDF_TARGET_ESP32S3)

View File

@ -1,53 +0,0 @@
#include "../Arduino_DataBus.h"
#if defined(ESP32) && (CONFIG_IDF_TARGET_ESP32S3)
#ifndef _ARDUINO_RPI_DPI_RGBPANEL_H_
#define _ARDUINO_RPI_DPI_RGBPANEL_H_
#include "../Arduino_GFX.h"
#include "../databus/Arduino_ESP32RGBPanel.h"
class Arduino_RPi_DPI_RGBPanel : public Arduino_GFX
{
public:
Arduino_RPi_DPI_RGBPanel(
Arduino_ESP32RGBPanel *bus,
int16_t w, uint16_t hsync_polarity, uint16_t hsync_front_porch, uint16_t hsync_pulse_width, uint16_t hsync_back_porch,
int16_t h, uint16_t vsync_polarity, uint16_t vsync_front_porch, uint16_t vsync_pulse_width, uint16_t vsync_back_porch,
uint16_t pclk_active_neg = 0, int32_t prefer_speed = GFX_NOT_DEFINED, bool auto_flush = true);
void 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 writeFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color) override;
void writeFillRectPreclipped(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) 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(void) override;
uint16_t *getFramebuffer();
protected:
uint16_t *_framebuffer;
size_t _framebuffer_size;
Arduino_ESP32RGBPanel *_bus;
uint16_t _hsync_polarity;
uint16_t _hsync_front_porch;
uint16_t _hsync_pulse_width;
uint16_t _hsync_back_porch;
uint16_t _vsync_polarity;
uint16_t _vsync_front_porch;
uint16_t _vsync_pulse_width;
uint16_t _vsync_back_porch;
uint16_t _pclk_active_neg;
int32_t _prefer_speed;
bool _auto_flush;
private:
};
#endif // _ARDUINO_RPI_DPI_RGBPANEL_H_
#endif // #if defined(ESP32) && (CONFIG_IDF_TARGET_ESP32S3)

View File

@ -1,362 +0,0 @@
#include "../Arduino_DataBus.h"
#if defined(ESP32) && (CONFIG_IDF_TARGET_ESP32S3)
#include "../Arduino_GFX.h"
#include "Arduino_ST7701_RGBPanel.h"
Arduino_ST7701_RGBPanel::Arduino_ST7701_RGBPanel(
Arduino_ESP32RGBPanel *bus, int8_t rst, uint8_t r,
bool ips, int16_t w, int16_t h,
const uint8_t *init_operations, size_t init_operations_len,
bool bgr,
uint16_t hsync_front_porch, uint16_t hsync_pulse_width, uint16_t hsync_back_porch,
uint16_t vsync_front_porch, uint16_t vsync_pulse_width, uint16_t vsync_back_porch)
: Arduino_GFX(w, h), _bus(bus), _rst(rst), _ips(ips),
_init_operations(init_operations), _init_operations_len(init_operations_len),
_bgr(bgr),
_hsync_front_porch(hsync_front_porch), _hsync_pulse_width(hsync_pulse_width), _hsync_back_porch(hsync_back_porch),
_vsync_front_porch(vsync_front_porch), _vsync_pulse_width(vsync_pulse_width), _vsync_back_porch(vsync_back_porch)
{
_rotation = r;
}
void Arduino_ST7701_RGBPanel::begin(int32_t speed)
{
_bus->begin(speed);
if (_rst != GFX_NOT_DEFINED)
{
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH);
delay(100);
digitalWrite(_rst, LOW);
delay(120);
digitalWrite(_rst, HIGH);
delay(120);
}
else
{
// Software Rest
_bus->sendCommand(0x01);
delay(120);
}
_bus->batchOperation((uint8_t *)_init_operations, _init_operations_len);
invertDisplay(false);
setRotation(_rotation);
_framebuffer = _bus->getFrameBuffer(_width, _height,
_hsync_pulse_width, _hsync_back_porch, _hsync_front_porch, 1,
_vsync_pulse_width, _vsync_back_porch, _vsync_front_porch, 1);
}
void Arduino_ST7701_RGBPanel::writePixelPreclipped(int16_t x, int16_t y, uint16_t color)
{
uint16_t *fb = _framebuffer;
fb += (int32_t)y * _width;
fb += x;
*fb = color;
Cache_WriteBack_Addr((uint32_t)fb, 2);
}
void Arduino_ST7701_RGBPanel::writeFastVLine(int16_t x, int16_t y,
int16_t h, uint16_t color)
{
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
uint16_t *fb = _framebuffer + ((int32_t)y * _width) + x;
while (h--)
{
*fb = color;
Cache_WriteBack_Addr((uint32_t)fb, 2);
fb += _width;
}
}
}
}
}
void Arduino_ST7701_RGBPanel::writeFastHLine(int16_t x, int16_t y,
int16_t w, uint16_t color)
{
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
uint16_t *fb = _framebuffer + ((int32_t)y * _width) + x;
uint32_t cachePos = (uint32_t)fb;
int16_t writeSize = w * 2;
while (w--)
{
*(fb++) = color;
}
Cache_WriteBack_Addr(cachePos, writeSize);
}
}
}
}
void Arduino_ST7701_RGBPanel::writeFillRectPreclipped(int16_t x, int16_t y,
int16_t w, int16_t h, uint16_t color)
{
uint16_t *row = _framebuffer;
row += y * _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 += _width;
}
Cache_WriteBack_Addr(cachePos, _width * h * 2);
}
void Arduino_ST7701_RGBPanel::draw16bitRGBBitmap(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
{
int16_t xskip = 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)
{
xskip = (x + w - 1) - _max_x;
w -= xskip;
}
if (x < 0)
{
bitmap -= x;
xskip -= x;
w += x;
x = 0;
}
uint16_t *row = _framebuffer;
row += y * _width;
uint32_t cachePos = (uint32_t)row;
row += x;
if (((_width & 1) == 0) && ((xskip & 1) == 0) && ((w & 1) == 0))
{
uint32_t *row2 = (uint32_t *)row;
uint32_t *bitmap2 = (uint32_t *)bitmap;
int16_t _width2 = _width >> 1;
int16_t xskip2 = xskip >> 1;
int16_t w2 = w >> 1;
for (int16_t j = 0; j < h; j++)
{
for (int16_t i = 0; i < w2; i++)
{
row2[i] = *bitmap2++;
}
bitmap2 += xskip2;
row2 += _width2;
}
}
else
{
for (int j = 0; j < h; j++)
{
for (int i = 0; i < w; i++)
{
row[i] = *bitmap++;
}
bitmap += xskip;
row += _width;
}
}
Cache_WriteBack_Addr(cachePos, _width * h * 2);
}
}
void Arduino_ST7701_RGBPanel::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
{
int16_t xskip = 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)
{
xskip = (x + w - 1) - _max_x;
w -= xskip;
}
if (x < 0)
{
bitmap -= x;
xskip -= x;
w += x;
x = 0;
}
uint16_t *row = _framebuffer;
row += y * _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 += xskip;
row += _width;
}
Cache_WriteBack_Addr(cachePos, _width * h * 2);
}
}
/**************************************************************************/
/*!
@brief Set origin of (0,0) and orientation of TFT display
@param m The index for rotation, from 0-3 inclusive
*/
/**************************************************************************/
void Arduino_ST7701_RGBPanel::setRotation(uint8_t r)
{
Arduino_GFX::setRotation(r);
_bus->beginWrite();
switch (_rotation)
{
case 1:
// not implemented
break;
case 2:
// Y direction
_bus->writeCommand(0xFF);
_bus->write(0x77);
_bus->write(0x01);
_bus->write(0x00);
_bus->write(0x00);
_bus->write(0x10);
_bus->writeCommand(0xC7);
_bus->write(0x04);
// X Direction and color order
_bus->writeCommand(0xFF);
_bus->write(0x77);
_bus->write(0x01);
_bus->write(0x00);
_bus->write(0x00);
_bus->write(0x00);
_bus->writeCommand(0x36);
_bus->write(_bgr ? 0x10 : 0x18);
break;
case 3:
// not implemented
break;
default: // case 0:
// Y direction
_bus->writeCommand(0xFF);
_bus->write(0x77);
_bus->write(0x01);
_bus->write(0x00);
_bus->write(0x00);
_bus->write(0x10);
_bus->writeCommand(0xC7);
_bus->write(0x00);
// X Direction and color order
_bus->writeCommand(0xFF);
_bus->write(0x77);
_bus->write(0x01);
_bus->write(0x00);
_bus->write(0x00);
_bus->write(0x00);
_bus->writeCommand(0x36);
_bus->write(_bgr ? 0x00 : 0x08);
break;
}
_bus->endWrite();
}
void Arduino_ST7701_RGBPanel::invertDisplay(bool i)
{
_bus->sendCommand(_ips ? (i ? 0x20 : 0x21) : (i ? 0x21 : 0x20));
}
uint16_t *Arduino_ST7701_RGBPanel::getFramebuffer()
{
return _framebuffer;
}
#endif // #if defined(ESP32) && (CONFIG_IDF_TARGET_ESP32S3)

View File

@ -1,757 +0,0 @@
#include "../Arduino_DataBus.h"
#if defined(ESP32) && (CONFIG_IDF_TARGET_ESP32S3)
#ifndef _ARDUINO_ST7701_RGBPANEL_H_
#define _ARDUINO_ST7701_RGBPANEL_H_
#include "../Arduino_GFX.h"
#include "../databus/Arduino_ESP32RGBPanel.h"
#define ST7701_TFTWIDTH 480
#define ST7701_TFTHEIGHT 864
static const uint8_t st7701_type1_init_operations[] = {
BEGIN_WRITE,
WRITE_COMMAND_8, 0xFF,
WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x10,
WRITE_C8_D16, 0xC0, 0x3B, 0x00,
WRITE_C8_D16, 0xC1, 0x0D, 0x02,
WRITE_C8_D16, 0xC2, 0x31, 0x05,
WRITE_C8_D8, 0xCD, 0x08,
WRITE_COMMAND_8, 0xB0, // Positive Voltage Gamma Control
WRITE_BYTES, 16,
0x00, 0x11, 0x18, 0x0E,
0x11, 0x06, 0x07, 0x08,
0x07, 0x22, 0x04, 0x12,
0x0F, 0xAA, 0x31, 0x18,
WRITE_COMMAND_8, 0xB1, // Negative Voltage Gamma Control
WRITE_BYTES, 16,
0x00, 0x11, 0x19, 0x0E,
0x12, 0x07, 0x08, 0x08,
0x08, 0x22, 0x04, 0x11,
0x11, 0xA9, 0x32, 0x18,
// PAGE1
WRITE_COMMAND_8, 0xFF,
WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x11,
WRITE_C8_D8, 0xB0, 0x60, // Vop=4.7375v
WRITE_C8_D8, 0xB1, 0x32, // VCOM=32
WRITE_C8_D8, 0xB2, 0x07, // VGH=15v
WRITE_C8_D8, 0xB3, 0x80,
WRITE_C8_D8, 0xB5, 0x49, // VGL=-10.17v
WRITE_C8_D8, 0xB7, 0x85,
WRITE_C8_D8, 0xB8, 0x21, // AVDD=6.6 & AVCL=-4.6
WRITE_C8_D8, 0xC1, 0x78,
WRITE_C8_D8, 0xC2, 0x78,
WRITE_COMMAND_8, 0xE0,
WRITE_BYTES, 3, 0x00, 0x1B, 0x02,
WRITE_COMMAND_8, 0xE1,
WRITE_BYTES, 11,
0x08, 0xA0, 0x00, 0x00,
0x07, 0xA0, 0x00, 0x00,
0x00, 0x44, 0x44,
WRITE_COMMAND_8, 0xE2,
WRITE_BYTES, 12,
0x11, 0x11, 0x44, 0x44,
0xED, 0xA0, 0x00, 0x00,
0xEC, 0xA0, 0x00, 0x00,
WRITE_COMMAND_8, 0xE3,
WRITE_BYTES, 4, 0x00, 0x00, 0x11, 0x11,
WRITE_C8_D16, 0xE4, 0x44, 0x44,
WRITE_COMMAND_8, 0xE5,
WRITE_BYTES, 16,
0x0A, 0xE9, 0xD8, 0xA0,
0x0C, 0xEB, 0xD8, 0xA0,
0x0E, 0xED, 0xD8, 0xA0,
0x10, 0xEF, 0xD8, 0xA0,
WRITE_COMMAND_8, 0xE6,
WRITE_BYTES, 4, 0x00, 0x00, 0x11, 0x11,
WRITE_C8_D16, 0xE7, 0x44, 0x44,
WRITE_COMMAND_8, 0xE8,
WRITE_BYTES, 16,
0x09, 0xE8, 0xD8, 0xA0,
0x0B, 0xEA, 0xD8, 0xA0,
0x0D, 0xEC, 0xD8, 0xA0,
0x0F, 0xEE, 0xD8, 0xA0,
WRITE_COMMAND_8, 0xEB,
WRITE_BYTES, 7,
0x02, 0x00, 0xE4, 0xE4,
0x88, 0x00, 0x40,
WRITE_C8_D16, 0xEC, 0x3C, 0x00,
WRITE_COMMAND_8, 0xED,
WRITE_BYTES, 16,
0xAB, 0x89, 0x76, 0x54,
0x02, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0x20,
0x45, 0x67, 0x98, 0xBA,
//-----------VAP & VAN---------------
WRITE_COMMAND_8, 0xFF,
WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x13,
WRITE_C8_D8, 0xE5, 0xE4,
WRITE_COMMAND_8, 0xFF,
WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x00,
WRITE_C8_D8, 0x3A, 0x60, // 0x70 RGB888, 0x60 RGB666, 0x50 RGB565
WRITE_COMMAND_8, 0x11, // Sleep Out
END_WRITE,
DELAY, 120,
BEGIN_WRITE,
WRITE_COMMAND_8, 0x29, // Display On
END_WRITE};
static const uint8_t st7701_type2_init_operations[] = {
BEGIN_WRITE,
WRITE_COMMAND_8, 0xFF,
WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x10,
WRITE_C8_D16, 0xC0, 0xE9, 0x03,
WRITE_C8_D16, 0xC1, 0x11, 0x02,
WRITE_C8_D16, 0xC2, 0x31, 0x08,
WRITE_COMMAND_8, 0xB0, // Positive Voltage Gamma Control
WRITE_BYTES, 16,
0x00, 0x0D, 0x14, 0x0D,
0x10, 0x05, 0x02, 0x08,
0x08, 0x1E, 0x05, 0x13,
0x11, 0xA3, 0x29, 0x18,
WRITE_COMMAND_8, 0xB1, // Negative Voltage Gamma Control
WRITE_BYTES, 16,
0x00, 0x0C, 0x14, 0x0C,
0x10, 0x05, 0x03, 0x08,
0x07, 0x20, 0x05, 0x13,
0x11, 0xA4, 0x29, 0x18,
// PAGE1
WRITE_COMMAND_8, 0xFF,
WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x11,
WRITE_C8_D8, 0xB0, 0x6C,
WRITE_C8_D8, 0xB1, 0x43,
WRITE_C8_D8, 0xB2, 0x07,
WRITE_C8_D8, 0xB3, 0x80,
WRITE_C8_D8, 0xB5, 0x47,
WRITE_C8_D8, 0xB7, 0x8A,
WRITE_C8_D8, 0xB8, 0x20,
WRITE_C8_D8, 0xC1, 0x78,
WRITE_C8_D8, 0xC2, 0x78,
WRITE_C8_D8, 0xD0, 0x88,
WRITE_COMMAND_8, 0xE0,
WRITE_BYTES, 3, 0x00, 0x00, 0x02,
WRITE_COMMAND_8, 0xE1,
WRITE_BYTES, 11,
0x08, 0x00, 0x0A, 0x00,
0x07, 0x00, 0x09, 0x00,
0x00, 0x33, 0x33,
WRITE_COMMAND_8, 0xE2,
WRITE_BYTES, 12,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
WRITE_COMMAND_8, 0xE3,
WRITE_BYTES, 4, 0x00, 0x00, 0x33, 0x33,
WRITE_C8_D16, 0xE4, 0x44, 0x44,
WRITE_COMMAND_8, 0xE5,
WRITE_BYTES, 16,
0x0E, 0x60, 0xA0, 0xA0,
0x10, 0x60, 0xA0, 0xA0,
0x0A, 0x60, 0xA0, 0xA0,
0x0C, 0x60, 0xA0, 0xA0,
WRITE_COMMAND_8, 0xE6,
WRITE_BYTES, 4, 0x00, 0x00, 0x33, 0x33,
WRITE_C8_D16, 0xE7, 0x44, 0x44,
WRITE_COMMAND_8, 0xE8,
WRITE_BYTES, 16,
0x0D, 0x60, 0xA0, 0xA0,
0x0F, 0x60, 0xA0, 0xA0,
0x09, 0x60, 0xA0, 0xA0,
0x0B, 0x60, 0xA0, 0xA0,
WRITE_COMMAND_8, 0xEB,
WRITE_BYTES, 7,
0x02, 0x01, 0xE4, 0xE4,
0x44, 0x00, 0x40,
WRITE_C8_D16, 0xEC, 0x02, 0x01,
WRITE_COMMAND_8, 0xED,
WRITE_BYTES, 16,
0xAB, 0x89, 0x76, 0x54,
0x01, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0x10,
0x45, 0x67, 0x98, 0xBA,
//-----------------------------------------End GIP Setting-----------------------------------------//
//--------------------------- Power Control Registers Initial End------------------------------//
//-------------------------------------Bank1 Setting------------------------------------------------//
WRITE_COMMAND_8, 0xFF,
WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x00,
WRITE_C8_D8, 0x3A, 0x77, // RGB 24bits D[23:0]
WRITE_COMMAND_8, 0x11, // Sleep Out
END_WRITE,
DELAY, 100,
BEGIN_WRITE,
WRITE_COMMAND_8, 0x29, // Display On
END_WRITE};
static const uint8_t st7701_type3_init_operations[] = {
BEGIN_WRITE,
WRITE_COMMAND_8, 0xFF,
WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x10,
WRITE_C8_D16, 0xC0, 0x3B, 0x00,
WRITE_C8_D16, 0xC1, 0x0B, 0x02, // VBP
WRITE_C8_D16, 0xC2, 0x00, 0x02,
WRITE_C8_D8, 0xCC, 0x10,
WRITE_C8_D8, 0xCD, 0x08,
WRITE_COMMAND_8, 0xB0, // Positive Voltage Gamma Control
WRITE_BYTES, 16,
0x02, 0x13, 0x1B, 0x0D,
0x10, 0x05, 0x08, 0x07,
0x07, 0x24, 0x04, 0x11,
0x0E, 0x2C, 0x33, 0x1D,
WRITE_COMMAND_8, 0xB1, // Negative Voltage Gamma Control
WRITE_BYTES, 16,
0x05, 0x13, 0x1B, 0x0D,
0x11, 0x05, 0x08, 0x07,
0x07, 0x24, 0x04, 0x11,
0x0E, 0x2C, 0x33, 0x1D,
// PAGE1
WRITE_COMMAND_8, 0xFF,
WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x11,
WRITE_C8_D8, 0xB0, 0x5d, // 5d
WRITE_C8_D8, 0xB1, 0x43, // VCOM amplitude setting
WRITE_C8_D8, 0xB2, 0x81, // VGH Voltage setting, 12V
WRITE_C8_D8, 0xB3, 0x80,
WRITE_C8_D8, 0xB5, 0x43, // VGL Voltage setting, -8.3V
WRITE_C8_D8, 0xB7, 0x85,
WRITE_C8_D8, 0xB8, 0x20,
WRITE_C8_D8, 0xC1, 0x78,
WRITE_C8_D8, 0xC2, 0x78,
WRITE_C8_D8, 0xD0, 0x88,
WRITE_COMMAND_8, 0xE0,
WRITE_BYTES, 3, 0x00, 0x00, 0x02,
WRITE_COMMAND_8, 0xE1,
WRITE_BYTES, 11,
0x03, 0xA0, 0x00, 0x00,
0x04, 0xA0, 0x00, 0x00,
0x00, 0x20, 0x20,
WRITE_COMMAND_8, 0xE2,
WRITE_BYTES, 12,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
WRITE_COMMAND_8, 0xE3,
WRITE_BYTES, 4, 0x00, 0x00, 0x11, 0x00,
WRITE_C8_D16, 0xE4, 0x22, 0x00,
WRITE_COMMAND_8, 0xE5,
WRITE_BYTES, 16,
0x05, 0xEC, 0xA0, 0xA0,
0x07, 0xEE, 0xA0, 0xA0,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
WRITE_COMMAND_8, 0xE6,
WRITE_BYTES, 4, 0x00, 0x00, 0x11, 0x00,
WRITE_C8_D16, 0xE7, 0x22, 0x00,
WRITE_COMMAND_8, 0xE8,
WRITE_BYTES, 16,
0x06, 0xED, 0xA0, 0xA0,
0x08, 0xEF, 0xA0, 0xA0,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
WRITE_COMMAND_8, 0xEB,
WRITE_BYTES, 7,
0x00, 0x00, 0x40, 0x40,
0x00, 0x00, 0x00,
WRITE_COMMAND_8, 0xED,
WRITE_BYTES, 16,
0xFF, 0xFF, 0xFF, 0xBA,
0x0A, 0xBF, 0x45, 0xFF,
0xFF, 0x54, 0xFB, 0xA0,
0xAB, 0xFF, 0xFF, 0xFF,
WRITE_COMMAND_8, 0xEF,
WRITE_BYTES, 6,
0x10, 0x0D, 0x04, 0x08,
0x3F, 0x1F,
WRITE_COMMAND_8, 0xFF,
WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x13,
WRITE_C8_D8, 0xEF, 0x08,
WRITE_COMMAND_8, 0xFF,
WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x00,
WRITE_COMMAND_8, 0x11, // Sleep Out
END_WRITE,
DELAY, 120,
BEGIN_WRITE,
WRITE_COMMAND_8, 0x29, // Display On
WRITE_C8_D8, 0x36, 0x00, // Display data access control
WRITE_C8_D8, 0x3A, 0x60, // 0x60 18bit 0x50 16bit
END_WRITE};
static const uint8_t st7701_type4_init_operations[] = {
BEGIN_WRITE,
WRITE_COMMAND_8, 0xFF,
WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x10,
WRITE_C8_D16, 0xC0, 0x3b, 0x00,
WRITE_C8_D16, 0xC1, 0x0b, 0x02,
WRITE_C8_D16, 0xC2, 0x07, 0x02,
WRITE_C8_D8, 0xCC, 0x10,
WRITE_C8_D8, 0xCD, 0x08,
WRITE_COMMAND_8, 0xB0, // Positive Voltage Gamma Control
WRITE_BYTES, 16,
0x00, 0x11, 0x16, 0x0e,
0x11, 0x06, 0x05, 0x09,
0x08, 0x21, 0x06, 0x13,
0x10, 0x29, 0x31, 0x18,
WRITE_COMMAND_8, 0xB1, // Negative Voltage Gamma Control
WRITE_BYTES, 16,
0x00, 0x11, 0x16, 0x0e,
0x11, 0x07, 0x05, 0x09,
0x09, 0x21, 0x05, 0x13,
0x11, 0x2a, 0x31, 0x18,
WRITE_COMMAND_8, 0xFF,
WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x11,
WRITE_C8_D8, 0xb0, 0x6d,
WRITE_C8_D8, 0xb1, 0x37,
WRITE_C8_D8, 0xb2, 0x81,
WRITE_C8_D8, 0xb3, 0x80,
WRITE_C8_D8, 0xb5, 0x43,
WRITE_C8_D8, 0xb7, 0x85,
WRITE_C8_D8, 0xb8, 0x20,
WRITE_C8_D8, 0xc1, 0x78,
WRITE_C8_D8, 0xc2, 0x78,
WRITE_C8_D8, 0xc3, 0x8c,
WRITE_C8_D8, 0xd0, 0x88,
WRITE_COMMAND_8, 0xe0,
WRITE_BYTES, 3, 0x00, 0x00, 0x02,
WRITE_COMMAND_8, 0xe1,
WRITE_BYTES, 11,
0x03, 0xa0, 0x00, 0x00,
0x04, 0xa0, 0x00, 0x00,
0x00, 0x20, 0x20,
WRITE_COMMAND_8, 0xe2,
WRITE_BYTES, 13,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00,
WRITE_COMMAND_8, 0xe3,
WRITE_BYTES, 4, 0x00, 0x00, 0x11, 0x00,
WRITE_C8_D16, 0xe4, 0x22, 0x00,
WRITE_COMMAND_8, 0xe5,
WRITE_BYTES, 16,
0x05, 0xec, 0xa0, 0xa0,
0x07, 0xee, 0xa0, 0xa0,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
WRITE_COMMAND_8, 0xe6,
WRITE_BYTES, 4, 0x00, 0x00, 0x11, 0x00,
WRITE_C8_D16, 0xe7, 0x22, 0x00,
WRITE_COMMAND_8, 0xe8,
WRITE_BYTES, 16,
0x06, 0xed, 0xa0, 0xa0,
0x08, 0xef, 0xa0, 0xa0,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
WRITE_COMMAND_8, 0xeb,
WRITE_BYTES, 7,
0x00, 0x00, 0x40, 0x40,
0x00, 0x00, 0x00,
WRITE_COMMAND_8, 0xed,
WRITE_BYTES, 16,
0xff, 0xff, 0xff, 0xba,
0x0a, 0xbf, 0x45, 0xff,
0xff, 0x54, 0xfb, 0xa0,
0xab, 0xff, 0xff, 0xff,
WRITE_COMMAND_8, 0xef,
WRITE_BYTES, 6,
0x10, 0x0d, 0x04, 0x08,
0x3f, 0x1f,
WRITE_COMMAND_8, 0xff,
WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x13,
WRITE_C8_D8, 0xef, 0x08,
WRITE_COMMAND_8, 0xff,
WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x00,
WRITE_C8_D8, 0x36, 0x08,
WRITE_C8_D8, 0x3a, 0x66,
WRITE_C8_D8, 0x11, 0x00,
WRITE_C8_D8, 0x29, 0x00,
WRITE_COMMAND_8, 0x11, // Sleep Out
END_WRITE,
DELAY, 120,
BEGIN_WRITE,
WRITE_COMMAND_8, 0x29, // Display On
WRITE_C8_D8, 0x36, 0x00, // Display data access control
WRITE_C8_D8, 0x3A, 0x60, // 0x60 18bit 0x50 16bit
END_WRITE};
static const uint8_t st7701_type5_init_operations[] = {
BEGIN_WRITE,
WRITE_COMMAND_8, 0xFF,
WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x10,
WRITE_C8_D16, 0xC0, 0x3B, 0x00,
WRITE_C8_D16, 0xC1, 0x0B, 0x02, // VBP
WRITE_C8_D16, 0xC2, 0x00, 0x02,
WRITE_C8_D8, 0xCC, 0x10,
WRITE_C8_D8, 0xCD, 0x08,
WRITE_COMMAND_8, 0xB0, // Positive Voltage Gamma Control
WRITE_BYTES, 16,
0x02, 0x13, 0x1B, 0x0D,
0x10, 0x05, 0x08, 0x07,
0x07, 0x24, 0x04, 0x11,
0x0E, 0x2C, 0x33, 0x1D,
WRITE_COMMAND_8, 0xB1, // Negative Voltage Gamma Control
WRITE_BYTES, 16,
0x05, 0x13, 0x1B, 0x0D,
0x11, 0x05, 0x08, 0x07,
0x07, 0x24, 0x04, 0x11,
0x0E, 0x2C, 0x33, 0x1D,
WRITE_COMMAND_8, 0xFF,
WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x11,
WRITE_C8_D8, 0xB0, 0x5d, // 5d
WRITE_C8_D8, 0xB1, 0x43, // VCOM amplitude setting
WRITE_C8_D8, 0xB2, 0x81, // VGH Voltage setting, 12V
WRITE_C8_D8, 0xB3, 0x80,
WRITE_C8_D8, 0xB5, 0x43, // VGL Voltage setting, -8.3V
WRITE_C8_D8, 0xB7, 0x85,
WRITE_C8_D8, 0xB8, 0x20,
WRITE_C8_D8, 0xC1, 0x78,
WRITE_C8_D8, 0xC2, 0x78,
WRITE_C8_D8, 0xD0, 0x88,
WRITE_COMMAND_8, 0xE0,
WRITE_BYTES, 3, 0x00, 0x00, 0x02,
WRITE_COMMAND_8, 0xE1,
WRITE_BYTES, 11,
0x03, 0xA0, 0x00, 0x00,
0x04, 0xA0, 0x00, 0x00,
0x00, 0x20, 0x20,
WRITE_COMMAND_8, 0xE2,
WRITE_BYTES, 13,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00,
WRITE_COMMAND_8, 0xE3,
WRITE_BYTES, 4, 0x00, 0x00, 0x11, 0x00,
WRITE_C8_D16, 0xE4, 0x22, 0x00,
WRITE_COMMAND_8, 0xE5,
WRITE_BYTES, 16,
0x05, 0xEC, 0xA0, 0xA0,
0x07, 0xEE, 0xA0, 0xA0,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
WRITE_COMMAND_8, 0xE6,
WRITE_BYTES, 4, 0x00, 0x00, 0x11, 0x00,
WRITE_C8_D16, 0xE7, 0x22, 0x00,
WRITE_COMMAND_8, 0xE8,
WRITE_BYTES, 16,
0x06, 0xED, 0xA0, 0xA0,
0x08, 0xEF, 0xA0, 0xA0,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
WRITE_COMMAND_8, 0xEB,
WRITE_BYTES, 7,
0x00, 0x00, 0x40, 0x40,
0x00, 0x00, 0x00,
WRITE_COMMAND_8, 0xED,
WRITE_BYTES, 16,
0xFF, 0xFF, 0xFF, 0xBA,
0x0A, 0xBF, 0x45, 0xFF,
0xFF, 0x54, 0xFB, 0xA0,
0xAB, 0xFF, 0xFF, 0xFF,
WRITE_COMMAND_8, 0xEF,
WRITE_BYTES, 6,
0x10, 0x0D, 0x04, 0x08,
0x3F, 0x1F,
WRITE_COMMAND_8, 0xFF,
WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x13,
WRITE_C8_D8, 0xEF, 0x08,
WRITE_COMMAND_8, 0xFF,
WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x00,
WRITE_C8_D8, 0x36, 0x00,
WRITE_C8_D8, 0x3A, 0x60, // 0x70 RGB888, 0x60 RGB666, 0x50 RGB565
// WRITE_COMMAND_8, 0x21, //Display Inversion On
WRITE_COMMAND_8, 0x11, // Sleep Out
END_WRITE,
DELAY, 100,
BEGIN_WRITE,
WRITE_COMMAND_8, 0x29, // Display On
END_WRITE,
DELAY, 50};
static const uint8_t st7701_type6_init_operations[] = {
BEGIN_WRITE,
WRITE_COMMAND_8, 0xFF,
WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x13,
WRITE_C8_D8, 0xEF, 0x08,
WRITE_COMMAND_8, 0xFF,
WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x10,
WRITE_C8_D16, 0xC0, 0x3B, 0x00,
WRITE_C8_D16, 0xC1, 0x10, 0x0C,
WRITE_C8_D16, 0xC2, 0x07, 0x0A,
WRITE_C8_D8, 0xC7, 0x04,
WRITE_C8_D8, 0xCC, 0x10,
WRITE_COMMAND_8, 0xB0,
WRITE_BYTES, 16,
0x05, 0x12, 0x98, 0x0E,
0x0F, 0x07, 0x07, 0x09,
0x09, 0x23, 0x05, 0x52,
0x0F, 0x67, 0x2C, 0x11,
WRITE_COMMAND_8, 0xB1,
WRITE_BYTES, 16,
0x0B, 0x11, 0x97, 0x0C,
0x12, 0x06, 0x06, 0x08,
0x08, 0x22, 0x03, 0x51,
0x11, 0x66, 0x2B, 0x0F,
WRITE_COMMAND_8, 0xFF,
WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x11,
WRITE_C8_D8, 0xB0, 0x5D,
WRITE_C8_D8, 0xB1, 0x2D,
WRITE_C8_D8, 0xB2, 0x81,
WRITE_C8_D8, 0xB3, 0x80,
WRITE_C8_D8, 0xB5, 0x4E,
WRITE_C8_D8, 0xB7, 0x85,
WRITE_C8_D8, 0xB8, 0x20,
WRITE_C8_D8, 0xC1, 0x78,
WRITE_C8_D8, 0xC2, 0x78,
WRITE_C8_D8, 0xD0, 0x88,
WRITE_COMMAND_8, 0xE0,
WRITE_BYTES, 3, 0x00, 0x00, 0x02,
WRITE_COMMAND_8, 0xE1,
WRITE_BYTES, 11,
0x06, 0x30, 0x08, 0x30,
0x05, 0x30, 0x07, 0x30,
0x00, 0x33, 0x33,
WRITE_COMMAND_8, 0xE2,
WRITE_BYTES, 12,
0x11, 0x11, 0x33, 0x33,
0xF4, 0x00, 0x00, 0x00,
0xF4, 0x00, 0x00, 0x00,
WRITE_COMMAND_8, 0xE3,
WRITE_BYTES, 4, 0x00, 0x00, 0x11, 0x11,
WRITE_C8_D16, 0xE4, 0x44, 0x44,
WRITE_COMMAND_8, 0xE5,
WRITE_BYTES, 16,
0x0D, 0xF5, 0x30, 0xF0,
0x0F, 0xF7, 0x30, 0xF0,
0x09, 0xF1, 0x30, 0xF0,
0x0B, 0xF3, 0x30, 0xF0,
WRITE_COMMAND_8, 0xE6,
WRITE_BYTES, 4, 0x00, 0x00, 0x11, 0x11,
WRITE_C8_D16, 0xE7, 0x44, 0x44,
WRITE_COMMAND_8, 0xE8,
WRITE_BYTES, 16,
0x0C, 0xF4, 0x30, 0xF0,
0x0E, 0xF6, 0x30, 0xF0,
0x08, 0xF0, 0x30, 0xF0,
0x0A, 0xF2, 0x30, 0xF0,
WRITE_C8_D16, 0xE9, 0x36, 0x01,
WRITE_COMMAND_8, 0xEB,
WRITE_BYTES, 7,
0x00, 0x01, 0xE4, 0xE4,
0x44, 0x88, 0x40,
WRITE_COMMAND_8, 0xED,
WRITE_BYTES, 16,
0xFF, 0x10, 0xAF, 0x76,
0x54, 0x2B, 0xCF, 0xFF,
0xFF, 0xFC, 0xB2, 0x45,
0x67, 0xFA, 0x01, 0xFF,
WRITE_COMMAND_8, 0xEF,
WRITE_BYTES, 6,
0x08, 0x08, 0x08, 0x45,
0x3F, 0x54,
WRITE_COMMAND_8, 0xFF,
WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x00,
WRITE_COMMAND_8, 0x11,
END_WRITE,
DELAY, 120, // ms
BEGIN_WRITE,
WRITE_C8_D8, 0x3A, 0x66,
WRITE_C8_D8, 0x36, 0x00,
WRITE_C8_D8, 0x35, 0x00,
WRITE_COMMAND_8, 0x29, // Display On
END_WRITE};
class Arduino_ST7701_RGBPanel : public Arduino_GFX
{
public:
Arduino_ST7701_RGBPanel(
Arduino_ESP32RGBPanel *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0,
bool ips = false, int16_t w = ST7701_TFTWIDTH, int16_t h = ST7701_TFTHEIGHT,
const uint8_t *init_operations = st7701_type1_init_operations,
size_t init_operations_len = sizeof(st7701_type1_init_operations),
bool bgr = true,
uint16_t hsync_front_porch = 6, uint16_t hsync_pulse_width = 18, uint16_t hsync_back_porch = 24,
uint16_t vsync_front_porch = 4, uint16_t vsync_pulse_width = 10, uint16_t vsync_back_porch = 16);
void 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 writeFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color) override;
void writeFillRectPreclipped(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) 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 setRotation(uint8_t r) override;
void invertDisplay(bool) override;
uint16_t *getFramebuffer();
protected:
uint16_t *_framebuffer;
Arduino_ESP32RGBPanel *_bus;
int8_t _rst;
bool _ips;
const uint8_t *_init_operations;
size_t _init_operations_len;
bool _bgr;
uint16_t _hsync_front_porch;
uint16_t _hsync_pulse_width;
uint16_t _hsync_back_porch;
uint16_t _vsync_front_porch;
uint16_t _vsync_pulse_width;
uint16_t _vsync_back_porch;
private:
};
#endif // _ARDUINO_ST7701_RGBPANEL_H_
#endif // #if defined(ESP32) && (CONFIG_IDF_TARGET_ESP32S3)

View File

@ -0,0 +1 @@
{"type": "library", "name": "GFX Library for Arduino", "version": "1.4.2", "spec": {"owner": "moononournation", "id": 11607, "name": "GFX Library for Arduino", "requirements": null, "uri": null}}

View File

@ -34,7 +34,7 @@ gfx->println("Hello World!");
## U8g2 Font Support
[U8g2](https://github.com/olikraus/u8g2.git) proivided various font type and stored in compressed format. So U8g2 font gives more UI design possibilities and still can fit in the MCU limited storage space. Using U8g2 font in Arduino_GFX simply include U8g2lib.h before Arduino_GFX_Library.h:
[U8g2](https://github.com/olikraus/u8g2.git) provided various font type and stored in compressed format. So U8g2 font gives more UI design possibilities and still can fit in the MCU limited storage space. Using U8g2 font in Arduino_GFX simply include U8g2lib.h before Arduino_GFX_Library.h:
```C
#include <U8g2lib.h>
@ -56,42 +56,82 @@ U8g2 font list can be found at: <https://github.com/olikraus/u8g2/wiki/fntlistal
Another U8g2 font advantage is the font support Unicode glyphs. Simply enable setUTF8Print:
```C
gfx->begin();
gfx->fillScreen(BLACK);
gfx->setUTF8Print(true);
gfx->begin();
gfx->fillScreen(BLACK);
gfx->setUTF8Print(true);
```
And then print UTF8 string as usual:
```C
gfx->setCursor(0, 16);
gfx->setCursor(0, 16);
gfx->setFont(u8g2_font_unifont_tr);
gfx->println("Hello World!");
gfx->setFont(u8g2_font_unifont_tr);
gfx->println("Hello World!");
gfx->setFont(u8g2_font_unifont_t_polish);
gfx->println("Witaj świecie!");
gfx->setFont(u8g2_font_unifont_t_polish);
gfx->println("Witaj świecie!");
gfx->setFont(u8g2_font_unifont_t_vietnamese1);
gfx->println("Chào thế giới!");
gfx->setFont(u8g2_font_unifont_t_vietnamese1);
gfx->println("Chào thế giới!");
gfx->setFont(u8g2_font_unifont_t_chinese2);
gfx->println("世界你好!");
gfx->setFont(u8g2_font_unifont_t_chinese2);
gfx->println("世界你好!");
gfx->setFont(u8g2_font_unifont_t_japanese1);
gfx->println("こんにちは世界!");
gfx->setFont(u8g2_font_unifont_t_japanese1);
gfx->println("こんにちは世界!");
gfx->setFont(u8g2_font_unifont_t_korean1);
gfx->println("안녕하세요, 세계입니다!");
gfx->setFont(u8g2_font_unifont_t_korean1);
gfx->println("안녕하세요, 세계입니다!");
```
U8g2 Unifont list can be found at: <https://github.com/olikraus/u8g2/wiki/fntgrpunifont>
### Extra Fonts
Besides U8g2 generated font, Arduino_GFX also generated some useful font set from latest [unifont_jp-14.0.02](http://unifoundry.com/pub/unifont/unifont-14.0.02/font-builds/unifont_jp-14.0.02.bdf.gz):
Besides U8g2 generated font, Arduino_GFX also generated some useful font set:
#### u8g2_font_unifont_h_utf8
#### [Chill-Bitmap v2.400](https://github.com/Warren2060/Chill-Bitmap)
##### u8g2_font_chill7_h_cjk
* Glyphs: 13478/13478
* Size: 254,960
* Generation script:
```console
otf2bdf ChillBitmap7x.ttf -p 6 -o ChillBitmap7x.bdf
bdfconv -v -f 1 -b 1 -m "0-4294967295" ChillBitmap7x.bdf -o u8g2_font_chill7_h_cjk.h -n u8g2_font_chill7_h_cjk
```
#### [Cubic 11 v1.013](https://github.com/ACh-K/Cubic-11)
##### u8g2_font_cubic11_h_cjk
* Glyphs: 10167/10167
* Size: 337,650
* Generation script:
```console
otf2bdf Cubic_11_1.013_R.ttf -p 9 -o Cubic_11_1.013_R.bdf
bdfconv -v -f 1 -b 1 -m "0-4294967295" Cubic_11_1.013_R.bdf -o u8g2_font_cubic11_h_cjk.h -n u8g2_font_cubic11_h_cjk
```
#### [QuanPixel](https://diaowinner.itch.io/galmuri-extended):
##### u8g2_font_quan7_h_cjk
* Glyphs: 18082/18082
* Size: 335,225
* Generation script:
```console
./bdfconv -v -f 1 -b 1 -m "0-4294967295" quan.bdf -o u8g2_font_quan7_h_cjk.h -n u8g2_font_quan7_h_cjk
```
#### [unifont_jp-14.0.02](http://unifoundry.com/pub/unifont/unifont-14.0.02/font-builds/unifont_jp-14.0.02.bdf.gz)
##### u8g2_font_unifont_h_utf8
* Glyphs: 57389/57389
* Size: 2,250,360
@ -101,7 +141,7 @@ Besides U8g2 generated font, Arduino_GFX also generated some useful font set fro
bdfconv -v -f 1 -b 1 -m "0-1114111" unifont_jp-14.0.02.bdf -o u8g2_font_unifont_h_utf8.h -n u8g2_font_unifont_h_utf8
```
#### u8g2_font_unifont_t_chinese
##### u8g2_font_unifont_t_chinese
* Glyphs: 22145/57389
* Size: 979,557
@ -111,7 +151,7 @@ bdfconv -v -f 1 -b 1 -m "0-1114111" unifont_jp-14.0.02.bdf -o u8g2_font_unifont_
bdfconv -v -f 1 -m "32-127,11904-12351,19968-40959,63744-64255,65280-65376" unifont_jp-14.0.02.bdf -o u8g2_font_unifont_t_chinese.h -n u8g2_font_unifont_t_chinese
```
#### u8g2_font_unifont_t_chinese4
##### u8g2_font_unifont_t_chinese4
* Glyphs: 7199/57389
* Size: 298,564
@ -121,17 +161,17 @@ bdfconv -v -f 1 -m "32-127,11904-12351,19968-40959,63744-64255,65280-65376" unif
* Generation script:
```console
bdfconv -v -f 1 -M common.txt unifont_jp-14.0.02.bdf -o u8g2_font_unifont_t_chinese4.h -n u8g2_font_unifont_t_chinese4
bdfconv -v -f 1 -M chinese4.list unifont_jp-14.0.02.bdf -o u8g2_font_unifont_t_chinese4.h -n u8g2_font_unifont_t_chinese4
```
#### u8g2_font_unifont_t_cjk
##### u8g2_font_unifont_t_cjk
* Glyphs: 41364/57389
* Size: 1,704,862
* Generation script:
```console
bdfconv -v -f 1 -m "32-127,4352-4607,11904-12255,12288-19903,19968-40943,43360-43391,44032-55203,55216-55295,63744-64255,65072-65103,65280-65519" unifont_jp-14.0.02.bdf -o u8g2_font_unifont_t_cjk.h -n u8g2_font_unifont_t_cjk
bdfconv -v -f 1 -m "32-127,4352-4607,11904-12255,12288-19903,19968-40943,43360-43391,44032-55203,55216-55295,63744-64255,65072-65103,65280-65519" unifont_jp-14.0.02.bdf -o u8g2_font_unifont_t_cjk.h -n u8g2_font_unifont_t_cjk
```
## Performance
@ -202,9 +242,13 @@ Some larger display require RGB + 3-bit SPI combo interface, This interface requ
* Ameba RTL8722DM Board (AMB 21)
* Ameba RTL8722DM MINI Board (AMB 23)
* Arduino Mega 2560 [[demo video](https://youtu.be/Hn2cTNrkOSM)]
* Arduino Nano
* Arduino Nano BLE 33
* Arduino Pro Micro
* Arduino UNO
* Arduino UNO R4 Minima [[demo video](https://youtu.be/M1TuEU5uPb0)]
* Arduino UNO R4 WiFi [[demo video](https://youtu.be/GB90AFSLIFo)]
* ESP8266 Series
* ESP32 Series
* ESP32-C3 Series
@ -215,55 +259,85 @@ Some larger display require RGB + 3-bit SPI combo interface, This interface requ
* rtlduino BW16 (by Ai-Thinker)
* Sony Spresense
* WeAct BlackPill V2.0 (BlackPill F411CE)
## Tobe Support Dev Board (Sponsors can make it happen)
* Arduino ATMega2560
* [Seeed Studio XIAO SAMD21](https://www.seeedstudio.com/Seeeduino-XIAO-3Pcs-p-4546.html)
* [Seeed Studio XIAO ESP32C3](https://www.seeedstudio.com/Seeed-XIAO-ESP32C3-p-5431.html)
* [Seeed Studio XIAO ESP32S3](https://www.seeedstudio.com/XIAO-ESP32S3-p-5627.html)
## Currently Supported Dev Device [[Wiki](https://github.com/moononournation/Arduino_GFX/wiki/Dev-Device-Declaration)]
* ESP32 LCDKIT
* ESP32-S3-EYE
* ESP32-S3-Box
* ESPboy [[demo video](https://youtu.be/Cx82XWrc8-0)]
* M5Stack Core Family
* Makerfabs ESP32 3.5" TFT Touch with Camera
* Odroid Go
* TTGO T-DISPLAY
* TTGO T-DISPLAY-S3 [[demo video](https://youtu.be/kpRC64QNQAo)]
* TTGO T-QT
* TTGO T-Watch
* wireless-tag WT-32-SC01
* Wio Terminal
* [ESP32-1732S019](https://www.aliexpress.com/item/1005005059421229.html) [[demo video](https://youtube.com/shorts/VS4Qb3g2dWk)] [[LVGL demo video](https://youtu.be/V5xib6OnWiM)]
* ESP32-2432S028
* ESP32-2424012 [[demo video](https://youtu.be/EXw_yEMgug8)]
* ESP32-3248S035
* ESP32-4827A043 [[demo video](https://youtu.be/pd1DTW9QHkg)] [[LVGL demo video](https://youtu.be/L8iYjiy-DUI)]
* [ESP32-4827S043](https://www.aliexpress.com/item/1005004788147691.html) [[demo video 1](https://youtu.be/60rl7QoU4Sc)] [[demo video 2](https://youtube.com/shorts/QY09u37htIk)] [[LVGL demo video](https://youtu.be/VvpILAVyPt8)]
* [ESP32-8048S043](https://www.aliexpress.com/item/1005004788147691.html) [[demo video](https://youtu.be/tXBVTAzSf58)]
* [ESP32-8048S070](https://www.aliexpress.com/item/1005004952726089.html) [[LVGL demo video](https://youtu.be/7BRGVsnQpgE)]
* [ESP32 LCDKIT](https://docs.espressif.com/projects/espressif-esp-dev-kits/en/latest/esp32/esp32-lcdkit/user_guide.html)
* [ESP32-S3-EYE](https://github.com/espressif/esp-who/blob/master/docs/en/get-started/ESP32-S3-EYE_Getting_Started_Guide.md)
* [ESP32-S3-Box](https://www.espressif.com/en/news/ESP32-S3-BOX_video)
* [ESP32-S3-Box-3](https://www.espressif.com/en/news/ESP32-S3-BOX-3)
* [ESP32-S3-RGB](https://github.com/W00ng/ESP32-S3-RGB-Panel) [[LVGL demo video](https://youtu.be/d11yUvjh34A)]
* ESP32S3-2.1-TP
* [ESPboy](https://www.espboy.com) [[demo video](https://youtu.be/Cx82XWrc8-0)]
* [LILYGO T-Deck](https://www.lilygo.cc/products/t-deck) [[demo video](https://youtube.com/shorts/fXKTVqjUoPM)]
* [LILYGO T-Display](https://www.lilygo.cc/products/lilygo®-ttgo-t-display-1-14-inch-lcd-esp32-control-board)
* [LILYGO T-Display-S3](https://www.lilygo.cc/products/t-display-s3) [[demo video](https://youtu.be/kpRC64QNQAo)]
* [LILYGO T-Display-S3 AMOLED](https://www.lilygo.cc/products/t-display-s3-amoled) [[demo video](https://youtu.be/NvOGJAMlh1M)]
* [LILYGO T-Display-s3-Pro](https://www.lilygo.cc/products/t-display-s3-pro) [[demo video](https://youtube.com/shorts/PE-GKTzbdP8)]
* [LILYGO T-QT](https://www.lilygo.cc/products/t-qt-v1-1) [[demo video](https://youtube.com/shorts/V1MCQ1tQ8PM)]
* [LILYGO T-RGB](https://www.lilygo.cc/products/t-rgb) [[LVGL demo video](https://youtu.be/BKEl_pWp_qQ)]
* [LILYGO T-Track](https://www.lilygo.cc/products/t-track) [[demo video](https://youtu.be/6wmUhp-5eMg)][[LVGL demo video](https://youtu.be/wQjMu5JZSkg)]
* [LILYGO T-Watch](http://www.lilygo.cn/prod_view.aspx?TypeId=50053&Id=1123)
* [LILYGO T-Watch 2021](https://www.lilygo.cc/products/t-watch-2021)
* [M5Stack Core Family](https://shop.m5stack.com/collections/m5-controllers/CORE)
* [M5Stack AtomS3](https://shop.m5stack.com/products/atoms3-dev-kit-w-0-85-inch-screen)[[demo video](https://youtu.be/8u4TwZHmnN0)]
* [Makerfabs ESP32 3.5" TFT Touch with Camera](https://www.makerfabs.com/esp32-3.5-inch-tft-touch-capacitive-with-camera.html)
* [Makerfabs ESP32-S3 TFT 4.0"](https://www.makerfabs.com/esp32-s3-parallel-tft-with-touch-4-inch.html) [[demo video](https://youtu.be/Fmxd-Xu97C8)]
* [Makerfabs ESP32-S3 TFT 4.3" v1.3](https://www.makerfabs.com/esp32-s3-parallel-tft-with-touch-4-3-inch.html) [[demo video](https://youtu.be/oQ57L2gTHoo)]
* [Odroid Go](https://www.hardkernel.com/shop/odroid-go/)
* [seeed studio Wio Terminal](https://wiki.seeedstudio.com/Wio-Terminal-Getting-Started/)
* [Waveshare RP2040-LCD-1.28](https://www.waveshare.com/wiki/RP2040-LCD-1.28)
* [wireless-tag WT-32-SC01](http://www.wireless-tag.com/portfolio/wt32-sc01/)
* [Elecrow ESP Terminal with 3.5" parallel RGB display DLC35010R](https://www.elecrow.com/esp-terminal-with-esp32-3-5-inch-parallel-480x320-tft-capacitive-touch-display-rgb-by-chip-ili9488.html) [[demo video](https://youtu.be/QRDVuwayNFw)]
* [Elecrow Wizee-ESP32 WZ8048C050](https://www.elecrow.com/esp32-display-5-inch-hmi-display-rgb-tft-lcd-touch-screen-support-lvgl.html)
* [wireless-tag ZX2D10GE10R-V4848](https://github.com/wireless-tag-com/ZX2D10GE01R-V4848)
* [wireless-tag ZX3D50CE02S](https://github.com/wireless-tag-com/ZX3D50CE02S)
* [wireless-tag ZX3D95CE01S-AR](https://github.com/wireless-tag-com/ZX3D95CE01S-AR-4848)
* [wireless-tag ZX3D95CE01S-TR](https://github.com/wireless-tag-com/ZX3D95CE01S-TR-4848) [[demo video](https://www.youtube.com/shorts/5u6_C-krK2Q)]
* [QM Smart Panlee 7.0 inch serial screen ZX7D00CE01S](http://en.smartpanle.com/product-item-19.html) [[demo video](https://youtu.be/r-zAMUzpkGE)]
## Currently Supported Display [[Wiki](https://github.com/moononournation/Arduino_GFX/wiki/Display-Class)]
* GC9A01 round display 240x240 [[demo video](https://youtu.be/kJrAFm20-zg)]
* GC9A01 240x240 round display [[demo video](https://youtu.be/kJrAFm20-zg)]
* GC9106 80x160 [[demo video](https://youtu.be/RToGeeb1jxQ)]
* GC9107 128x128 [[demo video](https://youtube.com/shorts/V1MCQ1tQ8PM)]
* GC9503V (RGB) 480x480 [[demo video](https://youtube.com/shorts/hk7ZMBRCmjI)]
* GC9503V 480x480 (RGB) [[demo video](https://youtube.com/shorts/hk7ZMBRCmjI)]
* HX8347C 240x320 [[demo video](https://youtu.be/25ymuV51YQM)]
* HX8347D 240x320 [[demo video](https://youtu.be/sv6LGkLRZjI)]
* HX8352C 240x400 [[demo video](https://youtu.be/m2xWYbS3t7s)]
* HX8357A 320x480 [[demo video](https://youtu.be/wJkLO_xCTXA)] (currently only portrait works, i.e. rotation 0 and 2)
* HX8357B (9-bit SPI) 320x480 [[demo video](https://youtu.be/pB6_LOCiUqg)]
* HX8369A 480x800 [[demo video](https://youtu.be/sXpU8bhtXKQ)]
* ILI6485 (RGB) 480x272 [[demo video](https://youtu.be/60rl7QoU4Sc)]
* HX8357B 320x480 (9-bit SPI) [[demo video](https://youtu.be/pB6_LOCiUqg)]
* HX8369A 480x800 [[demo video](https://youtu.be/sXpU8bhtXKQ)] [[LVGL demo video](https://youtu.be/q575lTuVDcU)]
* ILI6122 480x800 (RGB)
* ILI6485 480x272 (RGB) [[demo video](https://youtu.be/60rl7QoU4Sc)]
* ILI9225 176x220 [[demo video](https://youtu.be/jm2UrCG27F4)]
* ILI9341 240x320 [[demo video](https://youtu.be/NtlEEL7MkQY)]
* ILI9341 (8-bit Parallel) 240x320 [[demo video](https://youtu.be/xuVx0dzQ7nM)]
* ILI9341 240x320 (8-bit/16-bit Parallel) [[demo video](https://youtu.be/xuVx0dzQ7nM)]
* ILI9342 320x240 [[demo video](https://youtu.be/UoPpIjVSO5Q)]
* ILI9481 320x480 (18 bit color) [[demo video](https://youtu.be/YxjuuCFhlqM)]
* ILI9486 320x480 (8-bit/16-bit Parallel) [[demo video](https://youtu.be/GB90AFSLIFo)]
* ILI9486 320x480 (18 bit color) [[demo video](https://youtu.be/pZ6izDqmVds)]
* ILI9488 320x480 (3 bit color with canvas) [[demo video](https://youtu.be/r7be0WbIBYk)]
* ILI9488 320x480 (18 bit color) [[demo video](https://youtu.be/NkE-LhtLHBQ)]
* ILI9806 (8-bit/16-bit Parallel) 480x854 [[demo video](https://youtu.be/mYv-wdtWr8s)]
* JBT6K71 (8-bit Parallel) 240x320 [[demo video](https://youtu.be/qid3F4Gb0mM)]
* ILI9806 (8-bit/16-bit Parallel) 480x854 [[demo video](https://youtu.be/mYv-wdtWr8s)] [[LVGL demo video](https://youtu.be/PqjV8lovg_c)][[2](https://youtu.be/j31KZoQUKis)]
* JBT6K71 240x320 (8-bit Parallel) [[demo video](https://youtu.be/qid3F4Gb0mM)]
* NT35310 320x480 [[demo video](https://youtu.be/bvIz5CoYPNk)]
* NT35510 (8-bit/16-bit Parallel) 480x800 [[demo video](https://youtu.be/C_1ASzUN3bg)]
* NT39125 (8-bit/16-bit Parallel) 240x376 [[demo video](https://youtu.be/JGMrM18JAFA)]
* NT35510 480x800 (8-bit/16-bit Parallel) [[demo video](https://youtu.be/C_1ASzUN3bg)]
* NT39125 240x376 (8-bit/16-bit Parallel) [[demo video](https://youtu.be/JGMrM18JAFA)]
* NV3041A 480x272 [[demo video](https://youtu.be/pd1DTW9QHkg)]
* R61529 (8-bit/16-bit Parallel) 320x480 [[demo video](https://youtu.be/s93gxjbIAT8)]
* OTM8009A 480x800 (8-bit/16-bit Parallel)
* R61529 320x480 (8-bit/16-bit Parallel) [[demo video](https://youtu.be/s93gxjbIAT8)]
* Raspberry Pi DPI Display (RPi_DPI_RGBPanel) Any Resolution [[demo video](https://youtube.com/shorts/IqQEq-VLVwI)]
* SEPS525 160x128 [[demo video](https://youtu.be/tlmvFBHYv-k)]
* SSD1283A 130x130 [[demo video](https://youtu.be/OrIchaRikiQ)]
@ -274,13 +348,14 @@ Some larger display require RGB + 3-bit SPI combo interface, This interface requ
* ST7735 128x160 (various tabs) [[demo video](https://youtu.be/eRBSSD_N9II)]
* ST7735 128x128 (various tabs) [[demo video](https://youtu.be/6rueSV2Ee6c)]
* ST7735 80x160 [[demo video](https://youtu.be/qESHDuYo_Mk)]
* ST7701 (RGB) 480x480 [[demo video](https://youtube.com/shorts/JV8Rzxop5EQ)]
* ST7789 TTGO T-Display 135x240 [[demo video](https://youtu.be/Zk81_T8c20E)]
* ST7701 480x480 (RGB) [[demo video](https://youtube.com/shorts/JV8Rzxop5EQ)] [[2.1" round display demo video](https://youtube.com/shorts/WLWio1CjBoo?feature=share)] [[2.8" round display demo video](https://youtube.com/shorts/Ih_QlttWTVk?feature=share)]
* ST7789 135x240 [[demo video](https://youtu.be/Zk81_T8c20E)]
* ST7789 240x240 [[demo video](https://youtu.be/Z27zYg5uAsk)]
* ST7789 TTGO T-Watch 240x240 [[demo video](https://youtu.be/9AqsXMB8Qbk)]
* ST7789 round corner display 240x280 [[demo video](https://youtu.be/KzDC02wg8z0)]
* ST7789 240x240 [[demo video](https://youtu.be/9AqsXMB8Qbk)]
* ST7789 240x280 round corner display [[demo video](https://youtu.be/KzDC02wg8z0)]
* ST7789 240x320 [[demo video](https://youtu.be/ZEvc1LkuVuQ)]
* ST7796 320x480 [[demo video](https://youtu.be/hUL-RuG4MAQ)]
* WEA2012 356x400 [[demo video](https://youtube.com/shorts/neDyijFrfQY)] [[LVGL demo video](https://youtube.com/shorts/z9Z_u0xg_as)]
## Tobe Support Display (Sponsors can make it happen)
@ -305,13 +380,15 @@ Some larger display require RGB + 3-bit SPI combo interface, This interface requ
## Feature wishlist (Sponsors can make it happen)
* Set text box
* Round display mode (skip draw corner area)
* Canvas to FastLED
* Print color Emoji Characters
* Load bitmap font files from flash / SD
* Fill Gradient
* Fill Gradient #128
## Using source code come from
* <http://elm-chan.org/fsw/tjpgd/00index.html>
* <https://github.com/adafruit/Adafruit-GFX-Library.git>
* <https://github.com/adafruit/Adafruit_ILI9341.git>
* <https://github.com/adafruit/Adafruit-SSD1351-library.git>
@ -324,7 +401,12 @@ Some larger display require RGB + 3-bit SPI combo interface, This interface requ
* <https://github.com/gitcnd/LCDWIKI_SPI.git>
* <https://github.com/hi631/LCD_NT35510-MRB3971.git>
* <https://github.com/lcdwiki/LCDWIKI_SPI.git>
* <https://github.com/Xinyuan-LilyGO/T-RGB.git>
* <https://github.com/lovyan03/LovyanGFX.git>
* <https://github.com/lovyan03/M5Stack_JpgLoopAnime.git>
* <https://github.com/modi12jin/Arduino-ESP32-WEA2012.git>
* <https://github.com/nopnop2002/esp-idf-parallel-tft.git>
* <https://github.com/olikraus/u8g2.git>
## Sponsor vs Support
As you may already aware there are seldom sponsors in this project. Convert it in terms of man power, it is much lower than a manhour each month. So don't expect too much on the support. Expecially the feature not realted to my planned maker projects ;>

View File

@ -42,7 +42,7 @@ const char *VNC_PASSWORD = "PleaseInputYourPasswordHere";
* Arduino Nano, Micro and more: CS: 9, DC: 8, RST: 7, BL: 6, SCK: 13, MOSI: 11, MISO: 12
* ESP32 various dev board : CS: 5, DC: 27, RST: 33, BL: 22, SCK: 18, MOSI: 23, MISO: nil
* ESP32-C3 various dev board : CS: 7, DC: 2, RST: 1, BL: 3, SCK: 4, MOSI: 6, MISO: nil
* ESP32-S2 various dev board : CS: 34, DC: 35, RST: 33, BL: 21, SCK: 36, MOSI: 35, MISO: nil
* ESP32-S2 various dev board : CS: 34, DC: 38, RST: 33, BL: 21, SCK: 36, MOSI: 35, MISO: nil
* ESP32-S3 various dev board : CS: 40, DC: 41, RST: 42, BL: 48, SCK: 36, MOSI: 35, MISO: nil
* ESP8266 various dev board : CS: 15, DC: 4, RST: 2, BL: 5, SCK: 14, MOSI: 13, MISO: 12
* Raspberry Pi Pico dev board : CS: 17, DC: 27, RST: 26, BL: 28, SCK: 18, MOSI: 19, MISO: 16
@ -116,8 +116,10 @@ void TFTnoVNC(void)
void handle_touch()
{
if (touch_has_signal()) {
if (touch_touched()) {
if (touch_has_signal())
{
if (touch_touched())
{
vnc.mouseEvent(touch_last_x, touch_last_y, 0b001);
}
else if (touch_released())
@ -127,35 +129,38 @@ void handle_touch()
}
}
void handle_keyboard() {
void handle_keyboard()
{
int key = keyboard_get_key();
if (key > 0) {
if (key > 0)
{
// Serial.println(key);
switch (key) {
case 8:
key = 0xff08; // BackSpace
break;
case 9:
key = 0xff09; // Tab
break;
case 13:
key = 0xff0d; // Return or Enter
break;
case 27:
key = 0xff1b; // Escape
break;
case 180:
key = 0xff51; // Left
break;
case 181:
key = 0xff52; // Up
break;
case 182:
key = 0xff54; // Down
break;
case 183:
key = 0xff53; // Right
break;
switch (key)
{
case 8:
key = 0xff08; // BackSpace
break;
case 9:
key = 0xff09; // Tab
break;
case 13:
key = 0xff0d; // Return or Enter
break;
case 27:
key = 0xff1b; // Escape
break;
case 180:
key = 0xff51; // Left
break;
case 181:
key = 0xff52; // Up
break;
case 182:
key = 0xff54; // Down
break;
case 183:
key = 0xff53; // Right
break;
}
vnc.keyEvent(key, 0b001);
vnc.keyEvent(key, 0b000);
@ -165,24 +170,32 @@ void handle_keyboard() {
void setup(void)
{
Serial.begin(115200);
// while (!Serial);
// Serial.setDebugOutput(true);
Serial.println("Arduino VNC");
// while(!Serial);
Serial.println("Arduino_GFX VNC example");
// Init touch device
touch_init(gfx->width(), gfx->height());
#ifdef GFX_EXTRA_PRE_INIT
GFX_EXTRA_PRE_INIT();
#endif
// Init keyboard device
keyboard_init();
Serial.println("Init display");
gfx->begin();
if (!gfx->begin())
{
Serial.println("gfx->begin() failed!");
}
gfx->fillScreen(BLACK);
#ifdef GFX_BL
pinMode(GFX_BL, OUTPUT);
digitalWrite(GFX_BL, HIGH);
#endif
// Init touch device
touch_init(gfx->width(), gfx->height(), gfx->getRotation());
TFTnoWifi();
Serial.println("Init WiFi");

View File

@ -0,0 +1,192 @@
/*******************************************************************************
* Touch libraries:
* XPT2046: https://github.com/PaulStoffregen/XPT2046_Touchscreen.git
*
* Capacitive touchscreen libraries
* TouchLib: https://github.com/mmMicky/TouchLib.git
******************************************************************************/
/* uncomment for XPT2046 */
// #define TOUCH_XPT2046
// #define TOUCH_XPT2046_SCK 12
// #define TOUCH_XPT2046_MISO 13
// #define TOUCH_XPT2046_MOSI 11
// #define TOUCH_XPT2046_CS 10
// #define TOUCH_XPT2046_INT 18
// #define TOUCH_XPT2046_ROTATION 0
// #define TOUCH_XPT2046_SAMPLES 50
// uncomment for most capacitive touchscreen
// #define TOUCH_MODULES_FT5x06 // GT911 / CST_SELF / CST_MUTUAL / ZTW622 / L58 / FT3267 / FT5x06
// #define TOUCH_MODULE_ADDR FT5x06_ADDR // CTS328_SLAVE_ADDRESS / L58_SLAVE_ADDRESS / CTS826_SLAVE_ADDRESS / CTS820_SLAVE_ADDRESS / CTS816S_SLAVE_ADDRESS / FT3267_SLAVE_ADDRESS / FT5x06_ADDR / GT911_SLAVE_ADDRESS1 / GT911_SLAVE_ADDRESS2 / ZTW622_SLAVE1_ADDRESS / ZTW622_SLAVE2_ADDRESS
// #define TOUCH_SCL 5
// #define TOUCH_SDA 6
// #define TOUCH_RES -1
// #define TOUCH_INT -1
// Please fill below values from Arduino_GFX Example - TouchCalibration
bool touch_swap_xy = false;
int16_t touch_map_x1 = -1;
int16_t touch_map_x2 = -1;
int16_t touch_map_y1 = -1;
int16_t touch_map_y2 = -1;
int16_t touch_max_x = 0, touch_max_y = 0;
int16_t touch_raw_x = 0, touch_raw_y = 0;
int16_t touch_last_x = 0, touch_last_y = 0;
#if defined(TOUCH_XPT2046)
#include <XPT2046_Touchscreen.h>
#include <SPI.h>
XPT2046_Touchscreen ts(TOUCH_XPT2046_CS, TOUCH_XPT2046_INT);
#elif defined(TOUCH_MODULE_ADDR) // TouchLib
#include <Wire.h>
#include <TouchLib.h>
TouchLib touch(Wire, TOUCH_SDA, TOUCH_SCL, TOUCH_MODULE_ADDR);
#endif // TouchLib
void touch_init(int16_t w, int16_t h, uint8_t r)
{
touch_max_x = w - 1;
touch_max_y = h - 1;
if (touch_map_x1 == -1)
{
switch (r)
{
case 3:
touch_swap_xy = true;
touch_map_x1 = touch_max_x;
touch_map_x2 = 0;
touch_map_y1 = 0;
touch_map_y2 = touch_max_y;
break;
case 2:
touch_swap_xy = false;
touch_map_x1 = touch_max_x;
touch_map_x2 = 0;
touch_map_y1 = touch_max_y;
touch_map_y2 = 0;
break;
case 1:
touch_swap_xy = true;
touch_map_x1 = 0;
touch_map_x2 = touch_max_x;
touch_map_y1 = touch_max_y;
touch_map_y2 = 0;
break;
default: // case 0:
touch_swap_xy = false;
touch_map_x1 = 0;
touch_map_x2 = touch_max_x;
touch_map_y1 = 0;
touch_map_y2 = touch_max_y;
break;
}
}
#if defined(TOUCH_XPT2046)
SPI.begin(TOUCH_XPT2046_SCK, TOUCH_XPT2046_MISO, TOUCH_XPT2046_MOSI, TOUCH_XPT2046_CS);
ts.begin();
ts.setRotation(TOUCH_XPT2046_ROTATION);
#elif defined(TOUCH_MODULE_ADDR) // TouchLib
// Reset touchscreen
#if (TOUCH_RES > 0)
pinMode(TOUCH_RES, OUTPUT);
digitalWrite(TOUCH_RES, 0);
delay(200);
digitalWrite(TOUCH_RES, 1);
delay(200);
#endif
Wire.begin(TOUCH_SDA, TOUCH_SCL);
touch.init();
#endif // TouchLib
}
bool touch_has_signal()
{
#if defined(TOUCH_XPT2046)
return ts.tirqTouched();
#elif defined(TOUCH_MODULE_ADDR) // TouchLib
// TODO: implement TOUCH_INT
return true;
#endif // TouchLib
return false;
}
void translate_touch_raw()
{
if (touch_swap_xy)
{
touch_last_x = map(touch_raw_y, touch_map_x1, touch_map_x2, 0, touch_max_x);
touch_last_y = map(touch_raw_x, touch_map_y1, touch_map_y2, 0, touch_max_y);
}
else
{
touch_last_x = map(touch_raw_x, touch_map_x1, touch_map_x2, 0, touch_max_x);
touch_last_y = map(touch_raw_y, touch_map_y1, touch_map_y2, 0, touch_max_y);
}
// Serial.printf("touch_raw_x: %d, touch_raw_y: %d, touch_last_x: %d, touch_last_y: %d\n", touch_raw_x, touch_raw_y, touch_last_x, touch_last_y);
}
bool touch_touched()
{
#if defined(TOUCH_XPT2046)
if (ts.touched())
{
TS_Point p = ts.getPoint();
touch_raw_x = p.x;
touch_raw_y = p.y;
int max_z = p.z;
int count = 0;
while ((ts.touched()) && (count < TOUCH_XPT2046_SAMPLES))
{
count++;
TS_Point p = ts.getPoint();
if (p.z > max_z)
{
touch_raw_x = p.x;
touch_raw_y = p.y;
max_z = p.z;
}
// Serial.printf("touch_raw_x: %d, touch_raw_y: %d, p.z: %d\n", touch_raw_x, touch_raw_y, p.z);
}
translate_touch_raw();
return true;
}
#elif defined(TOUCH_MODULE_ADDR) // TouchLib
if (touch.read())
{
TP_Point t = touch.getPoint(0);
touch_raw_x = t.x;
touch_raw_y = t.y;
touch_last_x = touch_raw_x;
touch_last_y = touch_raw_y;
translate_touch_raw();
return true;
}
#endif // TouchLib
return false;
}
bool touch_released()
{
#if defined(TOUCH_XPT2046)
return true;
#elif defined(TOUCH_MODULE_ADDR) // TouchLib
return false;
#endif // TouchLib
return false;
}

View File

@ -6,14 +6,14 @@
*/
/*******************************************************************************
* Start of Arduino_GFX setting
*
*
* Arduino_GFX try to find the settings depends on selected board in Arduino IDE
* Or you can define the display dev kit not in the board list
* Defalult pin list for non display dev kit:
* Arduino Nano, Micro and more: CS: 9, DC: 8, RST: 7, BL: 6, SCK: 13, MOSI: 11, MISO: 12
* ESP32 various dev board : CS: 5, DC: 27, RST: 33, BL: 22, SCK: 18, MOSI: 23, MISO: nil
* ESP32-C3 various dev board : CS: 7, DC: 2, RST: 1, BL: 3, SCK: 4, MOSI: 6, MISO: nil
* ESP32-S2 various dev board : CS: 34, DC: 35, RST: 33, BL: 21, SCK: 36, MOSI: 35, MISO: nil
* ESP32-S2 various dev board : CS: 34, DC: 38, RST: 33, BL: 21, SCK: 36, MOSI: 35, MISO: nil
* ESP32-S3 various dev board : CS: 40, DC: 41, RST: 42, BL: 48, SCK: 36, MOSI: 35, MISO: nil
* ESP8266 various dev board : CS: 15, DC: 4, RST: 2, BL: 5, SCK: 14, MOSI: 13, MISO: 12
* Raspberry Pi Pico dev board : CS: 17, DC: 27, RST: 26, BL: 28, SCK: 18, MOSI: 19, MISO: 16
@ -46,37 +46,50 @@ Arduino_GFX *gfx = new Arduino_ILI9341(bus, DF_GFX_RST, 0 /* rotation */, false
void setup(void)
{
gfx->begin();
gfx->fillScreen(BLACK);
Serial.begin(115200);
// Serial.setDebugOutput(true);
// while(!Serial);
Serial.println("Arduino_GFX AsciiTable example");
#ifdef GFX_BL
pinMode(GFX_BL, OUTPUT);
digitalWrite(GFX_BL, HIGH);
#ifdef GFX_EXTRA_PRE_INIT
GFX_EXTRA_PRE_INIT();
#endif
gfx->setTextColor(GREEN);
// Init Display
if (!gfx->begin())
{
Serial.println("gfx->begin() failed!");
}
gfx->fillScreen(BLACK);
#ifdef GFX_BL
pinMode(GFX_BL, OUTPUT);
digitalWrite(GFX_BL, HIGH);
#endif
gfx->setTextColor(GREEN);
for (int x = 0; x < 16; x++)
{
gfx->setCursor(10 + x * 8, 2);
gfx->print(x, 16);
}
gfx->setTextColor(BLUE);
for (int y = 0; y < 16; y++)
{
gfx->setCursor(2, 12 + y * 10);
gfx->print(y, 16);
}
char c = 0;
for (int y = 0; y < 16; y++)
{
for (int x = 0; x < 16; x++)
{
gfx->setCursor(10 + x * 8, 2);
gfx->print(x, 16);
}
gfx->setTextColor(BLUE);
for (int y = 0; y < 16; y++)
{
gfx->setCursor(2, 12 + y * 10);
gfx->print(y, 16);
gfx->drawChar(10 + x * 8, 12 + y * 10, c++, WHITE, BLACK);
}
}
char c = 0;
for (int y = 0; y < 16; y++)
{
for (int x = 0; x < 16; x++)
{
gfx->drawChar(10 + x * 8, 12 + y * 10, c++, WHITE, BLACK);
}
}
delay(5000); // 5 seconds
delay(5000); // 5 seconds
}
void loop()

View File

@ -0,0 +1,395 @@
/*
Arduino Watch Lite Version
You may find full version at: https://github.com/moononournation/ArduinoWatch
*/
/*******************************************************************************
* Start of Arduino_GFX setting
*
* Arduino_GFX try to find the settings depends on selected board in Arduino IDE
* Or you can define the display dev kit not in the board list
* Defalult pin list for non display dev kit:
* Arduino Nano, Micro and more: CS: 9, DC: 8, RST: 7, BL: 6, SCK: 13, MOSI: 11, MISO: 12
* ESP32 various dev board : CS: 5, DC: 27, RST: 33, BL: 22, SCK: 18, MOSI: 23, MISO: nil
* ESP32-C3 various dev board : CS: 7, DC: 2, RST: 1, BL: 3, SCK: 4, MOSI: 6, MISO: nil
* ESP32-S2 various dev board : CS: 34, DC: 38, RST: 33, BL: 21, SCK: 36, MOSI: 35, MISO: nil
* ESP32-S3 various dev board : CS: 40, DC: 41, RST: 42, BL: 48, SCK: 36, MOSI: 35, MISO: nil
* ESP8266 various dev board : CS: 15, DC: 4, RST: 2, BL: 5, SCK: 14, MOSI: 13, MISO: 12
* Raspberry Pi Pico dev board : CS: 17, DC: 27, RST: 26, BL: 28, SCK: 18, MOSI: 19, MISO: 16
* RTL8720 BW16 old patch core : CS: 18, DC: 17, RST: 2, BL: 23, SCK: 19, MOSI: 21, MISO: 20
* RTL8720_BW16 Official core : CS: 9, DC: 8, RST: 6, BL: 3, SCK: 10, MOSI: 12, MISO: 11
* RTL8722 dev board : CS: 18, DC: 17, RST: 22, BL: 23, SCK: 13, MOSI: 11, MISO: 12
* RTL8722_mini dev board : CS: 12, DC: 14, RST: 15, BL: 13, SCK: 11, MOSI: 9, MISO: 10
* Seeeduino XIAO dev board : CS: 3, DC: 2, RST: 1, BL: 0, SCK: 8, MOSI: 10, MISO: 9
* Teensy 4.1 dev board : CS: 39, DC: 41, RST: 40, BL: 22, SCK: 13, MOSI: 11, MISO: 12
******************************************************************************/
#include <Arduino_GFX_Library.h>
#define GFX_BL DF_GFX_BL // default backlight pin, you may replace DF_GFX_BL to actual backlight pin
/* More dev device declaration: https://github.com/moononournation/Arduino_GFX/wiki/Dev-Device-Declaration */
#if defined(DISPLAY_DEV_KIT)
Arduino_GFX *gfx = create_default_Arduino_GFX();
#else /* !defined(DISPLAY_DEV_KIT) */
/* More data bus class: https://github.com/moononournation/Arduino_GFX/wiki/Data-Bus-Class */
Arduino_DataBus *bus = create_default_Arduino_DataBus();
/* More display class: https://github.com/moononournation/Arduino_GFX/wiki/Display-Class */
Arduino_GFX *gfx = new Arduino_ILI9341(bus, DF_GFX_RST, 0 /* rotation */, false /* IPS */);
#endif /* !defined(DISPLAY_DEV_KIT) */
/*******************************************************************************
* End of Arduino_GFX setting
******************************************************************************/
#define BACKGROUND BLACK
#define MARK_COLOR WHITE
#define SUBMARK_COLOR DARKGREY // LIGHTGREY
#define HOUR_COLOR WHITE
#define MINUTE_COLOR BLUE // LIGHTGREY
#define SECOND_COLOR RED
#define SIXTIETH 0.016666667
#define TWELFTH 0.08333333
#define SIXTIETH_RADIAN 0.10471976
#define TWELFTH_RADIAN 0.52359878
#define RIGHT_ANGLE_RADIAN 1.5707963
static uint8_t conv2d(const char *p)
{
uint8_t v = 0;
return (10 * (*p - '0')) + (*++p - '0');
}
static int16_t w, h, center;
static int16_t hHandLen, mHandLen, sHandLen, markLen;
static float sdeg, mdeg, hdeg;
static int16_t osx = 0, osy = 0, omx = 0, omy = 0, ohx = 0, ohy = 0; // Saved H, M, S x & y coords
static int16_t nsx, nsy, nmx, nmy, nhx, nhy; // H, M, S x & y coords
static int16_t xMin, yMin, xMax, yMax; // redraw range
static int16_t hh, mm, ss;
static unsigned long targetTime; // next action time
static int16_t *cached_points;
static uint16_t cached_points_idx = 0;
static int16_t *last_cached_point;
void setup(void)
{
Serial.begin(115200);
// Serial.setDebugOutput(true);
// while(!Serial);
Serial.println("Arduino_GFX Clock example");
#ifdef GFX_EXTRA_PRE_INIT
GFX_EXTRA_PRE_INIT();
#endif
// Init Display
if (!gfx->begin())
{
Serial.println("gfx->begin() failed!");
}
gfx->fillScreen(BACKGROUND);
#ifdef GFX_BL
pinMode(GFX_BL, OUTPUT);
digitalWrite(GFX_BL, HIGH);
#endif
// init LCD constant
w = gfx->width();
h = gfx->height();
if (w < h)
{
center = w / 2;
}
else
{
center = h / 2;
}
hHandLen = center * 3 / 8;
mHandLen = center * 2 / 3;
sHandLen = center * 5 / 6;
markLen = sHandLen / 6;
cached_points = (int16_t *)malloc((hHandLen + 1 + mHandLen + 1 + sHandLen + 1) * 2 * 2);
// Draw 60 clock marks
draw_round_clock_mark(
// draw_square_clock_mark(
center - markLen, center,
center - (markLen * 2 / 3), center,
center - (markLen / 2), center);
hh = conv2d(__TIME__);
mm = conv2d(__TIME__ + 3);
ss = conv2d(__TIME__ + 6);
targetTime = ((millis() / 1000) + 1) * 1000;
}
void loop()
{
unsigned long cur_millis = millis();
if (cur_millis >= targetTime)
{
targetTime += 1000;
ss++; // Advance second
if (ss == 60)
{
ss = 0;
mm++; // Advance minute
if (mm > 59)
{
mm = 0;
hh++; // Advance hour
if (hh > 23)
{
hh = 0;
}
}
}
}
// Pre-compute hand degrees, x & y coords for a fast screen update
sdeg = SIXTIETH_RADIAN * ((0.001 * (cur_millis % 1000)) + ss); // 0-59 (includes millis)
nsx = cos(sdeg - RIGHT_ANGLE_RADIAN) * sHandLen + center;
nsy = sin(sdeg - RIGHT_ANGLE_RADIAN) * sHandLen + center;
if ((nsx != osx) || (nsy != osy))
{
mdeg = (SIXTIETH * sdeg) + (SIXTIETH_RADIAN * mm); // 0-59 (includes seconds)
hdeg = (TWELFTH * mdeg) + (TWELFTH_RADIAN * hh); // 0-11 (includes minutes)
mdeg -= RIGHT_ANGLE_RADIAN;
hdeg -= RIGHT_ANGLE_RADIAN;
nmx = cos(mdeg) * mHandLen + center;
nmy = sin(mdeg) * mHandLen + center;
nhx = cos(hdeg) * hHandLen + center;
nhy = sin(hdeg) * hHandLen + center;
// redraw hands
redraw_hands_cached_draw_and_erase();
ohx = nhx;
ohy = nhy;
omx = nmx;
omy = nmy;
osx = nsx;
osy = nsy;
delay(1);
}
}
void draw_round_clock_mark(int16_t innerR1, int16_t outerR1, int16_t innerR2, int16_t outerR2, int16_t innerR3, int16_t outerR3)
{
float x, y;
int16_t x0, x1, y0, y1, innerR, outerR;
uint16_t c;
for (uint8_t i = 0; i < 60; i++)
{
if ((i % 15) == 0)
{
innerR = innerR1;
outerR = outerR1;
c = MARK_COLOR;
}
else if ((i % 5) == 0)
{
innerR = innerR2;
outerR = outerR2;
c = MARK_COLOR;
}
else
{
innerR = innerR3;
outerR = outerR3;
c = SUBMARK_COLOR;
}
mdeg = (SIXTIETH_RADIAN * i) - RIGHT_ANGLE_RADIAN;
x = cos(mdeg);
y = sin(mdeg);
x0 = x * outerR + center;
y0 = y * outerR + center;
x1 = x * innerR + center;
y1 = y * innerR + center;
gfx->drawLine(x0, y0, x1, y1, c);
}
}
void draw_square_clock_mark(int16_t innerR1, int16_t outerR1, int16_t innerR2, int16_t outerR2, int16_t innerR3, int16_t outerR3)
{
float x, y;
int16_t x0, x1, y0, y1, innerR, outerR;
uint16_t c;
for (uint8_t i = 0; i < 60; i++)
{
if ((i % 15) == 0)
{
innerR = innerR1;
outerR = outerR1;
c = MARK_COLOR;
}
else if ((i % 5) == 0)
{
innerR = innerR2;
outerR = outerR2;
c = MARK_COLOR;
}
else
{
innerR = innerR3;
outerR = outerR3;
c = SUBMARK_COLOR;
}
if ((i >= 53) || (i < 8))
{
x = tan(SIXTIETH_RADIAN * i);
x0 = center + (x * outerR);
y0 = center + (1 - outerR);
x1 = center + (x * innerR);
y1 = center + (1 - innerR);
}
else if (i < 23)
{
y = tan((SIXTIETH_RADIAN * i) - RIGHT_ANGLE_RADIAN);
x0 = center + (outerR);
y0 = center + (y * outerR);
x1 = center + (innerR);
y1 = center + (y * innerR);
}
else if (i < 38)
{
x = tan(SIXTIETH_RADIAN * i);
x0 = center - (x * outerR);
y0 = center + (outerR);
x1 = center - (x * innerR);
y1 = center + (innerR);
}
else if (i < 53)
{
y = tan((SIXTIETH_RADIAN * i) - RIGHT_ANGLE_RADIAN);
x0 = center + (1 - outerR);
y0 = center - (y * outerR);
x1 = center + (1 - innerR);
y1 = center - (y * innerR);
}
gfx->drawLine(x0, y0, x1, y1, c);
}
}
void redraw_hands_cached_draw_and_erase()
{
gfx->startWrite();
draw_and_erase_cached_line(center, center, nsx, nsy, SECOND_COLOR, cached_points, sHandLen + 1, false, false);
draw_and_erase_cached_line(center, center, nhx, nhy, HOUR_COLOR, cached_points + ((sHandLen + 1) * 2), hHandLen + 1, true, false);
draw_and_erase_cached_line(center, center, nmx, nmy, MINUTE_COLOR, cached_points + ((sHandLen + 1 + hHandLen + 1) * 2), mHandLen + 1, true, true);
gfx->endWrite();
}
void draw_and_erase_cached_line(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t color, int16_t *cache, int16_t cache_len, bool cross_check_second, bool cross_check_hour)
{
#if defined(ESP8266)
yield();
#endif
bool steep = _diff(y1, y0) > _diff(x1, x0);
if (steep)
{
_swap_int16_t(x0, y0);
_swap_int16_t(x1, y1);
}
int16_t dx, dy;
dx = _diff(x1, x0);
dy = _diff(y1, y0);
int16_t err = dx / 2;
int8_t xstep = (x0 < x1) ? 1 : -1;
int8_t ystep = (y0 < y1) ? 1 : -1;
x1 += xstep;
int16_t x, y, ox, oy;
for (uint16_t i = 0; i <= dx; i++)
{
if (steep)
{
x = y0;
y = x0;
}
else
{
x = x0;
y = y0;
}
ox = *(cache + (i * 2));
oy = *(cache + (i * 2) + 1);
if ((x == ox) && (y == oy))
{
if (cross_check_second || cross_check_hour)
{
write_cache_pixel(x, y, color, cross_check_second, cross_check_hour);
}
}
else
{
write_cache_pixel(x, y, color, cross_check_second, cross_check_hour);
if ((ox > 0) || (oy > 0))
{
write_cache_pixel(ox, oy, BACKGROUND, cross_check_second, cross_check_hour);
}
*(cache + (i * 2)) = x;
*(cache + (i * 2) + 1) = y;
}
if (err < dy)
{
y0 += ystep;
err += dx;
}
err -= dy;
x0 += xstep;
}
for (uint16_t i = dx + 1; i < cache_len; i++)
{
ox = *(cache + (i * 2));
oy = *(cache + (i * 2) + 1);
if ((ox > 0) || (oy > 0))
{
write_cache_pixel(ox, oy, BACKGROUND, cross_check_second, cross_check_hour);
}
*(cache + (i * 2)) = 0;
*(cache + (i * 2) + 1) = 0;
}
}
void write_cache_pixel(int16_t x, int16_t y, int16_t color, bool cross_check_second, bool cross_check_hour)
{
int16_t *cache = cached_points;
if (cross_check_second)
{
for (uint16_t i = 0; i <= sHandLen; i++)
{
if ((x == *(cache++)) && (y == *(cache)))
{
return;
}
cache++;
}
}
if (cross_check_hour)
{
cache = cached_points + ((sHandLen + 1) * 2);
for (uint16_t i = 0; i <= hHandLen; i++)
{
if ((x == *(cache++)) && (y == *(cache)))
{
return;
}
cache++;
}
}
gfx->writePixel(x, y, color);
}

View File

@ -1,13 +1,13 @@
/*******************************************************************************
* Start of Arduino_GFX setting
*
*
* Arduino_GFX try to find the settings depends on selected board in Arduino IDE
* Or you can define the display dev kit not in the board list
* Defalult pin list for non display dev kit:
* Arduino Nano, Micro and more: CS: 9, DC: 8, RST: 7, BL: 6, SCK: 13, MOSI: 11, MISO: 12
* ESP32 various dev board : CS: 5, DC: 27, RST: 33, BL: 22, SCK: 18, MOSI: 23, MISO: nil
* ESP32-C3 various dev board : CS: 7, DC: 2, RST: 1, BL: 3, SCK: 4, MOSI: 6, MISO: nil
* ESP32-S2 various dev board : CS: 34, DC: 35, RST: 33, BL: 21, SCK: 36, MOSI: 35, MISO: nil
* ESP32-S2 various dev board : CS: 34, DC: 38, RST: 33, BL: 21, SCK: 36, MOSI: 35, MISO: nil
* ESP32-S3 various dev board : CS: 40, DC: 41, RST: 42, BL: 48, SCK: 36, MOSI: 35, MISO: nil
* ESP8266 various dev board : CS: 15, DC: 4, RST: 2, BL: 5, SCK: 14, MOSI: 13, MISO: 12
* Raspberry Pi Pico dev board : CS: 17, DC: 27, RST: 26, BL: 28, SCK: 18, MOSI: 19, MISO: 16
@ -40,27 +40,40 @@ Arduino_GFX *gfx = new Arduino_ILI9341(bus, DF_GFX_RST, 0 /* rotation */, false
void setup(void)
{
gfx->begin();
gfx->fillScreen(BLACK);
Serial.begin(115200);
// Serial.setDebugOutput(true);
// while(!Serial);
Serial.println("Arduino_GFX Hello World example");
#ifdef GFX_BL
pinMode(GFX_BL, OUTPUT);
digitalWrite(GFX_BL, HIGH);
#ifdef GFX_EXTRA_PRE_INIT
GFX_EXTRA_PRE_INIT();
#endif
gfx->setCursor(10, 10);
gfx->setTextColor(RED);
gfx->println("Hello World!");
// Init Display
if (!gfx->begin())
{
Serial.println("gfx->begin() failed!");
}
gfx->fillScreen(BLACK);
delay(5000); // 5 seconds
#ifdef GFX_BL
pinMode(GFX_BL, OUTPUT);
digitalWrite(GFX_BL, HIGH);
#endif
gfx->setCursor(10, 10);
gfx->setTextColor(RED);
gfx->println("Hello World!");
delay(5000); // 5 seconds
}
void loop()
{
gfx->setCursor(random(gfx->width()), random(gfx->height()));
gfx->setTextColor(random(0xffff), random(0xffff));
gfx->setTextSize(random(6) /* x scale */, random(6) /* y scale */, random(2) /* pixel_margin */);
gfx->println("Hello World!");
gfx->setCursor(random(gfx->width()), random(gfx->height()));
gfx->setTextColor(random(0xffff), random(0xffff));
gfx->setTextSize(random(6) /* x scale */, random(6) /* y scale */, random(2) /* pixel_margin */);
gfx->println("Hello World!");
delay(1000); // 1 second
delay(1000); // 1 second
}

View File

@ -1,13 +1,13 @@
/*******************************************************************************
* Start of Arduino_GFX setting
*
*
* Arduino_GFX try to find the settings depends on selected board in Arduino IDE
* Or you can define the display dev kit not in the board list
* Defalult pin list for non display dev kit:
* Arduino Nano, Micro and more: CS: 9, DC: 8, RST: 7, BL: 6, SCK: 13, MOSI: 11, MISO: 12
* ESP32 various dev board : CS: 5, DC: 27, RST: 33, BL: 22, SCK: 18, MOSI: 23, MISO: nil
* ESP32-C3 various dev board : CS: 7, DC: 2, RST: 1, BL: 3, SCK: 4, MOSI: 6, MISO: nil
* ESP32-S2 various dev board : CS: 34, DC: 35, RST: 33, BL: 21, SCK: 36, MOSI: 35, MISO: nil
* ESP32-S2 various dev board : CS: 34, DC: 38, RST: 33, BL: 21, SCK: 36, MOSI: 35, MISO: nil
* ESP32-S3 various dev board : CS: 40, DC: 41, RST: 42, BL: 48, SCK: 36, MOSI: 35, MISO: nil
* ESP8266 various dev board : CS: 15, DC: 4, RST: 2, BL: 5, SCK: 14, MOSI: 13, MISO: 12
* Raspberry Pi Pico dev board : CS: 17, DC: 27, RST: 26, BL: 28, SCK: 18, MOSI: 19, MISO: 16
@ -45,41 +45,54 @@ Arduino_GFX *gfx = new Arduino_ILI9341(bus, DF_GFX_RST, 0 /* rotation */, false
void setup(void)
{
gfx->begin();
gfx->fillScreen(BLACK);
Serial.begin(115200);
// Serial.setDebugOutput(true);
// while(!Serial);
Serial.println("Arduino_GFX Hello World Gfxfont example");
#ifdef GFX_BL
pinMode(GFX_BL, OUTPUT);
digitalWrite(GFX_BL, HIGH);
#ifdef GFX_EXTRA_PRE_INIT
GFX_EXTRA_PRE_INIT();
#endif
gfx->setCursor(10, 10);
gfx->setFont(&FreeMono8pt7b);
gfx->setTextColor(RED);
gfx->println("Hello World!");
// Init Display
if (!gfx->begin())
{
Serial.println("gfx->begin() failed!");
}
gfx->fillScreen(BLACK);
delay(5000); // 5 seconds
#ifdef GFX_BL
pinMode(GFX_BL, OUTPUT);
digitalWrite(GFX_BL, HIGH);
#endif
gfx->setCursor(10, 10);
gfx->setFont(&FreeMono8pt7b);
gfx->setTextColor(RED);
gfx->println("Hello World!");
delay(5000); // 5 seconds
}
void loop()
{
gfx->setCursor(random(gfx->width()), random(gfx->height()));
gfx->setTextColor(random(0xffff));
uint8_t textSize = random(3);
switch (textSize)
{
case 1:
gfx->setFont(&FreeMono8pt7b);
break;
case 2:
gfx->setFont(&FreeSansBold10pt7b);
break;
default:
gfx->setFont(&FreeSerifBoldItalic12pt7b);
break;
}
gfx->setCursor(random(gfx->width()), random(gfx->height()));
gfx->setTextColor(random(0xffff));
uint8_t textSize = random(3);
switch (textSize)
{
case 1:
gfx->setFont(&FreeMono8pt7b);
break;
case 2:
gfx->setFont(&FreeSansBold10pt7b);
break;
default:
gfx->setFont(&FreeSerifBoldItalic12pt7b);
break;
}
gfx->println("Hello World!");
gfx->println("Hello World!");
delay(1000); // 1 second
delay(1000); // 1 second
}

View File

@ -1,6 +1,6 @@
/*******************************************************************************
* GIFDEC Wrapper Class
*
*
* Rewrite from: https://github.com/BasementCat/arduino-tft-gif
******************************************************************************/
#ifndef _GIFCLASS_H_
@ -29,7 +29,7 @@
typedef struct gd_Palette
{
uint8_t size;
int16_t len;
uint16_t colors[256];
} gd_Palette;
@ -44,7 +44,7 @@ typedef struct gd_GCE
typedef struct gd_Entry
{
int32_t length;
int32_t len;
uint16_t prefix;
uint8_t suffix;
} gd_Entry;
@ -75,6 +75,7 @@ typedef struct gd_GIF
uint16_t fx, fy, fw, fh;
uint8_t bgindex;
gd_Table *table;
bool processed_first_frame;
} gd_GIF;
class GifClass
@ -85,7 +86,7 @@ public:
uint8_t sigver[3];
uint16_t width, height, depth;
uint8_t fdsz, bgidx, aspect;
int32_t gct_sz;
int16_t gct_sz;
gd_GIF *gif;
// init global variables
@ -139,6 +140,7 @@ public:
gif->bgindex = bgidx;
gif->anim_start = file_pos; // fd->position();
gif->table = new_table();
gif->processed_first_frame = false;
return gif;
}
@ -254,11 +256,11 @@ private:
return gif_buf_read(fd) + (((uint16_t)gif_buf_read(fd)) << 8);
}
void read_palette(File *fd, gd_Palette *dest, int32_t num_colors)
void read_palette(File *fd, gd_Palette *dest, int16_t num_colors)
{
uint8_t r, g, b;
dest->size = num_colors;
for (int32_t i = 0; i < num_colors; i++)
dest->len = num_colors;
for (int16_t i = 0; i < num_colors; i++)
{
r = gif_buf_read(fd);
g = gif_buf_read(fd);
@ -269,13 +271,13 @@ private:
void discard_sub_blocks(gd_GIF *gif)
{
uint8_t size;
uint8_t len;
do
{
gif_buf_read(gif->fd, &size, 1);
gif_buf_seek(gif->fd, size);
} while (size);
gif_buf_read(gif->fd, &len, 1);
gif_buf_seek(gif->fd, len);
} while (len);
}
void read_plain_text_ext(gd_GIF *gif)
@ -424,10 +426,10 @@ private:
}
/* Add table entry. Return value:
* 0 on success
* +1 if key size must be incremented after this addition
* -1 if could not realloc table */
int32_t add_entry(gd_Table *table, int32_t length, uint16_t prefix, uint8_t suffix)
* 0 on success
* +1 if key size must be incremented after this addition
* -1 if could not realloc table */
int32_t add_entry(gd_Table *table, int32_t len, uint16_t prefix, uint8_t suffix)
{
// Table *table = *tablep;
// if (table->nentries == table->bulk) {
@ -437,7 +439,7 @@ private:
// table->entries = (Entry *) &table[1];
// *tablep = table;
// }
table->entries[table->nentries] = (gd_Entry){length, prefix, suffix};
table->entries[table->nentries] = (gd_Entry){len, prefix, suffix};
table->nentries++;
if ((table->nentries & (table->nentries - 1)) == 0)
return 1;
@ -494,7 +496,7 @@ private:
}
/* Decompress image pixels.
* Return 0 on success or -1 on out-of-memory (w.r.t. LZW code table). */
* Return 0 on success or -1 on out-of-memory (w.r.t. LZW code table). */
int8_t read_image_data(gd_GIF *gif, int16_t interlace, uint8_t *frame)
{
uint8_t sub_len, shift, byte, table_is_full = 0;
@ -558,19 +560,19 @@ private:
if (ret == 1)
key_size++;
entry = gif->table->entries[key];
str_len = entry.length;
str_len = entry.len;
uint8_t tindex = gif->gce.tindex;
// Serial.println("Interpret key");
while (1)
{
p = frm_off + entry.length - 1;
p = frm_off + entry.len - 1;
x = p % gif->fw;
y = p / gif->fw;
if (interlace)
{
y = interlaced_line_index((int16_t)gif->fh, y);
}
if (tindex != entry.suffix)
if ((!gif->processed_first_frame) || (tindex != entry.suffix))
{
frame[(gif->fy + y) * gif->width + gif->fx + x] = entry.suffix;
}
@ -587,11 +589,14 @@ private:
// free(table);
gif_buf_read(gif->fd, &sub_len, 1); /* Must be zero! */
// gif_buf_seek(gif->fd, end, SeekSet);
gif->processed_first_frame = true;
return 0;
}
/* Read image.
* Return 0 on success or -1 on out-of-memory (w.r.t. LZW code table). */
* Return 0 on success or -1 on out-of-memory (w.r.t. LZW code table). */
int8_t read_image(gd_GIF *gif, uint8_t *frame)
{
uint8_t fisrz;
@ -635,8 +640,10 @@ private:
{
index = frame[(gif->fy + j) * gif->width + gif->fx + k];
// color = &gif->palette->colors[index*2];
if (!gif->gce.transparency || index != gif->gce.tindex)
if ((!gif->gce.transparency) || (index != gif->gce.tindex))
{
buffer[(i + k)] = gif->palette->colors[index];
}
// memcpy(&buffer[(i+k)*2], color, 2);
}
i += gif->width;
@ -647,4 +654,4 @@ private:
uint8_t gif_buf[GIF_BUF_SIZE];
};
#endif /* _GIFCLASS_H_ */
#endif /* _GIFCLASS_H_ */

View File

@ -1,6 +1,6 @@
/*******************************************************************************
* Animated GIF Image Viewer
* This is a simple Animated GIF image viewer exsample
* This is a simple Animated GIF image viewer example
* Image Source: https://www.pexels.com/video/earth-rotating-video-856356/
* cropped: x: 598 y: 178 width: 720 height: 720 resized: 240x240
* optimized with ezgif.com
@ -28,7 +28,7 @@
/* Wio Terminal */
#if defined(ARDUINO_ARCH_SAMD) && defined(SEEED_GROVE_UI_WIRELESS)
#define GIF_FILENAME "/ezgif.com-optimize.gif"
#elif defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_RASPBERRY_PI_PICO_W)
#elif defined(TARGET_RP2040)
#define GIF_FILENAME "/ezgif.com-optimize.gif"
#elif defined(ESP32)
#define GIF_FILENAME "/ezgif.com-optimize.gif"
@ -45,7 +45,7 @@
* Arduino Nano, Micro and more: CS: 9, DC: 8, RST: 7, BL: 6, SCK: 13, MOSI: 11, MISO: 12
* ESP32 various dev board : CS: 5, DC: 27, RST: 33, BL: 22, SCK: 18, MOSI: 23, MISO: nil
* ESP32-C3 various dev board : CS: 7, DC: 2, RST: 1, BL: 3, SCK: 4, MOSI: 6, MISO: nil
* ESP32-S2 various dev board : CS: 34, DC: 35, RST: 33, BL: 21, SCK: 36, MOSI: 35, MISO: nil
* ESP32-S2 various dev board : CS: 34, DC: 38, RST: 33, BL: 21, SCK: 36, MOSI: 35, MISO: nil
* ESP32-S3 various dev board : CS: 40, DC: 41, RST: 42, BL: 48, SCK: 36, MOSI: 35, MISO: nil
* ESP8266 various dev board : CS: 15, DC: 4, RST: 2, BL: 5, SCK: 14, MOSI: 13, MISO: 12
* Raspberry Pi Pico dev board : CS: 17, DC: 27, RST: 26, BL: 28, SCK: 18, MOSI: 19, MISO: 16
@ -80,7 +80,7 @@ Arduino_GFX *gfx = new Arduino_ILI9341(bus, DF_GFX_RST, 3 /* rotation */, false
#if defined(ARDUINO_ARCH_SAMD) && defined(SEEED_GROVE_UI_WIRELESS)
#include <Seeed_FS.h>
#include <SD/Seeed_SD.h>
#elif defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_RASPBERRY_PI_PICO_W)
#elif defined(TARGET_RP2040)
#include <LittleFS.h>
#include <SD.h>
#elif defined(ESP32)
@ -101,9 +101,19 @@ static GifClass gifClass;
void setup()
{
Serial.begin(115200);
// Serial.setDebugOutput(true);
// while(!Serial);
Serial.println("Arduino_GFX Animated GIF Image Viewer example");
#ifdef GFX_EXTRA_PRE_INIT
GFX_EXTRA_PRE_INIT();
#endif
// Init Display
gfx->begin();
if (!gfx->begin())
{
Serial.println("gfx->begin() failed!");
}
gfx->fillScreen(BLACK);
#ifdef GFX_BL
@ -114,7 +124,7 @@ void setup()
/* Wio Terminal */
#if defined(ARDUINO_ARCH_SAMD) && defined(SEEED_GROVE_UI_WIRELESS)
if (!SD.begin(SDCARD_SS_PIN, SDCARD_SPI, 4000000UL))
#elif defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_RASPBERRY_PI_PICO_W)
#elif defined(TARGET_RP2040)
if (!LittleFS.begin())
// if (!SD.begin(SS))
#elif defined(ESP32)
@ -140,7 +150,7 @@ void loop()
/* Wio Terminal */
#if defined(ARDUINO_ARCH_SAMD) && defined(SEEED_GROVE_UI_WIRELESS)
File gifFile = SD.open(GIF_FILENAME, "r");
#elif defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_RASPBERRY_PI_PICO_W)
#elif defined(TARGET_RP2040)
File gifFile = LittleFS.open(GIF_FILENAME, "r");
// File gifFile = SD.open(GIF_FILENAME, "r");
#elif defined(ESP32)

View File

@ -29,14 +29,14 @@
/*******************************************************************************
* Start of Arduino_GFX setting
*
*
* Arduino_GFX try to find the settings depends on selected board in Arduino IDE
* Or you can define the display dev kit not in the board list
* Defalult pin list for non display dev kit:
* Arduino Nano, Micro and more: CS: 9, DC: 8, RST: 7, BL: 6, SCK: 13, MOSI: 11, MISO: 12
* ESP32 various dev board : CS: 5, DC: 27, RST: 33, BL: 22, SCK: 18, MOSI: 23, MISO: nil
* ESP32-C3 various dev board : CS: 7, DC: 2, RST: 1, BL: 3, SCK: 4, MOSI: 6, MISO: nil
* ESP32-S2 various dev board : CS: 34, DC: 35, RST: 33, BL: 21, SCK: 36, MOSI: 35, MISO: nil
* ESP32-S2 various dev board : CS: 34, DC: 38, RST: 33, BL: 21, SCK: 36, MOSI: 35, MISO: nil
* ESP32-S3 various dev board : CS: 40, DC: 41, RST: 42, BL: 48, SCK: 36, MOSI: 35, MISO: nil
* ESP8266 various dev board : CS: 15, DC: 4, RST: 2, BL: 5, SCK: 14, MOSI: 13, MISO: 12
* Raspberry Pi Pico dev board : CS: 17, DC: 27, RST: 26, BL: 28, SCK: 18, MOSI: 19, MISO: 16
@ -71,7 +71,7 @@ Arduino_GFX *gfx = new Arduino_ILI9341(bus, DF_GFX_RST, 3 /* rotation */, false
#if defined(ARDUINO_ARCH_SAMD) && defined(SEEED_GROVE_UI_WIRELESS)
#include <Seeed_FS.h>
#include <SD/Seeed_SD.h>
#elif defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_RASPBERRY_PI_PICO_W)
#elif defined(TARGET_RP2040)
#include <LittleFS.h>
#include <SD.h>
#elif defined(ESP32)
@ -99,22 +99,30 @@ static void bmpDrawCallback(int16_t x, int16_t y, uint16_t *bitmap, int16_t w, i
void setup()
{
Serial.begin(115200);
// while (!Serial);
Serial.println("BMP Image Viewer");
// Serial.setDebugOutput(true);
// while(!Serial);
Serial.println("Arduino_GFX BMP Image Viewer example");
#ifdef GFX_EXTRA_PRE_INIT
GFX_EXTRA_PRE_INIT();
#endif
// Init Display
gfx->begin();
if (!gfx->begin())
{
Serial.println("gfx->begin() failed!");
}
gfx->fillScreen(BLACK);
#ifdef GFX_BL
pinMode(GFX_BL, OUTPUT);
digitalWrite(GFX_BL, HIGH);
pinMode(GFX_BL, OUTPUT);
digitalWrite(GFX_BL, HIGH);
#endif
/* Wio Terminal */
#if defined(ARDUINO_ARCH_SAMD) && defined(SEEED_GROVE_UI_WIRELESS)
if (!SD.begin(SDCARD_SS_PIN, SDCARD_SPI, 4000000UL))
#elif defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_RASPBERRY_PI_PICO_W)
#elif defined(TARGET_RP2040)
if (!LittleFS.begin())
// if (!SD.begin(SS))
#elif defined(ESP32)
@ -138,7 +146,7 @@ void setup()
#if defined(ARDUINO_ARCH_SAMD) && defined(SEEED_GROVE_UI_WIRELESS)
File bmpFile = SD.open(BMP_FILENAME, "r");
#elif defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_RASPBERRY_PI_PICO_W)
#elif defined(TARGET_RP2040)
File bmpFile = LittleFS.open(BMP_FILENAME, "r");
// File bmpFile = SD.open(BMP_FILENAME, "r");
#elif defined(ESP32)

View File

@ -37,7 +37,7 @@
* Arduino Nano, Micro and more: CS: 9, DC: 8, RST: 7, BL: 6, SCK: 13, MOSI: 11, MISO: 12
* ESP32 various dev board : CS: 5, DC: 27, RST: 33, BL: 22, SCK: 18, MOSI: 23, MISO: nil
* ESP32-C3 various dev board : CS: 7, DC: 2, RST: 1, BL: 3, SCK: 4, MOSI: 6, MISO: nil
* ESP32-S2 various dev board : CS: 34, DC: 35, RST: 33, BL: 21, SCK: 36, MOSI: 35, MISO: nil
* ESP32-S2 various dev board : CS: 34, DC: 38, RST: 33, BL: 21, SCK: 36, MOSI: 35, MISO: nil
* ESP32-S3 various dev board : CS: 40, DC: 41, RST: 42, BL: 48, SCK: 36, MOSI: 35, MISO: nil
* ESP8266 various dev board : CS: 15, DC: 4, RST: 2, BL: 5, SCK: 14, MOSI: 13, MISO: 12
* Raspberry Pi Pico dev board : CS: 17, DC: 27, RST: 26, BL: 28, SCK: 18, MOSI: 19, MISO: 16
@ -72,7 +72,7 @@ Arduino_GFX *gfx = new Arduino_ILI9341(bus, DF_GFX_RST, 3 /* rotation */, false
#if defined(ARDUINO_ARCH_SAMD) && defined(SEEED_GROVE_UI_WIRELESS)
#include <Seeed_FS.h>
#include <SD/Seeed_SD.h>
#elif defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_RASPBERRY_PI_PICO_W)
#elif defined(TARGET_RP2040)
#include <LittleFS.h>
#include <SD.h>
#elif defined(ESP32)
@ -80,6 +80,7 @@ Arduino_GFX *gfx = new Arduino_ILI9341(bus, DF_GFX_RST, 3 /* rotation */, false
#include <LittleFS.h>
#include <SPIFFS.h>
#include <SD.h>
#include <SD_MMC.h>
#elif defined(ESP8266)
#include <LittleFS.h>
#include <SD.h>
@ -100,11 +101,19 @@ static int jpegDrawCallback(JPEGDRAW *pDraw)
void setup()
{
Serial.begin(115200);
// while (!Serial);
Serial.println("JPEG Image Viewer");
// Serial.setDebugOutput(true);
// while(!Serial);
Serial.println("Arduino_GFX JPEG Image Viewer example");
#ifdef GFX_EXTRA_PRE_INIT
GFX_EXTRA_PRE_INIT();
#endif
// Init Display
gfx->begin();
if (!gfx->begin())
{
Serial.println("gfx->begin() failed!");
}
gfx->fillScreen(BLACK);
#ifdef GFX_BL
@ -115,7 +124,7 @@ void setup()
/* Wio Terminal */
#if defined(ARDUINO_ARCH_SAMD) && defined(SEEED_GROVE_UI_WIRELESS)
if (!SD.begin(SDCARD_SS_PIN, SDCARD_SPI, 4000000UL))
#elif defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_RASPBERRY_PI_PICO_W)
#elif defined(TARGET_RP2040)
if (!LittleFS.begin())
// if (!SD.begin(SS))
#elif defined(ESP32)
@ -123,6 +132,10 @@ void setup()
if (!LittleFS.begin())
// if (!SPIFFS.begin())
// if (!SD.begin(SS))
// pinMode(10 /* CS */, OUTPUT);
// digitalWrite(10 /* CS */, HIGH);
// SD_MMC.setPins(12 /* CLK */, 11 /* CMD/MOSI */, 13 /* D0/MISO */);
// if (!SD_MMC.begin("/root", true))
#elif defined(ESP8266)
if (!LittleFS.begin())
// if (!SD.begin(SS))

View File

@ -18,7 +18,7 @@ static void *jpegOpenFile(const char *szFilename, int32_t *pFileSize)
// Serial.println("jpegOpenFile");
#if defined(ARDUINO_ARCH_SAMD) && defined(SEEED_GROVE_UI_WIRELESS)
_f = SD.open(szFilename, "r");
#elif defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_RASPBERRY_PI_PICO_W)
#elif defined(TARGET_RP2040)
_f = LittleFS.open(szFilename, "r");
// _f = SDFS.open(szFilename, "r");
#elif defined(ESP32)
@ -26,6 +26,7 @@ static void *jpegOpenFile(const char *szFilename, int32_t *pFileSize)
_f = LittleFS.open(szFilename, "r");
// _f = SPIFFS.open(szFilename, "r");
// _f = SD.open(szFilename, "r");
// _f = SD_MMC.open(szFilename, "r");
#elif defined(ESP8266)
_f = LittleFS.open(szFilename, "r");
// _f = SD.open(szFilename, "r");

View File

@ -7,7 +7,7 @@
*
* Dependent libraries:
* JPEGDEC: https://github.com/bitbank2/JPEGDEC.git
*
*
* Setup steps:
* 1. Change your LCD parameters in Arduino_GFX setting
* 2. Upload Motion JPEG file
@ -35,14 +35,14 @@
/*******************************************************************************
* Start of Arduino_GFX setting
*
*
* Arduino_GFX try to find the settings depends on selected board in Arduino IDE
* Or you can define the display dev kit not in the board list
* Defalult pin list for non display dev kit:
* Arduino Nano, Micro and more: CS: 9, DC: 8, RST: 7, BL: 6, SCK: 13, MOSI: 11, MISO: 12
* ESP32 various dev board : CS: 5, DC: 27, RST: 33, BL: 22, SCK: 18, MOSI: 23, MISO: nil
* ESP32-C3 various dev board : CS: 7, DC: 2, RST: 1, BL: 3, SCK: 4, MOSI: 6, MISO: nil
* ESP32-S2 various dev board : CS: 34, DC: 35, RST: 33, BL: 21, SCK: 36, MOSI: 35, MISO: nil
* ESP32-S2 various dev board : CS: 34, DC: 38, RST: 33, BL: 21, SCK: 36, MOSI: 35, MISO: nil
* ESP32-S3 various dev board : CS: 40, DC: 41, RST: 42, BL: 48, SCK: 36, MOSI: 35, MISO: nil
* ESP8266 various dev board : CS: 15, DC: 4, RST: 2, BL: 5, SCK: 14, MOSI: 13, MISO: 12
* Raspberry Pi Pico dev board : CS: 17, DC: 27, RST: 26, BL: 28, SCK: 18, MOSI: 19, MISO: 16
@ -77,7 +77,7 @@ Arduino_GFX *gfx = new Arduino_ILI9341(bus, DF_GFX_RST, 3 /* rotation */, false
#if defined(ARDUINO_ARCH_SAMD) && defined(SEEED_GROVE_UI_WIRELESS)
#include <Seeed_FS.h>
#include <SD/Seeed_SD.h>
#elif defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_RASPBERRY_PI_PICO_W)
#elif defined(TARGET_RP2040)
#include <LittleFS.h>
#include <SD.h>
#elif defined(ESP32)
@ -85,6 +85,7 @@ Arduino_GFX *gfx = new Arduino_ILI9341(bus, DF_GFX_RST, 3 /* rotation */, false
#include <LittleFS.h>
#include <SPIFFS.h>
#include <SD.h>
#include <SD_MMC.h>
#elif defined(ESP8266)
#include <LittleFS.h>
#include <SD.h>
@ -115,23 +116,31 @@ static int jpegDrawCallback(JPEGDRAW *pDraw)
void setup()
{
Serial.begin(115200);
// while (!Serial);
Serial.println("MJPEG Image Viewer");
// Serial.setDebugOutput(true);
// while(!Serial);
Serial.println("Arduino_GFX Motion JPEG Image Viewer example");
#ifdef GFX_EXTRA_PRE_INIT
GFX_EXTRA_PRE_INIT();
#endif
// Init Display
gfx->begin();
if (!gfx->begin())
{
Serial.println("gfx->begin() failed!");
}
gfx->fillScreen(BLACK);
#ifdef GFX_BL
pinMode(GFX_BL, OUTPUT);
digitalWrite(GFX_BL, HIGH);
pinMode(GFX_BL, OUTPUT);
digitalWrite(GFX_BL, HIGH);
#endif
/* Wio Terminal */
#if defined(ARDUINO_ARCH_SAMD) && defined(SEEED_GROVE_UI_WIRELESS)
// Init SPIFLASH
if (!SD.begin(SDCARD_SS_PIN, SDCARD_SPI, 4000000UL))
#elif defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_RASPBERRY_PI_PICO_W)
#elif defined(TARGET_RP2040)
if (!LittleFS.begin())
// if (!SD.begin(SS))
#elif defined(ESP32)
@ -139,6 +148,10 @@ void setup()
if (!LittleFS.begin())
// if (!SPIFFS.begin())
// if (!SD.begin(SS))
// pinMode(10 /* CS */, OUTPUT);
// digitalWrite(10 /* CS */, HIGH);
// SD_MMC.setPins(12 /* CLK */, 11 /* CMD/MOSI */, 13 /* D0/MISO */);
// if (!SD_MMC.begin("/root", true))
#elif defined(ESP8266)
if (!LittleFS.begin())
// if (!SD.begin(SS))
@ -153,7 +166,7 @@ void setup()
{
#if defined(ARDUINO_ARCH_SAMD) && defined(SEEED_GROVE_UI_WIRELESS)
File mjpegFile = SD.open(MJPEG_FILENAME, "r");
#elif defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_RASPBERRY_PI_PICO_W)
#elif defined(TARGET_RP2040)
File mjpegFile = LittleFS.open(MJPEG_FILENAME, "r");
// File mjpegFile = SD.open(MJPEG_FILENAME, "r");
#elif defined(ESP32)
@ -161,6 +174,7 @@ void setup()
File mjpegFile = LittleFS.open(MJPEG_FILENAME, "r");
// File mjpegFile = SPIFFS.open(MJPEG_FILENAME, "r");
// File mjpegFile = SD.open(MJPEG_FILENAME, "r");
// File mjpegFile = SD_MMC.open(MJPEG_FILENAME, "r");
#elif defined(ESP8266)
File mjpegFile = LittleFS.open(MJPEG_FILENAME, "r");
// File mjpegFile = SD.open(MJPEG_FILENAME, "r");

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

View File

@ -0,0 +1,206 @@
/*******************************************************************************
* Motion JPEG Image Viewer
* This is a simple Motion JPEG image viewer example
* Image Source: https://www.pexels.com/video/earth-rotating-video-856356/
* cropped: x: 598 y: 178 width: 720 height: 720 resized: 240x240
* ffmpeg -i "Pexels Videos 3931.mp4" -ss 0 -t 20.4s -vf "reverse,setpts=0.5*PTS,fps=10,vflip,hflip,rotate=90,crop=720:720:178:598,scale=240:240:flags=lanczos" -pix_fmt yuv420p -q:v 11 earth.mjpeg
*
* Dependent libraries:
* ESP32_JPEG: https://github.com/esp-arduino-libs/ESP32_JPEG.git
*
* Setup steps:
* 1. Change your LCD parameters in Arduino_GFX setting
* 2. Upload Motion JPEG file
* FFat/LittleFS:
* upload FFat (FatFS) data with ESP32 Sketch Data Upload:
* ESP32: https://github.com/lorol/arduino-esp32fs-plugin
* SD:
* Most Arduino system built-in support SD file system.
******************************************************************************/
#define MJPEG_FILENAME "/earth.mjpeg"
#define MJPEG_OUTPUT_SIZE (480 * 320 * 2) // memory for a output image frame
#define MJPEG_BUFFER_SIZE (MJPEG_OUTPUT_SIZE / 20) // memory for a single JPEG frame
/*******************************************************************************
* Start of Arduino_GFX setting
*
* Arduino_GFX try to find the settings depends on selected board in Arduino IDE
* Or you can define the display dev kit not in the board list
* Defalult pin list for non display dev kit:
* Arduino Nano, Micro and more: CS: 9, DC: 8, RST: 7, BL: 6, SCK: 13, MOSI: 11, MISO: 12
* ESP32 various dev board : CS: 5, DC: 27, RST: 33, BL: 22, SCK: 18, MOSI: 23, MISO: nil
* ESP32-C3 various dev board : CS: 7, DC: 2, RST: 1, BL: 3, SCK: 4, MOSI: 6, MISO: nil
* ESP32-S2 various dev board : CS: 34, DC: 38, RST: 33, BL: 21, SCK: 36, MOSI: 35, MISO: nil
* ESP32-S3 various dev board : CS: 40, DC: 41, RST: 42, BL: 48, SCK: 36, MOSI: 35, MISO: nil
******************************************************************************/
#include <Arduino_GFX_Library.h>
#define GFX_BL DF_GFX_BL // default backlight pin, you may replace DF_GFX_BL to actual backlight pin
/* More dev device declaration: https://github.com/moononournation/Arduino_GFX/wiki/Dev-Device-Declaration */
#if defined(DISPLAY_DEV_KIT)
Arduino_GFX *gfx = create_default_Arduino_GFX();
#else /* !defined(DISPLAY_DEV_KIT) */
/* More data bus class: https://github.com/moononournation/Arduino_GFX/wiki/Data-Bus-Class */
Arduino_DataBus *bus = create_default_Arduino_DataBus();
/* More display class: https://github.com/moononournation/Arduino_GFX/wiki/Display-Class */
Arduino_GFX *gfx = new Arduino_ILI9341(bus, DF_GFX_RST, 3 /* rotation */, false /* IPS */);
#endif /* !defined(DISPLAY_DEV_KIT) */
/*******************************************************************************
* End of Arduino_GFX setting
******************************************************************************/
#include <FFat.h>
#include <LittleFS.h>
#include <SPIFFS.h>
#include <SD.h>
#include <SD_MMC.h>
#include "MjpegClass.h"
static MjpegClass mjpeg;
/* variables */
static int total_frames = 0;
static unsigned long total_read_video = 0;
static unsigned long total_decode_video = 0;
static unsigned long total_show_video = 0;
static unsigned long start_ms, curr_ms;
static int16_t x = -1, y = -1, w = -1, h = -1;
void setup()
{
Serial.begin(115200);
// Serial.setDebugOutput(true);
// while(!Serial);
Serial.println("Arduino_GFX Motion JPEG SIMD Decoder Image Viewer example");
#ifdef GFX_EXTRA_PRE_INIT
GFX_EXTRA_PRE_INIT();
#endif
// Init Display
if (!gfx->begin())
{
Serial.println("gfx->begin() failed!");
}
gfx->fillScreen(BLACK);
#ifdef GFX_BL
pinMode(GFX_BL, OUTPUT);
digitalWrite(GFX_BL, HIGH);
#endif
// if (!FFat.begin())
if (!LittleFS.begin())
// if (!SPIFFS.begin())
// if (!SD.begin(SS))
// pinMode(10 /* CS */, OUTPUT);
// digitalWrite(10 /* CS */, HIGH);
// SD_MMC.setPins(12 /* CLK */, 11 /* CMD/MOSI */, 13 /* D0/MISO */);
// if (!SD_MMC.begin("/root", true))
{
Serial.println(F("ERROR: File System Mount Failed!"));
gfx->println(F("ERROR: File System Mount Failed!"));
}
else
{
// File mjpegFile = FFat.open(MJPEG_FILENAME, "r");
File mjpegFile = LittleFS.open(MJPEG_FILENAME, "r");
// File mjpegFile = SPIFFS.open(MJPEG_FILENAME, "r");
// File mjpegFile = SD.open(MJPEG_FILENAME, "r");
// File mjpegFile = SD_MMC.open(MJPEG_FILENAME, "r");
if (!mjpegFile || mjpegFile.isDirectory())
{
Serial.println(F("ERROR: Failed to open " MJPEG_FILENAME " file for reading"));
gfx->println(F("ERROR: Failed to open " MJPEG_FILENAME " file for reading"));
}
else
{
uint8_t *mjpeg_buf = (uint8_t *)malloc(MJPEG_BUFFER_SIZE);
if (!mjpeg_buf)
{
Serial.println(F("mjpeg_buf malloc failed!"));
}
else
{
uint16_t *output_buf = (uint16_t *)heap_caps_aligned_alloc(16, MJPEG_OUTPUT_SIZE, MALLOC_CAP_8BIT);
if (!output_buf)
{
Serial.println(F("output_buf malloc failed!"));
}
else
{
Serial.println(F("MJPEG start"));
start_ms = millis();
curr_ms = millis();
if (!mjpeg.setup(
&mjpegFile, mjpeg_buf,
output_buf, MJPEG_OUTPUT_SIZE, true /* useBigEndian */))
{
Serial.println(F("mjpeg.setup() failed!"));
}
else
{
while (mjpegFile.available() && mjpeg.readMjpegBuf())
{
// Read video
total_read_video += millis() - curr_ms;
curr_ms = millis();
// Play video
mjpeg.decodeJpg();
total_decode_video += millis() - curr_ms;
curr_ms = millis();
if (x == -1)
{
w = mjpeg.getWidth();
h = mjpeg.getHeight();
x = (w > gfx->width()) ? 0 : ((gfx->width() - w) / 2);
y = (h > gfx->height()) ? 0 : ((gfx->height() - h) / 2);
}
gfx->draw16bitBeRGBBitmap(x, y, output_buf, w, h);
total_show_video += millis() - curr_ms;
curr_ms = millis();
total_frames++;
}
int time_used = millis() - start_ms;
Serial.println(F("MJPEG end"));
float fps = 1000.0 * total_frames / time_used;
Serial.printf("Arduino_GFX ESP32 SIMD MJPEG decoder\n\n");
Serial.printf("Frame size: %d x %d\n", mjpeg.getWidth(), mjpeg.getHeight());
Serial.printf("Total frames: %d\n", total_frames);
Serial.printf("Time used: %d ms\n", time_used);
Serial.printf("Average FPS: %0.1f\n", fps);
Serial.printf("Read MJPEG: %lu ms (%0.1f %%)\n", total_read_video, 100.0 * total_read_video / time_used);
Serial.printf("Decode video: %lu ms (%0.1f %%)\n", total_decode_video, 100.0 * total_decode_video / time_used);
Serial.printf("Show video: %lu ms (%0.1f %%)\n", total_show_video, 100.0 * total_show_video / time_used);
gfx->setCursor(0, 0);
gfx->printf("Arduino_GFX ESP32 SIMD MJPEG decoder\n\n");
gfx->printf("Frame size: %d x %d\n", mjpeg.getWidth(), mjpeg.getHeight());
gfx->printf("Total frames: %d\n", total_frames);
gfx->printf("Time used: %d ms\n", time_used);
gfx->printf("Average FPS: %0.1f\n", fps);
gfx->printf("Read MJPEG: %lu ms (%0.1f %%)\n", total_read_video, 100.0 * total_read_video / time_used);
gfx->printf("Decode video: %lu ms (%0.1f %%)\n", total_decode_video, 100.0 * total_decode_video / time_used);
gfx->printf("Show video: %lu ms (%0.1f %%)\n", total_show_video, 100.0 * total_show_video / time_used);
mjpegFile.close();
}
}
}
}
}
}
void loop()
{
}

View File

@ -0,0 +1,206 @@
/*******************************************************************************
* ESP32_JPEG Wrapper Class
*
* Dependent libraries:
* ESP32_JPEG: https://github.com/esp-arduino-libs/ESP32_JPEG.git
******************************************************************************/
#pragma once
#if defined(ESP32)
#define READ_BUFFER_SIZE 1024
#define MAXOUTPUTSIZE (MAX_BUFFERED_PIXELS / 16 / 16)
#include <FS.h>
#include <ESP32_JPEG_Library.h>
class MjpegClass
{
public:
bool setup(
Stream *input, uint8_t *mjpeg_buf,
uint16_t *output_buf, size_t output_buf_size, bool useBigEndian)
{
_input = input;
_mjpeg_buf = mjpeg_buf;
_output_buf = (uint8_t *)output_buf;
_output_buf_size = output_buf_size;
_useBigEndian = useBigEndian;
_inputindex = 0;
if (!_read_buf)
{
_read_buf = (uint8_t *)malloc(READ_BUFFER_SIZE);
}
if (!_read_buf)
{
return false;
}
return true;
}
bool readMjpegBuf()
{
if (_inputindex == 0)
{
_buf_read = _input->readBytes(_read_buf, READ_BUFFER_SIZE);
_inputindex += _buf_read;
}
_mjpeg_buf_offset = 0;
int i = 0;
bool found_FFD8 = false;
while ((_buf_read > 0) && (!found_FFD8))
{
i = 0;
while ((i < _buf_read) && (!found_FFD8))
{
if ((_read_buf[i] == 0xFF) && (_read_buf[i + 1] == 0xD8)) // JPEG header
{
// Serial.printf("Found FFD8 at: %d.\n", i);
found_FFD8 = true;
}
++i;
}
if (found_FFD8)
{
--i;
}
else
{
_buf_read = _input->readBytes(_read_buf, READ_BUFFER_SIZE);
}
}
uint8_t *_p = _read_buf + i;
_buf_read -= i;
bool found_FFD9 = false;
if (_buf_read > 0)
{
i = 3;
while ((_buf_read > 0) && (!found_FFD9))
{
if ((_mjpeg_buf_offset > 0) && (_mjpeg_buf[_mjpeg_buf_offset - 1] == 0xFF) && (_p[0] == 0xD9)) // JPEG trailer
{
// Serial.printf("Found FFD9 at: %d.\n", i);
found_FFD9 = true;
}
else
{
while ((i < _buf_read) && (!found_FFD9))
{
if ((_p[i] == 0xFF) && (_p[i + 1] == 0xD9)) // JPEG trailer
{
found_FFD9 = true;
++i;
}
++i;
}
}
// Serial.printf("i: %d\n", i);
memcpy(_mjpeg_buf + _mjpeg_buf_offset, _p, i);
_mjpeg_buf_offset += i;
size_t o = _buf_read - i;
if (o > 0)
{
// Serial.printf("o: %d\n", o);
memcpy(_read_buf, _p + i, o);
_buf_read = _input->readBytes(_read_buf + o, READ_BUFFER_SIZE - o);
_p = _read_buf;
_inputindex += _buf_read;
_buf_read += o;
// Serial.printf("_buf_read: %d\n", _buf_read);
}
else
{
_buf_read = _input->readBytes(_read_buf, READ_BUFFER_SIZE);
_p = _read_buf;
_inputindex += _buf_read;
}
i = 0;
}
if (found_FFD9)
{
return true;
}
}
return false;
}
bool decodeJpg()
{
_remain = _mjpeg_buf_offset;
// Generate default configuration
jpeg_dec_config_t config = {
.output_type = JPEG_RAW_TYPE_RGB565_BE,
.rotate = JPEG_ROTATE_0D,
};
// Create jpeg_dec
_jpeg_dec = jpeg_dec_open(&config);
// Create io_callback handle
_jpeg_io = (jpeg_dec_io_t *)calloc(1, sizeof(jpeg_dec_io_t));
// Create out_info handle
_out_info = (jpeg_dec_header_info_t *)calloc(1, sizeof(jpeg_dec_header_info_t));
// Set input buffer and buffer len to io_callback
_jpeg_io->inbuf = _mjpeg_buf;
_jpeg_io->inbuf_len = _remain;
jpeg_dec_parse_header(_jpeg_dec, _jpeg_io, _out_info);
_w = _out_info->width;
_h = _out_info->height;
if ((_w * _h * 2) > _output_buf_size)
{
return false;
}
_jpeg_io->outbuf = _output_buf;
jpeg_dec_process(_jpeg_dec, _jpeg_io);
jpeg_dec_close(_jpeg_dec);
free(_jpeg_io);
free(_out_info);
return true;
}
int16_t getWidth()
{
return _w;
}
int16_t getHeight()
{
return _h;
}
private:
Stream *_input;
uint8_t *_mjpeg_buf;
uint8_t *_output_buf;
size_t _output_buf_size;
bool _useBigEndian;
uint8_t *_read_buf;
int32_t _mjpeg_buf_offset = 0;
jpeg_dec_handle_t *_jpeg_dec;
jpeg_dec_io_t *_jpeg_io;
jpeg_dec_header_info_t *_out_info;
int16_t _w = 0, _h = 0;
int32_t _inputindex = 0;
int32_t _buf_read;
int32_t _remain = 0;
};
#endif // defined(ESP32)

View File

@ -15,14 +15,14 @@
/*******************************************************************************
* Start of Arduino_GFX setting
*
*
* Arduino_GFX try to find the settings depends on selected board in Arduino IDE
* Or you can define the display dev kit not in the board list
* Defalult pin list for non display dev kit:
* Arduino Nano, Micro and more: CS: 9, DC: 8, RST: 7, BL: 6, SCK: 13, MOSI: 11, MISO: 12
* ESP32 various dev board : CS: 5, DC: 27, RST: 33, BL: 22, SCK: 18, MOSI: 23, MISO: nil
* ESP32-C3 various dev board : CS: 7, DC: 2, RST: 1, BL: 3, SCK: 4, MOSI: 6, MISO: nil
* ESP32-S2 various dev board : CS: 34, DC: 35, RST: 33, BL: 21, SCK: 36, MOSI: 35, MISO: nil
* ESP32-S2 various dev board : CS: 34, DC: 38, RST: 33, BL: 21, SCK: 36, MOSI: 35, MISO: nil
* ESP32-S3 various dev board : CS: 40, DC: 41, RST: 42, BL: 48, SCK: 36, MOSI: 35, MISO: nil
* ESP8266 various dev board : CS: 15, DC: 4, RST: 2, BL: 5, SCK: 14, MOSI: 13, MISO: 12
* Raspberry Pi Pico dev board : CS: 17, DC: 27, RST: 26, BL: 28, SCK: 18, MOSI: 19, MISO: 16
@ -56,19 +56,27 @@ Arduino_GFX *gfx = new Arduino_ILI9341(bus, DF_GFX_RST, 3 /* rotation */, false
void setup()
{
Serial.begin(115200);
// while (!Serial);
Serial.println("BMP Image Viewer");
// Serial.setDebugOutput(true);
// while(!Serial);
Serial.println("Arduino_GFX PROGMEM Image Viewer example");
#ifdef GFX_EXTRA_PRE_INIT
GFX_EXTRA_PRE_INIT();
#endif
// Init Display
gfx->begin();
if (!gfx->begin())
{
Serial.println("gfx->begin() failed!");
}
gfx->fillScreen(BLACK);
#ifdef GFX_BL
pinMode(GFX_BL, OUTPUT);
digitalWrite(GFX_BL, HIGH);
pinMode(GFX_BL, OUTPUT);
digitalWrite(GFX_BL, HIGH);
#endif
gfx->draw16bitRGBBitmap(0, 0, (const uint16_t*)Arduino_UNO_Rev3_Ok, IMG_WIDTH, IMG_HEIGHT);
gfx->draw16bitRGBBitmap(0, 0, (const uint16_t *)Arduino_UNO_Rev3_Ok, IMG_WIDTH, IMG_HEIGHT);
delay(5000); // 5 seconds
}
@ -77,7 +85,7 @@ void loop()
{
int16_t x = random(gfx->width());
int16_t y = random(gfx->height());
gfx->draw16bitRGBBitmap(x, y, (const uint16_t*)Arduino_UNO_Rev3_Ok, IMG_WIDTH, IMG_HEIGHT);
gfx->draw16bitRGBBitmap(x, y, (const uint16_t *)Arduino_UNO_Rev3_Ok, IMG_WIDTH, IMG_HEIGHT);
delay(1000); // 1 second
}

View File

@ -5,7 +5,7 @@
*
* Dependent libraries:
* PNGdec: https://github.com/bitbank2/PNGdec.git
*
*
* Setup steps:
* 1. Change your LCD parameters in Arduino_GFX setting
* 2. Upload PNG file
@ -31,14 +31,14 @@
/*******************************************************************************
* Start of Arduino_GFX setting
*
*
* Arduino_GFX try to find the settings depends on selected board in Arduino IDE
* Or you can define the display dev kit not in the board list
* Defalult pin list for non display dev kit:
* Arduino Nano, Micro and more: CS: 9, DC: 8, RST: 7, BL: 6, SCK: 13, MOSI: 11, MISO: 12
* ESP32 various dev board : CS: 5, DC: 27, RST: 33, BL: 22, SCK: 18, MOSI: 23, MISO: nil
* ESP32-C3 various dev board : CS: 7, DC: 2, RST: 1, BL: 3, SCK: 4, MOSI: 6, MISO: nil
* ESP32-S2 various dev board : CS: 34, DC: 35, RST: 33, BL: 21, SCK: 36, MOSI: 35, MISO: nil
* ESP32-S2 various dev board : CS: 34, DC: 38, RST: 33, BL: 21, SCK: 36, MOSI: 35, MISO: nil
* ESP32-S3 various dev board : CS: 40, DC: 41, RST: 42, BL: 48, SCK: 36, MOSI: 35, MISO: nil
* ESP8266 various dev board : CS: 15, DC: 4, RST: 2, BL: 5, SCK: 14, MOSI: 13, MISO: 12
* Raspberry Pi Pico dev board : CS: 17, DC: 27, RST: 26, BL: 28, SCK: 18, MOSI: 19, MISO: 16
@ -73,7 +73,7 @@ Arduino_GFX *gfx = new Arduino_ILI9341(bus, DF_GFX_RST, 3 /* rotation */, false
#if defined(ARDUINO_ARCH_SAMD) && defined(SEEED_GROVE_UI_WIRELESS)
#include <Seeed_FS.h>
#include <SD/Seeed_SD.h>
#elif defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_RASPBERRY_PI_PICO_W)
#elif defined(TARGET_RP2040)
#include <LittleFS.h>
#include <SD.h>
#elif defined(ESP32)
@ -101,7 +101,7 @@ void *myOpen(const char *filename, int32_t *size)
/* Wio Terminal */
#if defined(ARDUINO_ARCH_SAMD) && defined(SEEED_GROVE_UI_WIRELESS)
pngFile = SD.open(filename, "r");
#elif defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_RASPBERRY_PI_PICO_W)
#elif defined(TARGET_RP2040)
pngFile = LittleFS.open(filename, "r");
// pngFile = SD.open(filename, "r");
#elif defined(ESP32)
@ -159,35 +159,43 @@ void PNGDraw(PNGDRAW *pDraw)
// Serial.printf("Draw pos = 0,%d. size = %d x 1\n", pDraw->y, pDraw->iWidth);
png.getLineAsRGB565(pDraw, usPixels, PNG_RGB565_LITTLE_ENDIAN, 0x00000000);
png.getAlphaMask(pDraw, usMask, 1);
gfx->draw16bitRGBBitmap(xOffset, yOffset + pDraw->y, usPixels, usMask, pDraw->iWidth, 1);
gfx->draw16bitRGBBitmapWithMask(xOffset, yOffset + pDraw->y, usPixels, usMask, pDraw->iWidth, 1);
}
void setup()
{
Serial.begin(115200);
// while (!Serial);
Serial.println("PNG Image Viewer");
// Serial.setDebugOutput(true);
// while(!Serial);
Serial.println("Arduino_GFX PNG Image Viewer example");
#ifdef GFX_EXTRA_PRE_INIT
GFX_EXTRA_PRE_INIT();
#endif
// Init Display
gfx->begin();
if (!gfx->begin())
{
Serial.println("gfx->begin() failed!");
}
gfx->fillScreen(BLACK);
w = gfx->width(), h = gfx->height();
gfx->fillScreen(BLACK);
for (int16_t x = 0; x < w; x += 5)
{
gfx->drawFastVLine(x, 0, h, PINK);
gfx->drawFastVLine(x, 0, h, PALERED);
}
#ifdef GFX_BL
pinMode(GFX_BL, OUTPUT);
digitalWrite(GFX_BL, HIGH);
pinMode(GFX_BL, OUTPUT);
digitalWrite(GFX_BL, HIGH);
#endif
/* Wio Terminal */
#if defined(ARDUINO_ARCH_SAMD) && defined(SEEED_GROVE_UI_WIRELESS)
if (!SD.begin(SDCARD_SS_PIN, SDCARD_SPI, 4000000UL))
#elif defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_RASPBERRY_PI_PICO_W)
#elif defined(TARGET_RP2040)
if (!LittleFS.begin())
// if (!SD.begin(SS))
#elif defined(ESP32)

View File

@ -9,15 +9,27 @@
* LVGL Configuration file:
* Copy your_arduino_path/libraries/lvgl/lv_conf_template.h
* to your_arduino_path/libraries/lv_conf.h
*
* In lv_conf.h around line 15, enable config file:
* #if 1 // Set it to "1" to enable content
*
* Then find and set:
* #define LV_COLOR_DEPTH 16
* #define LV_TICK_CUSTOM 1
*
* For SPI display set color swap can be faster, parallel screen don't set!
* #define LV_COLOR_16_SWAP 1
*
* Optional: Show CPU usage and FPS count
* #define LV_USE_PERF_MONITOR 1
*
* For SPI/parallel 8 display set color swap can be faster, parallel 16/RGB screen don't swap!
* #define LV_COLOR_16_SWAP 1 // for SPI and parallel 8
* #define LV_COLOR_16_SWAP 0 // for parallel 16 and RGB
*
* Enable LVGL Demo Benchmark:
* #define LV_USE_DEMO_BENCHMARK 1
*
* Enables support for compressed fonts:
* #define LV_USE_FONT_COMPRESSED 1
*
* Customize font size:
* #define LV_FONT_MONTSERRAT_12 1
* #define LV_FONT_DEFAULT &lv_font_montserrat_12
******************************************************************************/
#include "lv_demo_benchmark.h"
@ -30,7 +42,7 @@
* Arduino Nano, Micro and more: CS: 9, DC: 8, RST: 7, BL: 6, SCK: 13, MOSI: 11, MISO: 12
* ESP32 various dev board : CS: 5, DC: 27, RST: 33, BL: 22, SCK: 18, MOSI: 23, MISO: nil
* ESP32-C3 various dev board : CS: 7, DC: 2, RST: 1, BL: 3, SCK: 4, MOSI: 6, MISO: nil
* ESP32-S2 various dev board : CS: 34, DC: 35, RST: 33, BL: 21, SCK: 36, MOSI: 35, MISO: nil
* ESP32-S2 various dev board : CS: 34, DC: 38, RST: 33, BL: 21, SCK: 36, MOSI: 35, MISO: nil
* ESP32-S3 various dev board : CS: 40, DC: 41, RST: 42, BL: 48, SCK: 36, MOSI: 35, MISO: nil
* ESP8266 various dev board : CS: 15, DC: 4, RST: 2, BL: 5, SCK: 14, MOSI: 13, MISO: 12
* Raspberry Pi Pico dev board : CS: 17, DC: 27, RST: 26, BL: 28, SCK: 18, MOSI: 19, MISO: 16
@ -61,6 +73,11 @@ Arduino_GFX *gfx = new Arduino_ILI9341(bus, DF_GFX_RST, 0 /* rotation */, false
* End of Arduino_GFX setting
******************************************************************************/
/*******************************************************************************
* Please config the touch panel in touch.h
******************************************************************************/
#include "touch.h"
/* Change to your screen resolution */
static uint32_t screenWidth;
static uint32_t screenHeight;
@ -72,74 +89,112 @@ static unsigned long last_ms;
/* Display flushing */
void my_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p)
{
uint32_t w = (area->x2 - area->x1 + 1);
uint32_t h = (area->y2 - area->y1 + 1);
uint32_t w = (area->x2 - area->x1 + 1);
uint32_t h = (area->y2 - area->y1 + 1);
#if (LV_COLOR_16_SWAP != 0)
gfx->draw16bitBeRGBBitmap(area->x1, area->y1, (uint16_t *)&color_p->full, w, h);
gfx->draw16bitBeRGBBitmap(area->x1, area->y1, (uint16_t *)&color_p->full, w, h);
#else
gfx->draw16bitRGBBitmap(area->x1, area->y1, (uint16_t *)&color_p->full, w, h);
gfx->draw16bitRGBBitmap(area->x1, area->y1, (uint16_t *)&color_p->full, w, h);
#endif
lv_disp_flush_ready(disp);
lv_disp_flush_ready(disp);
}
void my_touchpad_read(lv_indev_drv_t *indev_driver, lv_indev_data_t *data)
{
if (touch_has_signal())
{
if (touch_touched())
{
data->state = LV_INDEV_STATE_PR;
/*Set the coordinates*/
data->point.x = touch_last_x;
data->point.y = touch_last_y;
}
else if (touch_released())
{
data->state = LV_INDEV_STATE_REL;
}
}
else
{
data->state = LV_INDEV_STATE_REL;
}
}
void setup()
{
Serial.begin(115200);
// while (!Serial);
Serial.println("LVGL Benchmark Demo");
Serial.begin(115200);
// Serial.setDebugOutput(true);
// while(!Serial);
Serial.println("Arduino_GFX LVGL Benchmark example");
// Init Display
gfx->begin();
gfx->fillScreen(BLACK);
#ifdef GFX_EXTRA_PRE_INIT
GFX_EXTRA_PRE_INIT();
#endif
// Init Display
if (!gfx->begin())
{
Serial.println("gfx->begin() failed!");
}
gfx->fillScreen(BLACK);
#ifdef GFX_BL
pinMode(GFX_BL, OUTPUT);
digitalWrite(GFX_BL, HIGH);
pinMode(GFX_BL, OUTPUT);
digitalWrite(GFX_BL, HIGH);
#endif
lv_init();
// Init touch device
touch_init(gfx->width(), gfx->height(), gfx->getRotation());
screenWidth = gfx->width();
screenHeight = gfx->height();
lv_init();
screenWidth = gfx->width();
screenHeight = gfx->height();
#ifdef ESP32
disp_draw_buf = (lv_color_t *)heap_caps_malloc(sizeof(lv_color_t) * screenWidth * 10, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
disp_draw_buf = (lv_color_t *)heap_caps_malloc(sizeof(lv_color_t) * screenWidth * 40, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
#else
disp_draw_buf = (lv_color_t *)malloc(sizeof(lv_color_t) * screenWidth * 10);
disp_draw_buf = (lv_color_t *)malloc(sizeof(lv_color_t) * screenWidth * 40);
#endif
if (!disp_draw_buf)
{
Serial.println("LVGL disp_draw_buf allocate failed!");
}
else
{
lv_disp_draw_buf_init(&draw_buf, disp_draw_buf, NULL, screenWidth * 10);
if (!disp_draw_buf)
{
Serial.println("LVGL disp_draw_buf allocate failed!");
}
else
{
lv_disp_draw_buf_init(&draw_buf, disp_draw_buf, NULL, screenWidth * 40);
/* Initialize the display */
lv_disp_drv_init(&disp_drv);
/* Change the following line to your display resolution */
disp_drv.hor_res = screenWidth;
disp_drv.ver_res = screenHeight;
disp_drv.flush_cb = my_disp_flush;
disp_drv.draw_buf = &draw_buf;
lv_disp_drv_register(&disp_drv);
/* Initialize the display */
lv_disp_drv_init(&disp_drv);
/* Change the following line to your display resolution */
disp_drv.hor_res = screenWidth;
disp_drv.ver_res = screenHeight;
disp_drv.flush_cb = my_disp_flush;
disp_drv.draw_buf = &draw_buf;
lv_disp_drv_register(&disp_drv);
/* Initialize the (dummy) input device driver */
static lv_indev_drv_t indev_drv;
lv_indev_drv_init(&indev_drv);
indev_drv.type = LV_INDEV_TYPE_POINTER;
lv_indev_drv_register(&indev_drv);
/* Initialize the (dummy) input device driver */
static lv_indev_drv_t indev_drv;
lv_indev_drv_init(&indev_drv);
indev_drv.type = LV_INDEV_TYPE_POINTER;
indev_drv.read_cb = my_touchpad_read;
lv_indev_drv_register(&indev_drv);
lv_demo_benchmark();
lv_demo_benchmark();
Serial.println("Setup done");
}
last_ms = millis();
Serial.println("Setup done");
}
last_ms = millis();
}
void loop()
{
lv_timer_handler(); /* let the GUI do its work */
delay(5);
lv_timer_handler(); /* let the GUI do its work */
#ifdef CANVAS
gfx->flush();
#endif
delay(5);
}

View File

@ -496,7 +496,11 @@ static void sub_rectangle_cb(void)
lv_style_reset(&style_common);
lv_style_set_radius(&style_common, RADIUS);
lv_style_set_bg_opa(&style_common, opa_mode ? LV_OPA_50 : LV_OPA_COVER);
#if LV_GPU_SDL_CUSTOM_BLEND_MODE
lv_style_set_blend_mode(&style_common, LV_BLEND_MODE_SUBTRACTIVE);
#else
lv_style_set_blend_mode(&style_common, LV_BLEND_MODE_NORMAL);
#endif
rect_create(&style_common);
}
@ -506,7 +510,11 @@ static void sub_border_cb(void)
lv_style_set_radius(&style_common, RADIUS);
lv_style_set_border_width(&style_common, BORDER_WIDTH);
lv_style_set_border_opa(&style_common, opa_mode ? LV_OPA_50 : LV_OPA_COVER);
#if LV_GPU_SDL_CUSTOM_BLEND_MODE
lv_style_set_blend_mode(&style_common, LV_BLEND_MODE_SUBTRACTIVE);
#else
lv_style_set_blend_mode(&style_common, LV_BLEND_MODE_NORMAL);
#endif
rect_create(&style_common);
}
@ -519,7 +527,11 @@ static void sub_shadow_cb(void)
lv_style_set_shadow_opa(&style_common, opa_mode ? LV_OPA_80 : LV_OPA_COVER);
lv_style_set_shadow_width(&style_common, SHADOW_WIDTH_SMALL);
lv_style_set_shadow_spread(&style_common, SHADOW_WIDTH_SMALL);
#if LV_GPU_SDL_CUSTOM_BLEND_MODE
lv_style_set_blend_mode(&style_common, LV_BLEND_MODE_SUBTRACTIVE);
#else
lv_style_set_blend_mode(&style_common, LV_BLEND_MODE_NORMAL);
#endif
rect_create(&style_common);
}
@ -528,7 +540,11 @@ static void sub_img_cb(void)
{
lv_style_reset(&style_common);
lv_style_set_img_opa(&style_common, opa_mode ? LV_OPA_50 : LV_OPA_COVER);
#if LV_GPU_SDL_CUSTOM_BLEND_MODE
lv_style_set_blend_mode(&style_common, LV_BLEND_MODE_SUBTRACTIVE);
#else
lv_style_set_blend_mode(&style_common, LV_BLEND_MODE_NORMAL);
#endif
#if LV_DEMO_BENCHMARK_RGB565A8 && LV_COLOR_DEPTH == 16
img_create(&style_common, &img_benchmark_cogwheel_rgb565a8, false, false, false);
#else
@ -540,7 +556,11 @@ static void sub_line_cb(void)
lv_style_reset(&style_common);
lv_style_set_line_width(&style_common, LINE_WIDTH);
lv_style_set_line_opa(&style_common, opa_mode ? LV_OPA_50 : LV_OPA_COVER);
#if LV_GPU_SDL_CUSTOM_BLEND_MODE
lv_style_set_blend_mode(&style_common, LV_BLEND_MODE_SUBTRACTIVE);
#else
lv_style_set_blend_mode(&style_common, LV_BLEND_MODE_NORMAL);
#endif
line_create(&style_common);
}
@ -550,7 +570,11 @@ static void sub_arc_cb(void)
lv_style_reset(&style_common);
lv_style_set_arc_width(&style_common, ARC_WIDTH_THICK);
lv_style_set_arc_opa(&style_common, opa_mode ? LV_OPA_50 : LV_OPA_COVER);
#if LV_GPU_SDL_CUSTOM_BLEND_MODE
lv_style_set_blend_mode(&style_common, LV_BLEND_MODE_SUBTRACTIVE);
#else
lv_style_set_blend_mode(&style_common, LV_BLEND_MODE_NORMAL);
#endif
arc_create(&style_common);
}
@ -559,7 +583,11 @@ static void sub_text_cb(void)
lv_style_reset(&style_common);
lv_style_set_text_font(&style_common, lv_theme_get_font_normal(NULL));
lv_style_set_text_opa(&style_common, opa_mode ? LV_OPA_50 : LV_OPA_COVER);
#if LV_GPU_SDL_CUSTOM_BLEND_MODE
lv_style_set_blend_mode(&style_common, LV_BLEND_MODE_SUBTRACTIVE);
#else
lv_style_set_blend_mode(&style_common, LV_BLEND_MODE_NORMAL);
#endif
txt_create(&style_common);
}
@ -807,10 +835,10 @@ static void generate_report(void)
lv_obj_set_flex_flow(lv_scr_act(), LV_FLEX_FLOW_COLUMN);
title = lv_label_create(lv_scr_act());
lv_label_set_text_fmt(title, "Weighted FPS: %"LV_PRIu32, fps_weighted);
lv_label_set_text_fmt(title, "Arduino_GFX screen size: %"LV_PRIu32" x %"LV_PRIu32, LV_HOR_RES, LV_VER_RES);
subtitle = lv_label_create(lv_scr_act());
lv_label_set_text_fmt(subtitle, "Opa. speed: %"LV_PRIu32"%%", opa_speed_pct);
lv_label_set_text_fmt(subtitle, "LVGL weighted FPS: %"LV_PRIu32", Opa. speed: %"LV_PRIu32"%%", fps_weighted, opa_speed_pct);
lv_coord_t w = lv_obj_get_content_width(lv_scr_act());
lv_obj_t * table = lv_table_create(lv_scr_act());
@ -1000,11 +1028,15 @@ static void scene_next_task_cb(lv_timer_t * timer)
if(opa_mode) {
lv_label_set_text_fmt(subtitle, "Result of \"%s\": %"LV_PRId32" FPS", scenes[scene_act].name,
scenes[scene_act].fps_normal);
LV_LOG("Result of \"%s + opa\": %"LV_PRId32" FPS\n", scenes[scene_act].name,
scenes[scene_act].fps_normal);
}
else {
if(scene_act > 0) {
lv_label_set_text_fmt(subtitle, "Result of \"%s + opa\": %"LV_PRId32" FPS", scenes[scene_act - 1].name,
scenes[scene_act - 1].fps_opa);
LV_LOG("Result of \"%s + opa\": %"LV_PRId32" FPS\n", scenes[scene_act].name,
scenes[scene_act - 1].fps_opa);
}
else {
lv_label_set_text(subtitle, "");

View File

@ -15,7 +15,6 @@ extern "C" {
*********************/
// #include "../lv_demos.h"
#include <lvgl.h>
#define LV_USE_DEMO_BENCHMARK 1
/*********************
* DEFINES

View File

@ -0,0 +1,192 @@
/*******************************************************************************
* Touch libraries:
* XPT2046: https://github.com/PaulStoffregen/XPT2046_Touchscreen.git
*
* Capacitive touchscreen libraries
* TouchLib: https://github.com/mmMicky/TouchLib.git
******************************************************************************/
/* uncomment for XPT2046 */
// #define TOUCH_XPT2046
// #define TOUCH_XPT2046_SCK 12
// #define TOUCH_XPT2046_MISO 13
// #define TOUCH_XPT2046_MOSI 11
// #define TOUCH_XPT2046_CS 10
// #define TOUCH_XPT2046_INT 18
// #define TOUCH_XPT2046_ROTATION 0
// #define TOUCH_XPT2046_SAMPLES 50
// uncomment for most capacitive touchscreen
// #define TOUCH_MODULES_FT5x06 // GT911 / CST_SELF / CST_MUTUAL / ZTW622 / L58 / FT3267 / FT5x06
// #define TOUCH_MODULE_ADDR FT5x06_ADDR // CTS328_SLAVE_ADDRESS / L58_SLAVE_ADDRESS / CTS826_SLAVE_ADDRESS / CTS820_SLAVE_ADDRESS / CTS816S_SLAVE_ADDRESS / FT3267_SLAVE_ADDRESS / FT5x06_ADDR / GT911_SLAVE_ADDRESS1 / GT911_SLAVE_ADDRESS2 / ZTW622_SLAVE1_ADDRESS / ZTW622_SLAVE2_ADDRESS
// #define TOUCH_SCL 5
// #define TOUCH_SDA 6
// #define TOUCH_RES -1
// #define TOUCH_INT -1
// Please fill below values from Arduino_GFX Example - TouchCalibration
bool touch_swap_xy = false;
int16_t touch_map_x1 = -1;
int16_t touch_map_x2 = -1;
int16_t touch_map_y1 = -1;
int16_t touch_map_y2 = -1;
int16_t touch_max_x = 0, touch_max_y = 0;
int16_t touch_raw_x = 0, touch_raw_y = 0;
int16_t touch_last_x = 0, touch_last_y = 0;
#if defined(TOUCH_XPT2046)
#include <XPT2046_Touchscreen.h>
#include <SPI.h>
XPT2046_Touchscreen ts(TOUCH_XPT2046_CS, TOUCH_XPT2046_INT);
#elif defined(TOUCH_MODULE_ADDR) // TouchLib
#include <Wire.h>
#include <TouchLib.h>
TouchLib touch(Wire, TOUCH_SDA, TOUCH_SCL, TOUCH_MODULE_ADDR);
#endif // TouchLib
void touch_init(int16_t w, int16_t h, uint8_t r)
{
touch_max_x = w - 1;
touch_max_y = h - 1;
if (touch_map_x1 == -1)
{
switch (r)
{
case 3:
touch_swap_xy = true;
touch_map_x1 = touch_max_x;
touch_map_x2 = 0;
touch_map_y1 = 0;
touch_map_y2 = touch_max_y;
break;
case 2:
touch_swap_xy = false;
touch_map_x1 = touch_max_x;
touch_map_x2 = 0;
touch_map_y1 = touch_max_y;
touch_map_y2 = 0;
break;
case 1:
touch_swap_xy = true;
touch_map_x1 = 0;
touch_map_x2 = touch_max_x;
touch_map_y1 = touch_max_y;
touch_map_y2 = 0;
break;
default: // case 0:
touch_swap_xy = false;
touch_map_x1 = 0;
touch_map_x2 = touch_max_x;
touch_map_y1 = 0;
touch_map_y2 = touch_max_y;
break;
}
}
#if defined(TOUCH_XPT2046)
SPI.begin(TOUCH_XPT2046_SCK, TOUCH_XPT2046_MISO, TOUCH_XPT2046_MOSI, TOUCH_XPT2046_CS);
ts.begin();
ts.setRotation(TOUCH_XPT2046_ROTATION);
#elif defined(TOUCH_MODULE_ADDR) // TouchLib
// Reset touchscreen
#if (TOUCH_RES > 0)
pinMode(TOUCH_RES, OUTPUT);
digitalWrite(TOUCH_RES, 0);
delay(200);
digitalWrite(TOUCH_RES, 1);
delay(200);
#endif
Wire.begin(TOUCH_SDA, TOUCH_SCL);
touch.init();
#endif // TouchLib
}
bool touch_has_signal()
{
#if defined(TOUCH_XPT2046)
return ts.tirqTouched();
#elif defined(TOUCH_MODULE_ADDR) // TouchLib
// TODO: implement TOUCH_INT
return true;
#endif // TouchLib
return false;
}
void translate_touch_raw()
{
if (touch_swap_xy)
{
touch_last_x = map(touch_raw_y, touch_map_x1, touch_map_x2, 0, touch_max_x);
touch_last_y = map(touch_raw_x, touch_map_y1, touch_map_y2, 0, touch_max_y);
}
else
{
touch_last_x = map(touch_raw_x, touch_map_x1, touch_map_x2, 0, touch_max_x);
touch_last_y = map(touch_raw_y, touch_map_y1, touch_map_y2, 0, touch_max_y);
}
// Serial.printf("touch_raw_x: %d, touch_raw_y: %d, touch_last_x: %d, touch_last_y: %d\n", touch_raw_x, touch_raw_y, touch_last_x, touch_last_y);
}
bool touch_touched()
{
#if defined(TOUCH_XPT2046)
if (ts.touched())
{
TS_Point p = ts.getPoint();
touch_raw_x = p.x;
touch_raw_y = p.y;
int max_z = p.z;
int count = 0;
while ((ts.touched()) && (count < TOUCH_XPT2046_SAMPLES))
{
count++;
TS_Point p = ts.getPoint();
if (p.z > max_z)
{
touch_raw_x = p.x;
touch_raw_y = p.y;
max_z = p.z;
}
// Serial.printf("touch_raw_x: %d, touch_raw_y: %d, p.z: %d\n", touch_raw_x, touch_raw_y, p.z);
}
translate_touch_raw();
return true;
}
#elif defined(TOUCH_MODULE_ADDR) // TouchLib
if (touch.read())
{
TP_Point t = touch.getPoint(0);
touch_raw_x = t.x;
touch_raw_y = t.y;
touch_last_x = touch_raw_x;
touch_last_y = touch_raw_y;
translate_touch_raw();
return true;
}
#endif // TouchLib
return false;
}
bool touch_released()
{
#if defined(TOUCH_XPT2046)
return true;
#elif defined(TOUCH_MODULE_ADDR) // TouchLib
return false;
#endif // TouchLib
return false;
}

View File

@ -0,0 +1,74 @@
#ifndef _ADAFRUIT_NEOPIXEL_GFX_H_
#define _ADAFRUIT_NEOPIXEL_GFX_H_
#include <Adafruit_NeoPixel.h>
#include <Arduino_GFX.h>
#ifdef __AVR__
#include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif
// Which pin on the Arduino is connected to the NeoPixels?
#define NEOPIXEL_PIN 1 // On Trinket or Gemma, suggest changing this to 1
#define NEOPIXEL_WIDTH 30
#define NEOPIXEL_HEIGHT 8
#define NUMPIXELS (NEOPIXEL_WIDTH * NEOPIXEL_HEIGHT)
#define NEOPIXEL_BRIGHTNESS 3 // 1-255
// Pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
#define NEOPIXEL_TYPE (NEO_GRB + NEO_KHZ800)
class Adafruit_NeoPixel_GFX : public Arduino_GFX
{
public:
Adafruit_NeoPixel_GFX() : Arduino_GFX(NEOPIXEL_WIDTH, NEOPIXEL_HEIGHT)
{
wrap = false;
}
bool begin(int32_t speed = GFX_NOT_DEFINED) override
{
// These lines are specifically to support the Adafruit Trinket 5V 16 MHz.
// Any other board, you can remove this part (but no harm leaving it):
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
clock_prescale_set(clock_div_1);
#endif
// END of Trinket-specific code.
_pixels = new Adafruit_NeoPixel(NUMPIXELS, NEOPIXEL_PIN, NEOPIXEL_TYPE);
_pixels->begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
_pixels->show(); // Turn OFF all pixels ASAP
_pixels->setBrightness(NEOPIXEL_BRIGHTNESS);
return true;
}
void writePixelPreclipped(int16_t x, int16_t y, uint16_t color) override
{
// select you matrix mode
int32_t i = (x * NEOPIXEL_HEIGHT) + y; // vertical strip start from left top
// int32_t i = (x * NEOPIXEL_HEIGHT) + ((x % 2) ? y : (NEOPIXEL_HEIGHT - y - 1)); // vertical zigzag strip start from left top
// int32_t i = (x * NEOPIXEL_HEIGHT) + (NEOPIXEL_HEIGHT - y - 1); // vertical strip start from left bottom
// int32_t i = (x * NEOPIXEL_HEIGHT) + ((x % 2) ? (NEOPIXEL_HEIGHT - y - 1) : y); // vertical zigzag strip start from left bottom
// int32_t i = x + (y * NEOPIXEL_WIDTH); // horizontal strip start from left top
// int32_t i = ((y % 2) ? x : (NEOPIXEL_WIDTH - x - 1)) + (y * NEOPIXEL_WIDTH); // horizontal zigzag strip start from left top
// int32_t i = (NEOPIXEL_WIDTH - x - 1) + (y * NEOPIXEL_WIDTH); // horizontal strip start from right top
// int32_t i = ((y % 2) ? (NEOPIXEL_WIDTH - x - 1) : x) + (y * NEOPIXEL_WIDTH); // horizontal zigzag strip start from right top
_pixels->setPixelColor(i, RGB16TO24(color));
}
void endWrite(void) override
{
_pixels->show();
}
Adafruit_NeoPixel *_pixels;
};
#endif // _ADAFRUIT_NEOPIXEL_GFX_H_

View File

@ -0,0 +1,127 @@
/*******************************************************************************
* LVGL Hello NeoPixel demo
* This is a LVGL Hello World with NeoPixel matrix and Unicode text display
*
* Dependent libraries:
* LVGL: https://github.com/lvgl/lvgl.git
* Adafruit_NeoPixel: https://github.com/adafruit/Adafruit_NeoPixel.git
*
* Font:
* https://github.com/Warren2060/Chill-Bitmap.git
*
* LVGL Configuration file:
* Copy your_arduino_path/libraries/lvgl/lv_conf_template.h
* to your_arduino_path/libraries/lv_conf.h
*
* In lv_conf.h around line 15, enable config file:
* #if 1 // Set it to "1" to enable content
*
* Then find and set:
* #define LV_COLOR_DEPTH 16
* #define LV_TICK_CUSTOM 1
* #define LV_COLOR_16_SWAP 0
******************************************************************************/
#include <lvgl.h>
#include <Arduino_GFX_Library.h>
// all settings in header file
#include "Adafruit_NeoPixel_GFX.h"
Arduino_GFX *gfx = new Adafruit_NeoPixel_GFX();
int16_t x;
uint16_t w, tw;
static lv_disp_draw_buf_t draw_buf;
static lv_color_t *disp_draw_buf;
static lv_disp_drv_t disp_drv;
/* Display flushing */
void my_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p)
{
uint32_t w = (area->x2 - area->x1 + 1);
uint32_t h = (area->y2 - area->y1 + 1);
gfx->draw16bitRGBBitmap(area->x1, area->y1, (uint16_t *)&color_p->full, w, h);
lv_disp_flush_ready(disp);
}
void setup()
{
Serial.begin(115200);
// Serial.setDebugOutput(true);
// while(!Serial);
Serial.println("Arduino_GFX LVGL Hello NeoPixel example");
#ifdef GFX_EXTRA_PRE_INIT
GFX_EXTRA_PRE_INIT();
#endif
// Init Display
if (!gfx->begin())
{
Serial.println("gfx->begin() failed!");
}
gfx->fillScreen(BLACK);
#ifdef GFX_BL
pinMode(GFX_BL, OUTPUT);
digitalWrite(GFX_BL, HIGH);
#endif
lv_init();
#ifdef ESP32
disp_draw_buf = (lv_color_t *)heap_caps_malloc(sizeof(lv_color_t) * NEOPIXEL_WIDTH * NEOPIXEL_HEIGHT, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
#else
disp_draw_buf = (lv_color_t *)malloc(sizeof(lv_color_t) * NEOPIXEL_WIDTH * NEOPIXEL_HEIGHT);
#endif
if (!disp_draw_buf)
{
Serial.println("LVGL disp_draw_buf allocate failed!");
}
else
{
lv_disp_draw_buf_init(&draw_buf, disp_draw_buf, NULL, NEOPIXEL_WIDTH * NEOPIXEL_HEIGHT);
/* Initialize the display */
lv_disp_drv_init(&disp_drv);
/* Change the following line to your display resolution */
disp_drv.hor_res = NEOPIXEL_WIDTH;
disp_drv.ver_res = NEOPIXEL_HEIGHT;
disp_drv.flush_cb = my_disp_flush;
disp_drv.draw_buf = &draw_buf;
lv_disp_drv_register(&disp_drv);
/* Initialize the (dummy) input device driver */
static lv_indev_drv_t indev_drv;
lv_indev_drv_init(&indev_drv);
indev_drv.type = LV_INDEV_TYPE_POINTER;
lv_indev_drv_register(&indev_drv);
/* Set black background */
lv_obj_set_style_bg_color(lv_scr_act(), lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT );
/* Create label */
lv_obj_t *label = lv_label_create(lv_scr_act());
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_width(label, NEOPIXEL_WIDTH);
lv_obj_set_style_text_color(label, lv_color_hex(0xFF0000), LV_PART_MAIN | LV_STATE_DEFAULT );
lv_label_set_text(label, "LVGL Hello NeoPixel! 《陈亮手痕定律》 点阵屏测试");
/* Set font */
LV_FONT_DECLARE(ui_font_Chill7);
lv_obj_set_style_text_font(label, &ui_font_Chill7, LV_PART_MAIN| LV_STATE_DEFAULT);
/* Set scrolling */
lv_label_set_long_mode(label, LV_LABEL_LONG_SCROLL_CIRCULAR);
lv_obj_set_style_anim_speed(label, 10, LV_STATE_DEFAULT);
Serial.println("Setup done");
}
}
void loop()
{
lv_timer_handler(); /* let the GUI do its work */
#ifdef CANVAS
gfx->flush();
#endif
delay(5);
}

File diff suppressed because one or more lines are too long

View File

@ -9,15 +9,17 @@
* LVGL Configuration file:
* Copy your_arduino_path/libraries/lvgl/lv_conf_template.h
* to your_arduino_path/libraries/lv_conf.h
*
* In lv_conf.h around line 15, enable config file:
* #if 1 // Set it to "1" to enable content
*
* Then find and set:
* #define LV_COLOR_DEPTH 16
* #define LV_TICK_CUSTOM 1
*
* For SPI display set color swap can be faster, parallel screen don't set!
* #define LV_COLOR_16_SWAP 1
*
* Optional: Show CPU usage and FPS count
* #define LV_USE_PERF_MONITOR 1
*
* For SPI/parallel 8 display set color swap can be faster, parallel 16/RGB screen don't swap!
* #define LV_COLOR_16_SWAP 1 // for SPI and parallel 8
* #define LV_COLOR_16_SWAP 0 // for parallel 16 and RGB
******************************************************************************/
#include <lvgl.h>
@ -30,7 +32,7 @@
* Arduino Nano, Micro and more: CS: 9, DC: 8, RST: 7, BL: 6, SCK: 13, MOSI: 11, MISO: 12
* ESP32 various dev board : CS: 5, DC: 27, RST: 33, BL: 22, SCK: 18, MOSI: 23, MISO: nil
* ESP32-C3 various dev board : CS: 7, DC: 2, RST: 1, BL: 3, SCK: 4, MOSI: 6, MISO: nil
* ESP32-S2 various dev board : CS: 34, DC: 35, RST: 33, BL: 21, SCK: 36, MOSI: 35, MISO: nil
* ESP32-S2 various dev board : CS: 34, DC: 38, RST: 33, BL: 21, SCK: 36, MOSI: 35, MISO: nil
* ESP32-S3 various dev board : CS: 40, DC: 41, RST: 42, BL: 48, SCK: 36, MOSI: 35, MISO: nil
* ESP8266 various dev board : CS: 15, DC: 4, RST: 2, BL: 5, SCK: 14, MOSI: 13, MISO: 12
* Raspberry Pi Pico dev board : CS: 17, DC: 27, RST: 26, BL: 28, SCK: 18, MOSI: 19, MISO: 16
@ -71,76 +73,87 @@ static lv_disp_drv_t disp_drv;
/* Display flushing */
void my_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p)
{
uint32_t w = (area->x2 - area->x1 + 1);
uint32_t h = (area->y2 - area->y1 + 1);
uint32_t w = (area->x2 - area->x1 + 1);
uint32_t h = (area->y2 - area->y1 + 1);
#if (LV_COLOR_16_SWAP != 0)
gfx->draw16bitBeRGBBitmap(area->x1, area->y1, (uint16_t *)&color_p->full, w, h);
gfx->draw16bitBeRGBBitmap(area->x1, area->y1, (uint16_t *)&color_p->full, w, h);
#else
gfx->draw16bitRGBBitmap(area->x1, area->y1, (uint16_t *)&color_p->full, w, h);
gfx->draw16bitRGBBitmap(area->x1, area->y1, (uint16_t *)&color_p->full, w, h);
#endif
lv_disp_flush_ready(disp);
lv_disp_flush_ready(disp);
}
void setup()
{
Serial.begin(115200);
// while (!Serial);
Serial.println("LVGL Hello World");
Serial.begin(115200);
// Serial.setDebugOutput(true);
// while(!Serial);
Serial.println("Arduino_GFX LVGL Hello World example");
// Init Display
gfx->begin();
gfx->fillScreen(BLACK);
#ifdef GFX_EXTRA_PRE_INIT
GFX_EXTRA_PRE_INIT();
#endif
// Init Display
if (!gfx->begin())
{
Serial.println("gfx->begin() failed!");
}
gfx->fillScreen(BLACK);
#ifdef GFX_BL
pinMode(GFX_BL, OUTPUT);
digitalWrite(GFX_BL, HIGH);
pinMode(GFX_BL, OUTPUT);
digitalWrite(GFX_BL, HIGH);
#endif
lv_init();
lv_init();
screenWidth = gfx->width();
screenHeight = gfx->height();
screenWidth = gfx->width();
screenHeight = gfx->height();
#ifdef ESP32
disp_draw_buf = (lv_color_t *)heap_caps_malloc(sizeof(lv_color_t) * screenWidth * 10, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
disp_draw_buf = (lv_color_t *)heap_caps_malloc(sizeof(lv_color_t) * screenWidth * 40, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
#else
disp_draw_buf = (lv_color_t *)malloc(sizeof(lv_color_t) * screenWidth * 10);
disp_draw_buf = (lv_color_t *)malloc(sizeof(lv_color_t) * screenWidth * 40);
#endif
if (!disp_draw_buf)
{
Serial.println("LVGL disp_draw_buf allocate failed!");
}
else
{
lv_disp_draw_buf_init(&draw_buf, disp_draw_buf, NULL, screenWidth * 10);
if (!disp_draw_buf)
{
Serial.println("LVGL disp_draw_buf allocate failed!");
}
else
{
lv_disp_draw_buf_init(&draw_buf, disp_draw_buf, NULL, screenWidth * 40);
/* Initialize the display */
lv_disp_drv_init(&disp_drv);
/* Change the following line to your display resolution */
disp_drv.hor_res = screenWidth;
disp_drv.ver_res = screenHeight;
disp_drv.flush_cb = my_disp_flush;
disp_drv.draw_buf = &draw_buf;
lv_disp_drv_register(&disp_drv);
/* Initialize the display */
lv_disp_drv_init(&disp_drv);
/* Change the following line to your display resolution */
disp_drv.hor_res = screenWidth;
disp_drv.ver_res = screenHeight;
disp_drv.flush_cb = my_disp_flush;
disp_drv.draw_buf = &draw_buf;
lv_disp_drv_register(&disp_drv);
/* Initialize the (dummy) input device driver */
static lv_indev_drv_t indev_drv;
lv_indev_drv_init(&indev_drv);
indev_drv.type = LV_INDEV_TYPE_POINTER;
lv_indev_drv_register(&indev_drv);
/* Initialize the (dummy) input device driver */
static lv_indev_drv_t indev_drv;
lv_indev_drv_init(&indev_drv);
indev_drv.type = LV_INDEV_TYPE_POINTER;
lv_indev_drv_register(&indev_drv);
/* Create simple label */
lv_obj_t *label = lv_label_create(lv_scr_act());
lv_label_set_text(label, "Hello Arduino! (V8.0.X)");
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
/* Create simple label */
lv_obj_t *label = lv_label_create(lv_scr_act());
lv_label_set_text(label, "Hello Arduino! (V" GFX_STR(LVGL_VERSION_MAJOR) "." GFX_STR(LVGL_VERSION_MINOR) "." GFX_STR(LVGL_VERSION_PATCH) ")");
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
Serial.println("Setup done");
}
Serial.println("Setup done");
}
}
void loop()
{
lv_timer_handler(); /* let the GUI do its work */
delay(5);
lv_timer_handler(); /* let the GUI do its work */
#ifdef CANVAS
gfx->flush();
#endif
delay(5);
}

View File

@ -14,15 +14,20 @@
* LVGL Configuration file:
* Copy your_arduino_path/libraries/lvgl/lv_conf_template.h
* to your_arduino_path/libraries/lv_conf.h
*
* In lv_conf.h around line 15, enable config file:
* #if 1 // Set it to "1" to enable content
*
* Then find and set:
* #define LV_COLOR_DEPTH 16
* #define LV_TICK_CUSTOM 1
*
* For SPI display set color swap can be faster, parallel screen don't set!
* #define LV_COLOR_16_SWAP 1
* For SPI/parallel 8 display set color swap can be faster, parallel 16/RGB screen don't swap!
* #define LV_COLOR_16_SWAP 1 // for SPI and parallel 8
* #define LV_COLOR_16_SWAP 0 // for parallel 16 and RGB
*
* Optional: Show CPU usage and FPS count
* #define LV_USE_PERF_MONITOR 1
* Enable LVGL Demo Widgets
* #define LV_USE_DEMO_WIDGETS 1
******************************************************************************/
#include "lv_demo_widgets.h"
@ -35,7 +40,7 @@
* Arduino Nano, Micro and more: CS: 9, DC: 8, RST: 7, BL: 6, SCK: 13, MOSI: 11, MISO: 12
* ESP32 various dev board : CS: 5, DC: 27, RST: 33, BL: 22, SCK: 18, MOSI: 23, MISO: nil
* ESP32-C3 various dev board : CS: 7, DC: 2, RST: 1, BL: 3, SCK: 4, MOSI: 6, MISO: nil
* ESP32-S2 various dev board : CS: 34, DC: 35, RST: 33, BL: 21, SCK: 36, MOSI: 35, MISO: nil
* ESP32-S2 various dev board : CS: 34, DC: 38, RST: 33, BL: 21, SCK: 36, MOSI: 35, MISO: nil
* ESP32-S3 various dev board : CS: 40, DC: 41, RST: 42, BL: 48, SCK: 36, MOSI: 35, MISO: nil
* ESP8266 various dev board : CS: 15, DC: 4, RST: 2, BL: 5, SCK: 14, MOSI: 13, MISO: 12
* Raspberry Pi Pico dev board : CS: 17, DC: 27, RST: 26, BL: 28, SCK: 18, MOSI: 19, MISO: 16
@ -119,14 +124,19 @@ void my_touchpad_read(lv_indev_drv_t *indev_driver, lv_indev_data_t *data)
void setup()
{
Serial.begin(115200);
// while (!Serial);
Serial.println("LVGL Widgets Demo");
// Serial.setDebugOutput(true);
// while(!Serial);
Serial.println("Arduino_GFX LVGL Widgets example");
// Init touch device
touch_init(gfx->width(), gfx->height());
#ifdef GFX_EXTRA_PRE_INIT
GFX_EXTRA_PRE_INIT();
#endif
// Init Display
gfx->begin();
if (!gfx->begin())
{
Serial.println("gfx->begin() failed!");
}
gfx->fillScreen(BLACK);
#ifdef GFX_BL
@ -134,14 +144,17 @@ void setup()
digitalWrite(GFX_BL, HIGH);
#endif
// Init touch device
touch_init(gfx->width(), gfx->height(), gfx->getRotation());
lv_init();
screenWidth = gfx->width();
screenHeight = gfx->height();
#ifdef ESP32
disp_draw_buf = (lv_color_t *)heap_caps_malloc(sizeof(lv_color_t) * screenWidth * 10, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
disp_draw_buf = (lv_color_t *)heap_caps_malloc(sizeof(lv_color_t) * screenWidth * 40, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
#else
disp_draw_buf = (lv_color_t *)malloc(sizeof(lv_color_t) * screenWidth * 10);
disp_draw_buf = (lv_color_t *)malloc(sizeof(lv_color_t) * screenWidth * 40);
#endif
if (!disp_draw_buf)
{
@ -149,7 +162,7 @@ void setup()
}
else
{
lv_disp_draw_buf_init(&draw_buf, disp_draw_buf, NULL, screenWidth * 10);
lv_disp_draw_buf_init(&draw_buf, disp_draw_buf, NULL, screenWidth * 40);
/* Initialize the display */
lv_disp_drv_init(&disp_drv);
@ -176,5 +189,8 @@ void setup()
void loop()
{
lv_timer_handler(); /* let the GUI do its work */
#ifdef CANVAS
gfx->flush();
#endif
delay(5);
}

View File

@ -14,7 +14,6 @@ extern "C" {
* INCLUDES
*********************/
#include <lvgl.h>
#define LV_USE_DEMO_WIDGETS 1
/*********************
* DEFINES

View File

@ -0,0 +1,192 @@
/*******************************************************************************
* Touch libraries:
* XPT2046: https://github.com/PaulStoffregen/XPT2046_Touchscreen.git
*
* Capacitive touchscreen libraries
* TouchLib: https://github.com/mmMicky/TouchLib.git
******************************************************************************/
/* uncomment for XPT2046 */
// #define TOUCH_XPT2046
// #define TOUCH_XPT2046_SCK 12
// #define TOUCH_XPT2046_MISO 13
// #define TOUCH_XPT2046_MOSI 11
// #define TOUCH_XPT2046_CS 10
// #define TOUCH_XPT2046_INT 18
// #define TOUCH_XPT2046_ROTATION 0
// #define TOUCH_XPT2046_SAMPLES 50
// uncomment for most capacitive touchscreen
// #define TOUCH_MODULES_FT5x06 // GT911 / CST_SELF / CST_MUTUAL / ZTW622 / L58 / FT3267 / FT5x06
// #define TOUCH_MODULE_ADDR FT5x06_ADDR // CTS328_SLAVE_ADDRESS / L58_SLAVE_ADDRESS / CTS826_SLAVE_ADDRESS / CTS820_SLAVE_ADDRESS / CTS816S_SLAVE_ADDRESS / FT3267_SLAVE_ADDRESS / FT5x06_ADDR / GT911_SLAVE_ADDRESS1 / GT911_SLAVE_ADDRESS2 / ZTW622_SLAVE1_ADDRESS / ZTW622_SLAVE2_ADDRESS
// #define TOUCH_SCL 5
// #define TOUCH_SDA 6
// #define TOUCH_RES -1
// #define TOUCH_INT -1
// Please fill below values from Arduino_GFX Example - TouchCalibration
bool touch_swap_xy = false;
int16_t touch_map_x1 = -1;
int16_t touch_map_x2 = -1;
int16_t touch_map_y1 = -1;
int16_t touch_map_y2 = -1;
int16_t touch_max_x = 0, touch_max_y = 0;
int16_t touch_raw_x = 0, touch_raw_y = 0;
int16_t touch_last_x = 0, touch_last_y = 0;
#if defined(TOUCH_XPT2046)
#include <XPT2046_Touchscreen.h>
#include <SPI.h>
XPT2046_Touchscreen ts(TOUCH_XPT2046_CS, TOUCH_XPT2046_INT);
#elif defined(TOUCH_MODULE_ADDR) // TouchLib
#include <Wire.h>
#include <TouchLib.h>
TouchLib touch(Wire, TOUCH_SDA, TOUCH_SCL, TOUCH_MODULE_ADDR);
#endif // TouchLib
void touch_init(int16_t w, int16_t h, uint8_t r)
{
touch_max_x = w - 1;
touch_max_y = h - 1;
if (touch_map_x1 == -1)
{
switch (r)
{
case 3:
touch_swap_xy = true;
touch_map_x1 = touch_max_x;
touch_map_x2 = 0;
touch_map_y1 = 0;
touch_map_y2 = touch_max_y;
break;
case 2:
touch_swap_xy = false;
touch_map_x1 = touch_max_x;
touch_map_x2 = 0;
touch_map_y1 = touch_max_y;
touch_map_y2 = 0;
break;
case 1:
touch_swap_xy = true;
touch_map_x1 = 0;
touch_map_x2 = touch_max_x;
touch_map_y1 = touch_max_y;
touch_map_y2 = 0;
break;
default: // case 0:
touch_swap_xy = false;
touch_map_x1 = 0;
touch_map_x2 = touch_max_x;
touch_map_y1 = 0;
touch_map_y2 = touch_max_y;
break;
}
}
#if defined(TOUCH_XPT2046)
SPI.begin(TOUCH_XPT2046_SCK, TOUCH_XPT2046_MISO, TOUCH_XPT2046_MOSI, TOUCH_XPT2046_CS);
ts.begin();
ts.setRotation(TOUCH_XPT2046_ROTATION);
#elif defined(TOUCH_MODULE_ADDR) // TouchLib
// Reset touchscreen
#if (TOUCH_RES > 0)
pinMode(TOUCH_RES, OUTPUT);
digitalWrite(TOUCH_RES, 0);
delay(200);
digitalWrite(TOUCH_RES, 1);
delay(200);
#endif
Wire.begin(TOUCH_SDA, TOUCH_SCL);
touch.init();
#endif // TouchLib
}
bool touch_has_signal()
{
#if defined(TOUCH_XPT2046)
return ts.tirqTouched();
#elif defined(TOUCH_MODULE_ADDR) // TouchLib
// TODO: implement TOUCH_INT
return true;
#endif // TouchLib
return false;
}
void translate_touch_raw()
{
if (touch_swap_xy)
{
touch_last_x = map(touch_raw_y, touch_map_x1, touch_map_x2, 0, touch_max_x);
touch_last_y = map(touch_raw_x, touch_map_y1, touch_map_y2, 0, touch_max_y);
}
else
{
touch_last_x = map(touch_raw_x, touch_map_x1, touch_map_x2, 0, touch_max_x);
touch_last_y = map(touch_raw_y, touch_map_y1, touch_map_y2, 0, touch_max_y);
}
// Serial.printf("touch_raw_x: %d, touch_raw_y: %d, touch_last_x: %d, touch_last_y: %d\n", touch_raw_x, touch_raw_y, touch_last_x, touch_last_y);
}
bool touch_touched()
{
#if defined(TOUCH_XPT2046)
if (ts.touched())
{
TS_Point p = ts.getPoint();
touch_raw_x = p.x;
touch_raw_y = p.y;
int max_z = p.z;
int count = 0;
while ((ts.touched()) && (count < TOUCH_XPT2046_SAMPLES))
{
count++;
TS_Point p = ts.getPoint();
if (p.z > max_z)
{
touch_raw_x = p.x;
touch_raw_y = p.y;
max_z = p.z;
}
// Serial.printf("touch_raw_x: %d, touch_raw_y: %d, p.z: %d\n", touch_raw_x, touch_raw_y, p.z);
}
translate_touch_raw();
return true;
}
#elif defined(TOUCH_MODULE_ADDR) // TouchLib
if (touch.read())
{
TP_Point t = touch.getPoint(0);
touch_raw_x = t.x;
touch_raw_y = t.y;
touch_last_x = touch_raw_x;
touch_last_y = touch_raw_y;
translate_touch_raw();
return true;
}
#endif // TouchLib
return false;
}
bool touch_released()
{
#if defined(TOUCH_XPT2046)
return true;
#elif defined(TOUCH_MODULE_ADDR) // TouchLib
return false;
#endif // TouchLib
return false;
}

View File

@ -0,0 +1,657 @@
/*******************************************************************************
* GIFDEC Wrapper Class
*
* Rewrite from: https://github.com/BasementCat/arduino-tft-gif
******************************************************************************/
#ifndef _GIFCLASS_H_
#define _GIFCLASS_H_
/* Wio Terminal */
#if defined(ARDUINO_ARCH_SAMD) && defined(SEEED_GROVE_UI_WIRELESS)
#include <Seeed_FS.h>
#elif defined(ESP32) || defined(ESP8266)
#include <FS.h>
#else
#include <SD.h>
#endif
#include <sys/types.h>
#ifndef MIN
#define MIN(A, B) ((A) < (B) ? (A) : (B))
#endif
#ifndef MAX
#define MAX(A, B) ((A) > (B) ? (A) : (B))
#endif
#define GIF_BUF_SIZE 1024
typedef struct gd_Palette
{
int16_t len;
uint16_t colors[256];
} gd_Palette;
typedef struct gd_GCE
{
uint16_t delay;
uint8_t tindex;
uint8_t disposal;
uint8_t input;
uint8_t transparency;
} gd_GCE;
typedef struct gd_Entry
{
int32_t len;
uint16_t prefix;
uint8_t suffix;
} gd_Entry;
typedef struct gd_Table
{
int16_t bulk;
int16_t nentries;
gd_Entry *entries;
} gd_Table;
typedef struct gd_GIF
{
File *fd;
off_t anim_start;
uint16_t width, height;
uint16_t depth;
uint16_t loop_count;
gd_GCE gce;
gd_Palette *palette;
gd_Palette lct, gct;
void (*plain_text)(
struct gd_GIF *gif, uint16_t tx, uint16_t ty,
uint16_t tw, uint16_t th, uint8_t cw, uint8_t ch,
uint8_t fg, uint8_t bg);
void (*comment)(struct gd_GIF *gif);
void (*application)(struct gd_GIF *gif, char id[8], char auth[3]);
uint16_t fx, fy, fw, fh;
uint8_t bgindex;
gd_Table *table;
bool processed_first_frame;
} gd_GIF;
class GifClass
{
public:
gd_GIF *gd_open_gif(File *fd)
{
uint8_t sigver[3];
uint16_t width, height, depth;
uint8_t fdsz, bgidx, aspect;
int16_t gct_sz;
gd_GIF *gif;
// init global variables
gif_buf_last_idx = GIF_BUF_SIZE;
gif_buf_idx = gif_buf_last_idx; // no buffer yet
file_pos = 0;
/* Header */
gif_buf_read(fd, sigver, 3);
if (memcmp(sigver, "GIF", 3) != 0)
{
Serial.println(F("invalid signature"));
return NULL;
}
/* Version */
gif_buf_read(fd, sigver, 3);
if (memcmp(sigver, "89a", 3) != 0)
{
Serial.println(F("invalid version"));
return NULL;
}
/* Width x Height */
width = gif_buf_read16(fd);
height = gif_buf_read16(fd);
/* FDSZ */
gif_buf_read(fd, &fdsz, 1);
/* Presence of GCT */
if (!(fdsz & 0x80))
{
Serial.println(F("no global color table"));
return NULL;
}
/* Color Space's Depth */
depth = ((fdsz >> 4) & 7) + 1;
/* Ignore Sort Flag. */
/* GCT Size */
gct_sz = 1 << ((fdsz & 0x07) + 1);
/* Background Color Index */
gif_buf_read(fd, &bgidx, 1);
/* Aspect Ratio */
gif_buf_read(fd, &aspect, 1);
/* Create gd_GIF Structure. */
gif = (gd_GIF *)calloc(1, sizeof(*gif));
gif->fd = fd;
gif->width = width;
gif->height = height;
gif->depth = depth;
/* Read GCT */
read_palette(fd, &gif->gct, gct_sz);
gif->palette = &gif->gct;
gif->bgindex = bgidx;
gif->anim_start = file_pos; // fd->position();
gif->table = new_table();
gif->processed_first_frame = false;
return gif;
}
/* Return 1 if got a frame; 0 if got GIF trailer; -1 if error. */
int32_t gd_get_frame(gd_GIF *gif, uint8_t *frame)
{
char sep;
while (1)
{
gif_buf_read(gif->fd, (uint8_t *)&sep, 1);
if (sep == 0)
{
gif_buf_read(gif->fd, (uint8_t *)&sep, 1);
}
if (sep == ',')
{
break;
}
if (sep == ';')
{
return 0;
}
if (sep == '!')
{
read_ext(gif);
}
else
{
Serial.print(F("Read sep: ["));
Serial.print(sep);
Serial.println(F("].\n"));
return -1;
}
}
// Serial.println("Do read image");
if (read_image(gif, frame) == -1)
return -1;
return 1;
}
void gd_rewind(gd_GIF *gif)
{
#if defined(ESP32) || defined(ESP8266)
gif->fd->seek(gif->anim_start, SeekSet);
#else
gif->fd->seek(gif->anim_start);
#endif
file_pos = gif->anim_start;
gif_buf_idx = gif_buf_last_idx; // reset buffer
}
void gd_close_gif(gd_GIF *gif)
{
gif->fd->close();
free(gif->table);
free(gif);
}
private:
bool gif_buf_seek(File *fd, int16_t len)
{
if (len > (gif_buf_last_idx - gif_buf_idx))
{
#if defined(ESP32) || defined(ESP8266)
// fd->seek(len - (gif_buf_last_idx - gif_buf_idx), SeekCur);
fd->seek(file_pos + len - (gif_buf_last_idx - gif_buf_idx), SeekSet);
#else
fd->seek(file_pos + len - (gif_buf_last_idx - gif_buf_idx));
#endif
gif_buf_idx = gif_buf_last_idx;
}
else
{
gif_buf_idx += len;
}
file_pos += len;
return true;
}
int16_t gif_buf_read(File *fd, uint8_t *dest, int16_t len)
{
while (len--)
{
if (gif_buf_idx == gif_buf_last_idx)
{
gif_buf_last_idx = fd->read(gif_buf, GIF_BUF_SIZE);
gif_buf_idx = 0;
}
file_pos++;
*(dest++) = gif_buf[gif_buf_idx++];
}
return len;
}
uint8_t gif_buf_read(File *fd)
{
if (gif_buf_idx == gif_buf_last_idx)
{
gif_buf_last_idx = fd->read(gif_buf, GIF_BUF_SIZE);
gif_buf_idx = 0;
}
file_pos++;
return gif_buf[gif_buf_idx++];
}
uint16_t gif_buf_read16(File *fd)
{
return gif_buf_read(fd) + (((uint16_t)gif_buf_read(fd)) << 8);
}
void read_palette(File *fd, gd_Palette *dest, int16_t num_colors)
{
uint8_t r, g, b;
dest->len = num_colors;
for (int16_t i = 0; i < num_colors; i++)
{
r = gif_buf_read(fd);
g = gif_buf_read(fd);
b = gif_buf_read(fd);
dest->colors[i] = ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | ((b & 0xF8) >> 3);
}
}
void discard_sub_blocks(gd_GIF *gif)
{
uint8_t len;
do
{
gif_buf_read(gif->fd, &len, 1);
gif_buf_seek(gif->fd, len);
} while (len);
}
void read_plain_text_ext(gd_GIF *gif)
{
if (gif->plain_text)
{
uint16_t tx, ty, tw, th;
uint8_t cw, ch, fg, bg;
gif_buf_seek(gif->fd, 1); /* block size = 12 */
tx = gif_buf_read16(gif->fd);
ty = gif_buf_read16(gif->fd);
tw = gif_buf_read16(gif->fd);
th = gif_buf_read16(gif->fd);
cw = gif_buf_read(gif->fd);
ch = gif_buf_read(gif->fd);
fg = gif_buf_read(gif->fd);
bg = gif_buf_read(gif->fd);
gif->plain_text(gif, tx, ty, tw, th, cw, ch, fg, bg);
}
else
{
/* Discard plain text metadata. */
gif_buf_seek(gif->fd, 13);
}
/* Discard plain text sub-blocks. */
discard_sub_blocks(gif);
}
void read_graphic_control_ext(gd_GIF *gif)
{
uint8_t rdit;
/* Discard block size (always 0x04). */
gif_buf_seek(gif->fd, 1);
gif_buf_read(gif->fd, &rdit, 1);
gif->gce.disposal = (rdit >> 2) & 3;
gif->gce.input = rdit & 2;
gif->gce.transparency = rdit & 1;
gif->gce.delay = gif_buf_read16(gif->fd);
gif_buf_read(gif->fd, &gif->gce.tindex, 1);
/* Skip block terminator. */
gif_buf_seek(gif->fd, 1);
}
void read_comment_ext(gd_GIF *gif)
{
if (gif->comment)
{
gif->comment(gif);
}
/* Discard comment sub-blocks. */
discard_sub_blocks(gif);
}
void read_application_ext(gd_GIF *gif)
{
char app_id[8];
char app_auth_code[3];
/* Discard block size (always 0x0B). */
gif_buf_seek(gif->fd, 1);
/* Application Identifier. */
gif_buf_read(gif->fd, (uint8_t *)app_id, 8);
/* Application Authentication Code. */
gif_buf_read(gif->fd, (uint8_t *)app_auth_code, 3);
if (!strncmp(app_id, "NETSCAPE", sizeof(app_id)))
{
/* Discard block size (0x03) and constant byte (0x01). */
gif_buf_seek(gif->fd, 2);
gif->loop_count = gif_buf_read16(gif->fd);
/* Skip block terminator. */
gif_buf_seek(gif->fd, 1);
}
else if (gif->application)
{
gif->application(gif, app_id, app_auth_code);
discard_sub_blocks(gif);
}
else
{
discard_sub_blocks(gif);
}
}
void read_ext(gd_GIF *gif)
{
uint8_t label;
gif_buf_read(gif->fd, &label, 1);
switch (label)
{
case 0x01:
read_plain_text_ext(gif);
break;
case 0xF9:
read_graphic_control_ext(gif);
break;
case 0xFE:
read_comment_ext(gif);
break;
case 0xFF:
read_application_ext(gif);
break;
default:
Serial.print("unknown extension: ");
Serial.println(label, HEX);
}
}
gd_Table *new_table()
{
// uint16_t key;
// int16_t init_bulk = MAX(1 << (key_size + 1), 0x100);
// Table *table = (Table*) malloc(sizeof(*table) + sizeof(Entry) * init_bulk);
// if (table) {
// table->bulk = init_bulk;
// table->nentries = (1 << key_size) + 2;
// table->entries = (Entry *) &table[1];
// for (key = 0; key < (1 << key_size); key++)
// table->entries[key] = (Entry) {1, 0xFFF, key};
// }
// return table;
int32_t s = sizeof(gd_Table) + (sizeof(gd_Entry) * 4096);
gd_Table *table = (gd_Table *)malloc(s);
if (table)
{
Serial.print(F("new_table() malloc: "));
Serial.println(s);
}
else
{
Serial.print(F("new_table() malloc failed: "));
Serial.println(s);
}
table->entries = (gd_Entry *)&table[1];
return table;
}
void reset_table(gd_Table *table, uint16_t key_size)
{
table->nentries = (1 << key_size) + 2;
for (uint16_t key = 0; key < (1 << key_size); key++)
{
table->entries[key] = (gd_Entry){1, 0xFFF, (uint8_t)key};
}
}
/* Add table entry. Return value:
* 0 on success
* +1 if key size must be incremented after this addition
* -1 if could not realloc table */
int32_t add_entry(gd_Table *table, int32_t len, uint16_t prefix, uint8_t suffix)
{
// Table *table = *tablep;
// if (table->nentries == table->bulk) {
// table->bulk *= 2;
// table = (Table*) realloc(table, sizeof(*table) + sizeof(Entry) * table->bulk);
// if (!table) return -1;
// table->entries = (Entry *) &table[1];
// *tablep = table;
// }
table->entries[table->nentries] = (gd_Entry){len, prefix, suffix};
table->nentries++;
if ((table->nentries & (table->nentries - 1)) == 0)
return 1;
return 0;
}
uint16_t get_key(gd_GIF *gif, uint16_t key_size, uint8_t *sub_len, uint8_t *shift, uint8_t *byte)
{
int16_t bits_read;
int16_t rpad;
int16_t frag_size;
uint16_t key;
key = 0;
for (bits_read = 0; bits_read < key_size; bits_read += frag_size)
{
rpad = (*shift + bits_read) % 8;
if (rpad == 0)
{
/* Update byte. */
if (*sub_len == 0)
gif_buf_read(gif->fd, sub_len, 1); /* Must be nonzero! */
gif_buf_read(gif->fd, byte, 1);
(*sub_len)--;
}
frag_size = MIN(key_size - bits_read, 8 - rpad);
key |= ((uint16_t)((*byte) >> rpad)) << bits_read;
}
/* Clear extra bits to the left. */
key &= (1 << key_size) - 1;
*shift = (*shift + key_size) % 8;
return key;
}
/* Compute output index of y-th input line, in frame of height h. */
int16_t interlaced_line_index(int16_t h, int16_t y)
{
int16_t p; /* number of lines in current pass */
p = (h - 1) / 8 + 1;
if (y < p) /* pass 1 */
return y * 8;
y -= p;
p = (h - 5) / 8 + 1;
if (y < p) /* pass 2 */
return y * 8 + 4;
y -= p;
p = (h - 3) / 4 + 1;
if (y < p) /* pass 3 */
return y * 4 + 2;
y -= p;
/* pass 4 */
return y * 2 + 1;
}
/* Decompress image pixels.
* Return 0 on success or -1 on out-of-memory (w.r.t. LZW code table). */
int8_t read_image_data(gd_GIF *gif, int16_t interlace, uint8_t *frame)
{
uint8_t sub_len, shift, byte, table_is_full = 0;
uint16_t init_key_size, key_size;
int32_t frm_off, str_len = 0, p, x, y;
uint16_t key, clear, stop;
int32_t ret;
gd_Entry entry = {0, 0, 0};
// Serial.println("Read key size");
gif_buf_read(gif->fd, &byte, 1);
key_size = (uint16_t)byte;
// Serial.println("Set pos, discard sub blocks");
// start = gif->fd->position();
// discard_sub_blocks(gif);
// end = gif->fd->position();
// gif_buf_seek(gif->fd, start, SeekSet);
clear = 1 << key_size;
stop = clear + 1;
// Serial.println("New LZW table");
// table = new_table(key_size);
reset_table(gif->table, key_size);
key_size++;
init_key_size = key_size;
sub_len = shift = 0;
// Serial.println("Get init key");
key = get_key(gif, key_size, &sub_len, &shift, &byte); /* clear code */
frm_off = 0;
ret = 0;
while (1)
{
if (key == clear)
{
// Serial.println("Clear key, reset nentries");
key_size = init_key_size;
gif->table->nentries = (1 << (key_size - 1)) + 2;
table_is_full = 0;
}
else if (!table_is_full)
{
// Serial.println("Add entry to table");
ret = add_entry(gif->table, str_len + 1, key, entry.suffix);
// if (ret == -1) {
// // Serial.println("Table entry add failure");
// free(table);
// return -1;
// }
if (gif->table->nentries == 0x1000)
{
// Serial.println("Table is full");
ret = 0;
table_is_full = 1;
}
}
// Serial.println("Get key");
key = get_key(gif, key_size, &sub_len, &shift, &byte);
if (key == clear)
continue;
if (key == stop)
break;
if (ret == 1)
key_size++;
entry = gif->table->entries[key];
str_len = entry.len;
uint8_t tindex = gif->gce.tindex;
// Serial.println("Interpret key");
while (1)
{
p = frm_off + entry.len - 1;
x = p % gif->fw;
y = p / gif->fw;
if (interlace)
{
y = interlaced_line_index((int16_t)gif->fh, y);
}
if ((!gif->processed_first_frame) || (tindex != entry.suffix))
{
frame[(gif->fy + y) * gif->width + gif->fx + x] = entry.suffix;
}
if (entry.prefix == 0xFFF)
break;
else
entry = gif->table->entries[entry.prefix];
}
frm_off += str_len;
if (key < gif->table->nentries - 1 && !table_is_full)
gif->table->entries[gif->table->nentries - 1].suffix = entry.suffix;
}
// Serial.println("Done w/ img data, free table and seek to end");
// free(table);
gif_buf_read(gif->fd, &sub_len, 1); /* Must be zero! */
// gif_buf_seek(gif->fd, end, SeekSet);
gif->processed_first_frame = true;
return 0;
}
/* Read image.
* Return 0 on success or -1 on out-of-memory (w.r.t. LZW code table). */
int8_t read_image(gd_GIF *gif, uint8_t *frame)
{
uint8_t fisrz;
int16_t interlace;
/* Image Descriptor. */
// Serial.println("Read image descriptor");
gif->fx = gif_buf_read16(gif->fd);
gif->fy = gif_buf_read16(gif->fd);
gif->fw = gif_buf_read16(gif->fd);
gif->fh = gif_buf_read16(gif->fd);
// Serial.println("Read fisrz?");
gif_buf_read(gif->fd, &fisrz, 1);
interlace = fisrz & 0x40;
/* Ignore Sort Flag. */
/* Local Color Table? */
if (fisrz & 0x80)
{
/* Read LCT */
// Serial.println("Read LCT");
read_palette(gif->fd, &gif->lct, 1 << ((fisrz & 0x07) + 1));
gif->palette = &gif->lct;
}
else
{
gif->palette = &gif->gct;
}
/* Image Data. */
// Serial.println("Read image data");
return read_image_data(gif, interlace, frame);
}
void render_frame_rect(gd_GIF *gif, uint16_t *buffer, uint8_t *frame)
{
int16_t i, j, k;
uint8_t index;
i = gif->fy * gif->width + gif->fx;
for (j = 0; j < gif->fh; j++)
{
for (k = 0; k < gif->fw; k++)
{
index = frame[(gif->fy + j) * gif->width + gif->fx + k];
// color = &gif->palette->colors[index*2];
if ((!gif->gce.transparency) || (index != gif->gce.tindex))
{
buffer[(i + k)] = gif->palette->colors[index];
}
// memcpy(&buffer[(i+k)*2], color, 2);
}
i += gif->width;
}
}
int16_t gif_buf_last_idx, gif_buf_idx, file_pos;
uint8_t gif_buf[GIF_BUF_SIZE];
};
#endif /* _GIFCLASS_H_ */

View File

@ -1,6 +1,6 @@
/*******************************************************************************
* Animated GIF Image Viewer
* This is a simple Animated GIF image viewer exsample
* Multiple Animated GIF Image Viewer
* This is a simple Multiple Animated GIF image viewer example
* Image Source: https://www.geocities.ws/finalfantasyfive/ff5animations.html
* optimized with ezgif.com
*
@ -45,7 +45,7 @@ Arduino_GFX *gfx4 = new Arduino_ILI9341(bus4, GFX_NOT_DEFINED /* RST */, 0 /* ro
* End of Arduino_GFX setting
******************************************************************************/
#if defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_RASPBERRY_PI_PICO_W)
#if defined(TARGET_RP2040)
#include <LittleFS.h>
#include <SD.h>
#elif defined(ESP32)
@ -69,26 +69,45 @@ static GifClass gifClass4;
void setup()
{
Serial.begin(115200);
// while (!Serial);
Serial.println("Arduino_GFX library Multiple Device Test!");
// Serial.setDebugOutput(true);
// while(!Serial);
Serial.println("Arduino_GFX Multiple Display Animated GIF example!");
gfx1->begin();
#ifdef GFX_EXTRA_PRE_INIT
GFX_EXTRA_PRE_INIT();
#endif
// Init all displays
if (!gfx1->begin())
{
Serial.println("gfx1->begin() failed!");
}
gfx1->fillScreen(RED);
delay(200);
gfx2->begin();
if (!gfx2->begin())
{
Serial.println("gfx2->begin() failed!");
}
gfx2->fillScreen(YELLOW);
delay(200);
gfx3->begin();
if (!gfx3->begin())
{
Serial.println("gfx3->begin() failed!");
}
gfx3->fillScreen(GREEN);
delay(200);
gfx4->begin();
if (!gfx4->begin())
{
Serial.println("gfx4->begin() failed!");
}
gfx4->fillScreen(BLUE);
delay(200);
#if defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_RASPBERRY_PI_PICO_W)
#if defined(TARGET_RP2040)
if (!LittleFS.begin())
// if (!SD.begin(SS))
#elif defined(ESP32)
@ -111,7 +130,7 @@ void setup()
void loop()
{
#if defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_RASPBERRY_PI_PICO_W)
#if defined(TARGET_RP2040)
File gifFile1 = LittleFS.open(GIF_FILENAME1, "r");
File gifFile2 = LittleFS.open(GIF_FILENAME2, "r");
File gifFile3 = LittleFS.open(GIF_FILENAME3, "r");

View File

@ -32,22 +32,41 @@ uint8_t tsa, tsb, tsc, ds;
void setup()
{
Serial.begin(115200);
// while (!Serial);
Serial.println("Arduino_GFX library Multiple Device Test!");
// Serial.setDebugOutput(true);
// while(!Serial);
Serial.println("Arduino_GFX Multiple Display example!");
gfx1->begin();
#ifdef GFX_EXTRA_PRE_INIT
GFX_EXTRA_PRE_INIT();
#endif
// Init all displays
if (!gfx1->begin())
{
Serial.println("gfx1->begin() failed!");
}
gfx1->fillScreen(RED);
delay(200);
gfx2->begin();
if (!gfx2->begin())
{
Serial.println("gfx2->begin() failed!");
}
gfx2->fillScreen(YELLOW);
delay(200);
gfx3->begin();
if (!gfx3->begin())
{
Serial.println("gfx3->begin() failed!");
}
gfx3->fillScreen(GREEN);
delay(200);
gfx4->begin();
if (!gfx4->begin())
{
Serial.println("gfx4->begin() failed!");
}
gfx4->fillScreen(BLUE);
delay(200);
}
@ -356,7 +375,7 @@ int32_t testText()
gfx->println(F("Size 8"));
gfx->setTextSize(9);
gfx->setTextColor(PINK);
gfx->setTextColor(PALERED);
gfx->println(F("Size 9"));
return micros() - start;

View File

@ -0,0 +1,56 @@
/*******************************************************************************
* Adafruit NeoPixel GFX Example
* This is a simple GFX example for Adafruit_NeoPixel
*
* Dependent libraries:
* Adafruit_NeoPixel: https://github.com/adafruit/Adafruit_NeoPixel.git
******************************************************************************/
#include <Arduino_GFX_Library.h>
// all settings in header file
#include "Adafruit_NeoPixel_GFX.h"
Arduino_GFX *gfx = new Adafruit_NeoPixel_GFX();
int16_t x;
uint16_t w, tw;
void setup(void)
{
Serial.begin(115200);
// Serial.setDebugOutput(true);
// while(!Serial);
Serial.println("Arduino_GFX Adafruit_NeoPixel example");
// Init Display
if (!gfx->begin())
{
Serial.println("gfx->begin() failed!");
}
gfx->fillScreen(BLACK);
x = 0;
gfx->setCursor(x, 0);
gfx->setTextColor(RED);
gfx->println("Hello World!");
int16_t x1, y1;
uint16_t h;
gfx->getTextBounds("Hello World!", 0, 0, &x1, &y1, &w, &h);
tw = w;
w = gfx->width();
delay(1000); // 1 seconds
}
void loop()
{
x--;
if (x < (-tw))
{
x = w - 1;
}
gfx->setCursor(x, 0);
gfx->setTextColor(random(0xffff), BLACK);
gfx->println("Hello World!");
delay(100); // 0.1 second
}

View File

@ -0,0 +1,74 @@
#ifndef _ADAFRUIT_NEOPIXEL_GFX_H_
#define _ADAFRUIT_NEOPIXEL_GFX_H_
#include <Adafruit_NeoPixel.h>
#include <Arduino_GFX.h>
#ifdef __AVR__
#include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif
// Which pin on the Arduino is connected to the NeoPixels?
#define NEOPIXEL_PIN 1 // On Trinket or Gemma, suggest changing this to 1
#define NEOPIXEL_WIDTH 30
#define NEOPIXEL_HEIGHT 8
#define NUMPIXELS (NEOPIXEL_WIDTH * NEOPIXEL_HEIGHT)
#define NEOPIXEL_BRIGHTNESS 3 // 1-255
// Pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
#define NEOPIXEL_TYPE (NEO_GRB + NEO_KHZ800)
class Adafruit_NeoPixel_GFX : public Arduino_GFX
{
public:
Adafruit_NeoPixel_GFX() : Arduino_GFX(NEOPIXEL_WIDTH, NEOPIXEL_HEIGHT)
{
wrap = false;
}
bool begin(int32_t speed = GFX_NOT_DEFINED) override
{
// These lines are specifically to support the Adafruit Trinket 5V 16 MHz.
// Any other board, you can remove this part (but no harm leaving it):
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
clock_prescale_set(clock_div_1);
#endif
// END of Trinket-specific code.
_pixels = new Adafruit_NeoPixel(NUMPIXELS, NEOPIXEL_PIN, NEOPIXEL_TYPE);
_pixels->begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
_pixels->show(); // Turn OFF all pixels ASAP
_pixels->setBrightness(NEOPIXEL_BRIGHTNESS);
return true;
}
void writePixelPreclipped(int16_t x, int16_t y, uint16_t color) override
{
// select you matrix mode
int32_t i = (x * NEOPIXEL_HEIGHT) + y; // vertical strip start from left top
// int32_t i = (x * NEOPIXEL_HEIGHT) + ((x % 2) ? y : (NEOPIXEL_HEIGHT - y - 1)); // vertical zigzag strip start from left top
// int32_t i = (x * NEOPIXEL_HEIGHT) + (NEOPIXEL_HEIGHT - y - 1); // vertical strip start from left bottom
// int32_t i = (x * NEOPIXEL_HEIGHT) + ((x % 2) ? (NEOPIXEL_HEIGHT - y - 1) : y); // vertical zigzag strip start from left bottom
// int32_t i = x + (y * NEOPIXEL_WIDTH); // horizontal strip start from left top
// int32_t i = ((y % 2) ? x : (NEOPIXEL_WIDTH - x - 1)) + (y * NEOPIXEL_WIDTH); // horizontal zigzag strip start from left top
// int32_t i = (NEOPIXEL_WIDTH - x - 1) + (y * NEOPIXEL_WIDTH); // horizontal strip start from right top
// int32_t i = ((y % 2) ? (NEOPIXEL_WIDTH - x - 1) : x) + (y * NEOPIXEL_WIDTH); // horizontal zigzag strip start from right top
_pixels->setPixelColor(i, RGB16TO24(color));
}
void endWrite(void) override
{
_pixels->show();
}
Adafruit_NeoPixel *_pixels;
};
#endif // _ADAFRUIT_NEOPIXEL_GFX_H_

View File

@ -0,0 +1,56 @@
/*******************************************************************************
* FastLED GFX Example
* This is a simple GFX example for FastLED
*
* Dependent libraries:
* FastLED: https://github.com/FastLED/FastLED.git
******************************************************************************/
#include <Arduino_GFX_Library.h>
// all settings in header file
#include "FastLED_GFX.h"
Arduino_GFX *gfx = new FastLED_GFX();
int16_t x;
uint16_t w, tw;
void setup(void)
{
Serial.begin(115200);
// Serial.setDebugOutput(true);
// while(!Serial);
Serial.println("Arduino_GFX FastLED example");
// Init Display
if (!gfx->begin())
{
Serial.println("gfx->begin() failed!");
}
gfx->fillScreen(BLACK);
x = 0;
gfx->setCursor(x, 0);
gfx->setTextColor(RED);
gfx->println("Hello World!");
int16_t x1, y1;
uint16_t h;
gfx->getTextBounds("Hello World!", 0, 0, &x1, &y1, &w, &h);
tw = w;
w = gfx->width();
delay(1000); // 1 seconds
}
void loop()
{
x--;
if (x < (-tw))
{
x = w - 1;
}
gfx->setCursor(x, 0);
gfx->setTextColor(random(0xffff), BLACK);
gfx->println("Hello World!");
delay(100); // 0.1 second
}

View File

@ -0,0 +1,57 @@
#ifndef _FASTLED_GFX_H_
#define _FASTLED_GFX_H_
#include <FastLED.h>
#include <Arduino_GFX.h>
// Which pin on the Arduino is connected to the NeoPixels?
#define NEOPIXEL_PIN 1
#define NEOPIXEL_WIDTH 30
#define NEOPIXEL_HEIGHT 8
#define NUMPIXELS (NEOPIXEL_WIDTH * NEOPIXEL_HEIGHT)
#define NEOPIXEL_BRIGHTNESS 3 // 1-255
#define LED_TYPE WS2811
#define COLOR_ORDER GRB
CRGB leds[NUMPIXELS];
class FastLED_GFX : public Arduino_GFX
{
public:
FastLED_GFX() : Arduino_GFX(NEOPIXEL_WIDTH, NEOPIXEL_HEIGHT)
{
wrap = false;
}
bool begin(int32_t speed = GFX_NOT_DEFINED) override
{
FastLED.addLeds<LED_TYPE, NEOPIXEL_PIN, COLOR_ORDER>(leds, NUMPIXELS).setCorrection(TypicalLEDStrip);
FastLED.setBrightness(NEOPIXEL_BRIGHTNESS);
return true;
}
void writePixelPreclipped(int16_t x, int16_t y, uint16_t color) override
{
// select you matrix mode
int32_t i = (x * NEOPIXEL_HEIGHT) + y; // vertical strip start from left top
// int32_t i = (x * NEOPIXEL_HEIGHT) + ((x % 2) ? y : (NEOPIXEL_HEIGHT - y - 1)); // vertical zigzag strip start from left top
// int32_t i = (x * NEOPIXEL_HEIGHT) + (NEOPIXEL_HEIGHT - y - 1); // vertical strip start from left bottom
// int32_t i = (x * NEOPIXEL_HEIGHT) + ((x % 2) ? (NEOPIXEL_HEIGHT - y - 1) : y); // vertical zigzag strip start from left bottom
// int32_t i = x + (y * NEOPIXEL_WIDTH); // horizontal strip start from left top
// int32_t i = ((y % 2) ? x : (NEOPIXEL_WIDTH - x - 1)) + (y * NEOPIXEL_WIDTH); // horizontal zigzag strip start from left top
// int32_t i = (NEOPIXEL_WIDTH - x - 1) + (y * NEOPIXEL_WIDTH); // horizontal strip start from right top
// int32_t i = ((y % 2) ? (NEOPIXEL_WIDTH - x - 1) : x) + (y * NEOPIXEL_WIDTH); // horizontal zigzag strip start from right top
leds[i] = RGB16TO24(color);
}
void endWrite(void) override
{
FastLED.show();
}
};
#endif // _FASTLED_GFX_H_

View File

@ -0,0 +1,86 @@
// General software SPI
// Arduino_DataBus *bus = new Arduino_SWSPI(TFT_DC, TFT_CS, 18 /* SCK */, 23 /* MOSI */, GFX_NOT_DEFINED /* MISO */);
// hardware SPI (default DataBus, comment below block if you are not using hardware SPI)
#if defined(ARDUINO_ARCH_NRF52840)
// Arduino_DataBus *bus = new Arduino_mbedSPI(TFT_DC, TFT_CS);
Arduino_DataBus *bus = new Arduino_NRFXSPI(TFT_DC, TFT_CS, 13 /* SCK */, 11 /* MOSI */, 12 /* MISO */);
#elif defined(TARGET_RP2040)
Arduino_DataBus *bus = new Arduino_RPiPicoSPI(TFT_DC /* DC */, TFT_CS /* CS */, 18 /* SCK */, 19 /* MOSI */, 16 /* MISO */, spi0 /* spi */);
#elif defined(ESP32) && (CONFIG_IDF_TARGET_ESP32)
Arduino_DataBus *bus = new Arduino_ESP32SPI(TFT_DC, TFT_CS, 18 /* SCK */, 23 /* MOSI */, GFX_NOT_DEFINED /* MISO */, VSPI /* spi_num */);
#elif defined(ESP32) && (CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3)
Arduino_DataBus *bus = new Arduino_ESP32SPI(TFT_DC, TFT_CS, 36 /* SCK */, 35 /* MOSI */, GFX_NOT_DEFINED /* MISO */, HSPI /* spi_num */);
#elif defined(ESP32) && (CONFIG_IDF_TARGET_ESP32C3)
Arduino_DataBus *bus = new Arduino_ESP32SPI(TFT_DC, TFT_CS, 4 /* SCK */, 6 /* MOSI */, GFX_NOT_DEFINED /* MISO */, FSPI /* spi_num */);
#elif defined(ESP8266)
Arduino_DataBus *bus = new Arduino_ESP8266SPI(TFT_DC, TFT_CS);
#else
// General hardware SPI
Arduino_DataBus *bus = new Arduino_HWSPI(TFT_DC, TFT_CS);
#endif
// General Software parallel 8-bit
// Arduino_DataBus *bus = new Arduino_SWPAR8(A2 /* DC */, A3 /* CS */, A1 /* WR */, A0 /* RD */, 8 /* D0 */, 9 /* D1 */, 2 /* D2 */, 3 /* D3 */, 4 /* D4 */, 5 /* D5 */, 6 /* D6 */, 7 /* D7 */);
// General Software parallel 16-bit
// Arduino_DataBus *bus = new Arduino_SWPAR16(32 /* DC */, GFX_NOT_DEFINED /* CS */, 21 /* WR */, GFX_NOT_DEFINED /* RD */, 19 /* D0 */, 23 /* D1 */, 18 /* D2 */, 5 /* D3 */, 17 /* D4 */, 16 /* D5 */, 25 /* D6 */, 26 /* D7 */, 27 /* D8 */, 14 /* D9 */, 12 /* D10 */, 13 /* D11 */, 15 /* D12 */, 2 /* D13 */, 0 /* D14 */, 4 /* D15 */);
// Arduino UNO / UNO R4 MINIMA / UNO R4 WIFI parallel 8-bit
// Arduino_DataBus *bus = new Arduino_UNOPAR8();
// AVR PORT parallel 8-bit
// Arduino Pro Micro port 2(PB): 17, 15, 16, 14, 8, 9, 10, 11
// Arduino_DataBus *bus = new Arduino_AVRPAR8(4 /* DC */, 5 /* CS */, 18 /* WR */, 19 /* RD */, 2 /* PORT */);
// AVR PORT parallel 16-bit
// Arduino MEGA 2560
// port 3(PC): 37, 36, 35, 34, 33, 32, 31, 30
// port 1(PA): 22, 23, 24, 25, 26, 27, 28, 29
// Arduino_DataBus *bus = new Arduino_AVRPAR16(38 /* DC */, 40 /* CS */, 39 /* WR */, 43 /* RD */, 3 /* PORT LOW */, 1 /* PORT HIGH */);
// ESP32 parallel 8-bit
// Arduino_DataBus *bus = new Arduino_ESP32PAR8(TFT_DC, TFT_CS, 25 /* WR */, 32 /* RD */, 23 /* D0 */, 19 /* D1 */, 18 /* D2 */, 26 /* D3 */, 21 /* D4 */, 4 /* D5 */, 0 /* D6 */, 2 /* D7 */);
// ESP32 parallel 16-bit
// Almost all GPIO 0-31 used up for 16-bit and WR, disable PSRAM to gain 16 and 17 but still no GPIOs remain for CS and RD.
// CS connect to GND (enable); RD connect to Vcc (disable).
// Arduino_DataBus *bus = new Arduino_ESP32PAR16(
// 32 /* DC */, GFX_NOT_DEFINED /* CS */, 21 /* WR */, GFX_NOT_DEFINED /* RD */,
// 19 /* D0 */, 23 /* D1 */, 18 /* D2 */, 5 /* D3 */, 17 /* D4 */, 16 /* D5 */, 25 /* D6 */, 26 /* D7 */,
// 27 /* D8 */, 14 /* D9 */, 12 /* D10 */, 13 /* D11 */, 15 /* D12 */, 2 /* D13 */, 0 /* D14 */, 4 /* D15 */);
// ESP32 QSPI
// Arduino_DataBus *bus = new Arduino_ESP32QSPI(
// 10 /* CS */, 5 /* SCK */, 14 /* D0 */, 8 /* D1 */, 0 /* D2 */, 1 /* D3 */);
// ESP32S2 parallel 8-bit
// Display D0-D7 connect to GPIO 0-7
// Arduino_DataBus *bus = new Arduino_ESP32S2PAR8(TFT_DC, TFT_CS, 16 /* WR */, 17 /* RD */);
// ESP32S2 parallel 16-bit
// Display D0-D15 connect to GPIO 0-15
// Arduino_DataBus *bus = new Arduino_ESP32S2PAR16(TFT_DC, TFT_CS, 16 /* WR */, 17 /* RD */);
// ESP32S3 i80 LCD parallel 8-bit
// Arduino_DataBus *bus = new Arduino_ESP32LCD8(
// TFT_DC, TFT_CS, 16 /* WR */, 17 /* RD */,
// 0 /* D0 */, 1 /* D1 */, 2 /* D2 */, 3 /* D3 */, 4 /* D4 */, 5 /* D5 */, 6 /* D6 */, 7 /* D7 */);
// ESP32S3 i80 LCD parallel 16-bit
// Arduino_DataBus *bus = new Arduino_ESP32LCD16(
// TFT_DC, TFT_CS, 16 /* WR */, 17 /* RD */,
// 0 /* D0 */, 1 /* D1 */, 2 /* D2 */, 3 /* D3 */, 4 /* D4 */, 5 /* D5 */, 6 /* D6 */, 7 /* D7 */,
// 8 /* D8 */, 9 /* D9 */, 10 /* D10 */, 11 /* D11 */, 12 /* D12 */, 13 /* D13 */, 14 /* D14 */, 15 /* D15 */);
// Raspberry Pi Pico parallel 8-bit
// Display D0-D7 connect to GPIO 0-7
// Arduino_DataBus *bus = new Arduino_RPiPicoPAR8(TFT_DC, TFT_CS, 18 /* WR */, 19 /* RD */);
// Raspberry Pi Pico parallel 16-bit
// Display D0-D15 connect to GPIO 0-15
// Arduino_DataBus *bus = new Arduino_RPiPicoPAR16(TFT_DC, TFT_CS, 18 /* WR */, 19 /* RD */);
// RTL8722 parallel 8-bit
// Reduce GPIO usage: CS connect to GND (enable); RD connect to Vcc (disable); No Backlight pins.
// Arduino_DataBus *bus = new Arduino_RTLPAR8(0 /* DC */, GFX_NOT_DEFINED /* CS */, 1 /* WR */, GFX_NOT_DEFINED /* RD */, 18 /* D0 */, 22 /* D1 */, 17 /* D2 */, 20 /* D3 */, 19 /* D4 */, 23 /* D5 */, 21 /* D6 */, 16 /* D7 */);

View File

@ -0,0 +1,606 @@
// #define DLC35010R // or called "Elecrow ESP Terminal with 3.5inch Parallel RGB Capacitive Touch Display (ILI9488)"
// #define DRAGON_RADAR
// #define ESP32_1732S019
// #define ESP32_2424012
// #define ESP32_2432S028
// #define ESP32_3248S035
// #define ESP32_4827A043
// #define ESP32_4827S043
// #define ESP32_8048S043
// #define ESP32_8048S070
// #define ESP32_LCDKIT_SPI
// #define ESP32_LCDKIT_PAR8A
// #define ESP32_LCDKIT_PAR8B
// #define ESP32_LCDKIT_PAR16
// #define ESP32_S3_BOX_3
// #define ESP32_S3_EYE
// #define ESP32_S3_RGB
// #define ESP32_S3_RPI_DPI
// #define ESP32S3_2_1_TP
// #define LILYGO_T_DECK
// #define LILYGO_T_DISPLAY
// #define LILYGO_T_DISPLAY_S3
// #define LILYGO_T_Display_S3_AMOLED
// #define LILYGO_T_DISPLAY_S3_PRO
// #define LILYGO_T_QT
// #define LILYGO_T_RGB
// #define LILYGO_T_TRACK
// #define LILYGO_T_WATCH_2021
// #define MAKERFABS_TFT_TOUCH_3_5
// #define MAKERFABS_ESP32_S3_TFT_4_0
// #define MAKERFABS_ESP32_S3_TFT_4_3_v1_3
// #define WT32_SC01
// #define XIAO_SAMD21_ROUND_DISPLAY
// #define XIAO_ESP32C3_ROUND_DISPLAY
// #define XIAO_ESP32S3_ROUND_DISPLAY
// #define WZ8048C050 // or called "Elecrow Wizee-ESP32"
// #define ZX2D10GE10R_V4848
// #define ZX3D50CE02S // or called "WT32-SC01 PLUS"
// #define ZX3D95CE01S_AR
// #define ZX3D95CE01S_TR
// #define ZX7D00CE01S // or called "QM Smart Panlee 7.0 inch serial screen"
#if defined(DLC35010R)
#define GFX_DEV_DEVICE DLC35010R
#define GFX_BL 46
Arduino_DataBus *bus = new Arduino_ESP32PAR16(
45 /* DC */, GFX_NOT_DEFINED /* CS */, 18 /* WR */, 48 /* RD */,
47 /* D0 */, 21 /* D1 */, 14 /* D2 */, 13 /* D3 */, 12 /* D4 */, 11 /* D5 */, 10 /* D6 */, 9 /* D7 */,
3 /* D8 */, 8 /* D9 */, 16 /* D10 */, 15 /* D11 */, 7 /* D12 */, 6 /* D13 */, 5 /* D14 */, 4 /* D15 */);
Arduino_GFX *gfx = new Arduino_ILI9488(bus, GFX_NOT_DEFINED /* RST */, 0 /* rotation */, false /* IPS */);
#elif defined(DRAGON_RADAR)
#define GFX_DEV_DEVICE DRAGON_RADAR
#define GFX_BL 38
Arduino_DataBus *bus = new Arduino_SWSPI(
GFX_NOT_DEFINED /* DC */, 39 /* CS */,
48 /* SCK */, 47 /* MOSI */, GFX_NOT_DEFINED /* MISO */);
Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel(
18 /* DE */, 17 /* VSYNC */, 16 /* HSYNC */, 21 /* PCLK */,
11 /* R0 */, 12 /* R1 */, 13 /* R2 */, 45 /* R3 */, 0 /* R4 */,
8 /* G0 */, 19 /* G1 */, 20 /* G2 */, 46 /* G3 */, 9 /* G4 */, 10 /* G5 */,
4 /* B0 */, 5 /* B1 */, 6 /* B2 */, 7 /* B3 */, 15 /* B4 */,
1 /* hsync_polarity */, 50 /* hsync_front_porch */, 1 /* hsync_pulse_width */, 30 /* hsync_back_porch */,
1 /* vsync_polarity */, 20 /* vsync_front_porch */, 1 /* vsync_pulse_width */, 30 /* vsync_back_porch */);
Arduino_RGB_Display *gfx = new Arduino_RGB_Display(
480 /* width */, 480 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */,
bus, GFX_NOT_DEFINED /* RST */, st7701_type6_init_operations, sizeof(st7701_type6_init_operations));
#elif defined(ESP32_1732S019)
#define GFX_DEV_DEVICE ESP32_1732S019
#define GFX_BL 14
Arduino_DataBus *bus = new Arduino_ESP32SPI(11 /* DC */, 10 /* CS */, 12 /* SCK */, 13 /* MOSI */, GFX_NOT_DEFINED /* MISO */);
Arduino_GFX *gfx = new Arduino_ST7789(bus, 1 /* RST */, 0 /* rotation */, true /* IPS */, 170 /* width */, 320 /* height */, 35 /* col offset 1 */, 0 /* row offset 1 */, 35 /* col offset 2 */, 0 /* row offset 2 */);
#elif defined(ESP32_2424012)
#define GFX_DEV_DEVICE ESP32_2424012
#define GFX_BL 8
Arduino_DataBus *bus = new Arduino_ESP32SPI(2 /* DC */, 10 /* CS */, 6 /* SCK */, 7 /* MOSI */, GFX_NOT_DEFINED /* MISO */);
Arduino_GFX *gfx = new Arduino_GC9A01(bus, GFX_NOT_DEFINED /* RST */, 0 /* rotation */, true /* IPS */);
#elif defined(ESP32_2432S028)
#define GFX_DEV_DEVICE ESP32_2432S028
#define GFX_BL 21
Arduino_DataBus *bus = new Arduino_ESP32SPI(2 /* DC */, 15 /* CS */, 14 /* SCK */, 13 /* MOSI */, 12 /* MISO */);
Arduino_GFX *gfx = new Arduino_ILI9341(bus, GFX_NOT_DEFINED /* RST */, 0 /* rotation */);
#elif defined(ESP32_3248S035)
#define GFX_DEV_DEVICE ESP32_3248S035
#define GFX_BL 27
Arduino_DataBus *bus = new Arduino_ESP32SPI(2 /* DC */, 15 /* CS */, 14 /* SCK */, 13 /* MOSI */, 12 /* MISO */, VSPI /* spi_num */);
Arduino_GFX *gfx = new Arduino_ST7796(bus, GFX_NOT_DEFINED /* RST */, 0 /* rotation */);
#elif defined(ESP32_4827A043)
#define GFX_DEV_DEVICE ESP32_4827A043
#define GFX_BL 2
Arduino_DataBus *bus = new Arduino_ESP32LCD16(
48 /* DC */, 45 /* CS */, 47 /* WR */, 21 /* RD */,
5 /* D0 */, 6 /* D1 */, 7 /* D2 */, 15 /* D3 */, 16 /* D4 */, 4 /* D5 */, 8 /* D6 */, 3 /* D7 */,
46 /* D8 */, 9 /* D9 */, 1 /* D10 */, 42 /* D11 */, 39 /* D12 */, 41 /* D13 */, 40 /* D14 */, 14 /* D15 */);
Arduino_GFX *gfx = new Arduino_NV3041A(bus, 17 /* RST */, 0 /* rotation */, true /* IPS */);
#elif defined(ESP32_4827S043)
#define GFX_DEV_DEVICE ESP32_4827S043
#define GFX_BL 2
// option 1:
// Uncomment for ILI6485 LCD 480x272
Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel(
40 /* DE */, 41 /* VSYNC */, 39 /* HSYNC */, 42 /* PCLK */,
45 /* R0 */, 48 /* R1 */, 47 /* R2 */, 21 /* R3 */, 14 /* R4 */,
5 /* G0 */, 6 /* G1 */, 7 /* G2 */, 15 /* G3 */, 16 /* G4 */, 4 /* G5 */,
8 /* B0 */, 3 /* B1 */, 46 /* B2 */, 9 /* B3 */, 1 /* B4 */,
0 /* hsync_polarity */, 1 /* hsync_front_porch */, 1 /* hsync_pulse_width */, 43 /* hsync_back_porch */,
0 /* vsync_polarity */, 3 /* vsync_front_porch */, 1 /* vsync_pulse_width */, 12 /* vsync_back_porch */,
1 /* pclk_active_neg */, 10000000 /* prefer_speed */);
Arduino_RGB_Display *gfx = new Arduino_RGB_Display(
480 /* width */, 272 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */);
// option 2:
// Uncomment for ST7262 IPS LCD 800x480
// Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel(
// 40 /* DE */, 41 /* VSYNC */, 39 /* HSYNC */, 42 /* PCLK */,
// 45 /* R0 */, 48 /* R1 */, 47 /* R2 */, 21 /* R3 */, 14 /* R4 */,
// 5 /* G0 */, 6 /* G1 */, 7 /* G2 */, 15 /* G3 */, 16 /* G4 */, 4 /* G5 */,
// 8 /* B0 */, 3 /* B1 */, 46 /* B2 */, 9 /* B3 */, 1 /* B4 */,
// 0 /* hsync_polarity */, 8 /* hsync_front_porch */, 4 /* hsync_pulse_width */, 8 /* hsync_back_porch */,
// 0 /* vsync_polarity */, 8 /* vsync_front_porch */, 4 /* vsync_pulse_width */, 8 /* vsync_back_porch */,
// 1 /* pclk_active_neg */, 16000000 /* prefer_speed */);
// Arduino_RGB_Display *gfx = new Arduino_RGB_Display(
// 800 /* width */, 480 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */);
// option 3:
// Uncomment for RPi DPI 1024x600
// Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel(
// 40 /* DE */, 41 /* VSYNC */, 39 /* HSYNC */, 42 /* PCLK */,
// 45 /* R0 */, 48 /* R1 */, 47 /* R2 */, 21 /* R3 */, 14 /* R4 */,
// 5 /* G0 */, 6 /* G1 */, 7 /* G2 */, 15 /* G3 */, 16 /* G4 */, 4 /* G5 */,
// 8 /* B0 */, 3 /* B1 */, 46 /* B2 */, 9 /* B3 */, 1 /* B4 */,
// 0 /* hsync_polarity */, 8 /* hsync_front_porch */, 4 /* hsync_pulse_width */, 43 /* hsync_back_porch */,
// 0 /* vsync_polarity */, 8 /* vsync_front_porch */, 4 /* vsync_pulse_width */, 12 /* vsync_back_porch */,
// 1 /* pclk_active_neg */, 9000000 /* prefer_speed */);
// Arduino_RGB_Display *gfx = new Arduino_RGB_Display(
// 1024 /* width */, 600 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */);
#elif defined(ESP32_8048S043)
#define GFX_DEV_DEVICE ESP32_8048S043
#define GFX_BL 2
Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel(
40 /* DE */, 41 /* VSYNC */, 39 /* HSYNC */, 42 /* PCLK */,
45 /* R0 */, 48 /* R1 */, 47 /* R2 */, 21 /* R3 */, 14 /* R4 */,
5 /* G0 */, 6 /* G1 */, 7 /* G2 */, 15 /* G3 */, 16 /* G4 */, 4 /* G5 */,
8 /* B0 */, 3 /* B1 */, 46 /* B2 */, 9 /* B3 */, 1 /* B4 */,
0 /* hsync_polarity */, 8 /* hsync_front_porch */, 4 /* hsync_pulse_width */, 8 /* hsync_back_porch */,
0 /* vsync_polarity */, 8 /* vsync_front_porch */, 4 /* vsync_pulse_width */, 8 /* vsync_back_porch */,
1 /* pclk_active_neg */, 16000000 /* prefer_speed */);
Arduino_RGB_Display *gfx = new Arduino_RGB_Display(
800 /* width */, 480 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */);
#elif defined(ESP32_8048S070)
#define GFX_DEV_DEVICE ESP32_8048S070
#define GFX_BL 2
Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel(
41 /* DE */, 40 /* VSYNC */, 39 /* HSYNC */, 42 /* PCLK */,
14 /* R0 */, 21 /* R1 */, 47 /* R2 */, 48 /* R3 */, 45 /* R4 */,
9 /* G0 */, 46 /* G1 */, 3 /* G2 */, 8 /* G3 */, 16 /* G4 */, 1 /* G5 */,
15 /* B0 */, 7 /* B1 */, 6 /* B2 */, 5 /* B3 */, 4 /* B4 */,
0 /* hsync_polarity */, 180 /* hsync_front_porch */, 30 /* hsync_pulse_width */, 16 /* hsync_back_porch */,
0 /* vsync_polarity */, 12 /* vsync_front_porch */, 13 /* vsync_pulse_width */, 10 /* vsync_back_porch */);
Arduino_RGB_Display *gfx = new Arduino_RGB_Display(
800 /* width */, 480 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */);
#elif defined(ESP32_LCDKIT_SPI)
#define GFX_DEV_DEVICE ESP32_LCDKIT_SPI
#define GFX_BL 23
Arduino_DataBus *bus = new Arduino_ESP32SPI(19 /* DC */, 5 /* CS */, 22 /* SCK */, 21 /* MOSI */, 27 /* MISO */);
Arduino_GFX *gfx = new Arduino_ILI9341(bus, 18 /* RST */, 1 /* rotation */);
#elif defined(ESP32_LCDKIT_PAR8A)
#define GFX_DEV_DEVICE ESP32_LCDKIT_PAR8A
Arduino_DataBus *bus = new Arduino_ESP32PAR8(5 /* DC */, GFX_NOT_DEFINED /* CS */, 18 /* WR */, GFX_NOT_DEFINED /* RD */, 19 /* D0 */, 21 /* D1 */, 0 /* D2 */, 22 /* D3 */, 23 /* D4 */, 33 /* D5 */, 32 /* D6 */, 27 /* D7 */);
Arduino_GFX *gfx = new Arduino_ILI9341(bus, GFX_NOT_DEFINED /* RST */, 1 /* rotation */);
#elif defined(ESP32_LCDKIT_PAR8B)
#define GFX_DEV_DEVICE ESP32_LCDKIT_PAR8B
Arduino_DataBus *bus = new Arduino_ESP32PAR8(5 /* DC */, GFX_NOT_DEFINED /* CS */, 18 /* WR */, GFX_NOT_DEFINED /* RD */, 25 /* D0 */, 26 /* D1 */, 12 /* D2 */, 13 /* D3 */, 14 /* D4 */, 15 /* D5 */, 2 /* D6 */, 4 /* D7 */);
Arduino_GFX *gfx = new Arduino_ILI9341(bus, GFX_NOT_DEFINED /* RST */, 1 /* rotation */);
#elif defined(ESP32_LCDKIT_PAR16)
#define GFX_DEV_DEVICE ESP32_LCDKIT_PAR16
Arduino_DataBus *bus = new Arduino_ESP32PAR16(
5 /* DC */, GFX_NOT_DEFINED /* CS */, 18 /* WR */, GFX_NOT_DEFINED /* RD */,
19 /* D0 */, 21 /* D1 */, 0 /* D2 */, 22 /* D3 */, 23 /* D4 */, 33 /* D5 */, 32 /* D6 */, 27 /* D7 */,
25 /* D8 */, 26 /* D9 */, 12 /* D10 */, 13 /* D11 */, 14 /* D12 */, 15 /* D13 */, 2 /* D14 */, 4 /* D15 */);
Arduino_GFX *gfx = new Arduino_ILI9341(bus, GFX_NOT_DEFINED /* RST */, 1 /* rotation */);
#elif defined(ESP32_S3_BOX_3)
#define GFX_DEV_DEVICE ARDUINO_ESP32_S3_BOX_3
#define GFX_BL 47
Arduino_DataBus *bus = new Arduino_ESP32SPI(4 /* DC */, 5 /* CS */, 7 /* SCK */, 6 /* MOSI */, GFX_NOT_DEFINED /* MISO */);
Arduino_GFX *gfx = new Arduino_ILI9342(bus, GFX_NOT_DEFINED /* RST */, 0 /* rotation */);
#elif defined(ESP32_S3_EYE)
#define GFX_DEV_DEVICE ESP32_S3_EYE
#define GFX_EXTRA_PRE_INIT() \
{ \
pinMode(3 /* camera indicator */, OUTPUT); \
digitalWrite(3 /* camera indicator */, LOW); \
pinMode(48 /* BACKLIGHT */, OUTPUT); \
digitalWrite(48 /* BACKLIGHT */, LOW); \
}
Arduino_DataBus *bus = new Arduino_ESP32SPI(43 /* DC */, 44 /* CS */, 21 /* SCK */, 47 /* MOSI */, GFX_NOT_DEFINED /* MISO */);
Arduino_GFX *gfx = new Arduino_ST7789(bus, GFX_NOT_DEFINED /* RST */, 0 /* rotation */, true /* IPS */, 240 /* width */, 240 /* height */, 0 /* col offset 1 */, 0 /* row offset 1 */, 0 /* col offset 2 */, 80 /* row offset 2 */);
#elif defined(ESP32_S3_RGB)
#define GFX_DEV_DEVICE ESP32_S3_RGB
#define GFX_BL 38
Arduino_DataBus *bus = new Arduino_SWSPI(
GFX_NOT_DEFINED /* DC */, 39 /* CS */,
48 /* SCK */, 47 /* MOSI */, GFX_NOT_DEFINED /* MISO */);
// option 1:
// Uncomment for 4" rect display
Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel(
18 /* DE */, 17 /* VSYNC */, 16 /* HSYNC */, 21 /* PCLK */,
4 /* R0 */, 3 /* R1 */, 2 /* R2 */, 1 /* R3 */, 0 /* R4 */,
10 /* G0 */, 9 /* G1 */, 8 /* G2 */, 7 /* G3 */, 6 /* G4 */, 5 /* G5 */,
15 /* B0 */, 14 /* B1 */, 13 /* B2 */, 12 /* B3 */, 11 /* B4 */,
1 /* hsync_polarity */, 10 /* hsync_front_porch */, 8 /* hsync_pulse_width */, 50 /* hsync_back_porch */,
1 /* vsync_polarity */, 10 /* vsync_front_porch */, 8 /* vsync_pulse_width */, 20 /* vsync_back_porch */);
Arduino_RGB_Display *gfx = new Arduino_RGB_Display(
480 /* width */, 480 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */,
bus, GFX_NOT_DEFINED /* RST */, st7701_type1_init_operations, sizeof(st7701_type1_init_operations));
// option 2:
// Uncomment for 2.1" round display
// Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel(
// 18 /* DE */, 17 /* VSYNC */, 16 /* HSYNC */, 21 /* PCLK */,
// 4 /* R0 */, 3 /* R1 */, 2 /* R2 */, 1 /* R3 */, 0 /* R4 */,
// 10 /* G0 */, 9 /* G1 */, 8 /* G2 */, 7 /* G3 */, 6 /* G4 */, 5 /* G5 */,
// 15 /* B0 */, 14 /* B1 */, 13 /* B2 */, 12 /* B3 */, 11 /* B4 */,
// 1 /* hsync_polarity */, 10 /* hsync_front_porch */, 8 /* hsync_pulse_width */, 50 /* hsync_back_porch */,
// 1 /* vsync_polarity */, 10 /* vsync_front_porch */, 8 /* vsync_pulse_width */, 20 /* vsync_back_porch */);
// Arduino_RGB_Display *gfx = new Arduino_RGB_Display(
// 480 /* width */, 480 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */,
// bus, GFX_NOT_DEFINED /* RST */, st7701_type5_init_operations, sizeof(st7701_type5_init_operations));
// option 3:
// Uncomment for 2.8" round display
// Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel(
// 18 /* DE */, 17 /* VSYNC */, 16 /* HSYNC */, 21 /* PCLK */,
// 4 /* R0 */, 3 /* R1 */, 2 /* R2 */, 1 /* R3 */, 0 /* R4 */,
// 10 /* G0 */, 9 /* G1 */, 8 /* G2 */, 7 /* G3 */, 6 /* G4 */, 5 /* G5 */,
// 15 /* B0 */, 14 /* B1 */, 13 /* B2 */, 12 /* B3 */, 11 /* B4 */,
// 1 /* hsync_polarity */, 50 /* hsync_front_porch */, 1 /* hsync_pulse_width */, 30 /* hsync_back_porch */,
// 1 /* vsync_polarity */, 20 /* vsync_front_porch */, 1 /* vsync_pulse_width */, 30 /* vsync_back_porch */);
// Arduino_RGB_Display *gfx = new Arduino_RGB_Display(
// 480 /* width */, 480 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */,
// bus, GFX_NOT_DEFINED /* RST */, st7701_type6_init_operations, sizeof(st7701_type6_init_operations));
// option 4:
// Uncomment for 2.0" display
// Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel(
// 18 /* DE */, 17 /* VSYNC */, 16 /* HSYNC */, 21 /* PCLK */,
// 4 /* R0 */, 3 /* R1 */, 2 /* R2 */, 1 /* R3 */, 0 /* R4 */,
// 10 /* G0 */, 9 /* G1 */, 8 /* G2 */, 7 /* G3 */, 6 /* G4 */, 5 /* G5 */,
// 15 /* B0 */, 14 /* B1 */, 13 /* B2 */, 12 /* B3 */, 11 /* B4 */,
// 1 /* hsync_polarity */, 10 /* hsync_front_porch */, 8 /* hsync_pulse_width */, 50 /* hsync_back_porch */,
// 1 /* vsync_polarity */, 10 /* vsync_front_porch */, 8 /* vsync_pulse_width */, 20 /* vsync_back_porch */);
// Arduino_RGB_Display *gfx = new Arduino_RGB_Display(
// 480 /* width */, 360 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */,
// bus, GFX_NOT_DEFINED /* RST */, st7701_type8_init_operations, sizeof(st7701_type8_init_operations));
// option 5:
// Uncomment for 3.5" display
// Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel(
// 18 /* DE */, 17 /* VSYNC */, 16 /* HSYNC */, 21 /* PCLK */,
// 4 /* R0 */, 3 /* R1 */, 2 /* R2 */, 1 /* R3 */, 0 /* R4 */,
// 10 /* G0 */, 9 /* G1 */, 8 /* G2 */, 7 /* G3 */, 6 /* G4 */, 5 /* G5 */,
// 15 /* B0 */, 14 /* B1 */, 13 /* B2 */, 12 /* B3 */, 11 /* B4 */,
// 1 /* hsync_polarity */, 20 /* hsync_front_porch */, 30 /* hsync_pulse_width */, 38 /* hsync_back_porch */,
// 1 /* vsync_polarity */, 4 /* vsync_front_porch */, 3 /* vsync_pulse_width */, 15 /* vsync_back_porch */,
// 10, 16000000);
// Arduino_RGB_Display *gfx = new Arduino_RGB_Display(
// 640 /* width */, 480 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */,
// bus, GFX_NOT_DEFINED /* RST */, st7701_type1_init_operations, sizeof(st7701_type1_init_operations));
#elif defined(ESP32_S3_RPI_DPI)
#define GFX_DEV_DEVICE ESP32_S3_RPI_DPI
// #define GFX_BL 38
// e.g. Waveshare 7" RPi DPI LCD: https://www.waveshare.com/wiki/7inch_LCD_for_Pi
// dpi_timings=1024 1 40 48 128 600 1 13 3 45 0 0 0 60 0 37000000 6
Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel(
18 /* DE */, 17 /* VSYNC */, 16 /* HSYNC */, 21 /* PCLK */,
4 /* R0 */, 3 /* R1 */, 2 /* R2 */, 1 /* R3 */, 0 /* R4 */,
10 /* G0 */, 9 /* G1 */, 8 /* G2 */, 7 /* G3 */, 6 /* G4 */, 5 /* G5 */,
15 /* B0 */, 14 /* B1 */, 13 /* B2 */, 12 /* B3 */, 11 /* B4 */,
1 /* hsync_polarity */, 40 /* hsync_front_porch */, 48 /* hsync_pulse_width */, 128 /* hsync_back_porch */,
1 /* vsync_polarity */, 13 /* vsync_front_porch */, 3 /* vsync_pulse_width */, 45 /* vsync_back_porch */);
Arduino_RGB_Display *gfx = new Arduino_RGB_Display(
1024 /* width */, 600 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */);
#elif defined(ESP32S3_2_1_TP)
#define GFX_DEV_DEVICE ESP32S3_2_1_TP
#define GFX_BL 38
Arduino_DataBus *bus = new Arduino_SWSPI(
GFX_NOT_DEFINED /* DC */, 39 /* CS */,
48 /* SCK */, 47 /* MOSI */, GFX_NOT_DEFINED /* MISO */);
Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel(
18 /* DE */, 17 /* VSYNC */, 16 /* HSYNC */, 21 /* PCLK */,
4 /* R0 */, 5 /* R1 */, 6 /* R2 */, 7 /* R3 */, 15 /* R4 */,
8 /* G0 */, 20 /* G1 */, 3 /* G2 */, 46 /* G3 */, 9 /* G4 */, 10 /* G5 */,
11 /* B0 */, 12 /* B1 */, 13 /* B2 */, 14 /* B3 */, 0 /* B4 */,
1 /* hsync_polarity */, 10 /* hsync_front_porch */, 8 /* hsync_pulse_width */, 50 /* hsync_back_porch */,
1 /* vsync_polarity */, 10 /* vsync_front_porch */, 8 /* vsync_pulse_width */, 20 /* vsync_back_porch */);
Arduino_RGB_Display *gfx = new Arduino_RGB_Display(
480 /* width */, 480 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */,
bus, GFX_NOT_DEFINED /* RST */, st7701_type5_init_operations, sizeof(st7701_type5_init_operations));
#elif defined(LILYGO_T_DECK)
#define GFX_DEV_DEVICE LILYGO_T_DECK
#define GFX_EXTRA_PRE_INIT() \
{ \
pinMode(39 /* TDECK_SDCARD_CS */, OUTPUT); \
digitalWrite(39 /* TDECK_SDCARD_CS */, HIGH); \
pinMode(9 /* TDECK_RADIO_CS */, OUTPUT); \
digitalWrite(9 /* TDECK_RADIO_CS */, HIGH); \
pinMode(10 /* TDECK_PERI_POWERON */, OUTPUT); \
digitalWrite(10 /* TDECK_PERI_POWERON */, HIGH); \
delay(500); \
}
#define GFX_BL 42
Arduino_DataBus *bus = new Arduino_ESP32SPI(11 /* DC */, 12 /* CS */, 40 /* SCK */, 41 /* MOSI */, 38 /* MISO */);
Arduino_GFX *gfx = new Arduino_ST7789(bus, GFX_NOT_DEFINED /* RST */, 1 /* rotation */, false /* IPS */);
#elif defined(LILYGO_T_DISPLAY)
#define GFX_DEV_DEVICE LILYGO_T_DISPLAY
#define GFX_BL 4
Arduino_DataBus *bus = new Arduino_ESP32SPI(16 /* DC */, 5 /* CS */, 18 /* SCK */, 19 /* MOSI */, GFX_NOT_DEFINED /* MISO */);
Arduino_GFX *gfx = new Arduino_ST7789(bus, 23 /* RST */, 0 /* rotation */, true /* IPS */, 135 /* width */, 240 /* height */, 52 /* col offset 1 */, 40 /* row offset 1 */, 53 /* col offset 2 */, 40 /* row offset 2 */);
#elif defined(LILYGO_T_DISPLAY_S3)
#define GFX_DEV_DEVICE LILYGO_T_DISPLAY_S3
#define GFX_EXTRA_PRE_INIT() \
{ \
pinMode(15 /* PWD */, OUTPUT); \
digitalWrite(15 /* PWD */, HIGH); \
}
#define GFX_BL 38
Arduino_DataBus *bus = new Arduino_ESP32PAR8Q(
7 /* DC */, 6 /* CS */, 8 /* WR */, 9 /* RD */,
39 /* D0 */, 40 /* D1 */, 41 /* D2 */, 42 /* D3 */, 45 /* D4 */, 46 /* D5 */, 47 /* D6 */, 48 /* D7 */);
Arduino_GFX *gfx = new Arduino_ST7789(bus, 5 /* RST */, 0 /* rotation */, true /* IPS */, 170 /* width */, 320 /* height */, 35 /* col offset 1 */, 0 /* row offset 1 */, 35 /* col offset 2 */, 0 /* row offset 2 */);
#elif defined(LILYGO_T_Display_S3_AMOLED)
#define GFX_DEV_DEVICE LILYGO_T_DISPLAY_S3_AMOLED
Arduino_DataBus *bus = new Arduino_ESP32QSPI(
6 /* cs */, 47 /* sck */, 18 /* d0 */, 7 /* d1 */, 48 /* d2 */, 5 /* d3 */);
Arduino_GFX *gfx = new Arduino_RM67162(bus, 17 /* RST */, 0 /* rotation */);
#elif defined(LILYGO_T_QT)
#define GFX_DEV_DEVICE LILYGO_T_QT
#define GFX_EXTRA_PRE_INIT() \
{ \
pinMode(10 /* BL */, OUTPUT); \
digitalWrite(10 /* BL */, LOW); \
}
Arduino_DataBus *bus = new Arduino_ESP32SPI(6 /* DC */, 5 /* CS */, 3 /* SCK */, 2 /* MOSI */, GFX_NOT_DEFINED /* MISO */);
Arduino_GFX *gfx = new Arduino_GC9107(bus, 1 /* RST */, 0 /* rotation */, true /* IPS */);
#elif defined(LILYGO_T_DISPLAY_S3_PRO)
#define GFX_DEV_DEVICE LILYGO_T_DISPLAY_S3_PRO
#define GFX_BL 48
Arduino_DataBus *bus = new Arduino_ESP32SPI(9 /* DC */, 39 /* CS */, 18 /* SCK */, 17 /* MOSI */, 8 /* MISO */);
Arduino_GFX *gfx = new Arduino_ST7796(bus, 47 /* RST */, 0 /* rotation */, true /* IPS */, 222 /* width */, 480 /* height */, 49 /* col offset 1 */, 0 /* row offset 1 */, 49 /* col offset 2 */, 0 /* row offset 2 */);
#elif defined(LILYGO_T_RGB)
#define GFX_DEV_DEVICE LILYGO_T_RGB
#include <Wire.h>
#define GFX_EXTRA_PRE_INIT() \
{ \
Wire.begin(8 /* SDA */, 48 /* SCL */, 800000L /* speed */); \
}
#define GFX_BL 46
Arduino_DataBus *bus = new Arduino_XL9535SWSPI(8 /* SDA */, 48 /* SCL */, 2 /* XL PWD */, 3 /* XL CS */, 5 /* XL SCK */, 4 /* XL MOSI */);
Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel(
45 /* DE */, 41 /* VSYNC */, 47 /* HSYNC */, 42 /* PCLK */,
21 /* R0 */, 18 /* R1 */, 17 /* R2 */, 16 /* R3 */, 15 /* R4 */,
14 /* G0 */, 13 /* G1 */, 12 /* G2 */, 11 /* G3 */, 10 /* G4 */, 9 /* G5 */,
7 /* B0 */, 6 /* B1 */, 5 /* B2 */, 3 /* B3 */, 2 /* B4 */,
1 /* hsync_polarity */, 50 /* hsync_front_porch */, 1 /* hsync_pulse_width */, 30 /* hsync_back_porch */,
1 /* vsync_polarity */, 20 /* vsync_front_porch */, 1 /* vsync_pulse_width */, 30 /* vsync_back_porch */,
1 /* pclk_active_neg */);
Arduino_RGB_Display *gfx = new Arduino_RGB_Display(
480 /* width */, 480 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */,
bus, GFX_NOT_DEFINED /* RST */, st7701_type4_init_operations, sizeof(st7701_type4_init_operations));
#elif defined(LILYGO_T_TRACK)
#define GFX_DEV_DEVICE LILYGO_T_TRACK
#define GFX_EXTRA_PRE_INIT() \
{ \
pinMode(4 /* POWER */, OUTPUT); \
digitalWrite(4 /* POWER */, HIGH); \
}
Arduino_DataBus *bus = new Arduino_ESP32SPIDMA(7 /* DC */, 9 /* CS */, 5 /* SCK */, 6 /* MOSI */, GFX_NOT_DEFINED /* MISO */);
Arduino_G *g = new Arduino_JD9613(bus, 8 /* RST */);
Arduino_GFX *gfx = new Arduino_Canvas(126 /* width */, 294 /* height */, g, 0, 0, 3);
#define CANVAS
#elif defined(LILYGO_T_WATCH_2021)
#define GFX_DEV_DEVICE LILYGO_T_WATCH_2021
#define GFX_BL 21
Arduino_DataBus *bus = new Arduino_ESP32SPI(19 /* DC */, 15 /* CS */, 14 /* SCK */, 13 /* MOSI */, GFX_NOT_DEFINED /* MISO */);
Arduino_GFX *gfx = new Arduino_GC9A01(bus, 27 /* RST */, 0 /* rotation */, true /* IPS */);
#elif defined(MAKERFABS_TFT_TOUCH_3_5)
#define GFX_DEV_DEVICE MAKERFABS_TFT_TOUCH_3_5
Arduino_DataBus *bus = new Arduino_ESP32SPI(33 /* DC */, 15 /* CS */, 14 /* SCK */, 13 /* MOSI */, 12 /* MISO */);
Arduino_GFX *gfx = new Arduino_ILI9488_18bit(bus, GFX_NOT_DEFINED /* RST */, 1 /* rotation */, false /* IPS */);
#elif defined(MAKERFABS_ESP32_S3_TFT_4_0)
#define GFX_DEV_DEVICE MAKERFABS_ESP32_S3_TFT_4_0
Arduino_DataBus *bus = new Arduino_SWSPI(
GFX_NOT_DEFINED /* DC */, 1 /* CS */,
12 /* SCK */, 11 /* MOSI */, GFX_NOT_DEFINED /* MISO */);
Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel(
45 /* DE */, 4 /* VSYNC */, 5 /* HSYNC */, 21 /* PCLK */,
39 /* R0 */, 40 /* R1 */, 41 /* R2 */, 42 /* R3 */, 2 /* R4 */,
0 /* G0 */, 9 /* G1 */, 14 /* G2 */, 47 /* G3 */, 48 /* G4 */, 3 /* G5 */,
6 /* B0 */, 7 /* B1 */, 15 /* B2 */, 16 /* B3 */, 8 /* B4 */,
1 /* hsync_polarity */, 10 /* hsync_front_porch */, 8 /* hsync_pulse_width */, 50 /* hsync_back_porch */,
1 /* vsync_polarity */, 10 /* vsync_front_porch */, 8 /* vsync_pulse_width */, 20 /* vsync_back_porch */);
Arduino_RGB_Display *gfx = new Arduino_RGB_Display(
480 /* width */, 480 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */,
bus, GFX_NOT_DEFINED /* RST */, st7701_type1_init_operations, sizeof(st7701_type1_init_operations));
#elif defined(MAKERFABS_ESP32_S3_TFT_4_3_v1_3)
#define GFX_DEV_DEVICE MAKERFABS_ESP32_S3_TFT_4_3_v1_3
#define GFX_BL 2
Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel(
40 /* DE */, 41 /* VSYNC */, 39 /* HSYNC */, 42 /* PCLK */,
45 /* R0 */, 48 /* R1 */, 47 /* R2 */, 21 /* R3 */, 14 /* R4 */,
5 /* G0 */, 6 /* G1 */, 7 /* G2 */, 15 /* G3 */, 16 /* G4 */, 4 /* G5 */,
8 /* B0 */, 3 /* B1 */, 46 /* B2 */, 9 /* B3 */, 1 /* B4 */,
0 /* hsync_polarity */, 40 /* hsync_front_porch */, 48 /* hsync_pulse_width */, 88 /* hsync_back_porch */,
0 /* vsync_polarity */, 13 /* vsync_front_porch */, 3 /* vsync_pulse_width */, 32 /* vsync_back_porch */,
1 /* pclk_active_neg */, 16000000 /* prefer_speed */);
Arduino_RGB_Display *gfx = new Arduino_RGB_Display(
800 /* width */, 480 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */);
#elif defined(WT32_SC01)
#define GFX_DEV_DEVICE WT32_SC01
#define GFX_BL 23
Arduino_DataBus *bus = new Arduino_ESP32SPI(21 /* DC */, 15 /* CS */, 14 /* SCK */, 13 /* MOSI */, GFX_NOT_DEFINED /* MISO */);
Arduino_GFX *gfx = new Arduino_ST7796(bus, 22 /* RST */, 3 /* rotation */);
#elif defined(WZ8048C050)
#define GFX_DEV_DEVICE WZ8048C050
#define GFX_BL 2
// ILI6122
Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel(
40 /* DE */, 41 /* VSYNC */, 39 /* HSYNC */, 0 /* PCLK */,
45 /* R0 */, 48 /* R1 */, 47 /* R2 */, 21 /* R3 */, 14 /* R4 */,
5 /* G0 */, 6 /* G1 */, 7 /* G2 */, 15 /* G3 */, 16 /* G4 */, 4 /* G5 */,
8 /* B0 */, 3 /* B1 */, 46 /* B2 */, 9 /* B3 */, 1 /* B4 */,
0 /* hsync_polarity */, 8 /* hsync_front_porch */, 1 /* hsync_pulse_width */, 32 /* hsync_back_porch */,
0 /* vsync_polarity */, 8 /* vsync_front_porch */, 1 /* vsync_pulse_width */, 8 /* vsync_back_porch */,
1 /* pclk_active_neg */, 16000000 /* prefer_speed */);
Arduino_RGB_Display *gfx = new Arduino_RGB_Display(
800 /* width */, 480 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */);
#elif defined(XIAO_SAMD21_ROUND_DISPLAY)
#define GFX_DEV_DEVICE XIAO_SAMD21_ROUND_DISPLAY
Arduino_DataBus *bus = new Arduino_HWSPI(3 /* DC */, 1 /* CS */);
Arduino_GFX *gfx = new Arduino_GC9A01(bus, GFX_NOT_DEFINED /* RST */, 0 /* rotation */, true /* IPS */);
#elif defined(XIAO_ESP32C3_ROUND_DISPLAY)
#define GFX_DEV_DEVICE XIAO_ESP32C3_ROUND_DISPLAY
Arduino_DataBus *bus = new Arduino_ESP32SPI(5 /* DC */, 3 /* CS */, 8 /* SCK */, 10 /* MOSI */, 9 /* MISO */);
Arduino_GFX *gfx = new Arduino_GC9A01(bus, GFX_NOT_DEFINED /* RST */, 0 /* rotation */, true /* IPS */);
#elif defined(XIAO_ESP32S3_ROUND_DISPLAY)
#define GFX_DEV_DEVICE XIAO_ESP32S3_ROUND_DISPLAY
Arduino_DataBus *bus = new Arduino_ESP32SPI(4 /* DC */, 2 /* CS */, 7 /* SCK */, 9 /* MOSI */, 8 /* MISO */);
Arduino_GFX *gfx = new Arduino_GC9A01(bus, GFX_NOT_DEFINED /* RST */, 0 /* rotation */, true /* IPS */);
#elif defined(ZX2D10GE10R_V4848)
#define GFX_DEV_DEVICE ZX2D10GE10R_V4848
#define GFX_BL 38
Arduino_DataBus *bus = new Arduino_SWSPI(
GFX_NOT_DEFINED /* DC */, 21 /* CS */,
47 /* SCK */, 41 /* MOSI */, GFX_NOT_DEFINED /* MISO */);
Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel(
39 /* DE */, 48 /* VSYNC */, 40 /* HSYNC */, 45 /* PCLK */,
10 /* R0 */, 16 /* R1 */, 9 /* R2 */, 15 /* R3 */, 46 /* R4 */,
8 /* G0 */, 13 /* G1 */, 18 /* G2 */, 12 /* G3 */, 11 /* G4 */, 17 /* G5 */,
47 /* B0 */, 41 /* B1 */, 0 /* B2 */, 42 /* B3 */, 14 /* B4 */,
1 /* hsync_polarity */, 10 /* hsync_front_porch */, 10 /* hsync_pulse_width */, 10 /* hsync_back_porch */,
1 /* vsync_polarity */, 14 /* vsync_front_porch */, 2 /* vsync_pulse_width */, 12 /* vsync_back_porch */);
Arduino_RGB_Display *gfx = new Arduino_RGB_Display(
480 /* width */, 480 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */,
bus, GFX_NOT_DEFINED /* RST */, st7701_type7_init_operations, sizeof(st7701_type7_init_operations));
#elif defined(ZX3D50CE02S)
#define GFX_DEV_DEVICE ZX3D50CE02S
#define GFX_BL 45
Arduino_DataBus *bus = new Arduino_ESP32LCD8(
0 /* DC */, GFX_NOT_DEFINED /* CS */, 47 /* WR */, GFX_NOT_DEFINED /* RD */,
9 /* D0 */, 46 /* D1 */, 3 /* D2 */, 8 /* D3 */, 18 /* D4 */, 17 /* D5 */, 16 /* D6 */, 15 /* D7 */);
Arduino_GFX *gfx = new Arduino_ST7796(bus, 4 /* RST */, 0 /* rotation */, true /* IPS */);
#elif defined(ZX3D95CE01S_AR)
#define GFX_DEV_DEVICE ZX3D95CE01S_AR
#define GFX_BL 45
Arduino_DataBus *bus = new Arduino_SWSPI(
GFX_NOT_DEFINED /* DC */, 0 /* CS */,
10 /* SCK */, 9 /* MOSI */, GFX_NOT_DEFINED /* MISO */);
Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel(
13 /* DE */, 12 /* VSYNC */, 11 /* HSYNC */, 14 /* PCLK */,
2 /* R0 */, 17 /* R1 */, 16 /* R2 */, 1 /* R3 */, 15 /* R4 */,
41 /* G0 */, 46 /* G1 */, 3 /* G2 */, 42 /* G3 */, 8 /* G4 */, 18 /* G5 */,
10 /* B0 */, 9 /* B1 */, 40 /* B2 */, 20 /* B3 */, 19 /* B4 */,
1 /* hsync_polarity */, 10 /* hsync_front_porch */, 8 /* hsync_pulse_width */, 50 /* hsync_back_porch */,
1 /* vsync_polarity */, 10 /* vsync_front_porch */, 8 /* vsync_pulse_width */, 20 /* vsync_back_porch */);
Arduino_RGB_Display *gfx = new Arduino_RGB_Display(
480 /* width */, 480 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */,
bus, GFX_NOT_DEFINED /* RST */, gc9503v_type1_init_operations, sizeof(gc9503v_type1_init_operations));
#elif defined(ZX3D95CE01S_TR)
#define GFX_DEV_DEVICE ZX3D95CE01S_TR
#define GFX_BL 5
Arduino_DataBus *bus = new Arduino_SWSPI(
GFX_NOT_DEFINED /* DC */, 38 /* CS */,
45 /* SCK or SCLK */, 48 /* MOSI */, GFX_NOT_DEFINED /* MISO */);
Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel(
40 /* DE */, 41 /* VSYNC */, 42 /* HSYNC */, 39 /* PCLK */,
18 /* R0 */, 8 /* R1 */, 3 /* R2 */, 46 /* R3 */, 10 /* R4 */,
14 /* G0 */, 13 /* G1 */, 12 /* G2 */, 11 /* G3 */, 16 /* G4 */, 17 /* G5 */,
45 /* B0 */, 48 /* B1 */, 47 /* B2 */, 0 /* B3 */, 21 /* B4 */,
1 /* hsync_polarity */, 8 /* hsync_front_porch */, 10 /* hsync_pulse_width */, 50 /* hsync_back_porch */,
1 /* vsync_polarity */, 8 /* vsync_front_porch */, 10 /* vsync_pulse_width */, 20 /* vsync_back_porch */);
Arduino_RGB_Display *gfx = new Arduino_RGB_Display(
480 /* width */, 480 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */,
bus, 41 /* RST */, gc9503v_type1_init_operations, sizeof(gc9503v_type1_init_operations));
#elif defined(ZX7D00CE01S)
#define GFX_DEV_DEVICE ZX7D00CE01S
#define GFX_BL 45
Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel(
39 /* DE */, 38 /* VSYNC */, 5 /* HSYNC */, 9 /* PCLK */,
10 /* R0 */, 11 /* R1 */, 12 /* R2 */, 13 /* R3 */, 14 /* R4 */,
21 /* G0 */, 0 /* G1 */, 46 /* G2 */, 3 /* G3 */, 8 /* G4 */, 18 /* G5 */,
17 /* B0 */, 16 /* B1 */, 15 /* B2 */, 7 /* B3 */, 6 /* B4 */,
0 /* hsync_polarity */, 0 /* hsync_front_porch */, 210 /* hsync_pulse_width */, 30 /* hsync_back_porch */,
0 /* vsync_polarity */, 0 /* vsync_front_porch */, 22 /* vsync_pulse_width */, 13 /* vsync_back_porch */);
Arduino_RGB_Display *gfx = new Arduino_RGB_Display(
800 /* width */, 480 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */);
/* Wio Terminal */
#elif defined(ARDUINO_ARCH_SAMD) && defined(SEEED_GROVE_UI_WIRELESS)
#define GFX_DEV_DEVICE WIO_TERMINAL
// #define GFX_BL LCD_BACKLIGHT
Arduino_DataBus *bus = new Arduino_HWSPI(LCD_DC /* DC */, LCD_SS_PIN /* CS */);
Arduino_GFX *gfx = new Arduino_ILI9341(bus, GFX_NOT_DEFINED /* RST */, 1 /* rotation */);
/* ESP32-S3-BOX */
#elif defined(ARDUINO_ESP32_S3_BOX)
#define GFX_DEV_DEVICE ARDUINO_ESP32_S3_BOX
#define GFX_BL 45
Arduino_DataBus *bus = new Arduino_ESP32SPI(4 /* DC */, 5 /* CS */, 7 /* SCK */, 6 /* MOSI */, 0 /* MISO */);
Arduino_GFX *gfx = new Arduino_ILI9342(bus, 48 /* RST */, 0 /* rotation */);
/* M5Stack */
#elif defined(ARDUINO_M5Stack_Core_ESP32) || defined(ARDUINO_M5STACK_FIRE)
#define GFX_DEV_DEVICE ARDUINO_M5Stack_Core_ESP32
// #define GFX_BL 32
Arduino_DataBus *bus = new Arduino_ESP32SPI(27 /* DC */, 14 /* CS */, SCK, MOSI, MISO);
Arduino_GFX *gfx = new Arduino_ILI9342(bus, 33 /* RST */, 2 /* rotation */);
#elif defined(ARDUINO_M5Stack_ATOMS3)
#define GFX_DEV_DEVICE ARDUINO_M5Stack_ATOMS3
#define GFX_BL 16
Arduino_DataBus *bus = new Arduino_ESP32SPI(33 /* DC */, 15 /* CS */, 17 /* SCK */, 21 /* MOSI */, GFX_NOT_DEFINED /* MISO */);
Arduino_GFX *gfx = new Arduino_GC9107(bus, 34 /* RST */, 0 /* rotation */, true /* IPS */);
/* Odroid-Go */
#elif defined(ARDUINO_ODROID_ESP32)
#define GFX_DEV_DEVICE ARDUINO_ODROID_ESP32
// #define GFX_BL 14
Arduino_DataBus *bus = new Arduino_ESP32SPI(21 /* DC */, 5 /* CS */, SCK, MOSI, MISO);
Arduino_GFX *gfx = new Arduino_ILI9341(bus, GFX_NOT_DEFINED /* RST */, 3 /* rotation */);
// Arduino_ST7789 *gfx = new Arduino_ST7789(bus, GFX_NOT_DEFINED /* RST */, 3 /* rotation */, true /* IPS */);
/* LILYGO T-Watch */
#elif defined(ARDUINO_T) || defined(ARDUINO_TWATCH_BASE) || defined(ARDUINO_TWATCH_2020_V1) || defined(ARDUINO_TWATCH_2020_V2)
#define GFX_DEV_DEVICE ARDUINO_T_WATCH
#define GFX_BL 12
Arduino_DataBus *bus = new Arduino_ESP32SPI(27 /* DC */, 5 /* CS */, 18 /* SCK */, 19 /* MOSI */, GFX_NOT_DEFINED /* MISO */);
Arduino_GFX *gfx = new Arduino_ST7789(bus, GFX_NOT_DEFINED /* RST */, 0 /* rotation */, true /* IPS */, 240 /* width */, 240 /* height */, 0 /* col offset 1 */, 0 /* row offset 1 */, 0 /* col offset 2 */, 80 /* row offset 2 */);
/* Waveshare RP2040-LCD-1.28 */
#elif defined(ARDUINO_WAVESHARE_RP2040_LCD_1_28)
#define GFX_DEV_DEVICE ARDUINO_WAVESHARE_RP2040_LCD_1_28
#define GFX_BL 25
Arduino_DataBus *bus = new Arduino_RPiPicoSPI(8 /* DC */, 9 /* CS */, 10 /* SCK */, 11 /* MOSI */, 12 /* MISO */, spi1 /* spi */);
Arduino_GFX *gfx = new Arduino_GC9A01(bus, 12 /* RST */, 0 /* rotation */, true /* IPS */);
#endif

View File

@ -0,0 +1,158 @@
/***************************************
* Start of Canvas (framebuffer)
**************************************/
// #define CANVAS
// 16-bit color Canvas (240x320 resolution only works for ESP32 with PSRAM)
// Arduino_G *output_display = new Arduino_ST7789(bus, TFT_RST, 0 /* rotation */, true /* IPS */);
// Arduino_GFX *gfx = new Arduino_Canvas(240 /* width */, 320 /* height */, output_display);
// Indexed color Canvas, mask_level: 0-2, larger mask level mean less color variation but can have faster index mapping
// Arduino_G *output_display = new Arduino_ST7789(bus, TFT_RST, 0 /* rotation */, true /* IPS */);
// Arduino_GFX *gfx = new Arduino_Canvas_Indexed(240 /* width */, 320 /* height */, output_display, 0 /* output_x */, 0 /* output_y */, MAXMASKLEVEL /* mask_level */);
// 3-bit color Canvas, R1G1B1, 8 colors
// Arduino_G *output_display = new Arduino_ILI9488_3bit(bus, GFX_NOT_DEFINED /* RST */, 1 /* rotation */, false /* IPS */);
// Arduino_GFX *gfx = new Arduino_Canvas_3bit(480 /* width */, 320 /* height */, output_display, 0 /* output_x */, 0 /* output_y */);
// Mono color Canvas
// Arduino_G *output_display = new Arduino_ST7789(bus, TFT_RST, 0 /* rotation */, true /* IPS */);
// Arduino_GFX *gfx = new Arduino_Canvas_Mono(240 /* width */, 320 /* height */, output_display, 0 /* output_x */, 0 /* output_y */);
/***************************************
* End of Canvas (framebuffer)
**************************************/
// GC9A01 IPS LCD 240x240
// Arduino_GFX *gfx = new Arduino_GC9A01(bus, TFT_RST, 0 /* rotation */, true /* IPS */);
// GC9106 IPS LCD 80x160
// Arduino_GFX *gfx = new Arduino_GC9106(bus, TFT_RST, 0 /* rotation */, true /* IPS */);
// GC9107 IPS LCD 128x128
// Arduino_GFX *gfx = new Arduino_GC9107(bus, TFT_RST, 0 /* rotation */, true /* IPS */);
// HX8347C IPS LCD 240x320
// Arduino_GFX *gfx = new Arduino_HX8347C(bus, TFT_RST, 0 /* rotation */, true /* IPS */);
// HX8347D IPS LCD 240x320
// Arduino_GFX *gfx = new Arduino_HX8347D(bus, TFT_RST, 0 /* rotation */, true /* IPS */);
// HX8352C IPS LCD 240x400
// Arduino_GFX *gfx = new Arduino_HX8352C(bus, TFT_RST, 0 /* rotation */, true /* IPS */);
// HX8357A IPS LCD 320x480 (currently only portrait works, i.e. rotation 0 and 2)
// Arduino_GFX *gfx = new Arduino_HX8357A(bus, TFT_RST, 0 /* rotation */, true /* IPS */);
// HX8357B IPS LCD 320x480
// Arduino_GFX *gfx = new Arduino_HX8357B(bus, TFT_RST, 0 /* rotation */, true /* IPS */);
// HX8369A LCD 480x800
// Arduino_GFX *gfx = new Arduino_HX8369A(bus, TFT_RST, 0 /* rotation */, false /* IPS */, 480, 800, 0, 7, 0, 57);
// ILI9225 LCD 176x220
// Arduino_GFX *gfx = new Arduino_ILI9225(bus, TFT_RST);
// ILI9341 LCD 240x320 (default Display, comment below line if you are not using ILI9341)
Arduino_GFX *gfx = new Arduino_ILI9341(bus, TFT_RST, 0 /* rotation */, false /* IPS */);
// ILI9342 LCD 320x240
// Arduino_GFX *gfx = new Arduino_ILI9342(bus, TFT_RST, 0 /* rotation */, false /* IPS */);
// ILI9481 parallel 8/16-bit LCD 320x480
// Arduino_GFX *gfx = new Arduino_ILI9481(bus, TFT_RST, 0 /* rotation */, false /* IPS */);
// ILI9481 SPI LCD 320x480
// Arduino_GFX *gfx = new Arduino_ILI9481_18bit(bus, TFT_RST, 0 /* rotation */, false /* IPS */);
// ILI9486 parallel 8/16-bit LCD 320x480
// Arduino_GFX *gfx = new Arduino_ILI9486(bus, TFT_RST, 0 /* rotation */, false /* IPS */);
// ILI9486 SPI LCD 320x480
// Arduino_GFX *gfx = new Arduino_ILI9486_18bit(bus, TFT_RST, 0 /* rotation */, false /* IPS */);
// ILI9488 parallel 8/16-bit LCD 320x480
// Arduino_GFX *gfx = new Arduino_ILI9488(bus, TFT_RST, 0 /* rotation */, false /* IPS */);
// ILI9488 SPI LCD 320x480
// Arduino_GFX *gfx = new Arduino_ILI9488_18bit(bus, TFT_RST, 0 /* rotation */, false /* IPS */);
// ILI9806 LCD 480x854
// Arduino_GFX *gfx = new Arduino_ILI9806(bus, TFT_RST, 0 /* rotation */, false /* IPS */);
// JBT6K71 LCD 240x320
// Arduino_GFX *gfx = new Arduino_JBT6K71(bus, TFT_RST, 0 /* rotation */, true /* IPS */, 240, 320, 0, 0, 16, 0);
// NT35310 LCD 320x480
// Arduino_GFX *gfx = new Arduino_NT35310(bus, TFT_RST, 0 /* rotation */);
// NT35510 LCD 480x800
// Arduino_GFX *gfx = new Arduino_NT35510(bus, TFT_RST, 0 /* rotation */);
// NT39125 LCD 240x376
// Arduino_GFX *gfx = new Arduino_NT39125(bus, TFT_RST, 0 /* rotation */, false /* IPS */, 240, 376, 0, 0, 0, 56);
// NV3041A IPS LCD
// Arduino_GFX *gfx = new Arduino_NV3041A(bus, TFT_RST, 0 /* rotation */, true /* IPS */);
// OTM8009A LCD 480x800
// Arduino_GFX *gfx = new Arduino_OTM8009A(bus, TFT_RST, 0 /* rotation */);
// R61529 IPS LCD 320x480
// Arduino_GFX *gfx = new Arduino_R61529(bus, TFT_RST, 0 /* rotation */, true /* IPS */);
// SEPS525 OLED 160x128
// Arduino_GFX *gfx = new Arduino_SEPS525(bus, TFT_RST, 0 /* rotation */);
// SSD1283A OLED 130x130
// Arduino_GFX *gfx = new Arduino_SSD1283A(bus, TFT_RST, 0 /* rotation */);
// SSD1331 OLED 96x64
// Arduino_GFX *gfx = new Arduino_SSD1331(bus, TFT_RST, 0 /* rotation */);
// SSD1351 OLED 128x128
// Arduino_GFX *gfx = new Arduino_SSD1351(bus, TFT_RST, 0 /* rotation */);
// ST7735 LCD
// 1.8" REDTAB 128x160
// Arduino_GFX *gfx = new Arduino_ST7735(bus, TFT_RST, 0 /* rotation */);
// 1.8" BLACKTAB 128x160
// Arduino_GFX *gfx = new Arduino_ST7735(bus, TFT_RST, 0 /* rotation */, false /* IPS */, 128 /* width */, 160 /* height */, 2 /* col offset 1 */, 1 /* row offset 1 */, 2 /* col offset 2 */, 1 /* row offset 2 */, false /* BGR */);
// 1.8" GREENTAB A 128x160
// Arduino_GFX *gfx = new Arduino_ST7735(bus, TFT_RST, 0 /* rotation */, false /* IPS */, 128 /* width */, 160 /* height */, 2 /* col offset 1 */, 1 /* row offset 1 */, 2 /* col offset 2 */, 1 /* row offset 2 */);
// 1.8" GREENTAB B 128x160
// Arduino_GFX *gfx = new Arduino_ST7735(bus, TFT_RST, 0 /* rotation */, false /* IPS */, 128 /* width */, 160 /* height */, 2 /* col offset 1 */, 3 /* row offset 1 */, 2 /* col offset 2 */, 1 /* row offset 2 */);
// 1.8" Wide angle LCD 128x160
// Arduino_GFX *gfx = new Arduino_ST7735(bus, TFT_RST, 0 /* rotation */, false /* IPS */, 128 /* width */, 160 /* height */, 0 /* col offset 1 */, 0 /* row offset 1 */, 0 /* col offset 2 */, 0 /* row offset 2 */, false /* BGR */);
// 1.5" GREENTAB B 128x128
// Arduino_GFX *gfx = new Arduino_ST7735(bus, TFT_RST, 0 /* rotation */, false /* IPS */, 128 /* width */, 128 /* height */, 2 /* col offset 1 */, 3 /* row offset 1 */, 2 /* col offset 2 */, 1 /* row offset 2 */);
// 1.5" GREENTAB C 128x128
// Arduino_GFX *gfx = new Arduino_ST7735(bus, TFT_RST, 0 /* rotation */, false /* IPS */, 128 /* width */, 128 /* height */, 0 /* col offset 1 */, 32 /* row offset 1 */);
// 0.96" IPS LCD 80x160
// Arduino_GFX *gfx = new Arduino_ST7735(bus, TFT_RST, 0 /* rotation */, true /* IPS */, 80 /* width */, 160 /* height */, 26 /* col offset 1 */, 1 /* row offset 1 */, 26 /* col offset 2 */, 1 /* row offset 2 */);
// ST7789 LCD
// 2.4" LCD 240x320
// Arduino_GFX *gfx = new Arduino_ST7789(bus, TFT_RST, 0 /* rotation */);
// 2.4" IPS LCD 240x320
// Arduino_GFX *gfx = new Arduino_ST7789(bus, TFT_RST, 0 /* rotation */, true /* IPS */);
// 1.9" IPS round corner LCD 170x320
// Arduino_GFX *gfx = new Arduino_ST7789(bus, TFT_RST, 0 /* rotation */, true /* IPS */, 170 /* width */, 320 /* height */, 35 /* col offset 1 */, 0 /* row offset 1 */, 35 /* col offset 2 */, 0 /* row offset 2 */);
// 1.69" IPS round corner LCD 240x280
// Arduino_GFX *gfx = new Arduino_ST7789(bus, TFT_RST, 0 /* rotation */, true /* IPS */, 240 /* width */, 280 /* height */, 0 /* col offset 1 */, 20 /* row offset 1 */, 0 /* col offset 2 */, 20 /* row offset 2 */);
// 1.47" IPS round corner LCD 172x320
// Arduino_GFX *gfx = new Arduino_ST7789(bus, TFT_RST, 0 /* rotation */, true /* IPS */, 172 /* width */, 320 /* height */, 34 /* col offset 1 */, 0 /* row offset 1 */, 34 /* col offset 2 */, 0 /* row offset 2 */);
// 1.3"/1.5" square IPS LCD 240x240
// Arduino_GFX *gfx = new Arduino_ST7789(bus, TFT_RST, 0 /* rotation */, true /* IPS */, 240 /* width */, 240 /* height */, 0 /* col offset 1 */, 0 /* row offset 1 */, 0 /* col offset 2 */, 80 /* row offset 2 */);
// 1.14" IPS LCD 135x240
// Arduino_GFX *gfx = new Arduino_ST7789(bus, TFT_RST, 0 /* rotation */, true /* IPS */, 135 /* width */, 240 /* height */, 52 /* col offset 1 */, 40 /* row offset 1 */, 53 /* col offset 2 */, 40 /* row offset 2 */);
// ST7796 LCD
// 4" LCD 320x480
// Arduino_GFX *gfx = new Arduino_ST7796(bus, TFT_RST, 0 /* rotation */);
// 4" IPS LCD 320x480
// Arduino_GFX *gfx = new Arduino_ST7796(bus, TFT_RST, 0 /* rotation */, true /* IPS */);
// WEA2012 LCD
// #define CANVAS
// Arduino_GFX *output_display = new Arduino_WEA2012(bus, TFT_RST);
// Arduino_GFX *gfx = new Arduino_Canvas(356 /* width */, 400 /* height */, output_display);

View File

@ -0,0 +1,74 @@
#if defined(__IMXRT1052__) || defined(__IMXRT1062__)
// PJRC Teensy 4.x
#define TFT_CS 39 // GFX_NOT_DEFINED for display without CS pin
#define TFT_DC 41
#define TFT_RST 40
#define GFX_BL 22
#elif defined(ARDUINO_BLACKPILL_F411CE)
#define TFT_CS 4 // GFX_NOT_DEFINED for display without CS pin
#define TFT_DC 3
#define TFT_RST 2
#define GFX_BL 1
#elif defined(TARGET_RP2040)
#define TFT_CS 17 // GFX_NOT_DEFINED for display without CS pin
#define TFT_DC 27
#define TFT_RST 26
#define GFX_BL 28
#elif defined(ESP32) && (CONFIG_IDF_TARGET_ESP32)
#define TFT_CS 5 // GFX_NOT_DEFINED for display without CS pin
#define TFT_DC 27 // GFX_NOT_DEFINED for display without DC pin (9-bit SPI)
#define TFT_RST 33
#define GFX_BL 22
#elif defined(ESP32) && (CONFIG_IDF_TARGET_ESP32S2)
#define TFT_CS 34 // GFX_NOT_DEFINED for display without CS pin
#define TFT_DC 38
#define TFT_RST 33
#define GFX_BL 21
#elif defined(ESP32) && (CONFIG_IDF_TARGET_ESP32S3)
#define TFT_CS 40 // GFX_NOT_DEFINED for display without CS pin
#define TFT_DC 41
#define TFT_RST 42
#define GFX_BL 48
#elif defined(ESP32) && (CONFIG_IDF_TARGET_ESP32C3)
#define TFT_CS 7 // GFX_NOT_DEFINED for display without CS pin
#define TFT_DC 2
#define TFT_RST 1
#define GFX_BL 3
#elif defined(ESP8266)
#define TFT_CS 15 // GFX_NOT_DEFINED for display without CS pin
#define TFT_DC 4
#define TFT_RST 2
#define GFX_BL 5
#elif defined(RTL8722DM)
#if defined(BOARD_RTL8720DN_BW16)
#define TFT_CS 9
#define TFT_DC 8
#define TFT_RST 6
#define GFX_BL 3
#elif defined(BOARD_RTL8722DM)
#define TFT_CS 18
#define TFT_DC 17
#define TFT_RST 22
#define GFX_BL 23
#elif defined(BOARD_RTL8722DM_MINI)
#define TFT_CS 12
#define TFT_DC 14
#define TFT_RST 15
#define GFX_BL 13
#else // old version
#define TFT_CS 18 // GFX_NOT_DEFINED for display without CS pin
#define TFT_DC 17
#define TFT_RST 2
#define GFX_BL 23
#endif
#elif defined(SEEED_XIAO_M0)
#define TFT_CS 3 // GFX_NOT_DEFINED for display without CS pin
#define TFT_DC 2
#define TFT_RST 1
#define GFX_BL 0
#else
#define TFT_CS 9 // GFX_NOT_DEFINED for display without CS pin
#define TFT_DC 8
#define TFT_RST 7
#define GFX_BL 6
#endif

View File

@ -0,0 +1,678 @@
/*
Adapted from the Adafruit and Xark's PDQ graphicstest sketch.
See end of file for original header text and MIT license info.
*/
/*******************************************************************************
* Start of Arduino_GFX setting
******************************************************************************/
#include <Arduino_GFX_Library.h>
/* OPTION 1: Uncomment a dev device in Arduino_GFX_dev_device.h */
#include "Arduino_GFX_dev_device.h"
#ifndef GFX_DEV_DEVICE
/* OPTION 2: Manual define hardware */
/* Step 1: Define pins in Arduino_GFX_databus.h */
#include "Arduino_GFX_pins.h"
/* Step 2: Uncomment your databus in Arduino_GFX_databus.h */
#include "Arduino_GFX_databus.h"
/* Step 3: Uncomment your display driver in Arduino_GFX_display.h */
#include "Arduino_GFX_display.h"
#endif /* Manual define hardware */
/*******************************************************************************
* End of Arduino_GFX setting
******************************************************************************/
#ifdef ESP32
#undef F
#define F(s) (s)
#endif
int32_t w, h, n, n1, cx, cy, cx1, cy1, cn, cn1;
uint8_t tsa, tsb, tsc, ds;
void setup()
{
Serial.begin(115200);
// Serial.setDebugOutput(true);
// while(!Serial);
Serial.println("Arduino_GFX PDQgraphicstest example!");
#ifdef GFX_EXTRA_PRE_INIT
GFX_EXTRA_PRE_INIT();
#endif
// Init Display
if (!gfx->begin())
// if (!gfx->begin(80000000)) /* specify data bus speed */
{
Serial.println("gfx->begin() failed!");
}
w = gfx->width();
h = gfx->height();
n = min(w, h);
n1 = n - 1;
cx = w / 2;
cy = h / 2;
cx1 = cx - 1;
cy1 = cy - 1;
cn = min(cx1, cy1);
cn1 = cn - 1;
tsa = ((w <= 176) || (h <= 160)) ? 1 : (((w <= 240) || (h <= 240)) ? 2 : 3); // text size A
tsb = ((w <= 272) || (h <= 220)) ? 1 : 2; // text size B
tsc = ((w <= 220) || (h <= 220)) ? 1 : 2; // text size C
ds = (w <= 160) ? 9 : 12; // digit size
#ifdef GFX_BL
pinMode(GFX_BL, OUTPUT);
digitalWrite(GFX_BL, HIGH);
#endif
}
static inline uint32_t micros_start() __attribute__((always_inline));
static inline uint32_t micros_start()
{
uint8_t oms = millis();
while ((uint8_t)millis() == oms)
;
return micros();
}
void loop(void)
{
Serial.println(F("Benchmark\tmicro-secs"));
int32_t usecFillScreen = testFillScreen();
serialOut(F("Screen fill\t"), usecFillScreen, 100, true);
int32_t usecText = testText();
serialOut(F("Text\t"), usecText, 3000, true);
int32_t usecPixels = testPixels();
serialOut(F("Pixels\t"), usecPixels, 100, true);
int32_t usecLines = testLines();
serialOut(F("Lines\t"), usecLines, 100, true);
int32_t usecFastLines = testFastLines();
serialOut(F("Horiz/Vert Lines\t"), usecFastLines, 100, true);
int32_t usecFilledRects = testFilledRects();
serialOut(F("Rectangles (filled)\t"), usecFilledRects, 100, false);
int32_t usecRects = testRects();
serialOut(F("Rectangles (outline)\t"), usecRects, 100, true);
int32_t usecFilledTrangles = testFilledTriangles();
serialOut(F("Triangles (filled)\t"), usecFilledTrangles, 100, false);
int32_t usecTriangles = testTriangles();
serialOut(F("Triangles (outline)\t"), usecTriangles, 100, true);
int32_t usecFilledCircles = testFilledCircles(10);
serialOut(F("Circles (filled)\t"), usecFilledCircles, 100, false);
int32_t usecCircles = testCircles(10);
serialOut(F("Circles (outline)\t"), usecCircles, 100, true);
int32_t usecFilledArcs = testFillArcs();
serialOut(F("Arcs (filled)\t"), usecFilledArcs, 100, false);
int32_t usecArcs = testArcs();
serialOut(F("Arcs (outline)\t"), usecArcs, 100, true);
int32_t usecFilledRoundRects = testFilledRoundRects();
serialOut(F("Rounded rects (filled)\t"), usecFilledRoundRects, 100, false);
int32_t usecRoundRects = testRoundRects();
serialOut(F("Rounded rects (outline)\t"), usecRoundRects, 100, true);
#ifdef CANVAS
uint32_t start = micros_start();
gfx->flush();
int32_t usecFlush = micros() - start;
serialOut(F("flush (Canvas only)\t"), usecFlush, 0, false);
#endif
Serial.println(F("Done!"));
uint16_t c = 4;
int8_t d = 1;
for (int32_t i = 0; i < h; i++)
{
gfx->drawFastHLine(0, i, w, c);
c += d;
if (c <= 4 || c >= 11)
{
d = -d;
}
}
gfx->setCursor(0, 0);
gfx->setTextSize(tsa);
gfx->setTextColor(MAGENTA);
gfx->println(F("Arduino GFX PDQ"));
if (h > w)
{
gfx->setTextSize(tsb);
gfx->setTextColor(GREEN);
gfx->print(F("\nBenchmark "));
gfx->setTextSize(tsc);
if (ds == 12)
{
gfx->print(F(" "));
}
gfx->println(F("micro-secs"));
}
printnice(F("Screen fill "), usecFillScreen);
printnice(F("Text "), usecText);
printnice(F("Pixels "), usecPixels);
printnice(F("Lines "), usecLines);
printnice(F("H/V Lines "), usecFastLines);
printnice(F("Rectangles F"), usecFilledRects);
printnice(F("Rectangles "), usecRects);
printnice(F("Triangles F "), usecFilledTrangles);
printnice(F("Triangles "), usecTriangles);
printnice(F("Circles F "), usecFilledCircles);
printnice(F("Circles "), usecCircles);
printnice(F("Arcs F "), usecFilledArcs);
printnice(F("Arcs "), usecArcs);
printnice(F("RoundRects F"), usecFilledRoundRects);
printnice(F("RoundRects "), usecRoundRects);
if ((h > w) || (h > 240))
{
gfx->setTextSize(tsc);
gfx->setTextColor(GREEN);
gfx->print(F("\nBenchmark Complete!"));
}
#ifdef CANVAS
gfx->flush();
#endif
delay(60 * 1000L);
}
#ifdef ESP32
void serialOut(const char *item, int32_t v, uint32_t d, bool clear)
#else
void serialOut(const __FlashStringHelper *item, int32_t v, uint32_t d, bool clear)
#endif
{
#ifdef CANVAS
gfx->flush();
#endif
Serial.print(item);
if (v < 0)
{
Serial.println(F("N/A"));
}
else
{
Serial.println(v);
}
delay(d);
if (clear)
{
gfx->fillScreen(BLACK);
}
}
#ifdef ESP32
void printnice(const char *item, long int v)
#else
void printnice(const __FlashStringHelper *item, long int v)
#endif
{
gfx->setTextSize(tsb);
gfx->setTextColor(CYAN);
gfx->print(item);
gfx->setTextSize(tsc);
gfx->setTextColor(YELLOW);
if (v < 0)
{
gfx->println(F(" N / A"));
}
else
{
char str[32] = {0};
#ifdef RTL8722DM
sprintf(str, "%d", (int)v);
#else
sprintf(str, "%ld", v);
#endif
for (char *p = (str + strlen(str)) - 3; p > str; p -= 3)
{
memmove(p + 1, p, strlen(p) + 1);
*p = ',';
}
while (strlen(str) < ds)
{
memmove(str + 1, str, strlen(str) + 1);
*str = ' ';
}
gfx->println(str);
}
}
int32_t testFillScreen()
{
uint32_t start = micros_start();
// Shortened this tedious test!
gfx->fillScreen(WHITE);
gfx->fillScreen(RED);
gfx->fillScreen(GREEN);
gfx->fillScreen(BLUE);
gfx->fillScreen(BLACK);
return micros() - start;
}
int32_t testText()
{
uint32_t start = micros_start();
gfx->setCursor(0, 0);
gfx->setTextSize(1);
gfx->setTextColor(WHITE, BLACK);
gfx->println(F("Hello World!"));
gfx->setTextSize(2);
gfx->setTextColor(gfx->color565(0xff, 0x00, 0x00));
gfx->print(F("RED "));
gfx->setTextColor(gfx->color565(0x00, 0xff, 0x00));
gfx->print(F("GREEN "));
gfx->setTextColor(gfx->color565(0x00, 0x00, 0xff));
gfx->println(F("BLUE"));
gfx->setTextSize(tsa);
gfx->setTextColor(YELLOW);
gfx->println(1234.56);
gfx->setTextColor(WHITE);
gfx->println((w > 128) ? 0xDEADBEEF : 0xDEADBEE, HEX);
gfx->setTextColor(CYAN, WHITE);
gfx->println(F("Groop,"));
gfx->setTextSize(tsc);
gfx->setTextColor(MAGENTA, WHITE);
gfx->println(F("I implore thee,"));
gfx->setTextSize(1);
gfx->setTextColor(NAVY, WHITE);
gfx->println(F("my foonting turlingdromes."));
gfx->setTextColor(DARKGREEN, WHITE);
gfx->println(F("And hooptiously drangle me"));
gfx->setTextColor(DARKCYAN, WHITE);
gfx->println(F("with crinkly bindlewurdles,"));
gfx->setTextColor(MAROON, WHITE);
gfx->println(F("Or I will rend thee"));
gfx->setTextColor(PURPLE, WHITE);
gfx->println(F("in the gobberwartsb"));
gfx->setTextColor(OLIVE, WHITE);
gfx->println(F("with my blurglecruncheon,"));
gfx->setTextColor(DARKGREY, WHITE);
gfx->println(F("see if I don't!"));
gfx->setTextSize(2);
gfx->setTextColor(RED);
gfx->println(F("Size 2"));
gfx->setTextSize(3);
gfx->setTextColor(ORANGE);
gfx->println(F("Size 3"));
gfx->setTextSize(4);
gfx->setTextColor(YELLOW);
gfx->println(F("Size 4"));
gfx->setTextSize(5);
gfx->setTextColor(GREENYELLOW);
gfx->println(F("Size 5"));
gfx->setTextSize(6);
gfx->setTextColor(GREEN);
gfx->println(F("Size 6"));
gfx->setTextSize(7);
gfx->setTextColor(BLUE);
gfx->println(F("Size 7"));
gfx->setTextSize(8);
gfx->setTextColor(PURPLE);
gfx->println(F("Size 8"));
gfx->setTextSize(9);
gfx->setTextColor(PALERED);
gfx->println(F("Size 9"));
return micros() - start;
}
int32_t testPixels()
{
uint32_t start = micros_start();
for (int16_t y = 0; y < h; y++)
{
for (int16_t x = 0; x < w; x++)
{
gfx->drawPixel(x, y, gfx->color565(x << 3, y << 3, x * y));
}
#ifdef ESP8266
yield(); // avoid long run triggered ESP8266 WDT restart
#endif
}
return micros() - start;
}
int32_t testLines()
{
uint32_t start;
int32_t x1, y1, x2, y2;
start = micros_start();
x1 = y1 = 0;
y2 = h - 1;
for (x2 = 0; x2 < w; x2 += 6)
{
gfx->drawLine(x1, y1, x2, y2, BLUE);
}
#ifdef ESP8266
yield(); // avoid long run triggered ESP8266 WDT restart
#endif
x2 = w - 1;
for (y2 = 0; y2 < h; y2 += 6)
{
gfx->drawLine(x1, y1, x2, y2, BLUE);
}
#ifdef ESP8266
yield(); // avoid long run triggered ESP8266 WDT restart
#endif
x1 = w - 1;
y1 = 0;
y2 = h - 1;
for (x2 = 0; x2 < w; x2 += 6)
{
gfx->drawLine(x1, y1, x2, y2, BLUE);
}
#ifdef ESP8266
yield(); // avoid long run triggered ESP8266 WDT restart
#endif
x2 = 0;
for (y2 = 0; y2 < h; y2 += 6)
{
gfx->drawLine(x1, y1, x2, y2, BLUE);
}
#ifdef ESP8266
yield(); // avoid long run triggered ESP8266 WDT restart
#endif
x1 = 0;
y1 = h - 1;
y2 = 0;
for (x2 = 0; x2 < w; x2 += 6)
{
gfx->drawLine(x1, y1, x2, y2, BLUE);
}
#ifdef ESP8266
yield(); // avoid long run triggered ESP8266 WDT restart
#endif
x2 = w - 1;
for (y2 = 0; y2 < h; y2 += 6)
{
gfx->drawLine(x1, y1, x2, y2, BLUE);
}
#ifdef ESP8266
yield(); // avoid long run triggered ESP8266 WDT restart
#endif
x1 = w - 1;
y1 = h - 1;
y2 = 0;
for (x2 = 0; x2 < w; x2 += 6)
{
gfx->drawLine(x1, y1, x2, y2, BLUE);
}
#ifdef ESP8266
yield(); // avoid long run triggered ESP8266 WDT restart
#endif
x2 = 0;
for (y2 = 0; y2 < h; y2 += 6)
{
gfx->drawLine(x1, y1, x2, y2, BLUE);
}
#ifdef ESP8266
yield(); // avoid long run triggered ESP8266 WDT restart
#endif
return micros() - start;
}
int32_t testFastLines()
{
uint32_t start;
int32_t x, y;
start = micros_start();
for (y = 0; y < h; y += 5)
{
gfx->drawFastHLine(0, y, w, RED);
}
for (x = 0; x < w; x += 5)
{
gfx->drawFastVLine(x, 0, h, BLUE);
}
return micros() - start;
}
int32_t testFilledRects()
{
uint32_t start;
int32_t i, i2;
start = micros_start();
for (i = n; i > 0; i -= 6)
{
i2 = i / 2;
gfx->fillRect(cx - i2, cy - i2, i, i, gfx->color565(i, i, 0));
}
return micros() - start;
}
int32_t testRects()
{
uint32_t start;
int32_t i, i2;
start = micros_start();
for (i = 2; i < n; i += 6)
{
i2 = i / 2;
gfx->drawRect(cx - i2, cy - i2, i, i, GREEN);
}
return micros() - start;
}
int32_t testFilledCircles(uint8_t radius)
{
uint32_t start;
int32_t x, y, r2 = radius * 2;
start = micros_start();
for (x = radius; x < w; x += r2)
{
for (y = radius; y < h; y += r2)
{
gfx->fillCircle(x, y, radius, MAGENTA);
}
}
return micros() - start;
}
int32_t testCircles(uint8_t radius)
{
uint32_t start;
int32_t x, y, r2 = radius * 2;
int32_t w1 = w + radius;
int32_t h1 = h + radius;
// Screen is not cleared for this one -- this is
// intentional and does not affect the reported time.
start = micros_start();
for (x = 0; x < w1; x += r2)
{
for (y = 0; y < h1; y += r2)
{
gfx->drawCircle(x, y, radius, WHITE);
}
}
return micros() - start;
}
int32_t testFillArcs()
{
int16_t i, r = 360 / cn;
uint32_t start = micros_start();
for (i = 6; i < cn; i += 6)
{
gfx->fillArc(cx1, cy1, i, i - 3, 0, i * r, RED);
}
return micros() - start;
}
int32_t testArcs()
{
int16_t i, r = 360 / cn;
uint32_t start = micros_start();
for (i = 6; i < cn; i += 6)
{
gfx->drawArc(cx1, cy1, i, i - 3, 0, i * r, WHITE);
}
return micros() - start;
}
int32_t testFilledTriangles()
{
uint32_t start;
int32_t i;
start = micros_start();
for (i = cn1; i > 10; i -= 5)
{
gfx->fillTriangle(cx1, cy1 - i, cx1 - i, cy1 + i, cx1 + i, cy1 + i,
gfx->color565(0, i, i));
}
return micros() - start;
}
int32_t testTriangles()
{
uint32_t start;
int32_t i;
start = micros_start();
for (i = 0; i < cn; i += 5)
{
gfx->drawTriangle(
cx1, cy1 - i, // peak
cx1 - i, cy1 + i, // bottom left
cx1 + i, cy1 + i, // bottom right
gfx->color565(0, 0, i));
}
return micros() - start;
}
int32_t testFilledRoundRects()
{
uint32_t start;
int32_t i, i2;
start = micros_start();
for (i = n1; i > 20; i -= 6)
{
i2 = i / 2;
gfx->fillRoundRect(cx - i2, cy - i2, i, i, i / 8, gfx->color565(0, i, 0));
}
return micros() - start;
}
int32_t testRoundRects()
{
uint32_t start;
int32_t i, i2;
start = micros_start();
for (i = 20; i < n1; i += 6)
{
i2 = i / 2;
gfx->drawRoundRect(cx - i2, cy - i2, i, i, i / 8, gfx->color565(i, 0, 0));
}
return micros() - start;
}
/***************************************************
Original sketch text:
This is an example sketch for the Adafruit 2.2" SPI display.
This library works with the Adafruit 2.2" TFT Breakout w/SD card
----> http://www.adafruit.com/products/1480
Check out the links above for our tutorials and wiring diagrams
These displays use SPI to communicate, 4 or 5 pins are required to
interface (RST is optional)
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
MIT license, all text above must be included in any redistribution
****************************************************/

View File

@ -0,0 +1,84 @@
/*******************************************************************************
* Start of Arduino_GFX setting
*
* Arduino_GFX try to find the settings depends on selected board in Arduino IDE
* Or you can define the display dev kit not in the board list
* Defalult pin list for non display dev kit:
* Arduino Nano, Micro and more: CS: 9, DC: 8, RST: 7, BL: 6, SCK: 13, MOSI: 11, MISO: 12
* ESP32 various dev board : CS: 5, DC: 27, RST: 33, BL: 22, SCK: 18, MOSI: 23, MISO: nil
* ESP32-C3 various dev board : CS: 7, DC: 2, RST: 1, BL: 3, SCK: 4, MOSI: 6, MISO: nil
* ESP32-S2 various dev board : CS: 34, DC: 38, RST: 33, BL: 21, SCK: 36, MOSI: 35, MISO: nil
* ESP32-S3 various dev board : CS: 40, DC: 41, RST: 42, BL: 48, SCK: 36, MOSI: 35, MISO: nil
* ESP8266 various dev board : CS: 15, DC: 4, RST: 2, BL: 5, SCK: 14, MOSI: 13, MISO: 12
* Raspberry Pi Pico dev board : CS: 17, DC: 27, RST: 26, BL: 28, SCK: 18, MOSI: 19, MISO: 16
* RTL8720 BW16 old patch core : CS: 18, DC: 17, RST: 2, BL: 23, SCK: 19, MOSI: 21, MISO: 20
* RTL8720_BW16 Official core : CS: 9, DC: 8, RST: 6, BL: 3, SCK: 10, MOSI: 12, MISO: 11
* RTL8722 dev board : CS: 18, DC: 17, RST: 22, BL: 23, SCK: 13, MOSI: 11, MISO: 12
* RTL8722_mini dev board : CS: 12, DC: 14, RST: 15, BL: 13, SCK: 11, MOSI: 9, MISO: 10
* Seeeduino XIAO dev board : CS: 3, DC: 2, RST: 1, BL: 0, SCK: 8, MOSI: 10, MISO: 9
* Teensy 4.1 dev board : CS: 39, DC: 41, RST: 40, BL: 22, SCK: 13, MOSI: 11, MISO: 12
******************************************************************************/
#include <Arduino_GFX_Library.h>
#define GFX_BL DF_GFX_BL // default backlight pin, you may replace DF_GFX_BL to actual backlight pin
/* More dev device declaration: https://github.com/moononournation/Arduino_GFX/wiki/Dev-Device-Declaration */
#if defined(DISPLAY_DEV_KIT)
Arduino_GFX *gfx = create_default_Arduino_GFX();
#else /* !defined(DISPLAY_DEV_KIT) */
/* More data bus class: https://github.com/moononournation/Arduino_GFX/wiki/Data-Bus-Class */
Arduino_DataBus *bus = create_default_Arduino_DataBus();
/* More display class: https://github.com/moononournation/Arduino_GFX/wiki/Display-Class */
Arduino_GFX *gfx = new Arduino_ILI9341(bus, DF_GFX_RST, 0 /* rotation */, false /* IPS */);
#endif /* !defined(DISPLAY_DEV_KIT) */
/*******************************************************************************
* End of Arduino_GFX setting
******************************************************************************/
void setup(void)
{
Serial.begin(115200);
// Serial.setDebugOutput(true);
// while(!Serial);
Serial.println("Arduino_GFX Set Text Bound example");
#ifdef GFX_EXTRA_PRE_INIT
GFX_EXTRA_PRE_INIT();
#endif
// Init Display
if (!gfx->begin())
{
Serial.println("gfx->begin() failed!");
}
gfx->fillScreen(BLACK);
#ifdef GFX_BL
pinMode(GFX_BL, OUTPUT);
digitalWrite(GFX_BL, HIGH);
#endif
gfx->drawRect(16, 16, 120, 90, WHITE);
gfx->setTextBound(18, 18, 116, 86);
// gfx->setTextWrap(false);
// gfx->setTextSize(3, 3, 1);
gfx->setCursor(30, 18);
gfx->setTextColor(WHITE);
gfx->println("Arduino has over the years released over 100 hardware products: boards, shields, carriers, kits and other accessories. In this page, you will find an overview of all active Arduino hardware, including the Nano, MKR and Classic families.");
delay(5000); // 5 seconds
}
void loop()
{
gfx->fillRect(18, 18, 116, 86, BLACK);
gfx->setCursor(30, 18);
gfx->setTextColor(random(0xffff), random(0xffff));
gfx->setTextSize(random(6) /* x scale */, random(6) /* y scale */, random(2) /* pixel_margin */);
gfx->println("Arduino has over the years released over 100 hardware products: boards, shields, carriers, kits and other accessories. In this page, you will find an overview of all active Arduino hardware, including the Nano, MKR and Classic families.");
delay(1000); // 1 second
}

View File

@ -1,6 +1,6 @@
/*******************************************************************************
* GIFDEC Wrapper Class
*
*
* Rewrite from: https://github.com/BasementCat/arduino-tft-gif
******************************************************************************/
#ifndef _GIFCLASS_H_
@ -29,7 +29,7 @@
typedef struct gd_Palette
{
uint8_t size;
int16_t len;
uint16_t colors[256];
} gd_Palette;
@ -44,7 +44,7 @@ typedef struct gd_GCE
typedef struct gd_Entry
{
int32_t length;
int32_t len;
uint16_t prefix;
uint8_t suffix;
} gd_Entry;
@ -75,6 +75,7 @@ typedef struct gd_GIF
uint16_t fx, fy, fw, fh;
uint8_t bgindex;
gd_Table *table;
bool read_first_frame;
} gd_GIF;
class GifClass
@ -85,7 +86,7 @@ public:
uint8_t sigver[3];
uint16_t width, height, depth;
uint8_t fdsz, bgidx, aspect;
int32_t gct_sz;
int16_t gct_sz;
gd_GIF *gif;
// init global variables
@ -139,6 +140,7 @@ public:
gif->bgindex = bgidx;
gif->anim_start = file_pos; // fd->position();
gif->table = new_table();
gif->read_first_frame = false;
return gif;
}
@ -254,11 +256,11 @@ private:
return gif_buf_read(fd) + (((uint16_t)gif_buf_read(fd)) << 8);
}
void read_palette(File *fd, gd_Palette *dest, int32_t num_colors)
void read_palette(File *fd, gd_Palette *dest, int16_t num_colors)
{
uint8_t r, g, b;
dest->size = num_colors;
for (int32_t i = 0; i < num_colors; i++)
dest->len = num_colors;
for (int16_t i = 0; i < num_colors; i++)
{
r = gif_buf_read(fd);
g = gif_buf_read(fd);
@ -269,13 +271,13 @@ private:
void discard_sub_blocks(gd_GIF *gif)
{
uint8_t size;
uint8_t len;
do
{
gif_buf_read(gif->fd, &size, 1);
gif_buf_seek(gif->fd, size);
} while (size);
gif_buf_read(gif->fd, &len, 1);
gif_buf_seek(gif->fd, len);
} while (len);
}
void read_plain_text_ext(gd_GIF *gif)
@ -424,10 +426,10 @@ private:
}
/* Add table entry. Return value:
* 0 on success
* +1 if key size must be incremented after this addition
* -1 if could not realloc table */
int32_t add_entry(gd_Table *table, int32_t length, uint16_t prefix, uint8_t suffix)
* 0 on success
* +1 if key size must be incremented after this addition
* -1 if could not realloc table */
int32_t add_entry(gd_Table *table, int32_t len, uint16_t prefix, uint8_t suffix)
{
// Table *table = *tablep;
// if (table->nentries == table->bulk) {
@ -437,7 +439,7 @@ private:
// table->entries = (Entry *) &table[1];
// *tablep = table;
// }
table->entries[table->nentries] = (gd_Entry){length, prefix, suffix};
table->entries[table->nentries] = (gd_Entry){len, prefix, suffix};
table->nentries++;
if ((table->nentries & (table->nentries - 1)) == 0)
return 1;
@ -494,7 +496,7 @@ private:
}
/* Decompress image pixels.
* Return 0 on success or -1 on out-of-memory (w.r.t. LZW code table). */
* Return 0 on success or -1 on out-of-memory (w.r.t. LZW code table). */
int8_t read_image_data(gd_GIF *gif, int16_t interlace, uint8_t *frame)
{
uint8_t sub_len, shift, byte, table_is_full = 0;
@ -558,19 +560,19 @@ private:
if (ret == 1)
key_size++;
entry = gif->table->entries[key];
str_len = entry.length;
str_len = entry.len;
uint8_t tindex = gif->gce.tindex;
// Serial.println("Interpret key");
while (1)
{
p = frm_off + entry.length - 1;
p = frm_off + entry.len - 1;
x = p % gif->fw;
y = p / gif->fw;
if (interlace)
{
y = interlaced_line_index((int16_t)gif->fh, y);
}
if (tindex != entry.suffix)
if ((!gif->read_first_frame) || (tindex != entry.suffix))
{
frame[(gif->fy + y) * gif->width + gif->fx + x] = entry.suffix;
}
@ -587,11 +589,14 @@ private:
// free(table);
gif_buf_read(gif->fd, &sub_len, 1); /* Must be zero! */
// gif_buf_seek(gif->fd, end, SeekSet);
gif->read_first_frame = true;
return 0;
}
/* Read image.
* Return 0 on success or -1 on out-of-memory (w.r.t. LZW code table). */
* Return 0 on success or -1 on out-of-memory (w.r.t. LZW code table). */
int8_t read_image(gd_GIF *gif, uint8_t *frame)
{
uint8_t fisrz;
@ -635,8 +640,10 @@ private:
{
index = frame[(gif->fy + j) * gif->width + gif->fx + k];
// color = &gif->palette->colors[index*2];
// if (!gif->gce.transparency || index != gif->gce.tindex)
if ((!gif->gce.transparency) || (index != gif->gce.tindex))
{
buffer[(i + k)] = gif->palette->colors[index];
}
// memcpy(&buffer[(i+k)*2], color, 2);
}
i += gif->width;

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