Im objektorientierten C++ wäre ein Lösungsansatz die Definition eines Images (hier als Struktur).
Danach muss dem display-Objekt noch beigebracht werden, wie Images gezeichnet werden:
Code:
// Definition eines Images
struct Image {
const int16_t width, height;
const char* text;
const uint16_t* data;
};
// Klasse MyTFT erweitert Adafruit_ILI9341 um Methode drawImage
class MyTFT : public Adafruit_ILI9341 {
public:
void drawImage(int16_t x, int16_t y, Image i) {
this->drawRGBBitmap(x, y, i.data, i.height, i.width);
}
};
// Bitmaps im Flash
uint16_t wolke_bitmap[] PROGMEM = {
0x0000, 0x0020, 0x0020, 0x0020, 0x0020, 0x0841
};
uint16_t sonne_bitmap[] PROGMEM = {
0x0861, 0x1082, 0x10a2, 0x18c3, 0x18e3, 0x2104, 0x2124
};
// Images erstellen
const Image wolke = { 20, 25, "Wolke", wolke_bitmap };
const Image sonne = { 68, 2, "Sonne", sonne_bitmap };
// display-Objekt, dass mit Images umgehen kann, erstellen
MyTFT display = MyTFT(TFT_CS, TFT_DC, TFT_RST); // Hier Pins eintragen
//...
void loop(){
//...
display.drawImage(10, 10, sonne);
}
Lesezeichen