first commit
This commit is contained in:
commit
e6a42e28e9
4355 changed files with 4626605 additions and 0 deletions
|
|
@ -0,0 +1,756 @@
|
|||
/*
|
||||
Adapted from the Adafruit and Xark's PDQ graphicstest sketch.
|
||||
|
||||
See end of file for original header text and MIT license info.
|
||||
|
||||
This sketch uses the GLCD font only.
|
||||
|
||||
*/
|
||||
|
||||
#include <LGFX_TFT_eSPI.hpp>
|
||||
//#include <TFT_eSPI.h>
|
||||
|
||||
#ifdef min
|
||||
#undef min
|
||||
#endif
|
||||
#ifdef max
|
||||
#undef max
|
||||
#endif
|
||||
#include <algorithm>
|
||||
|
||||
static TFT_eSPI tft;
|
||||
|
||||
unsigned long total = 0;
|
||||
unsigned long tn = 0;
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
Serial.println(""); Serial.println("");
|
||||
Serial.println("Lovyan's LovyanGFX library Test!");
|
||||
|
||||
tft.init();
|
||||
tft.setRotation(0);
|
||||
tft.startWrite();
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
|
||||
Serial.println(F("Benchmark Time (microseconds)"));
|
||||
|
||||
uint32_t usecHaD = testHaD();
|
||||
Serial.print(F("HaD pushColor "));
|
||||
Serial.println(usecHaD);
|
||||
delay(100);
|
||||
|
||||
uint32_t usecFillScreen = testFillScreen();
|
||||
Serial.print(F("Screen fill "));
|
||||
Serial.println(usecFillScreen);
|
||||
delay(100);
|
||||
|
||||
uint32_t usecText = testText();
|
||||
Serial.print(F("Text "));
|
||||
Serial.println(usecText);
|
||||
delay(100);
|
||||
|
||||
uint32_t usecPixels = testPixels();
|
||||
Serial.print(F("Pixels "));
|
||||
Serial.println(usecPixels);
|
||||
delay(100);
|
||||
|
||||
uint32_t usecLines = testLines(TFT_BLUE);
|
||||
Serial.print(F("Lines "));
|
||||
Serial.println(usecLines);
|
||||
delay(100);
|
||||
|
||||
uint32_t usecFastLines = testFastLines(TFT_RED, TFT_BLUE);
|
||||
Serial.print(F("Horiz/Vert Lines "));
|
||||
Serial.println(usecFastLines);
|
||||
delay(100);
|
||||
|
||||
uint32_t usecRects = testRects(TFT_GREEN);
|
||||
Serial.print(F("Rectangles (outline) "));
|
||||
Serial.println(usecRects);
|
||||
delay(100);
|
||||
|
||||
uint32_t usecFilledRects = testFilledRects(TFT_YELLOW, TFT_MAGENTA);
|
||||
Serial.print(F("Rectangles (filled) "));
|
||||
Serial.println(usecFilledRects);
|
||||
delay(100);
|
||||
|
||||
uint32_t usecFilledCircles = testFilledCircles(10, TFT_MAGENTA);
|
||||
Serial.print(F("Circles (filled) "));
|
||||
Serial.println(usecFilledCircles);
|
||||
delay(100);
|
||||
|
||||
uint32_t usecCircles = testCircles(10, TFT_WHITE);
|
||||
Serial.print(F("Circles (outline) "));
|
||||
Serial.println(usecCircles);
|
||||
delay(100);
|
||||
|
||||
uint32_t usecTriangles = testTriangles();
|
||||
Serial.print(F("Triangles (outline) "));
|
||||
Serial.println(usecTriangles);
|
||||
delay(100);
|
||||
|
||||
uint32_t usecFilledTrangles = testFilledTriangles();
|
||||
Serial.print(F("Triangles (filled) "));
|
||||
Serial.println(usecFilledTrangles);
|
||||
delay(100);
|
||||
|
||||
uint32_t usecRoundRects = testRoundRects();
|
||||
Serial.print(F("Rounded rects (outline) "));
|
||||
Serial.println(usecRoundRects);
|
||||
delay(100);
|
||||
|
||||
uint32_t usedFilledRoundRects = testFilledRoundRects();
|
||||
Serial.print(F("Rounded rects (filled) "));
|
||||
Serial.println(usedFilledRoundRects);
|
||||
delay(100);
|
||||
|
||||
Serial.println(F("Done!"));
|
||||
|
||||
uint16_t c = 4;
|
||||
int8_t d = 1;
|
||||
for (int32_t i = 0; i < tft.height(); i++)
|
||||
{
|
||||
tft.drawFastHLine(0, i, tft.width(), c);
|
||||
c += d;
|
||||
if (c <= 4 || c >= 11)
|
||||
d = -d;
|
||||
}
|
||||
|
||||
tft.setCursor(0, 0);
|
||||
tft.setTextColor(TFT_MAGENTA);
|
||||
tft.setTextSize(2);
|
||||
|
||||
tft.println(F(" LovyanGFX test"));
|
||||
|
||||
tft.setTextSize(1);
|
||||
tft.setTextColor(TFT_WHITE);
|
||||
tft.println(F(""));
|
||||
tft.setTextSize(1);
|
||||
tft.println(F(""));
|
||||
tft.setTextColor(tft.color565(0x80, 0x80, 0x80));
|
||||
|
||||
tft.println(F(""));
|
||||
|
||||
|
||||
tft.setTextColor(TFT_GREEN);
|
||||
tft.println(F(" Benchmark microseconds"));
|
||||
tft.println(F(""));
|
||||
tft.setTextColor(TFT_YELLOW);
|
||||
|
||||
tft.setTextColor(TFT_CYAN); tft.setTextSize(1);
|
||||
tft.print(F("HaD pushColor "));
|
||||
tft.setTextColor(TFT_YELLOW); tft.setTextSize(2);
|
||||
printnice(usecHaD);
|
||||
|
||||
tft.setTextColor(TFT_CYAN); tft.setTextSize(1);
|
||||
tft.print(F("Screen fill "));
|
||||
tft.setTextColor(TFT_YELLOW); tft.setTextSize(2);
|
||||
printnice(usecFillScreen);
|
||||
|
||||
tft.setTextColor(TFT_CYAN); tft.setTextSize(1);
|
||||
tft.print(F("Text "));
|
||||
tft.setTextColor(TFT_YELLOW); tft.setTextSize(2);
|
||||
printnice(usecText);
|
||||
|
||||
tft.setTextColor(TFT_CYAN); tft.setTextSize(1);
|
||||
tft.print(F("Pixels "));
|
||||
tft.setTextColor(TFT_YELLOW); tft.setTextSize(2);
|
||||
printnice(usecPixels);
|
||||
|
||||
tft.setTextColor(TFT_CYAN); tft.setTextSize(1);
|
||||
tft.print(F("Lines "));
|
||||
tft.setTextColor(TFT_YELLOW); tft.setTextSize(2);
|
||||
printnice(usecLines);
|
||||
|
||||
tft.setTextColor(TFT_CYAN); tft.setTextSize(1);
|
||||
tft.print(F("Horiz/Vert Lines "));
|
||||
tft.setTextColor(TFT_YELLOW); tft.setTextSize(2);
|
||||
printnice(usecFastLines);
|
||||
|
||||
tft.setTextColor(TFT_CYAN); tft.setTextSize(1);
|
||||
tft.print(F("Rectangles "));
|
||||
tft.setTextColor(TFT_YELLOW); tft.setTextSize(2);
|
||||
printnice(usecRects);
|
||||
|
||||
tft.setTextColor(TFT_CYAN); tft.setTextSize(1);
|
||||
tft.print(F("Rectangles-filled "));
|
||||
tft.setTextColor(TFT_YELLOW); tft.setTextSize(2);
|
||||
printnice(usecFilledRects);
|
||||
|
||||
tft.setTextColor(TFT_CYAN); tft.setTextSize(1);
|
||||
tft.print(F("Circles "));
|
||||
tft.setTextColor(TFT_YELLOW); tft.setTextSize(2);
|
||||
printnice(usecCircles);
|
||||
|
||||
tft.setTextColor(TFT_CYAN); tft.setTextSize(1);
|
||||
tft.print(F("Circles-filled "));
|
||||
tft.setTextColor(TFT_YELLOW); tft.setTextSize(2);
|
||||
printnice(usecFilledCircles);
|
||||
|
||||
tft.setTextColor(TFT_CYAN); tft.setTextSize(1);
|
||||
tft.print(F("Triangles "));
|
||||
tft.setTextColor(TFT_YELLOW); tft.setTextSize(2);
|
||||
printnice(usecTriangles);
|
||||
|
||||
tft.setTextColor(TFT_CYAN); tft.setTextSize(1);
|
||||
tft.print(F("Triangles-filled "));
|
||||
tft.setTextColor(TFT_YELLOW); tft.setTextSize(2);
|
||||
printnice(usecFilledTrangles);
|
||||
|
||||
tft.setTextColor(TFT_CYAN); tft.setTextSize(1);
|
||||
tft.print(F("Rounded rects "));
|
||||
tft.setTextColor(TFT_YELLOW); tft.setTextSize(2);
|
||||
printnice(usecRoundRects);
|
||||
|
||||
tft.setTextColor(TFT_CYAN); tft.setTextSize(1);
|
||||
tft.print(F("Rounded rects-fill "));
|
||||
tft.setTextColor(TFT_YELLOW); tft.setTextSize(2);
|
||||
printnice(usedFilledRoundRects);
|
||||
|
||||
tft.setTextSize(1);
|
||||
tft.println(F(""));
|
||||
tft.setTextColor(TFT_GREEN); tft.setTextSize(2);
|
||||
tft.print(F("Benchmark Complete!"));
|
||||
|
||||
delay(60 * 1000L);
|
||||
}
|
||||
|
||||
void printnice(int32_t v)
|
||||
{
|
||||
char str[32] = { 0 };
|
||||
sprintf(str, "%d", v);
|
||||
for (char *p = (str+strlen(str))-3; p > str; p -= 3)
|
||||
{
|
||||
memmove(p+1, p, strlen(p)+1);
|
||||
*p = ',';
|
||||
|
||||
}
|
||||
while (strlen(str) < 10)
|
||||
{
|
||||
memmove(str+1, str, strlen(str)+1);
|
||||
*str = ' ';
|
||||
}
|
||||
tft.println(str);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
uint32_t testHaD()
|
||||
{
|
||||
// pseudo-code for cheesy RLE
|
||||
// start with color1
|
||||
// while more input data remaining
|
||||
// count = 0nnnnnnn = 1 byte or 1nnnnnnn nnnnnnnn 2 bytes (0 - 32767)
|
||||
// repeat color count times
|
||||
// toggle color1/color2
|
||||
static const uint8_t HaD_240x320[] PROGMEM =
|
||||
{
|
||||
0xb9, 0x50, 0x0e, 0x80, 0x93, 0x0e, 0x41, 0x11, 0x80, 0x8d, 0x11, 0x42, 0x12, 0x80, 0x89, 0x12,
|
||||
0x45, 0x12, 0x80, 0x85, 0x12, 0x48, 0x12, 0x80, 0x83, 0x12, 0x4a, 0x13, 0x7f, 0x13, 0x4c, 0x13,
|
||||
0x7d, 0x13, 0x4e, 0x13, 0x7b, 0x13, 0x50, 0x13, 0x79, 0x13, 0x52, 0x13, 0x77, 0x13, 0x54, 0x13,
|
||||
0x75, 0x13, 0x57, 0x11, 0x75, 0x11, 0x5a, 0x11, 0x73, 0x11, 0x5c, 0x11, 0x71, 0x11, 0x5e, 0x10,
|
||||
0x71, 0x10, 0x60, 0x10, 0x6f, 0x10, 0x61, 0x10, 0x6f, 0x10, 0x60, 0x11, 0x6f, 0x11, 0x5e, 0x13,
|
||||
0x6d, 0x13, 0x5c, 0x14, 0x6d, 0x14, 0x5a, 0x15, 0x6d, 0x15, 0x58, 0x17, 0x6b, 0x17, 0x37, 0x01,
|
||||
0x1f, 0x17, 0x6b, 0x17, 0x1f, 0x01, 0x17, 0x02, 0x1d, 0x18, 0x6b, 0x18, 0x1d, 0x02, 0x17, 0x03,
|
||||
0x1b, 0x19, 0x6b, 0x19, 0x1b, 0x03, 0x17, 0x05, 0x18, 0x1a, 0x6b, 0x1a, 0x18, 0x05, 0x17, 0x06,
|
||||
0x16, 0x1b, 0x6b, 0x1b, 0x16, 0x06, 0x17, 0x07, 0x14, 0x1c, 0x6b, 0x1c, 0x14, 0x07, 0x17, 0x08,
|
||||
0x12, 0x1d, 0x6b, 0x1d, 0x12, 0x08, 0x17, 0x09, 0x10, 0x1e, 0x6b, 0x1e, 0x10, 0x09, 0x17, 0x0a,
|
||||
0x0e, 0x1f, 0x6b, 0x1f, 0x0e, 0x0a, 0x17, 0x0b, 0x0c, 0x20, 0x6b, 0x20, 0x0c, 0x0b, 0x17, 0x0c,
|
||||
0x0b, 0x21, 0x69, 0x21, 0x0b, 0x0c, 0x18, 0x0d, 0x08, 0x23, 0x67, 0x23, 0x08, 0x0d, 0x19, 0x0e,
|
||||
0x06, 0x26, 0x63, 0x26, 0x06, 0x0e, 0x19, 0x0f, 0x04, 0x28, 0x61, 0x28, 0x04, 0x0f, 0x19, 0x10,
|
||||
0x02, 0x2a, 0x5f, 0x2a, 0x02, 0x10, 0x1a, 0x3c, 0x5d, 0x3c, 0x1b, 0x3d, 0x5b, 0x3d, 0x1c, 0x3d,
|
||||
0x59, 0x3d, 0x1d, 0x3e, 0x57, 0x3e, 0x1e, 0x3e, 0x55, 0x3e, 0x1f, 0x40, 0x51, 0x40, 0x20, 0x40,
|
||||
0x4f, 0x40, 0x22, 0x40, 0x22, 0x09, 0x22, 0x40, 0x24, 0x40, 0x1a, 0x17, 0x1a, 0x40, 0x26, 0x40,
|
||||
0x16, 0x1d, 0x16, 0x40, 0x28, 0x40, 0x12, 0x23, 0x12, 0x40, 0x2a, 0x40, 0x0f, 0x27, 0x0f, 0x40,
|
||||
0x2c, 0x41, 0x0b, 0x2b, 0x0b, 0x41, 0x2f, 0x3f, 0x09, 0x2f, 0x09, 0x3f, 0x32, 0x3d, 0x08, 0x33,
|
||||
0x08, 0x3d, 0x35, 0x3a, 0x08, 0x35, 0x08, 0x3a, 0x3a, 0x36, 0x07, 0x39, 0x07, 0x36, 0x41, 0x09,
|
||||
0x05, 0x23, 0x07, 0x3b, 0x07, 0x23, 0x05, 0x09, 0x54, 0x21, 0x07, 0x3d, 0x07, 0x21, 0x64, 0x1f,
|
||||
0x06, 0x41, 0x06, 0x1f, 0x66, 0x1d, 0x06, 0x43, 0x06, 0x1d, 0x68, 0x1b, 0x06, 0x45, 0x06, 0x1b,
|
||||
0x6b, 0x18, 0x06, 0x47, 0x06, 0x18, 0x6e, 0x16, 0x06, 0x49, 0x06, 0x16, 0x70, 0x14, 0x06, 0x4b,
|
||||
0x06, 0x14, 0x72, 0x13, 0x06, 0x4b, 0x06, 0x13, 0x74, 0x11, 0x06, 0x4d, 0x06, 0x11, 0x76, 0x0f,
|
||||
0x06, 0x4f, 0x06, 0x0f, 0x78, 0x0e, 0x05, 0x51, 0x05, 0x0e, 0x7a, 0x0c, 0x06, 0x51, 0x06, 0x0c,
|
||||
0x7d, 0x09, 0x06, 0x53, 0x06, 0x09, 0x80, 0x80, 0x08, 0x05, 0x55, 0x05, 0x08, 0x80, 0x82, 0x06,
|
||||
0x05, 0x57, 0x05, 0x06, 0x80, 0x84, 0x05, 0x05, 0x57, 0x05, 0x05, 0x80, 0x86, 0x03, 0x05, 0x59,
|
||||
0x05, 0x03, 0x80, 0x88, 0x02, 0x05, 0x59, 0x05, 0x02, 0x80, 0x8f, 0x5b, 0x80, 0x95, 0x5b, 0x80,
|
||||
0x94, 0x5d, 0x80, 0x93, 0x5d, 0x80, 0x92, 0x5e, 0x80, 0x92, 0x5f, 0x80, 0x91, 0x5f, 0x80, 0x90,
|
||||
0x61, 0x80, 0x8f, 0x61, 0x80, 0x8f, 0x61, 0x80, 0x8e, 0x63, 0x80, 0x8d, 0x63, 0x80, 0x8d, 0x63,
|
||||
0x80, 0x8d, 0x63, 0x80, 0x8c, 0x19, 0x07, 0x25, 0x07, 0x19, 0x80, 0x8b, 0x16, 0x0d, 0x1f, 0x0d,
|
||||
0x16, 0x80, 0x8b, 0x14, 0x11, 0x1b, 0x11, 0x14, 0x80, 0x8b, 0x13, 0x13, 0x19, 0x13, 0x13, 0x80,
|
||||
0x8b, 0x12, 0x15, 0x17, 0x15, 0x12, 0x80, 0x8a, 0x12, 0x17, 0x15, 0x17, 0x12, 0x80, 0x89, 0x11,
|
||||
0x19, 0x13, 0x19, 0x11, 0x80, 0x89, 0x11, 0x19, 0x13, 0x19, 0x11, 0x80, 0x89, 0x10, 0x1b, 0x11,
|
||||
0x1b, 0x10, 0x80, 0x89, 0x0f, 0x1c, 0x11, 0x1c, 0x0f, 0x80, 0x89, 0x0f, 0x1c, 0x11, 0x1c, 0x0f,
|
||||
0x80, 0x89, 0x0f, 0x1c, 0x11, 0x1c, 0x0f, 0x80, 0x89, 0x0e, 0x1d, 0x11, 0x1d, 0x0e, 0x80, 0x89,
|
||||
0x0e, 0x1c, 0x13, 0x1c, 0x0e, 0x80, 0x89, 0x0e, 0x1b, 0x15, 0x1b, 0x0e, 0x80, 0x89, 0x0e, 0x1b,
|
||||
0x15, 0x1b, 0x0e, 0x80, 0x89, 0x0e, 0x1a, 0x17, 0x1a, 0x0e, 0x80, 0x89, 0x0e, 0x18, 0x1b, 0x18,
|
||||
0x0e, 0x80, 0x89, 0x0e, 0x16, 0x1f, 0x16, 0x0e, 0x80, 0x89, 0x0e, 0x14, 0x23, 0x14, 0x0e, 0x80,
|
||||
0x89, 0x0f, 0x11, 0x27, 0x11, 0x0f, 0x80, 0x89, 0x0f, 0x0e, 0x2d, 0x0e, 0x0f, 0x80, 0x89, 0x0f,
|
||||
0x0c, 0x31, 0x0c, 0x0f, 0x80, 0x89, 0x0f, 0x0b, 0x33, 0x0b, 0x0f, 0x80, 0x8a, 0x0f, 0x09, 0x35,
|
||||
0x09, 0x0f, 0x80, 0x8b, 0x10, 0x08, 0x35, 0x08, 0x10, 0x80, 0x8b, 0x10, 0x07, 0x37, 0x07, 0x10,
|
||||
0x80, 0x8b, 0x11, 0x06, 0x37, 0x06, 0x11, 0x80, 0x8b, 0x12, 0x05, 0x37, 0x05, 0x12, 0x80, 0x8c,
|
||||
0x13, 0x03, 0x1b, 0x01, 0x1b, 0x03, 0x13, 0x80, 0x8d, 0x30, 0x03, 0x30, 0x80, 0x8d, 0x30, 0x04,
|
||||
0x2f, 0x80, 0x8d, 0x2f, 0x05, 0x2f, 0x80, 0x8e, 0x2e, 0x06, 0x2d, 0x80, 0x8f, 0x2d, 0x07, 0x2d,
|
||||
0x80, 0x8f, 0x2d, 0x07, 0x2d, 0x80, 0x90, 0x2c, 0x08, 0x2b, 0x80, 0x91, 0x2b, 0x09, 0x2b, 0x80,
|
||||
0x8c, 0x01, 0x05, 0x2a, 0x09, 0x2a, 0x05, 0x01, 0x80, 0x85, 0x03, 0x05, 0x2a, 0x09, 0x2a, 0x05,
|
||||
0x03, 0x80, 0x82, 0x04, 0x05, 0x2a, 0x09, 0x2a, 0x04, 0x05, 0x80, 0x80, 0x06, 0x05, 0x29, 0x04,
|
||||
0x02, 0x03, 0x29, 0x05, 0x06, 0x7e, 0x07, 0x05, 0x29, 0x03, 0x03, 0x03, 0x29, 0x05, 0x07, 0x7c,
|
||||
0x09, 0x05, 0x28, 0x02, 0x05, 0x02, 0x28, 0x05, 0x09, 0x7a, 0x0a, 0x05, 0x28, 0x02, 0x05, 0x02,
|
||||
0x28, 0x05, 0x0a, 0x78, 0x0c, 0x05, 0x27, 0x02, 0x05, 0x02, 0x27, 0x05, 0x0c, 0x76, 0x0d, 0x06,
|
||||
0x26, 0x01, 0x07, 0x01, 0x26, 0x06, 0x0d, 0x73, 0x10, 0x05, 0x55, 0x05, 0x10, 0x70, 0x12, 0x05,
|
||||
0x53, 0x05, 0x12, 0x6e, 0x13, 0x06, 0x51, 0x06, 0x13, 0x6c, 0x15, 0x05, 0x51, 0x05, 0x15, 0x6a,
|
||||
0x16, 0x06, 0x4f, 0x06, 0x16, 0x68, 0x18, 0x06, 0x4d, 0x06, 0x18, 0x66, 0x1a, 0x06, 0x4b, 0x06,
|
||||
0x1a, 0x64, 0x1c, 0x06, 0x49, 0x06, 0x1c, 0x55, 0x07, 0x05, 0x1e, 0x06, 0x49, 0x06, 0x1e, 0x05,
|
||||
0x07, 0x42, 0x30, 0x06, 0x47, 0x06, 0x30, 0x3a, 0x34, 0x06, 0x45, 0x06, 0x34, 0x35, 0x37, 0x06,
|
||||
0x43, 0x06, 0x37, 0x32, 0x39, 0x07, 0x3f, 0x07, 0x39, 0x2f, 0x3c, 0x07, 0x3d, 0x07, 0x3c, 0x2c,
|
||||
0x3e, 0x07, 0x3b, 0x07, 0x3e, 0x2a, 0x40, 0x06, 0x3b, 0x06, 0x40, 0x28, 0x40, 0x06, 0x3c, 0x07,
|
||||
0x40, 0x26, 0x3f, 0x08, 0x3d, 0x08, 0x3f, 0x24, 0x3f, 0x09, 0x3d, 0x09, 0x3f, 0x22, 0x3f, 0x0a,
|
||||
0x14, 0x01, 0x13, 0x02, 0x13, 0x0a, 0x3f, 0x20, 0x3f, 0x0b, 0x14, 0x01, 0x13, 0x02, 0x13, 0x0b,
|
||||
0x3f, 0x1f, 0x3e, 0x0c, 0x14, 0x01, 0x13, 0x02, 0x13, 0x0c, 0x3e, 0x1e, 0x3e, 0x0d, 0x13, 0x02,
|
||||
0x13, 0x02, 0x13, 0x0d, 0x3e, 0x1d, 0x3d, 0x0e, 0x13, 0x02, 0x13, 0x02, 0x13, 0x0e, 0x3d, 0x1c,
|
||||
0x3c, 0x11, 0x11, 0x04, 0x11, 0x04, 0x11, 0x11, 0x3c, 0x1b, 0x10, 0x01, 0x2a, 0x12, 0x11, 0x04,
|
||||
0x11, 0x04, 0x11, 0x12, 0x2a, 0x01, 0x10, 0x1a, 0x0f, 0x04, 0x28, 0x14, 0x0f, 0x06, 0x0f, 0x06,
|
||||
0x0f, 0x14, 0x28, 0x04, 0x0f, 0x19, 0x0e, 0x06, 0x26, 0x16, 0x0d, 0x08, 0x0d, 0x08, 0x0d, 0x16,
|
||||
0x26, 0x06, 0x0e, 0x19, 0x0d, 0x07, 0x25, 0x18, 0x0b, 0x0a, 0x0b, 0x0a, 0x0b, 0x18, 0x25, 0x07,
|
||||
0x0d, 0x19, 0x0c, 0x09, 0x23, 0x1c, 0x06, 0x0f, 0x05, 0x10, 0x05, 0x1c, 0x23, 0x09, 0x0c, 0x18,
|
||||
0x0c, 0x0b, 0x21, 0x69, 0x21, 0x0b, 0x0c, 0x17, 0x0b, 0x0d, 0x1f, 0x6b, 0x1f, 0x0d, 0x0b, 0x17,
|
||||
0x0a, 0x0f, 0x1e, 0x6b, 0x1e, 0x0f, 0x0a, 0x17, 0x09, 0x11, 0x1d, 0x6b, 0x1d, 0x11, 0x09, 0x17,
|
||||
0x07, 0x14, 0x1c, 0x6b, 0x1c, 0x14, 0x07, 0x17, 0x06, 0x16, 0x1b, 0x6b, 0x1b, 0x16, 0x06, 0x17,
|
||||
0x05, 0x18, 0x1a, 0x6b, 0x1a, 0x18, 0x05, 0x17, 0x04, 0x1a, 0x19, 0x6b, 0x19, 0x1a, 0x04, 0x17,
|
||||
0x03, 0x1b, 0x19, 0x6b, 0x19, 0x1b, 0x03, 0x17, 0x02, 0x1d, 0x18, 0x6b, 0x18, 0x1d, 0x02, 0x37,
|
||||
0x17, 0x6b, 0x17, 0x58, 0x16, 0x6b, 0x16, 0x5a, 0x14, 0x6d, 0x14, 0x5c, 0x13, 0x6d, 0x13, 0x5e,
|
||||
0x12, 0x6d, 0x12, 0x60, 0x10, 0x6f, 0x10, 0x61, 0x10, 0x6f, 0x10, 0x60, 0x11, 0x6f, 0x11, 0x5e,
|
||||
0x11, 0x71, 0x11, 0x5c, 0x12, 0x71, 0x12, 0x5a, 0x12, 0x73, 0x12, 0x58, 0x12, 0x75, 0x12, 0x56,
|
||||
0x13, 0x75, 0x13, 0x54, 0x13, 0x77, 0x13, 0x51, 0x14, 0x79, 0x14, 0x4e, 0x14, 0x7b, 0x14, 0x4c,
|
||||
0x14, 0x7d, 0x14, 0x4a, 0x14, 0x7f, 0x14, 0x48, 0x13, 0x80, 0x83, 0x13, 0x46, 0x13, 0x80, 0x85,
|
||||
0x13, 0x44, 0x12, 0x80, 0x89, 0x12, 0x42, 0x11, 0x80, 0x8d, 0x11, 0x40, 0x0f, 0x80, 0x93, 0x0f,
|
||||
0x45, 0x04, 0x80, 0x9d, 0x04, 0xb9, 0x56,
|
||||
};
|
||||
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
|
||||
uint32_t start = micros_start();
|
||||
|
||||
for (int i = 0; i < 0x10; i++)
|
||||
{
|
||||
tft.setAddrWindow(0, 0, 240, 320);
|
||||
|
||||
uint16_t cnt = 0;
|
||||
uint16_t color = tft.color565((i << 4) | i, (i << 4) | i, (i << 4) | i);
|
||||
uint16_t curcolor = 0;
|
||||
|
||||
const uint8_t *cmp = &HaD_240x320[0];
|
||||
|
||||
tft.startWrite();
|
||||
while (cmp < &HaD_240x320[sizeof(HaD_240x320)])
|
||||
{
|
||||
cnt = pgm_read_byte(cmp++);
|
||||
if (cnt & 0x80) cnt = ((cnt & 0x7f) << 8) | pgm_read_byte(cmp++);
|
||||
tft.pushColor(curcolor, cnt); // PDQ_GFX has count
|
||||
curcolor ^= color;
|
||||
}
|
||||
tft.endWrite();
|
||||
}
|
||||
|
||||
uint32_t t = micros() - start;
|
||||
|
||||
tft.setTextColor(TFT_YELLOW);
|
||||
tft.setTextSize(2);
|
||||
tft.setCursor(8, 285);
|
||||
tft.print(F("http://hackaday.io/"));
|
||||
tft.setCursor(96, 302);
|
||||
tft.print(F("Xark"));
|
||||
|
||||
delay(3 * 1000L);
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
uint32_t testFillScreen()
|
||||
{
|
||||
uint32_t start = micros_start();
|
||||
// Shortened this tedious test!
|
||||
tft.fillScreen(TFT_WHITE);
|
||||
tft.fillScreen(TFT_RED);
|
||||
tft.fillScreen(TFT_GREEN);
|
||||
tft.fillScreen(TFT_BLUE);
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
|
||||
return (micros() - start)/5;
|
||||
}
|
||||
|
||||
uint32_t testText()
|
||||
{
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
uint32_t start = micros_start();
|
||||
tft.setCursor(0, 0);
|
||||
tft.setTextColor(TFT_WHITE,TFT_BLACK); tft.setTextSize(1);
|
||||
tft.println(F("Hello World!"));
|
||||
tft.setTextSize(2);
|
||||
tft.setTextColor(tft.color565(0xff, 0x00, 0x00));
|
||||
tft.print(F("RED "));
|
||||
tft.setTextColor(tft.color565(0x00, 0xff, 0x00));
|
||||
tft.print(F("GREEN "));
|
||||
tft.setTextColor(tft.color565(0x00, 0x00, 0xff));
|
||||
tft.println(F("BLUE"));
|
||||
tft.setTextColor(TFT_YELLOW); tft.setTextSize(2);
|
||||
tft.println(1234.56);
|
||||
tft.setTextColor(TFT_RED); tft.setTextSize(3);
|
||||
tft.println(0xDEADBEEF, HEX);
|
||||
tft.println();
|
||||
tft.setTextColor(TFT_GREEN);
|
||||
tft.setTextSize(5);
|
||||
tft.println(F("Groop"));
|
||||
tft.setTextSize(2);
|
||||
tft.println(F("I implore thee,"));
|
||||
tft.setTextColor(TFT_GREEN);
|
||||
tft.setTextSize(1);
|
||||
tft.println(F("my foonting turlingdromes."));
|
||||
tft.println(F("And hooptiously drangle me"));
|
||||
tft.println(F("with crinkly bindlewurdles,"));
|
||||
tft.println(F("Or I will rend thee"));
|
||||
tft.println(F("in the gobberwarts"));
|
||||
tft.println(F("with my blurglecruncheon,"));
|
||||
tft.println(F("see if I don't!"));
|
||||
tft.println(F(""));
|
||||
tft.println(F(""));
|
||||
tft.setTextColor(TFT_MAGENTA);
|
||||
tft.setTextSize(6);
|
||||
tft.println(F("Woot!"));
|
||||
uint32_t t = micros() - start;
|
||||
delay(1000);
|
||||
return t;
|
||||
}
|
||||
|
||||
uint32_t testPixels()
|
||||
{
|
||||
int32_t w = tft.width();
|
||||
int32_t h = tft.height();
|
||||
|
||||
uint32_t start = micros_start();
|
||||
tft.startWrite();
|
||||
for (uint16_t y = 0; y < h; y++)
|
||||
{
|
||||
for (uint16_t x = 0; x < w; x++)
|
||||
{
|
||||
tft.drawPixel(x, y, tft.color565(x<<3, y<<3, x*y));
|
||||
}
|
||||
}
|
||||
tft.endWrite();
|
||||
return micros() - start;
|
||||
}
|
||||
|
||||
|
||||
uint32_t testLines(uint16_t color)
|
||||
{
|
||||
uint32_t start, t;
|
||||
int32_t x1, y1, x2, y2;
|
||||
int32_t w = tft.width();
|
||||
int32_t h = tft.height();
|
||||
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
|
||||
x1 = y1 = 0;
|
||||
y2 = h - 1;
|
||||
|
||||
start = micros_start();
|
||||
|
||||
for (x2 = 0; x2 < w; x2 += 6)
|
||||
{
|
||||
tft.drawLine(x1, y1, x2, y2, color);
|
||||
}
|
||||
|
||||
x2 = w - 1;
|
||||
|
||||
for (y2 = 0; y2 < h; y2 += 6)
|
||||
{
|
||||
tft.drawLine(x1, y1, x2, y2, color);
|
||||
}
|
||||
|
||||
t = micros() - start; // fillScreen doesn't count against timing
|
||||
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
|
||||
x1 = w - 1;
|
||||
y1 = 0;
|
||||
y2 = h - 1;
|
||||
|
||||
start = micros_start();
|
||||
|
||||
for (x2 = 0; x2 < w; x2 += 6)
|
||||
{
|
||||
tft.drawLine(x1, y1, x2, y2, color);
|
||||
}
|
||||
|
||||
x2 = 0;
|
||||
for (y2 = 0; y2 < h; y2 += 6)
|
||||
{
|
||||
tft.drawLine(x1, y1, x2, y2, color);
|
||||
}
|
||||
|
||||
t += micros() - start;
|
||||
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
|
||||
x1 = 0;
|
||||
y1 = h - 1;
|
||||
y2 = 0;
|
||||
|
||||
start = micros_start();
|
||||
|
||||
for (x2 = 0; x2 < w; x2 += 6)
|
||||
{
|
||||
tft.drawLine(x1, y1, x2, y2, color);
|
||||
}
|
||||
x2 = w - 1;
|
||||
for (y2 = 0; y2 < h; y2 += 6)
|
||||
{
|
||||
tft.drawLine(x1, y1, x2, y2, color);
|
||||
}
|
||||
t += micros() - start;
|
||||
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
|
||||
x1 = w - 1;
|
||||
y1 = h - 1;
|
||||
y2 = 0;
|
||||
|
||||
start = micros_start();
|
||||
|
||||
for (x2 = 0; x2 < w; x2 += 6)
|
||||
{
|
||||
tft.drawLine(x1, y1, x2, y2, color);
|
||||
}
|
||||
|
||||
x2 = 0;
|
||||
for (y2 = 0; y2 < h; y2 += 6)
|
||||
{
|
||||
tft.drawLine(x1, y1, x2, y2, color);
|
||||
}
|
||||
|
||||
t += micros() - start;
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
uint32_t testFastLines(uint16_t color1, uint16_t color2)
|
||||
{
|
||||
uint32_t start;
|
||||
int32_t x, y;
|
||||
int32_t w = tft.width();
|
||||
int32_t h = tft.height();
|
||||
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
|
||||
start = micros_start();
|
||||
|
||||
for (y = 0; y < h; y += 5)
|
||||
tft.drawFastHLine(0, y, w, color1);
|
||||
for (x = 0; x < w; x += 5)
|
||||
tft.drawFastVLine(x, 0, h, color2);
|
||||
|
||||
return micros() - start;
|
||||
}
|
||||
|
||||
uint32_t testRects(uint16_t color)
|
||||
{
|
||||
uint32_t start;
|
||||
int32_t n, i, i2;
|
||||
int32_t cx = tft.width() / 2;
|
||||
int32_t cy = tft.height() / 2;
|
||||
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
n = std::min(tft.width(), tft.height());
|
||||
start = micros_start();
|
||||
for (i = 2; i < n; i += 6)
|
||||
{
|
||||
i2 = i / 2;
|
||||
tft.drawRect(cx-i2, cy-i2, i, i, color);
|
||||
}
|
||||
|
||||
return micros() - start;
|
||||
}
|
||||
|
||||
uint32_t testFilledRects(uint16_t color1, uint16_t color2)
|
||||
{
|
||||
uint32_t start, t = 0;
|
||||
int32_t n, i, i2;
|
||||
int32_t cx = tft.width() / 2 - 1;
|
||||
int32_t cy = tft.height() / 2 - 1;
|
||||
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
n = std::min(tft.width(), tft.height());
|
||||
for (i = n; i > 0; i -= 6)
|
||||
{
|
||||
i2 = i / 2;
|
||||
|
||||
start = micros_start();
|
||||
|
||||
tft.fillRect(cx-i2, cy-i2, i, i, color1);
|
||||
|
||||
t += micros() - start;
|
||||
|
||||
// Outlines are not included in timing results
|
||||
tft.drawRect(cx-i2, cy-i2, i, i, color2);
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
uint32_t testFilledCircles(uint8_t radius, uint16_t color)
|
||||
{
|
||||
uint32_t start;
|
||||
int32_t x, y, w = tft.width(), h = tft.height(), r2 = radius * 2;
|
||||
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
|
||||
start = micros_start();
|
||||
|
||||
for (x = radius; x < w; x += r2)
|
||||
{
|
||||
for (y = radius; y < h; y += r2)
|
||||
{
|
||||
tft.fillCircle(x, y, radius, color);
|
||||
}
|
||||
}
|
||||
|
||||
return micros() - start;
|
||||
}
|
||||
|
||||
uint32_t testCircles(uint8_t radius, uint16_t color)
|
||||
{
|
||||
uint32_t start;
|
||||
int32_t x, y, r2 = radius * 2;
|
||||
int32_t w = tft.width() + radius;
|
||||
int32_t h = tft.height() + 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 < w; x += r2)
|
||||
{
|
||||
for (y = 0; y < h; y += r2)
|
||||
{
|
||||
tft.drawCircle(x, y, radius, color);
|
||||
}
|
||||
}
|
||||
|
||||
return micros() - start;
|
||||
}
|
||||
|
||||
uint32_t testTriangles()
|
||||
{
|
||||
uint32_t start;
|
||||
int32_t n, i;
|
||||
int32_t cx = tft.width()/ 2 - 1;
|
||||
int32_t cy = tft.height() / 2 - 1;
|
||||
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
n = std::min(cx, cy);
|
||||
|
||||
start = micros_start();
|
||||
|
||||
for (i = 0; i < n; i += 5)
|
||||
{
|
||||
tft.drawTriangle(
|
||||
cx , cy - i, // peak
|
||||
cx - i, cy + i, // bottom left
|
||||
cx + i, cy + i, // bottom right
|
||||
tft.color565(0, 0, i));
|
||||
}
|
||||
|
||||
return micros() - start;
|
||||
}
|
||||
|
||||
uint32_t testFilledTriangles()
|
||||
{
|
||||
uint32_t start, t = 0;
|
||||
int32_t i;
|
||||
int32_t cx = tft.width() / 2 - 1;
|
||||
int32_t cy = tft.height() / 2 - 1;
|
||||
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
|
||||
start = micros_start();
|
||||
|
||||
for (i = std::min(cx,cy); i > 10; i -= 5) {
|
||||
start = micros_start();
|
||||
tft.fillTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,
|
||||
tft.color565(0, i, i));
|
||||
t += micros() - start;
|
||||
tft.drawTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,
|
||||
tft.color565(i, i, 0));
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
uint32_t testRoundRects()
|
||||
{
|
||||
uint32_t start;
|
||||
int32_t w, i, i2;
|
||||
int32_t cx = tft.width() / 2 - 1;
|
||||
int32_t cy = tft.height() / 2 - 1;
|
||||
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
|
||||
w = std::min(tft.width(), tft.height());
|
||||
|
||||
start = micros_start();
|
||||
|
||||
for (i = 0; i < w; i += 6)
|
||||
{
|
||||
i2 = i / 2;
|
||||
tft.drawRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(i, 0, 0));
|
||||
}
|
||||
|
||||
return micros() - start;
|
||||
}
|
||||
|
||||
uint32_t testFilledRoundRects()
|
||||
{
|
||||
uint32_t start;
|
||||
int32_t i, i2;
|
||||
int32_t cx = tft.width() / 2 - 1;
|
||||
int32_t cy = tft.height() / 2 - 1;
|
||||
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
|
||||
start = micros_start();
|
||||
|
||||
for (i = std::min(tft.width(), tft.height()); i > 20; i -= 6)
|
||||
{
|
||||
i2 = i / 2;
|
||||
tft.fillRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(0, i, 0));
|
||||
}
|
||||
|
||||
return micros() - start;
|
||||
}
|
||||
|
||||
/***************************************************
|
||||
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
|
||||
****************************************************/
|
||||
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
cmake_minimum_required(VERSION 3.16.0)
|
||||
list(APPEND EXTRA_COMPONENT_DIRS "$(PROJECT_PATH)/../../../../../LovyanGFX")
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(LovyanGFX-build-test)
|
||||
|
||||
|
||||
|
|
@ -0,0 +1 @@
|
|||
#include "main/main.cpp"
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
idf_component_register(
|
||||
SRCS "main.cpp"
|
||||
INCLUDE_DIRS "."
|
||||
REQUIRES LovyanGFX)
|
||||
239
libraries/LovyanGFX/examples/Test/build_test/main/main.cpp
Normal file
239
libraries/LovyanGFX/examples/Test/build_test/main/main.cpp
Normal file
|
|
@ -0,0 +1,239 @@
|
|||
#if !defined LGFX_AUTODETECT
|
||||
#define LGFX_AUTODETECT
|
||||
#endif
|
||||
|
||||
#if !defined LGFX_USE_V1
|
||||
#define LGFX_USE_V1
|
||||
#endif
|
||||
|
||||
#if defined ( ARDUINO ) && defined ( ESP32 )
|
||||
#include <SPIFFS.h>
|
||||
#endif
|
||||
|
||||
#include <LovyanGFX.hpp>
|
||||
|
||||
#if defined SKIP_I2C_TEST
|
||||
#define DUMMY_DISPLAY
|
||||
#endif
|
||||
|
||||
|
||||
#if defined DUMMY_DISPLAY
|
||||
// AUTODETECT will fail, so let's build a dummy object
|
||||
// with arbitraty display for the sakes of testing
|
||||
class LGFX : public lgfx::LGFX_Device
|
||||
{
|
||||
lgfx::Panel_ST7735S _panel_instance;
|
||||
lgfx::Bus_SPI _bus_instance;
|
||||
|
||||
public:
|
||||
LGFX(void)
|
||||
{
|
||||
{
|
||||
auto cfg = _bus_instance.config();
|
||||
_bus_instance.config(cfg);
|
||||
_panel_instance.setBus(&_bus_instance);
|
||||
}
|
||||
{
|
||||
auto cfg = _panel_instance.config();
|
||||
_panel_instance.config(cfg);
|
||||
}
|
||||
setPanel(&_panel_instance);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined SKIP_I2C_TEST
|
||||
|
||||
class LGFX_I2C : public lgfx::LGFX_Device
|
||||
{
|
||||
lgfx::Bus_I2C _bus_instance;
|
||||
lgfx::Panel_SSD1306 _panel_instance;
|
||||
lgfx::Touch_FT5x06 _touch_instance;
|
||||
|
||||
public:
|
||||
LGFX_I2C(void)
|
||||
{
|
||||
{
|
||||
auto cfg = _bus_instance.config();
|
||||
_bus_instance.config(cfg);
|
||||
_panel_instance.setBus(&_bus_instance);
|
||||
}
|
||||
{
|
||||
auto cfg = _panel_instance.config();
|
||||
_panel_instance.config(cfg);
|
||||
}
|
||||
{
|
||||
auto cfg = _touch_instance.config();
|
||||
_touch_instance.config(cfg);
|
||||
_panel_instance.setTouch(&_touch_instance);
|
||||
}
|
||||
setPanel(&_panel_instance);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
static LGFX display1;
|
||||
|
||||
#if !defined SKIP_I2C_TEST
|
||||
static LGFX_I2C display2;
|
||||
#endif
|
||||
|
||||
static LGFX_Sprite sprite(&display1);
|
||||
|
||||
void test(LGFX_Device &lcd)
|
||||
{
|
||||
lcd.init();
|
||||
lcd.setRotation(1);
|
||||
lcd.setBrightness(128);
|
||||
lcd.setColorDepth(24);
|
||||
lcd.drawPixel(0, 0, 0xFFFF);
|
||||
lcd.drawFastVLine(2, 0, 100, lcd.color888(255, 0, 0));
|
||||
lcd.drawFastVLine(4, 0, 100, lcd.color565( 0, 255, 0));
|
||||
lcd.drawFastVLine(6, 0, 100, lcd.color332( 0, 0, 255));
|
||||
uint32_t red = 0xFF0000;
|
||||
lcd.drawFastHLine(0, 2, 100, red);
|
||||
lcd.drawFastHLine(0, 4, 100, 0x00FF00U);
|
||||
lcd.drawFastHLine(0, 6, 100, (uint32_t)0xFF);
|
||||
uint16_t green = 0x07E0;
|
||||
lcd.drawRect(10, 10, 50, 50, 0xF800);
|
||||
lcd.drawRect(12, 12, 50, 50, green);
|
||||
lcd.drawRect(14, 14, 50, 50, (uint16_t)0x1F);
|
||||
uint8_t blue = 0x03;
|
||||
lcd.fillRect(20, 20, 20, 20, (uint8_t)0xE0);
|
||||
lcd.fillRect(30, 30, 20, 20, (uint8_t)0x1C);
|
||||
lcd.fillRect(40, 40, 20, 20, blue);
|
||||
lcd.setColor(0xFF0000U);
|
||||
lcd.fillCircle ( 40, 80, 20 );
|
||||
lcd.fillEllipse( 80, 40, 10, 20);
|
||||
lcd.fillArc ( 80, 80, 20, 10, 0, 90);
|
||||
lcd.fillTriangle(80, 80, 60, 80, 80, 60);
|
||||
lcd.setColor(0x0000FFU);
|
||||
lcd.drawCircle ( 40, 80, 20 );
|
||||
lcd.drawEllipse( 80, 40, 10, 20);
|
||||
lcd.drawArc ( 80, 80, 20, 10, 0, 90);
|
||||
lcd.drawTriangle(60, 80, 80, 80, 80, 60);
|
||||
lcd.setColor(0x00FF00U);
|
||||
lcd.drawBezier( 60, 80, 80, 80, 80, 60);
|
||||
lcd.drawBezier( 60, 80, 80, 20, 20, 80, 80, 60);
|
||||
lcd.drawGradientLine( 0, 80, 80, 0, 0xFF0000U, 0x0000FFU);
|
||||
|
||||
lcd.fillScreen(0xFFFFFFu);
|
||||
lcd.setColor(0x00FF00u);
|
||||
lcd.fillScreen();
|
||||
lcd.clear(0xFFFFFFu);
|
||||
lcd.setBaseColor(0x000000u);
|
||||
lcd.clear();
|
||||
lcd.drawLine(0, 1, 39, 40, red);
|
||||
lcd.drawLine(1, 0, 40, 39, blue);
|
||||
lcd.startWrite();
|
||||
lcd.drawLine(38, 0, 0, 38, 0xFFFF00U);
|
||||
lcd.drawLine(39, 1, 1, 39, 0xFF00FFU);
|
||||
lcd.drawLine(40, 2, 2, 40, 0x00FFFFU);
|
||||
lcd.endWrite();
|
||||
lcd.startWrite();
|
||||
lcd.startWrite();
|
||||
lcd.startWrite();
|
||||
lcd.endWrite();
|
||||
lcd.endWrite();
|
||||
lcd.endWrite();
|
||||
lcd.endWrite();
|
||||
lcd.startWrite();
|
||||
lcd.startWrite();
|
||||
lcd.drawPixel(0, 0);
|
||||
lcd.endTransaction();
|
||||
lcd.beginTransaction();
|
||||
lcd.drawPixel(0, 0);
|
||||
lcd.endWrite();
|
||||
lcd.endWrite();
|
||||
lcd.startWrite();
|
||||
for (uint32_t x = 0; x < 128; ++x) {
|
||||
for (uint32_t y = 0; y < 128; ++y) {
|
||||
lcd.writePixel(x, y, lcd.color888( x*2, x + y, y*2));
|
||||
}
|
||||
}
|
||||
lcd.endWrite();
|
||||
|
||||
sprite.setColorDepth(24);
|
||||
sprite.createSprite(65, 65);
|
||||
|
||||
for (uint32_t x = 0; x < 64; ++x) {
|
||||
for (uint32_t y = 0; y < 64; ++y) {
|
||||
sprite.drawPixel(x, y, lcd.color888(3 + x*4, (x + y)*2, 3 + y*4));
|
||||
}
|
||||
}
|
||||
sprite.drawRect(0, 0, 65, 65, 0xFFFF);
|
||||
sprite.pushSprite(64, 0);
|
||||
sprite.pushSprite(&lcd, 0, 64);
|
||||
|
||||
|
||||
sprite.setPivot(32, 32);
|
||||
int32_t center_x = lcd.width()/2;
|
||||
int32_t center_y = lcd.height()/2;
|
||||
lcd.startWrite();
|
||||
for (int angle = 0; angle <= 360; ++angle) {
|
||||
sprite.pushRotateZoom(center_x, center_y, angle, 2.5, 3);
|
||||
if ((angle % 36) == 0) lcd.display();
|
||||
}
|
||||
lcd.endWrite();
|
||||
|
||||
sprite.deleteSprite();
|
||||
|
||||
sprite.setColorDepth(4);
|
||||
sprite.createSprite(65, 65);
|
||||
sprite.setPaletteColor(1, 0x0000FFU);
|
||||
sprite.setPaletteColor(2, 0x00FF00U);
|
||||
sprite.setPaletteColor(3, 0xFF0000U);
|
||||
|
||||
sprite.fillRect(10, 10, 45, 45, 1);
|
||||
sprite.fillCircle(32, 32, 22, 2);
|
||||
sprite.fillTriangle(32, 12, 15, 43, 49, 43, 3);
|
||||
|
||||
sprite.pushSprite(&lcd, 0, 0, 0);
|
||||
|
||||
lcd.drawBmp((uint8_t*)nullptr, 0, 0, 0);
|
||||
lcd.drawPng((uint8_t*)nullptr, 0, 0, 0);
|
||||
lcd.drawJpg((uint8_t*)nullptr, 0, 0, 0);
|
||||
lcd.drawQoi((uint8_t*)nullptr, 0, 0, 0);
|
||||
|
||||
#if defined ( ARDUINO ) && defined ( ESP32 )
|
||||
lcd.drawBmpFile(SPIFFS, "/test.bmp");
|
||||
lcd.drawPngFile(SPIFFS, "/test.png");
|
||||
lcd.drawJpgFile(SPIFFS, "/test.jpg");
|
||||
lcd.drawQoiFile(SPIFFS, "/test.qoi");
|
||||
#endif
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
test(display1);
|
||||
#if !defined SKIP_I2C_TEST
|
||||
test(display2);
|
||||
#endif
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
lgfx::delay(1000);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if !defined ARDUINO
|
||||
extern "C" {
|
||||
void loopTask(void*)
|
||||
{
|
||||
setup();
|
||||
for(;;) {
|
||||
loop();
|
||||
}
|
||||
}
|
||||
void app_main()
|
||||
{
|
||||
xTaskCreatePinnedToCore( loopTask, "loopTask", 8192, NULL, 1, NULL, 1 );
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
15
libraries/LovyanGFX/examples/Test/build_test/platformio.ini
Normal file
15
libraries/LovyanGFX/examples/Test/build_test/platformio.ini
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
; Inspired from https://github.com/Jason2866/Tasmota-build
|
||||
[platformio]
|
||||
description = LGFX Build test suite for platformio
|
||||
default_envs = esp8266
|
||||
; lib_extra_dirs = ../../../../LovyanGFX
|
||||
|
||||
src_dir = main
|
||||
extra_configs = platformio_esp8266.ini
|
||||
platformio_esp32.ini
|
||||
platformio_atmelsam.ini
|
||||
platformio_rpipico.ini
|
||||
|
||||
[env]
|
||||
framework = arduino
|
||||
lib_deps = LovyanGFX
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
|
||||
[atmelsam_default]
|
||||
platform = atmelsam
|
||||
|
||||
[env:seeed_wio_terminal]
|
||||
[env:adafruit_pybadge_m4]
|
||||
|
||||
[env:seeed_wio_terminal-default]
|
||||
platform = ${atmelsam_default.platform}
|
||||
board = seeed_wio_terminal
|
||||
|
||||
[env:adafruit_pybadge_m4-default]
|
||||
platform = ${atmelsam_default.platform}
|
||||
board = adafruit_pybadge_m4
|
||||
build_src_flags =
|
||||
${env.src_build_flags}
|
||||
-DLED_PIN=13
|
||||
-O3 -flto
|
||||
|
|
@ -0,0 +1,268 @@
|
|||
|
||||
[coding_standards]
|
||||
build_flags =
|
||||
-Wno-unused-variable
|
||||
-Wno-unused-but-set-variable
|
||||
-Wno-sign-compare
|
||||
-Wunreachable-code
|
||||
-Wall
|
||||
-Wextra
|
||||
-Wshadow
|
||||
-Wdouble-promotion
|
||||
-Wformat
|
||||
-Wnonnull
|
||||
|
||||
|
||||
[esp32_1_0_6]
|
||||
platform = espressif32 @ ^3
|
||||
build_flags = ${coding_standards.build_flags}
|
||||
[esp32_2_0_0]
|
||||
platform = espressif32 @ ^4
|
||||
platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.0
|
||||
build_flags = ${coding_standards.build_flags}
|
||||
[esp32_2_0_1]
|
||||
platform = espressif32 @ ^4
|
||||
platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.1
|
||||
build_flags = ${coding_standards.build_flags}
|
||||
[esp32_2_0_2]
|
||||
platform = espressif32 @ ^4
|
||||
platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.2
|
||||
build_flags = ${coding_standards.build_flags}
|
||||
[esp32_2_0_3]
|
||||
platform = https://github.com/tasmota/platform-espressif32
|
||||
platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32/releases/download/2.0.3/esp32-2.0.3.zip
|
||||
build_flags = ${coding_standards.build_flags}
|
||||
|
||||
|
||||
[esp32_2_0_4]
|
||||
platform = https://github.com/tasmota/platform-espressif32
|
||||
platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32/releases/download/2.0.4/esp32-2.0.4.zip
|
||||
build_flags = ${coding_standards.build_flags}
|
||||
[esp32_2_0_5]
|
||||
platform = https://github.com/tasmota/platform-espressif32
|
||||
platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32/releases/download/2.0.5/esp32-2.0.5.zip
|
||||
build_flags = ${coding_standards.build_flags}
|
||||
[esp32_2_0_6]
|
||||
platform = https://github.com/tasmota/platform-espressif32
|
||||
platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32/releases/download/2.0.6/esp32-2.0.6.zip
|
||||
build_flags = ${coding_standards.build_flags}
|
||||
[esp32_2_0_7]
|
||||
platform = https://github.com/tasmota/platform-espressif32
|
||||
platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32/releases/download/2.0.7/esp32-2.0.7.zip
|
||||
build_flags = ${coding_standards.build_flags}
|
||||
[esp32_2_0_8]
|
||||
platform = https://github.com/tasmota/platform-espressif32
|
||||
platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32/releases/download/2.0.8/esp32-2.0.8.zip
|
||||
build_flags = ${coding_standards.build_flags}
|
||||
|
||||
|
||||
|
||||
[esp32_default]
|
||||
platform = https://github.com/tasmota/platform-espressif32
|
||||
;platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32/releases/download/2.0.3/esp32-2.0.3.zip
|
||||
build_flags = ${coding_standards.build_flags}
|
||||
|
||||
|
||||
[esp32]
|
||||
board = esp32dev
|
||||
[M5StickC]
|
||||
board = m5stick-c
|
||||
[M5Stack]
|
||||
board = m5stack-core-esp32
|
||||
[M5Core2]
|
||||
board = m5stack-core2
|
||||
[M5CoreS3]
|
||||
board = esp32-s3-devkitc-1
|
||||
board_upload.flash_size = 16MB
|
||||
board_upload.maximum_size = 16777216
|
||||
board_build.partitions = default_16MB.csv
|
||||
board_build.arduino.memory_type = qio_qspi
|
||||
build_flags =
|
||||
${env.build_flags}
|
||||
-DARDUINO_M5STACK_CORES3
|
||||
-DBOARD_HAS_PSRAM
|
||||
-DARDUINO_UDB_MODE=1
|
||||
|
||||
[esp32c3]
|
||||
board = esp32dev
|
||||
board_build.mcu = esp32c3
|
||||
build_flags =
|
||||
-DDUMMY_DISPLAY
|
||||
${coding_standards.build_flags}
|
||||
[esp32s2]
|
||||
board = esp32dev
|
||||
board_build.mcu = esp32s2
|
||||
[esp32s3]
|
||||
board = esp32dev
|
||||
board_build.mcu = esp32s3
|
||||
|
||||
|
||||
; for some reason platformio 5.0 wants this
|
||||
[env:esp32]
|
||||
[env:m5stick-c]
|
||||
[env:m5stack-core-esp32]
|
||||
[env:m5stack-core2]
|
||||
[env:m5stack-cores3]
|
||||
[env:esp32-s2]
|
||||
[env:esp32-s3]
|
||||
[env:esp32-c3]
|
||||
|
||||
|
||||
[env:m5stack-cores3-2_0_5]
|
||||
extends = M5CoreS3, esp32_2_0_5
|
||||
[env:m5stack-cores3-2_0_6]
|
||||
extends = M5CoreS3, esp32_2_0_6
|
||||
[env:m5stack-cores3-2_0_7]
|
||||
extends = M5CoreS3, esp32_2_0_7
|
||||
[env:m5stack-cores3-2_0_8]
|
||||
extends = M5CoreS3, esp32_2_0_8
|
||||
[env:m5stack-cores3-default]
|
||||
extends = M5CoreS3, esp32_2_0_8
|
||||
|
||||
|
||||
[env:esp32-1_0_6]
|
||||
extends = esp32, esp32_1_0_6
|
||||
board = esp32dev
|
||||
[env:esp32-2_0_0]
|
||||
extends = esp32, esp32_2_0_0
|
||||
[env:esp32-2_0_1]
|
||||
extends = esp32, esp32_2_0_1
|
||||
[env:esp32-2_0_2]
|
||||
extends = esp32, esp32_2_0_2
|
||||
[env:esp32-2_0_3]
|
||||
extends = esp32, esp32_2_0_3
|
||||
[env:esp32-2_0_4]
|
||||
extends = esp32, esp32_2_0_4
|
||||
[env:esp32-2_0_5]
|
||||
extends = esp32, esp32_2_0_5
|
||||
[env:esp32-2_0_6]
|
||||
extends = esp32, esp32_2_0_6
|
||||
[env:esp32-2_0_7]
|
||||
extends = esp32, esp32_2_0_7
|
||||
[env:esp32-2_0_8]
|
||||
extends = esp32, esp32_2_0_8
|
||||
[env:esp32-default]
|
||||
extends = esp32, esp32_default
|
||||
|
||||
[env:m5stick-c-1_0_6]
|
||||
extends = M5StickC, esp32_1_0_6
|
||||
[env:m5stick-c-2_0_0]
|
||||
extends = M5StickC, esp32_2_0_0
|
||||
[env:m5stick-c-2_0_1]
|
||||
extends = M5StickC, esp32_2_0_1
|
||||
[env:m5stick-c-2_0_2]
|
||||
extends = M5StickC, esp32_2_0_2
|
||||
[env:m5stick-c-2_0_3]
|
||||
extends = M5StickC, esp32_2_0_3
|
||||
[env:m5stick-c-2_0_4]
|
||||
extends = esp32, esp32_2_0_4
|
||||
[env:m5stick-c-2_0_5]
|
||||
extends = esp32, esp32_2_0_5
|
||||
[env:m5stick-c-2_0_6]
|
||||
extends = esp32, esp32_2_0_6
|
||||
[env:m5stick-c-2_0_7]
|
||||
extends = esp32, esp32_2_0_7
|
||||
[env:m5stick-c-2_0_8]
|
||||
extends = esp32, esp32_2_0_8
|
||||
[env:m5stick-c-default]
|
||||
extends = M5StickC, esp32_default
|
||||
|
||||
|
||||
[env:m5stack-core-esp32-1_0_6]
|
||||
extends = M5Stack, esp32_1_0_6
|
||||
[env:m5stack-core-esp32-2_0_0]
|
||||
extends = M5Stack, esp32_2_0_0
|
||||
[env:m5stack-core-esp32-2_0_1]
|
||||
extends = M5Stack, esp32_2_0_1
|
||||
[env:m5stack-core-esp32-2_0_2]
|
||||
extends = M5Stack, esp32_2_0_2
|
||||
[env:m5stack-core-esp32-2_0_3]
|
||||
extends = M5Stack, esp32_2_0_3
|
||||
[env:m5stack-core-esp32-2_0_4]
|
||||
extends = esp32, esp32_2_0_4
|
||||
[env:m5stack-core-esp32-2_0_5]
|
||||
extends = esp32, esp32_2_0_5
|
||||
[env:m5stack-core-esp32-2_0_6]
|
||||
extends = esp32, esp32_2_0_6
|
||||
[env:m5stack-core-esp32-2_0_7]
|
||||
extends = esp32, esp32_2_0_7
|
||||
[env:m5stack-core-esp32-2_0_8]
|
||||
extends = esp32, esp32_2_0_8
|
||||
[env:m5stack-core-esp32-default]
|
||||
extends = M5Stack, esp32_default
|
||||
|
||||
[env:m5stack-core2-1_0_6]
|
||||
extends = M5Core2, esp32_1_0_6
|
||||
[env:m5stack-core2-2_0_0]
|
||||
extends = M5Core2, esp32_2_0_0
|
||||
[env:m5stack-core2-2_0_1]
|
||||
extends = M5Core2, esp32_2_0_1
|
||||
[env:m5stack-core2-2_0_2]
|
||||
extends = M5Core2, esp32_2_0_2
|
||||
[env:m5stack-core2-2_0_3]
|
||||
extends = M5Core2, esp32_2_0_3
|
||||
[env:m5stack-core2-2_0_4]
|
||||
extends = esp32, esp32_2_0_4
|
||||
[env:m5stack-core2-2_0_5]
|
||||
extends = esp32, esp32_2_0_5
|
||||
[env:m5stack-core2-2_0_6]
|
||||
extends = esp32, esp32_2_0_6
|
||||
[env:m5stack-core2-2_0_7]
|
||||
extends = esp32, esp32_2_0_7
|
||||
[env:m5stack-core2-2_0_8]
|
||||
extends = esp32, esp32_2_0_8
|
||||
[env:m5stack-core2-default]
|
||||
extends = M5Core2, esp32_default
|
||||
|
||||
[env:esp32-c3-2_0_1]
|
||||
extends = esp32c3, esp32_2_0_1
|
||||
[env:esp32-c3-2_0_2]
|
||||
extends = esp32c3, esp32_2_0_2
|
||||
[env:esp32-c3-2_0_3]
|
||||
extends = esp32c3, esp32_2_0_3
|
||||
[env:esp32-c3-2_0_4]
|
||||
extends = esp32c3, esp32_2_0_4
|
||||
[env:esp32-c3-2_0_5]
|
||||
extends = esp32c3, esp32_2_0_5
|
||||
[env:esp32-c3-2_0_6]
|
||||
extends = esp32c3, esp32_2_0_6
|
||||
[env:esp32-c3-2_0_7]
|
||||
extends = esp32c3, esp32_2_0_7
|
||||
[env:esp32-c3-2_0_8]
|
||||
extends = esp32c3, esp32_2_0_8
|
||||
[env:esp32-c3-default]
|
||||
extends = esp32c3, esp32_default
|
||||
|
||||
[env:esp32-s2-2_0_1]
|
||||
extends = esp32s2, esp32_2_0_1
|
||||
[env:esp32-s2-2_0_2]
|
||||
extends = esp32s2, esp32_2_0_2
|
||||
[env:esp32-s2-2_0_3]
|
||||
extends = esp32s2, esp32_2_0_3
|
||||
[env:esp32-s2-2_0_4]
|
||||
extends = esp32, esp32_2_0_4
|
||||
[env:esp32-s2-2_0_5]
|
||||
extends = esp32, esp32_2_0_5
|
||||
[env:esp32-s2-2_0_6]
|
||||
extends = esp32, esp32_2_0_6
|
||||
[env:esp32-s2-2_0_7]
|
||||
extends = esp32, esp32_2_0_7
|
||||
[env:esp32-s2-2_0_8]
|
||||
extends = esp32, esp32_2_0_8
|
||||
[env:esp32-s2-default]
|
||||
extends = esp32s2, esp32_default
|
||||
|
||||
[env:esp32-s3-2_0_3]
|
||||
extends = esp32s3, esp32_2_0_3
|
||||
[env:esp32-s3-2_0_4]
|
||||
extends = esp32, esp32_2_0_4
|
||||
[env:esp32-s3-2_0_5]
|
||||
extends = esp32, esp32_2_0_5
|
||||
[env:esp32-s3-2_0_6]
|
||||
extends = esp32, esp32_2_0_6
|
||||
[env:esp32-s3-2_0_7]
|
||||
extends = esp32, esp32_2_0_7
|
||||
[env:esp32-s3-2_0_8]
|
||||
extends = esp32, esp32_2_0_8
|
||||
[env:esp32-s3-default]
|
||||
extends = esp32s3, esp32_default
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
[esp8266_default]
|
||||
platform = espressif8266
|
||||
|
||||
[esp8266_3_0_0]
|
||||
platform = espressif8266@3.0.0
|
||||
|
||||
[esp8266_3_1_0]
|
||||
platform = espressif8266@3.1.0
|
||||
|
||||
[esp8266_3_2_0]
|
||||
platform = espressif8266@3.2.0
|
||||
|
||||
|
||||
[env:esp8266]
|
||||
|
||||
[env:esp8266-3_0_0]
|
||||
platform = ${esp8266_3_0_0.platform}
|
||||
board = d1_mini
|
||||
|
||||
[env:esp8266-3_1_0]
|
||||
platform = ${esp8266_3_1_0.platform}
|
||||
board = d1_mini
|
||||
|
||||
[env:esp8266-3_2_0]
|
||||
platform = ${esp8266_3_2_0.platform}
|
||||
board = d1_mini
|
||||
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
[rpipico_default]
|
||||
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
|
||||
board = pico
|
||||
framework = arduino
|
||||
board_build.core = earlephilhower
|
||||
|
||||
|
||||
|
||||
[env:pico-default]
|
||||
extends = rpipico_default
|
||||
build_flags =
|
||||
-DDUMMY_DISPLAY
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=n
|
||||
CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=n
|
||||
|
|
@ -0,0 +1,141 @@
|
|||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <LovyanGFX.hpp>
|
||||
|
||||
static LGFX lcd;
|
||||
|
||||
static void tileRect(int x, int y, int w, int h, int tile, uint16_t color)
|
||||
{
|
||||
if (tile == 0) return;
|
||||
int px = 0;
|
||||
int py = 0;
|
||||
for (int i = 0;i < h; i++) {
|
||||
py = y + i;
|
||||
for (int j = 0;j < w; j++) {
|
||||
px = x + j;
|
||||
switch (tile >> 1) {
|
||||
case 0: if ((px+py)&4) { continue; }
|
||||
case 1: if (px&2) { continue; }
|
||||
case 2: if ((px+py)&2) { continue; }
|
||||
case 3: if (px&1) { continue; }
|
||||
}
|
||||
if ( (px+py) & 1 ) { lcd.drawPixel(px, py, color); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void drawTile(int y, int h, uint16_t r, uint16_t g, uint16_t b)
|
||||
{
|
||||
uint16_t color = lcd.color565(r,g,b);
|
||||
int step = 10;
|
||||
int x1 = lcd.width() / step;
|
||||
int x2 = (step-1) * lcd.width() / step;
|
||||
lcd.fillRect(0, y, x2, h, 0);
|
||||
lcd.fillRect(x2, y, lcd.width() - x2, h, color);
|
||||
for (uint32_t i = 1; i < step; i++) {
|
||||
x2 = i * lcd.width() / step;
|
||||
tileRect(x1, y, x2 - x1, h, i, color);
|
||||
x1 = x2;
|
||||
}
|
||||
}
|
||||
|
||||
static void drawStep(int y, int h, int step, uint32_t r, uint32_t g, uint32_t b)
|
||||
{
|
||||
int x1 = 0;
|
||||
int x2 = 0;
|
||||
for (uint32_t i = 0; i < step; i++) {
|
||||
x2 = (i+1) * lcd.width() / step;
|
||||
uint16_t color = i == 0 ? 0
|
||||
: lcd.color565(r ? r*((i+1)>>1)/(step>>1) : 0
|
||||
,g ? g*((i+1)>>1)/(step>>1) : 0
|
||||
,b ? b*((i+1)>>1)/(step>>1) : 0);
|
||||
lcd.fillRect( x1, y, x2 - x1, h
|
||||
, color
|
||||
);
|
||||
x1 = x2;
|
||||
}
|
||||
}
|
||||
|
||||
static void drawGrad(int y, int h, uint16_t r, uint16_t g, uint16_t b)
|
||||
{
|
||||
int x1 = 0;
|
||||
int x2 = 0;
|
||||
for (int i = 0; i <= 256; i++) {
|
||||
x2 = i * lcd.width() / 256;
|
||||
if (x1 < x2) {
|
||||
lcd.fillRect(x1, y, x2 - x1, h, lcd.color565(r*i>>8, g*i>>8, b*i>>8));
|
||||
x1 = x2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void drawTestPattern(void)
|
||||
{
|
||||
int w = lcd.width() >> 5;
|
||||
int h = (lcd.height() >> 5)+1;
|
||||
int minwh = std::min(w,h);
|
||||
|
||||
drawGrad(h* 0, h, 255, 0, 0);
|
||||
drawStep(h* 1, h,32 ,255, 0, 0);
|
||||
drawStep(h* 2, h,16 ,255, 0, 0);
|
||||
drawStep(h* 3, h, 8 ,255, 0, 0);
|
||||
drawTile(h* 4, h, 255, 0, 0);
|
||||
drawGrad(h* 5, h, 0, 255, 0);
|
||||
drawStep(h* 6, h,32 , 0, 255, 0);
|
||||
drawStep(h* 7, h,16 , 0, 255, 0);
|
||||
drawStep(h* 8, h, 8 , 0, 255, 0);
|
||||
drawTile(h* 9, h, 0, 255, 0);
|
||||
drawGrad(h*10, h, 0, 0, 255);
|
||||
drawStep(h*11, h,32 , 0, 0, 255);
|
||||
drawStep(h*12, h,16 , 0, 0, 255);
|
||||
drawStep(h*13, h, 8 , 0, 0, 255);
|
||||
drawTile(h*14, h, 0, 0, 255);
|
||||
drawGrad(h*15, h, 255, 255, 255);
|
||||
drawStep(h*16, h,32 ,255, 255, 255);
|
||||
drawStep(h*17, h,16 ,255, 255, 255);
|
||||
drawStep(h*18, h, 8 ,255, 255, 255);
|
||||
drawTile(h*19, h, 255, 255, 255);
|
||||
|
||||
for (int i = 0; i < minwh*6; i++) {
|
||||
lcd.drawRect( i, h*20+i, w*8-(i<<1), h*12-(i<<1), lcd.color565(255-(i<<4),0,0));
|
||||
lcd.drawRoundRect(w*8+i, h*20+i, w*8-(i<<1), h*12-(i<<1),(h*6-i)>>1, lcd.color565(0,255-(i<<4),0));
|
||||
lcd.drawCircle( w*20 , h*26, i, lcd.color565(0,0,255-(i<<4)));
|
||||
lcd.drawLine ( w*24, h*20 + (i<<1), lcd.width()-1, h*32-1-(i<<1), lcd.color565(i<<4,i<<4,255-(i<<4)));
|
||||
lcd.drawLine ( lcd.width()-1-(i<<1), h*20, w*24+(i<<1), h*32-1, lcd.color565(255-(i<<4), i<<4,i<<4));
|
||||
}
|
||||
}
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
lcd.init();
|
||||
|
||||
lcd.fillScreen(0x00FF);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
static int count = 0;
|
||||
|
||||
lcd.startWrite();
|
||||
|
||||
lcd.fillScreen(0);
|
||||
lcd.setColorDepth((count & 1) ? 24 : 16);
|
||||
lcd.setRotation((count>>1) & 7);
|
||||
++count;
|
||||
|
||||
drawTestPattern();
|
||||
lcd.setCursor(0, 10);
|
||||
lcd.printf("color %d\nrotation %d", lcd.getColorDepth(), lcd.getRotation());
|
||||
delay(500);
|
||||
|
||||
int16_t ie = std::min(lcd.width() , lcd.height()) - 2;
|
||||
for (int i = 0; i < ie; ++i) {
|
||||
lcd.copyRect(i, i+1, lcd.width() - (i<<1), lcd.height() - i - 1, i, i);
|
||||
}
|
||||
delay(500);
|
||||
lcd.endWrite();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue