diff --git a/esp32_marauder/a32u4_interface.cpp b/esp32_marauder/a32u4_interface.cpp index 759707f..1a1f2e7 100644 --- a/esp32_marauder/a32u4_interface.cpp +++ b/esp32_marauder/a32u4_interface.cpp @@ -19,16 +19,16 @@ void A32u4Interface::test() { } void A32u4Interface::main(uint32_t current_time) { -/* + if (current_time - this->initTime >= 1000) { this->initTime = millis(); - MySerial_two.write("PING"); + //MySerial_two.write("PING"); - delay(1); + //delay(1); if (MySerial_two.available()) { Serial.println("Got A32U4 Serial data"); - Serial.println(MySerial_two.readString()); + Serial.println(MySerial_two.read()); } } diff --git a/esp32_marauder/esp32_marauder.ino b/esp32_marauder/esp32_marauder.ino index f8d2020..4459a81 100644 --- a/esp32_marauder/esp32_marauder.ino +++ b/esp32_marauder/esp32_marauder.ino @@ -74,10 +74,6 @@ void setup() Serial.begin(115200); //Serial.begin(115200); - - esp_obj.begin(); - - a32u4_obj.begin(); display_obj.RunSetup(); display_obj.tft.setTextColor(TFT_CYAN, TFT_BLACK); @@ -152,7 +148,7 @@ void setup() display_obj.tft.println(F("Starting...")); - delay(1000); + delay(500); display_obj.tft.setTextColor(TFT_WHITE, TFT_BLACK); @@ -166,7 +162,11 @@ void setup() digitalWrite(TFT_BL, HIGH); - delay(5000); + esp_obj.begin(); + + a32u4_obj.begin(); // This goes last to make sure nothing is messed up when reading serial + + delay(2000); menu_function_obj.RunSetup(); } diff --git a/esp32_marauder/esp_interface.cpp b/esp32_marauder/esp_interface.cpp index 4028250..f90270c 100644 --- a/esp32_marauder/esp_interface.cpp +++ b/esp32_marauder/esp_interface.cpp @@ -10,9 +10,40 @@ void EspInterface::begin() { digitalWrite(ESP_ZERO, HIGH); + Serial.println("Checking for ESP8266..."); + MySerial.begin(BAUD, SERIAL_8N1, 27, 26); - //this->bootRunMode(); + delay(100); + + //display_obj.tft.println("Checking for ESP8266..."); + + this->bootRunMode(); + + delay(500); + + while (MySerial.available()) + MySerial.read(); + + MySerial.write("PING"); + + delay(2000); + + String display_string = ""; + + while (MySerial.available()) { + display_string.concat((char)MySerial.read()); + } + + display_string.trim(); + + Serial.println("\nDisplay string: " + (String)display_string); + + if (display_string == "ESP8266 Pong") { + //display_obj.tft.println("ESP8266 Found!"); + Serial.println("ESP8266 Found!"); + this->supported = true; + } this->initTime = millis(); } @@ -42,7 +73,7 @@ void EspInterface::bootProgramMode() { digitalWrite(ESP_ZERO, HIGH); Serial.println("[!] Complete"); Serial.end(); - Serial.begin(BAUD); + Serial.begin(57600); } void EspInterface::bootRunMode() { @@ -75,11 +106,11 @@ void EspInterface::program() { void EspInterface::main(uint32_t current_time) { if (current_time - this->initTime >= 1000) { this->initTime = millis(); - MySerial.write("PING"); + //MySerial.write("PING"); } - if (MySerial.available()) { - Serial.write((uint8_t)MySerial.read()); + while (MySerial.available()) { + Serial.print((char)MySerial.read()); } if (Serial.available()) { diff --git a/esp32_marauder/esp_interface.h b/esp32_marauder/esp_interface.h index cd850f2..5821b93 100644 --- a/esp32_marauder/esp_interface.h +++ b/esp32_marauder/esp_interface.h @@ -6,7 +6,7 @@ #define ESP_RST 14 #define ESP_ZERO 13 -#define BAUD 57600 +#define BAUD 115200 extern Display display_obj; diff --git a/esp8266_marauder/esp8266_marauder.ino b/esp8266_marauder/esp8266_marauder.ino index f328aa9..ad04ab2 100644 --- a/esp8266_marauder/esp8266_marauder.ino +++ b/esp8266_marauder/esp8266_marauder.ino @@ -1,13 +1,37 @@ // the setup function runs once when you press reset or power the board void setup() { + Serial.begin(115200); + + delay(100); + // initialize digital pin LED_BUILTIN as an output. pinMode(LED_BUILTIN, OUTPUT); + + digitalWrite(LED_BUILTIN, HIGH); } // the loop function runs over and over again forever void loop() { - digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) - delay(1000); // wait for a second - digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW - delay(1000); // wait for a second + //digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) + //delay(1000); // wait for a second + //digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW + //delay(1000); // wait for a second + + if (Serial.available()) { + String input = Serial.readString(); + + input.trim(); + + if (input == "PING") { + Serial.println("ESP8266 Pong"); + + digitalWrite(LED_BUILTIN, LOW); + delay(1); + digitalWrite(LED_BUILTIN, HIGH); + } + + //Serial.println(input); + } + else + delay(1); }