From 3bf9c6600d1af436a600b5f0d3fcf2a7fd01a48a Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Sat, 26 Aug 2023 12:53:25 +0700 Subject: [PATCH] Serial Output adjustment --- platformio.ini | 5 +++-- src/main.cpp | 31 ++++++++++++++++++++++--------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/platformio.ini b/platformio.ini index 03bad5f..7110682 100644 --- a/platformio.ini +++ b/platformio.ini @@ -12,8 +12,9 @@ platform = espressif32 board = wt32-eth01 framework = arduino -lib_deps = siwats/espmegapror3 +lib_deps = siwats/espmegapror3@^1.0.2 knolleary/PubSubClient@^2.8 ivanseidel/ArduinoThread@^2.1.1 arduino-libraries/Arduino_BuiltIn@^1.0.0 - dersimn/PubSubClientTools@^0.6 \ No newline at end of file + dersimn/PubSubClientTools@^0.6 +monitor_speed = 115200 \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index e19bdfd..8972a1b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -44,6 +44,7 @@ void mqtt_connect(); void mqtt_subscribe(); void thread_initialization(); void mqtt_callback(String topic, String message); +void io_begin(); void publish_pwm_states(); void publish_pwm_state(int id); @@ -63,17 +64,12 @@ StaticThreadController<1> thread_controller(&mqtt_reconnector); void setup() { - ESPMega_begin(); Serial.begin(115200); Serial.println("ESPMega R3 Initializing . . ."); - Serial.println("Initializing I/O . . ."); - memset(pwm_states, 0, PWM_COUNT); - memset(pwm_values, 255, PWM_COUNT); - Serial.println("Initializing Network . . ."); + ESPMega_begin(); network_begin(); Serial.println("Initializing MQTT . . ."); mqtt_connect(); - Serial.println("Initializing Threads . . ."); thread_initialization(); } @@ -82,13 +78,28 @@ void loop() virtual_interrupt_loop(); mqtt_client.loop(); ESPMega_loop(); + thread_controller.run(); +} + +void io_begin() +{ + Serial.println("Initializing I/O . . ."); + memset(pwm_states, 0, PWM_COUNT); + memset(pwm_values, 255, PWM_COUNT); } void network_begin() { - ETH.setHostname(HOSTNAME); - ETH.config(IP, GATEWAY, SUBNET, DNS); + Serial.print("Initializing Network "); ETH.begin(); + ETH.setHostname(HOSTNAME); + ETH.config(IP, GATEWAY, SUBNET, DNS, DNS); + for (int i = 0; i < 3; i++) + { + delay(2500); + Serial.print(" ."); + } + Serial.println(); } void mqtt_connect() @@ -120,7 +131,8 @@ void mqtt_subscribe() void thread_initialization() { - Serial.print("Initializing MQTT Thread\n"); + Serial.println("Initializing Threads . . ."); + Serial.println("Initializing MQTT Thread . . ."); mqtt_reconnector.onRun(mqtt_connect); mqtt_reconnector.setInterval(30000); } @@ -131,6 +143,7 @@ void mqtt_callback(String topic, String message) void virtual_interrupt_callback(int pin, int state) { + Serial.printf("Pin %d changed to %d\n", pin, state); } void virtual_interrupt_loop()