diff --git a/src/TCP.cpp b/src/TCP.cpp index 7b2fa17..0852fb0 100644 --- a/src/TCP.cpp +++ b/src/TCP.cpp @@ -73,6 +73,8 @@ void TCP::sendData(float& potData, int& emoteIndex) { } void TCP::receiveImage() { + client.setTimeout(500); + uint8_t* imageData = new uint8_t[w * h * 3]; // Allocate memory for a 64x80 image // Read bytes from the client and store the count of bytes received @@ -113,9 +115,6 @@ void TCP::receiveImage() { } else { Serial.print("Error: Expected "); - Serial.print(w * h * 3); - Serial.print(" bytes, but received "); - Serial.println(bytesRead); } delete[] imageData; // Clean up diff --git a/src/main.cpp b/src/main.cpp index 0ccec9e..bb5ca6a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -22,23 +22,17 @@ // Define some colors to match individual emotions const uint16_t emotionColors[] = { - 0xFFE0, // HAPPY = YELLOW - 0x07E0, // SAD = BLUE - 0xF800, // ANGRY = RED - 0xFA60, // FEAR = ORANGE - 0xF8FF, // SURPRISED = PURPLE - 0x07E0, // DISGUST = GREEN - 0xFFFF // NEUTRAL = WHITE + 0xF800, // HAPPY = YELLOW + 0xFFFF, // SAD = BLUE + 0x07E0, // ANGRY = RED + 0xFA60 // NEUTRAL = WHITE }; enum Emotion { - HAPPY, - SAD, - ANGRY, - FEAR, - SURPRISED, - DISGUST, - NEUTRAL + HAPPY = 0, + SAD = 1, + ANGRY = 2, + NEUTRAL = 3 }; int past_prc_reading = 0; @@ -47,7 +41,7 @@ float pot_data = 0; Emotion emote; int screen_width, screen_height; // pass for beta: n->stubborn_vectors p->sv-beta24, and change IP address to server! -TCP tcp("VM9093853", "kfrzuk8UngxyytUz", "192.168.0.169", 12345); +TCP tcp("stubborn_vectors", "sv-beta24", "192.168.0.3", 6762); TFT_eSPI tft = TFT_eSPI(); void setupWiFi(){ @@ -71,6 +65,7 @@ void drawText(String& emotionText, int& i){ tft.drawCentreString(ps, screen_width / 2, screen_height - (screen_height / 6), 1); int emotionIndex = static_cast(emote); tcp.sendData(dec_val, emotionIndex); + Serial.println(emotionIndex); } void setupEmotion(String& emotionText){ @@ -78,9 +73,6 @@ void setupEmotion(String& emotionText){ case HAPPY: emotionText = "HAPPY"; break; case SAD: emotionText = "SAD"; break; case ANGRY: emotionText = "ANGRY"; break; - case FEAR: emotionText = "FEAR"; break; - case SURPRISED: emotionText = "SURPRISED"; break; - case DISGUST: emotionText = "DISGUST"; break; case NEUTRAL: emotionText = "NEUTRAL"; break; } @@ -135,14 +127,13 @@ void setup(void) { } void loop() { - unsigned long currentTime = millis(); - tft.setCursor(0, 0, 2); int x = readSensor(5); String emotionText; setupEmotion(emotionText); tcp.receiveImage(); drawText(emotionText, x); + delay(50); }