mirror of
https://github.com/justcallmekoko/ESP32Marauder.git
synced 2025-12-23 07:29:14 -08:00
Add detect ESP8266
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#define ESP_RST 14
|
||||
#define ESP_ZERO 13
|
||||
#define BAUD 57600
|
||||
#define BAUD 115200
|
||||
|
||||
extern Display display_obj;
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user