2026-10-18 18:12:41 +02:00
|
|
|
// Test sketch: bring up the EL512.256-H and slowly cycle through test images.
|
2026-10-05 21:00:42 +02:00
|
|
|
#include <Arduino.h>
|
|
|
|
|
#include <EL512.h>
|
|
|
|
|
|
|
|
|
|
#include "pins.h"
|
|
|
|
|
|
|
|
|
|
static EL512Panel panel({
|
|
|
|
|
el512pins::VCLK,
|
|
|
|
|
el512pins::VID,
|
|
|
|
|
el512pins::TVID,
|
|
|
|
|
el512pins::HS,
|
|
|
|
|
el512pins::VS,
|
|
|
|
|
el512pins::ENABLE,
|
|
|
|
|
el512pins::LOWPWR_N,
|
|
|
|
|
});
|
|
|
|
|
static EL512_GFX display(panel);
|
|
|
|
|
|
2026-10-18 18:12:41 +02:00
|
|
|
static constexpr uint32_t IMAGE_MS = 5000; // time per test image
|
2026-10-05 21:00:42 +02:00
|
|
|
|
2026-10-18 18:12:41 +02:00
|
|
|
static const int16_t W = EL512Panel::WIDTH;
|
|
|
|
|
static const int16_t H = EL512Panel::HEIGHT;
|
2026-10-05 21:00:42 +02:00
|
|
|
|
2026-10-18 18:12:41 +02:00
|
|
|
// Name tag in the bottom-right corner so each image can be identified.
|
|
|
|
|
static void drawLabel(const char* name) {
|
|
|
|
|
int16_t bx, by;
|
|
|
|
|
uint16_t bw, bh;
|
|
|
|
|
display.setTextSize(1);
|
|
|
|
|
display.getTextBounds(name, 0, 0, &bx, &by, &bw, &bh);
|
|
|
|
|
const int16_t w = bw + 8, h = bh + 6;
|
|
|
|
|
const int16_t x = W - w - 4, y = H - h - 4;
|
|
|
|
|
display.fillRect(x, y, w, h, 0);
|
|
|
|
|
display.drawRect(x, y, w, h, 1);
|
|
|
|
|
display.setTextColor(1);
|
|
|
|
|
display.setCursor(x + 4, y + 3);
|
|
|
|
|
display.print(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void drawOverview() {
|
|
|
|
|
display.drawRect(0, 0, W, H, 1);
|
|
|
|
|
display.drawLine(0, 0, W - 1, H - 1, 1);
|
|
|
|
|
display.drawLine(W - 1, 0, 0, H - 1, 1);
|
|
|
|
|
display.fillCircle(W / 2, H / 2, 40, 1);
|
2026-10-05 21:00:42 +02:00
|
|
|
display.setTextColor(1);
|
|
|
|
|
display.setTextSize(2);
|
2026-10-18 18:12:41 +02:00
|
|
|
display.setCursor(8, 8);
|
2026-10-05 21:00:42 +02:00
|
|
|
display.print("EL512.256-H");
|
|
|
|
|
display.setTextSize(1);
|
2026-10-18 18:12:41 +02:00
|
|
|
display.setCursor(8, 32);
|
|
|
|
|
display.printf("%ux%u %.1f Hz", W, H, EL512Panel::refreshHz());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void drawAllOff() {}
|
|
|
|
|
|
|
|
|
|
static void drawAllOn() { display.fillScreen(1); }
|
|
|
|
|
|
|
|
|
|
// Datasheet columns are numbered from 1: x = 0 is column 1 (odd, TVID).
|
|
|
|
|
static void drawVidColumns() {
|
|
|
|
|
for (int16_t x = 1; x < W; x += 2) display.drawFastVLine(x, 0, H, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void drawTvidColumns() {
|
|
|
|
|
for (int16_t x = 0; x < W; x += 2) display.drawFastVLine(x, 0, H, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void drawRowStripes() {
|
|
|
|
|
for (int16_t y = 0; y < H; y += 2) display.drawFastHLine(0, y, W, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void drawCheckerboard() {
|
|
|
|
|
for (int16_t y = 0; y < H; y++)
|
|
|
|
|
for (int16_t x = 0; x < W; x++)
|
|
|
|
|
if ((x ^ y) & 1) display.drawPixel(x, y, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void drawBlocks() {
|
|
|
|
|
for (int16_t y = 0; y < H; y += 16)
|
|
|
|
|
for (int16_t x = 0; x < W; x += 16)
|
|
|
|
|
if (((x ^ y) >> 4) & 1) display.fillRect(x, y, 16, 16, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void drawGrid() {
|
|
|
|
|
display.setTextSize(1);
|
|
|
|
|
display.setTextColor(1);
|
|
|
|
|
for (int16_t x = 0; x < W; x += 32) display.drawFastVLine(x, 0, H, 1);
|
|
|
|
|
for (int16_t y = 0; y < H; y += 32) display.drawFastHLine(0, y, W, 1);
|
|
|
|
|
display.drawFastVLine(W - 1, 0, H, 1);
|
|
|
|
|
display.drawFastHLine(0, H - 1, W, 1);
|
|
|
|
|
for (int16_t y = 0; y < H; y += 64)
|
|
|
|
|
for (int16_t x = 0; x < W; x += 64) {
|
|
|
|
|
display.setCursor(x + 3, y + 3);
|
|
|
|
|
display.printf("%d,%d", x, y);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void drawCircles() {
|
|
|
|
|
for (int16_t r = 8; r < W; r += 12) display.drawCircle(W / 2, H / 2, r, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Ordered 4x4 dither from left (dark) to right (bright).
|
|
|
|
|
static void drawDither() {
|
|
|
|
|
static const uint8_t bayer[4][4] = {
|
|
|
|
|
{0, 8, 2, 10}, {12, 4, 14, 6}, {3, 11, 1, 9}, {15, 7, 13, 5}};
|
|
|
|
|
for (int16_t y = 0; y < H; y++)
|
|
|
|
|
for (int16_t x = 0; x < W; x++)
|
|
|
|
|
if (bayer[y & 3][x & 3] < (x * 17) / W) display.drawPixel(x, y, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void drawText() {
|
|
|
|
|
display.setTextColor(1);
|
|
|
|
|
display.setTextSize(1);
|
|
|
|
|
display.setCursor(0, 0);
|
|
|
|
|
for (int line = 0; line < 30; line++) {
|
|
|
|
|
for (char c = ' ' + (line % 3) * 32; c < ' ' + (line % 3) * 32 + 32 && c <= '~'; c++)
|
|
|
|
|
display.print(c);
|
|
|
|
|
display.print(" The quick brown fox jumps over the lazy dog.\n");
|
|
|
|
|
}
|
|
|
|
|
display.setTextSize(3);
|
|
|
|
|
display.setCursor(8, H - 40);
|
|
|
|
|
display.print("Size 3 text");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct TestImage {
|
|
|
|
|
const char* name;
|
|
|
|
|
void (*draw)();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const TestImage images[] = {
|
|
|
|
|
{"overview", drawOverview},
|
|
|
|
|
{"all off", drawAllOff},
|
|
|
|
|
{"all on", drawAllOn},
|
|
|
|
|
{"VID columns (even)", drawVidColumns},
|
|
|
|
|
{"TVID columns (odd)", drawTvidColumns},
|
|
|
|
|
{"row stripes", drawRowStripes},
|
|
|
|
|
{"checkerboard", drawCheckerboard},
|
|
|
|
|
{"16px blocks", drawBlocks},
|
|
|
|
|
{"grid 32px", drawGrid},
|
|
|
|
|
{"circles", drawCircles},
|
|
|
|
|
{"dither ramp", drawDither},
|
|
|
|
|
{"text", drawText},
|
|
|
|
|
};
|
|
|
|
|
static constexpr size_t IMAGE_COUNT = sizeof(images) / sizeof(images[0]);
|
|
|
|
|
|
|
|
|
|
static void showImage(size_t i) {
|
|
|
|
|
display.fillScreen(0);
|
|
|
|
|
images[i].draw();
|
|
|
|
|
drawLabel(images[i].name);
|
2026-10-05 21:00:42 +02:00
|
|
|
display.display();
|
2026-10-18 18:12:41 +02:00
|
|
|
Serial.printf("image %u/%u: %s\n", (unsigned)(i + 1), (unsigned)IMAGE_COUNT, images[i].name);
|
2026-10-05 21:00:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setup() {
|
|
|
|
|
Serial.begin(115200);
|
|
|
|
|
Serial.println("EL512.256-H test");
|
|
|
|
|
|
|
|
|
|
if (!display.begin()) {
|
|
|
|
|
Serial.println("panel init failed (out of DMA memory?)");
|
|
|
|
|
while (true) delay(1000);
|
|
|
|
|
}
|
|
|
|
|
Serial.printf("free heap: %u\n", ESP.getFreeHeap());
|
2026-10-18 18:12:41 +02:00
|
|
|
showImage(0);
|
2026-10-05 21:00:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void loop() {
|
2026-10-18 18:12:41 +02:00
|
|
|
static size_t current = 0;
|
|
|
|
|
static uint32_t last = millis();
|
|
|
|
|
if (millis() - last >= IMAGE_MS) {
|
2026-10-05 21:00:42 +02:00
|
|
|
last = millis();
|
2026-10-18 18:12:41 +02:00
|
|
|
current = (current + 1) % IMAGE_COUNT;
|
|
|
|
|
showImage(current);
|
2026-10-05 21:00:42 +02:00
|
|
|
}
|
|
|
|
|
}
|