#include <Adafruit_ILI9341.h>
#include <Adafruit_GFX.h>
#define TFT_CS 10
#define TFT_DC 9
#define TFT_RST 8
// Create an instance of the ILI9341 display
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
// Function to draw emoji at a given position (x, y) on the screen
void drawEmoji(int16_t x, int16_t y, const uint16_t* emoji_bitmap, int16_t width, int16_t height) {
tft.startWrite();
tft.setAddrWindow(x, y, x + width - 1, y + height - 1);
for (int16_t y0 = 0; y0 < height; y0++) {
for (int16_t x0 = 0; x0 < width; x0++) {
tft.write16(emoji_bitmap[y0 * width + x0]);
}
}
tft.endWrite();
}
// Emoji bitmap data (replace this with your own emoji bitmaps)
// Each emoji is represented by an array of 16-bit color values
const uint16_t emoji_smiley[] = {
0x0000, 0x0000, 0x0000, 0xE0E0, 0xE0E0, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xF9F9, 0xE0E0, 0xE0E0, 0xF9F9, 0x0000, 0x0000,
0x0000, 0x0000, 0xE0E0, 0x0000, 0x0000, 0xE0E0, 0x0000, 0x0000,
0x0000, 0xE0E0, 0x0000, 0x0000, 0x0000, 0x0000, 0xE0E0, 0x0000,
0xE0E0, 0x0000, 0xF9F9, 0x0000, 0x0000, 0xF9F9, 0x0000, 0xE0E0,
0xE0E0, 0xF9F9, 0xE0E0, 0xE0E0, 0xE0E0, 0xF9F9, 0xE0E0, 0xE0E0,
0xE0E0, 0x0000, 0x0000, 0xF9F9, 0xF9F9, 0x0000, 0x0000, 0xE0E0,
0x0000, 0x0000, 0x0000, 0xE0E0, 0xE0E0, 0x0000, 0x0000, 0x0000,
};
void setup() {
tft.begin();
tft.setRotation(3); // Adjust the rotation to match your display orientation
}
void loop() {
tft.fillScreen(ILI9341_BLACK); // Clear the screen
// Draw the emoji at position (50, 50)
drawEmoji(50, 50, emoji_smiley, 16, 16);
delay(5000); // Wait for 5 seconds before redrawing the emoji
}
Loading
ili9341-cap-touch
ili9341-cap-touch