martinberlin / cale-idf

CalEPD is an Epaper component driver for the ESP-IDF framework with GFX and font support, optional touch interface, compatible with ESP32 / S2 / S3 / C3
https://fasani.de
Apache License 2.0
270 stars 24 forks source link

Add display.printf like function #65

Closed martinberlin closed 1 year ago

martinberlin commented 1 year ago

Is your feature request related to a problem? Please describe. Right now display.print assess only a string or char* but users want to add printf

Describe the solution you'd like

Implement something like shown here: https://stackoverflow.com/questions/14766040/function-arguments-like-printf-in-c

So you can show sensor information in ePaper like: display.printf("Air quality: %s CO2: %d", "good", 500);

Results in:

Air quality: good CO2: 500
martinberlin commented 1 year ago

Added like display.printerf(char* buffer, args) https://github.com/martinberlin/cale-idf/commit/818179647a25519f68857fe63c2844f25c3d62cd

Typically called like: printerf("%d CO2", co2_int_value);

So this function will work like a printf. Didn't use that since I'm inheriting this from all classes and want to do that for all the models in a single place.

https://github.com/martinberlin/cale-idf/commit/818179647a25519f68857fe63c2844f25c3d62cd