//#include <GxEPD2_BW.h>
#include <GxEPD2_3C.h>
#include <U8g2_for_Adafruit_GFX.h>
#include "Climacons30x30.h"
#include "weathericons_regular_webfont20pt7b.h"
#include "weathericons_regular_webfont10pt7b.h"
#include "f.h"
#define ENABLE_GxEPD2_GFX 0
#define EPD_SCK 12
#define EPD_MOSI 11
#define EPD_MISO -1
#define EPD_CS 10
#define EPD_DC 9
#define EPD_RST 46
#define EPD_BUSY 3
GxEPD2_3C<GxEPD2_290_C90c, GxEPD2_290_C90c::HEIGHT> display(GxEPD2_290_C90c(EPD_CS, EPD_DC, EPD_RST, EPD_BUSY)); // GDEM029C90 128x296, SSD1680
const int cellWidth = 32;
const int cellHeight = 32;
const int gapX = 1;
const int gapY = 0;
const int displayWidth = 296;
const int displayHeight = 128;
const int xOffset = 1;
const int yOffset = 31;
// Zakres glifów
const uint8_t FIRST_CHAR = 0x20;
const uint8_t LAST_CHAR = 0x7F;
// Ile ikon mieści się na jednej stronie
const int cols = (displayWidth + gapX) / (cellWidth + gapX); // (296+1)/33 = 9
const int rows = (displayHeight + gapY) / (cellHeight + gapY); // 128/32 = 4
const int iconsPerPage = cols * rows; // = 36
int currentPage = 0;
int totalPages = 0;
void rysujStrone(int page) {
int startIdx = page * iconsPerPage;
uint16_t startChar = FIRST_CHAR + startIdx; // Zmienione na uint16_t dla szerokich fontów
Serial.print("--- Strona ");
Serial.print(page + 1);
Serial.print("/");
Serial.print(totalPages);
Serial.print(" (Start HEX: 0x");
Serial.print(startChar, HEX);
Serial.println(") ---");
display.setFullWindow();
display.firstPage();
do {
display.fillScreen(GxEPD_WHITE);
int currentIdx = 0;
for (int row = 0; row < rows; row++) {
for (int col = 0; col < cols; col++) {
uint16_t ch = startChar + currentIdx;
if (ch > LAST_CHAR) break;
int x = col * (cellWidth + gapX);
int y = row * (cellHeight + gapY);
// 1. RYSOWANIE RAMKI
display.drawRect(x, y, cellWidth, cellHeight, GxEPD_RED);
// 2. NUMER GLIFU
/* display.setFont(NULL); // Standardowy mały font systemowy
display.setTextColor(GxEPD_RED);
display.setCursor(x + 2, y + 2);
display.setTextSize(1);
display.print(ch, HEX);*/
// 3. RYSOWANIE IKONY
display.setFont(&weathericons_regular_webfont10pt7b);
display.setTextColor(GxEPD_BLACK);
display.setCursor(x + xOffset, y + yOffset);
// Testowe wypisanie - jeśli ikona jest pusta, nic nie zobaczymy
display.write((uint8_t)ch);
currentIdx++;
}
}
} while (display.nextPage());
Serial.println(">>> Strona wysłana do wyświetlacza.");
}
void setup() {
Serial.begin(115200);
delay(1500);
SPI.begin(EPD_SCK, EPD_MISO, EPD_MOSI, EPD_CS);
display.init(115200, true, 50, false);
display.setRotation(1);
// Oblicz liczbę stron
int totalGlyphs = LAST_CHAR - FIRST_CHAR + 1;
totalPages = (totalGlyphs + iconsPerPage - 1) / iconsPerPage;
Serial.print("Glifów łącznie: ");
Serial.println(totalGlyphs);
Serial.print("Ikon na stronie: ");
Serial.println(iconsPerPage);
Serial.print("Stron łącznie: ");
Serial.println(totalPages);
// Wyświetl pierwszą stronę
rysujStrone(currentPage);
}
void loop() {
//Serial.println("loop()");
delay(10000);
currentPage++;
if (currentPage >= totalPages) currentPage = 0;
rysujStrone(currentPage);
}
/*
https://tchapi.github.io/Adafruit-GFX-Font-Customiser/
https://rop.nl/truetype2gfx/
https://www.fontconverter.org/
ttps://icomoon.io/app/#/selecth
https://erikflowers.github.io/weather-icons/
https://github.com/erikflowers/weather-icons
// { bitmapOffset, width, height, xAdvance, xOffset, yOffset }
*/