Customer:
I’m working on a project with Inkplate 2 and using InkplateLibrary installed via Arduino IDE Library Manager. I encountered two compilation problems:
Initialization / 1-bit mode: Some examples show initialization as Inkplate display(INKPLATE_1BIT); display.begin(); while others show Inkplate display; display.begin(INKPLATE_1BIT);. Both fail to compile in my library version with “no matching function” errors.
Dynamic font sizing: I want to dynamically adjust text size based on screen width using getTextBounds():
int textSize = 3;
while (textSize > 1) {
display.setTextSize(textSize);
display.getTextBounds(headerText, 0, 0, &x1, &y1, &w, &h);
if (w <= display.width() - 10) break;
textSize--;
}
This also fails to compile with an error on the getTextBounds() call.
Minimal example 1 – initialization problem:
#include <Inkplate.h>
Inkplate display(INKPLATE_1BIT); // does not compile
void setup() {
Serial.begin(115200);
display.begin(); // or: display.begin(INKPLATE_1BIT); → also doesn't
}
void loop() {
}
Minimal example 2 – dynamic text sizing problem:
#include <Inkplate.h>
Inkplate display(INKPLATE_1BIT);
void setup() {
Serial.begin(115200);
display.begin();
String headerText = "Very Long Station Name That Might Not Fit";
int16_t x1, y1;
uint16_t w, h;
int textSize = 3;
while (textSize > 1) {
display.setTextSize(textSize);
// ❌ compilation fails here
display.getTextBounds(headerText, 0, 0, &x1, &y1, &w, &h);
if (w <= display.width() - 10) break;
textSize--;
}
display.setCursor(10, 20);
display.print(headerText);
display.display();
}
void loop() {
}
What is the correct way to initialize Inkplate 2 in 1-bit mode in the current library version? Is dynamic font sizing with getTextBounds() supported on Inkplate 2?
Original message (Croatian)
Dober dan, radim projekt s Inkplate 2 i koristim InkplateLibrary instaliranu putem Arduino IDE Library Managera. Naišao sam na dva problema koja onemogućuju kompilaciju koda: Inicijalizacija / 1-bitni način rada U nekim primjerima inicijalizacija izgleda ovako: Inkplate display(INKPLATE_1BIT); display.begin(); U drugima ovako: Inkplate display; display.begin(INKPLATE_1BIT); Međutim, u mojoj verziji knjižnice oba primjera ne uspijevaju se kompilirati: Konstruktor s argumentom → “no matching function” begin(INKPLATE_1BIT) → “no matching function for call to ‘Inkplate::begin(int)’”
Dakle, nije jasno kako pravilno postaviti 1-bitni način rada na Inkplate 2. Dinamičko podešavanje veličine fonta
Želio bih dinamički prilagoditi veličinu teksta prema širini zaslona pomoću getTextBounds(), primjerice: int textSize = 3; while (textSize > 1) { display.setTextSize(textSize); display.getTextBounds(headerText, 0, 0, &x1, &y1, &w, &h); if (w <= display.width() - 10) break; textSize–; } Nažalost, i ovo se ne može kompilirati – pojavljuje se greška kod poziva getTextBounds(). Za referencu prilažem dva minimalna .ino primjera koja demonstriraju probleme: Minimal example 1 – initialization problem #include Inkplate display(INKPLATE_1BIT); // does not compile void setup() { Serial.begin(115200); display.begin(); // or: display.begin(INKPLATE_1BIT); → also doesn’t } void loop() { } Minimal example 2 – dynamic text sizing problem #include Inkplate display(INKPLATE_1BIT); void setup() { Serial.begin(115200); display.begin(); String headerText = “Very Long Station Name That Might Not Fit”; int16_t x1, y1; uint16_t w, h; int textSize = 3; while (textSize > 1) { display.setTextSize(textSize); //
compilation fails here display.getTextBounds(headerText, 0, 0, &x1, &y1, &w, &h); if (w <= display.width() - 10) break; textSize–; } display.setCursor(10, 20); display.print(headerText); display.display(); } void loop() { } Molim te, objasni koji je ispravan način inicijalizacije Inkplate 2 u 1-bitnom modu u trenutnoj verziji knjižnice? Je li dinamičko podešavanje veličine fonta s getTextBounds() podržano na Inkplate 2? Ako da, molim Vas za minimalni radni primjer. Općenite primjedbe su da sam, pregledavajući razna foruma, saznao za nesklad između verzija biblioteka. Na primjer, konstruktor Inkplate(INKPLATE_1BIT) radi samo u novijim verzijama, što može dovesti do pogrešaka pri kompilaciji ako se koristi verzija instalirana putem Library Managera. Neki linkovi su zastarjeli i gubi se vrijeme na pretraživanje jer navedene stranice ili repozitoriji više ne postoje. Ako moje pisanje na hrvatskom nije točno i/ili potpuno razumljivo, možemo prijeći na engleski. Srdačan pozdrav, [name removed]