#include #include #include #define TFT_CS 20 #define TFT_DC 22 #define TFT_RST 21 #define SERIAL_BAUDRATE 115200 #define SCREEN_WIDTH 240 #define SCREEN_HEIGHT 320 #define TITLE_SIZE 2 Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST); static const unsigned char PROGMEM image_passport_happy1_bits[] = {0x80,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0f,0xfe,0x00,0x00,0x00,0x00,0x70,0x01,0x80,0x00,0x00,0x00,0x8f,0xfe,0x60,0x00,0x00,0x01,0x7f,0xff,0x90,0x00,0x00,0x02,0xff,0xff,0xe8,0x00,0x00,0x05,0xff,0xff,0xf4,0x00,0x00,0x0b,0xff,0xff,0xf4,0x3f,0x00,0x17,0xff,0xff,0xfa,0xc0,0x80,0x17,0xff,0xff,0xfb,0x3f,0x40,0x2f,0xff,0xff,0xfc,0xff,0xa0,0x2f,0xff,0xff,0xfb,0xff,0xa0,0x5f,0xf8,0xff,0xf7,0xf8,0x20,0x5f,0xe0,0x3f,0xef,0xe0,0x20,0x5f,0xc0,0x3f,0xdf,0xc0,0x40,0x3f,0x80,0x7f,0xbf,0x80,0x80,0x3f,0x86,0x1f,0xff,0x01,0x00,0x3f,0x8d,0xef,0xfe,0x02,0x00,0x3f,0x8b,0xff,0xfc,0x04,0x00,0x3f,0xd7,0xff,0xf8,0x08,0x00,0x3f,0xf7,0xff,0xf0,0x10,0x00,0x3f,0xf7,0xff,0xe0,0x20,0x00,0x7f,0xff,0x7f,0xc0,0x60,0x00,0x7f,0xff,0x7f,0x80,0x18,0x00,0x7f,0xff,0x9e,0x1e,0x06,0x00,0x7f,0xff,0xe0,0x3f,0x81,0x80,0x7f,0xff,0xf8,0x1f,0xe0,0x60,0x7f,0xff,0xff,0x01,0xf8,0x10,0x7f,0xff,0xff,0xfe,0x00,0x28,0x7f,0xf3,0x9f,0xff,0xff,0xe8,0x7f,0xed,0x6f,0xff,0xff,0xe8,0x7f,0xee,0xef,0xff,0xff,0x90,0x7f,0xee,0xef,0xff,0xf8,0x60,0x7f,0xde,0xf7,0xa0,0x07,0x80,0x7f,0xde,0xf7,0xf0,0x38,0x00,0x7f,0xbe,0xfb,0xfe,0x20,0x00,0x7f,0xbe,0xfb,0xff,0xa0,0x00,0x7f,0x7e,0xfd,0xff,0xa0,0x00,0x7f,0x7e,0xfd,0xff,0xd0,0x00,0x7e,0xfe,0xfe,0xff,0xd0,0x00,0x7d,0xfe,0xff,0x7f,0xd0,0x00,0x7d,0xfc,0x7f,0x7f,0xe8,0x00,0x7b,0xfc,0x7f,0xbf,0xe8,0x00,0x77,0xfc,0x7f,0xdf,0xf4,0x00,0x4f,0xf8,0x3f,0xe7,0xf4,0x00,0x3f,0xf8,0x3f,0xf8,0xfa,0x00,0x7f,0xf0,0x1f,0xff,0x19,0x00,0x80,0x00,0x00,0x00,0x00,0x04}; static const unsigned char PROGMEM image_Cry_dolph_bits[] = {0xff,0xff,0xe0,0x00,0x7f,0xff,0xfe,0xff,0xff,0x80,0x00,0x0f,0xff,0xfe,0xff,0xfe,0x1f,0xff,0x83,0xff,0xfe,0xff,0xf8,0x7f,0xff,0xf0,0xff,0xfe,0xff,0xf1,0xff,0xff,0xfc,0x7f,0xfe,0xff,0xe7,0xff,0xff,0xff,0x3f,0xfe,0xff,0xcf,0xff,0xff,0xff,0x9f,0xfe,0xff,0x9f,0xff,0xff,0xff,0xcf,0xfe,0xff,0x3f,0xff,0xff,0xff,0xe7,0xfe,0xfe,0x7f,0xff,0xff,0xff,0xe7,0xfe,0xfe,0x7f,0xff,0xff,0xff,0xf3,0xfe,0xfc,0xff,0xff,0xff,0xff,0xf3,0xfe,0xfc,0xff,0xff,0xff,0xff,0xf9,0xfe,0xf9,0xff,0xff,0xff,0xff,0xf9,0xfe,0xf9,0xff,0xff,0xff,0xff,0xfc,0xfe,0xf9,0xff,0xff,0xff,0xff,0xfc,0xfe,0xf3,0xff,0xff,0xff,0xff,0x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x0f,0x0e,0x3f,0xed,0xff,0xd5,0x40,0x00,0x1e,0x3f,0xed,0xff,0xfe,0xa0,0x10,0xfe,0x3f,0xf3,0xff,0xf5,0x50,0x29,0xfe}; static const unsigned char PROGMEM image_passport_bad1_bits[] = {0x80,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0xe0,0x00,0x00,0x00,0x01,0x80,0x18,0x00,0x00,0x00,0x06,0x7f,0xe6,0x00,0x00,0x00,0x09,0xff,0xf9,0x80,0x00,0x00,0x17,0xff,0xfe,0x40,0x00,0x00,0x2f,0xff,0xff,0xa0,0x00,0x00,0x5f,0xff,0xff,0xd0,0x00,0x00,0xbf,0xff,0xff,0xd0,0x00,0x01,0x7f,0xff,0xff,0xe8,0x00,0x02,0xff,0xff,0xff,0xe8,0x00,0x02,0xff,0xff,0xff,0xf4,0x00,0x05,0xff,0x9f,0xff,0xf4,0x00,0x05,0xff,0xef,0xff,0xfa,0x00,0x0b,0xff,0xf7,0xff,0xfa,0x00,0x0b,0xff,0x19,0xff,0xfa,0x00,0x0b,0xfe,0x8c,0x7f,0xfa,0x00,0x17,0xfd,0x86,0x3f,0xfa,0x00,0x17,0xfd,0x93,0xff,0xfa,0x00,0x17,0xfd,0x81,0xff,0xfa,0x00,0x17,0xfd,0xc1,0xff,0xfa,0x00,0x17,0xfe,0xfd,0xff,0xfa,0x00,0x17,0xfc,0x03,0xff,0xfa,0x00,0x17,0xfb,0xef,0xff,0xfa,0x00,0x17,0xff,0xf7,0xff,0xaa,0x00,0x27,0xff,0xff,0xff,0xf3,0x00,0x27,0xff,0xff,0xff,0xfc,0x80,0x27,0xff,0xff,0xff,0xff,0x40,0x27,0xff,0x8f,0xff,0xff,0xa0,0x4f,0xff,0x73,0xff,0xff,0xd0,0x4f,0xff,0xfc,0xff,0xff,0xe8,0x4f,0xff,0xff,0x3f,0xff,0xe8,0x4f,0xff,0xff,0xcf,0xff,0xe8,0x2f,0xff,0xff,0xf3,0xf0,0x28,0x2f,0xff,0xff,0xfc,0x0f,0xc8,0x2f,0xff,0xfe,0x7f,0xff,0xe8,0x6f,0xff,0xff,0x8f,0xff,0xd0,0x6f,0xff,0xff,0xc0,0xff,0x20,0x6f,0xff,0xff,0xf0,0x00,0x40,0x6f,0xff,0xff,0xfc,0x01,0x80,0x6f,0xff,0xff,0xff,0x02,0x00,0x6f,0xff,0xff,0xff,0xc2,0x00,0x6f,0xff,0xff,0xff,0xfa,0x00,0x6f,0xff,0xff,0xff,0xfa,0x00,0x6f,0xff,0xff,0xff,0xfa,0x00,0x6f,0xff,0xff,0xff,0xfa,0x00,0x6f,0xff,0xff,0xff,0xfa,0x00,0x80,0x00,0x00,0x00,0x00,0x04}; void setup() { Serial.begin(SERIAL_BAUDRATE); tft.begin(); tft.setRotation(3); // Adjust rotation if needed // Clear screen to white tft.fillScreen(0xFFFF); // Set text properties for the title tft.setTextSize(TITLE_SIZE); tft.setTextColor(0x380B,0x04D7); // Print title tft.setCursor(text_wrap("Emotional Monitor"), 10); // Adjust position if needed tft.println("Emotional Monitor"); } int text_wrap(String text){ int16_t x, y; uint16_t w, h; // Get bounding box of the text tft.getTextBounds(text, 0, 0, &x, &y, &w, &h); // Calculate starting position in x-direction int displayWidth = tft.width(); return (displayWidth - w) / 2; } void loop() { if (Serial.available() > 0) { String command = Serial.readStringUntil('\n'); handleCommand(command); } } void handleCommand(String command) { // Display the received command on the ILI9341 screen tft.fillRect(0, TITLE_SIZE * 8 + 10, SCREEN_WIDTH, SCREEN_HEIGHT - TITLE_SIZE * 8 - 10, ILI9341_WHITE); // Clear previous text tft.setCursor(text_wrap("The person is feeling: "), TITLE_SIZE * 8 + 10); // Adjust position if needed tft.setTextColor(0x0000); tft.println("The person is feeling: "); tft.setCursor(text_wrap(command), TITLE_SIZE * 8 + 30); tft.println(command); // Perform actions based on the received command if (command == "happy") { tft.drawBitmap(131, 95, image_passport_happy1_bits, 46, 49, 0x0); // Add code to perform action for "happy" command } else if (command == "sad") { tft.drawBitmap(117, 70, image_Cry_dolph_bits, 55, 52, 0x0); } else if (command == "angry") { tft.drawBitmap(132, 100, image_passport_bad1_bits, 46, 49, 0x0000); // Add code to perform action for "angry" command } else { // Invalid command tft.println("Invalid command"); } // Clear screen to white after 3 seconds delay(3000); tft.fillScreen(0xFFFF); // Print title again tft.setTextSize(TITLE_SIZE); tft.setTextColor(0x380B,0x04D7); // Print title tft.setCursor(text_wrap("Emotional Monitor"), 10); // Adjust position if needed tft.println("Emotional Monitor"); }