Added macro for controling serial port
This commit is contained in:
parent
b6fcf94191
commit
411cec08c7
@ -153,8 +153,8 @@ bool Config::saveFile() {
|
||||
createJson(doc);
|
||||
|
||||
#if LOG_LEVEL == 6 && !defined(DISABLE_LOGGING)
|
||||
serializeJson(doc, Serial);
|
||||
Serial.print(CR);
|
||||
serializeJson(doc, EspSerial);
|
||||
EspSerial.print(CR);
|
||||
#endif
|
||||
|
||||
serializeJson(doc, configFile);
|
||||
@ -192,8 +192,8 @@ bool Config::loadFile() {
|
||||
DynamicJsonDocument doc(3000);
|
||||
DeserializationError err = deserializeJson(doc, configFile);
|
||||
#if LOG_LEVEL == 6
|
||||
serializeJson(doc, Serial);
|
||||
Serial.print(CR);
|
||||
serializeJson(doc, EspSerial);
|
||||
EspSerial.print(CR);
|
||||
#endif
|
||||
configFile.close();
|
||||
|
||||
@ -395,8 +395,8 @@ bool AdvancedConfig::saveFile() {
|
||||
doc[PARAM_HW_IGNORE_LOW_ANGLES] = this->isIgnoreLowAnges();
|
||||
|
||||
#if LOG_LEVEL == 6 && !defined(DISABLE_LOGGING)
|
||||
serializeJson(doc, Serial);
|
||||
Serial.print(CR);
|
||||
serializeJson(doc, EspSerial);
|
||||
EspSerial.print(CR);
|
||||
#endif
|
||||
|
||||
serializeJson(doc, configFile);
|
||||
@ -434,8 +434,8 @@ bool AdvancedConfig::loadFile() {
|
||||
DynamicJsonDocument doc(512);
|
||||
DeserializationError err = deserializeJson(doc, configFile);
|
||||
#if LOG_LEVEL == 6
|
||||
serializeJson(doc, Serial);
|
||||
Serial.print(CR);
|
||||
serializeJson(doc, EspSerial);
|
||||
EspSerial.print(CR);
|
||||
#endif
|
||||
configFile.close();
|
||||
|
||||
|
@ -314,14 +314,14 @@ void GyroSensor::calibrateSensor() {
|
||||
Log.verbose(F("GYRO: Calibrating sensor" CR));
|
||||
#endif
|
||||
// accelgyro.PrintActiveOffsets();
|
||||
// Serial.print( CR );
|
||||
// EspSerial.print( CR );
|
||||
|
||||
accelgyro.setDLPFMode(MPU6050_DLPF_BW_5);
|
||||
accelgyro.CalibrateAccel(6); // 6 = 600 readings
|
||||
accelgyro.CalibrateGyro(6);
|
||||
|
||||
accelgyro.PrintActiveOffsets();
|
||||
Serial.print(CR);
|
||||
EspSerial.print(CR);
|
||||
|
||||
_calibrationOffset.ax = accelgyro.getXAccelOffset();
|
||||
_calibrationOffset.ay = accelgyro.getYAccelOffset();
|
||||
|
@ -203,11 +203,9 @@ void printBuildOptions() {
|
||||
|
||||
SerialDebug::SerialDebug(const uint32_t serialSpeed) {
|
||||
// Start serial with auto-detected rate (default to defined BAUD)
|
||||
//Serial.flush();
|
||||
Serial.begin(serialSpeed);
|
||||
Serial.println("Serial connection established");
|
||||
|
||||
getLog()->begin(LOG_LEVEL, &Serial, true);
|
||||
EspSerial.begin(serialSpeed);
|
||||
EspSerial.println("Serial connection established");
|
||||
getLog()->begin(LOG_LEVEL, &EspSerial, true);
|
||||
getLog()->setPrefix(printTimestamp);
|
||||
getLog()->notice(F("SDBG: Serial logging started at %u." CR), serialSpeed);
|
||||
}
|
||||
|
@ -22,6 +22,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#include <ble.hpp>
|
||||
#undef LOG_LEVEL_ERROR
|
||||
#undef LOG_LEVEL_INFO
|
||||
#include <calc.hpp>
|
||||
#include <config.hpp>
|
||||
#include <gyro.hpp>
|
||||
|
@ -92,4 +92,11 @@ extern RunMode runMode;
|
||||
// #define PIN_A0 A4
|
||||
#endif
|
||||
|
||||
#if defined(ESP32C3) && defined(USE_SERIAL0)
|
||||
#define EspSerial Serial0
|
||||
// #warning "Using Serial0 for output RX/TX pins on ESP32C3"
|
||||
#else
|
||||
#define EspSerial Serial
|
||||
#endif
|
||||
|
||||
#endif // SRC_MAIN_HPP_
|
||||
|
@ -174,11 +174,11 @@ class TemplatingEngine {
|
||||
void dumpAll() {
|
||||
int max = sizeof(_items) / sizeof(KeyVal);
|
||||
for (int i = 0; i < max; i++) {
|
||||
Serial.print("Key=\'");
|
||||
Serial.print(_items[i].key.c_str());
|
||||
Serial.print("\', Val=\'");
|
||||
Serial.print(_items[i].val.c_str());
|
||||
Serial.println("\'");
|
||||
EspSerial.print("Key=\'");
|
||||
EspSerial.print(_items[i].key.c_str());
|
||||
EspSerial.print("\', Val=\'");
|
||||
EspSerial.print(_items[i].val.c_str());
|
||||
EspSerial.println("\'");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,8 +96,8 @@ void WebServerHandler::webHandleConfig() {
|
||||
#endif
|
||||
|
||||
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
|
||||
serializeJson(doc, Serial);
|
||||
Serial.print(CR);
|
||||
serializeJson(doc, EspSerial);
|
||||
EspSerial.print(CR);
|
||||
#endif
|
||||
|
||||
String out;
|
||||
@ -280,8 +280,8 @@ void WebServerHandler::webHandleStatus() {
|
||||
#endif
|
||||
|
||||
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
|
||||
serializeJson(doc, Serial);
|
||||
Serial.print(CR);
|
||||
serializeJson(doc, EspSerial);
|
||||
EspSerial.print(CR);
|
||||
#endif
|
||||
|
||||
String out;
|
||||
@ -631,8 +631,8 @@ void WebServerHandler::webHandleConfigAdvancedRead() {
|
||||
doc[PARAM_HW_IGNORE_LOW_ANGLES] = myAdvancedConfig.isIgnoreLowAnges();
|
||||
|
||||
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
|
||||
serializeJson(doc, Serial);
|
||||
Serial.print(CR);
|
||||
serializeJson(doc, EspSerial);
|
||||
EspSerial.print(CR);
|
||||
#endif
|
||||
|
||||
String out;
|
||||
@ -714,8 +714,8 @@ void WebServerHandler::webHandleFormulaRead() {
|
||||
}
|
||||
|
||||
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
|
||||
serializeJson(doc, Serial);
|
||||
Serial.print(CR);
|
||||
serializeJson(doc, EspSerial);
|
||||
EspSerial.print(CR);
|
||||
#endif
|
||||
|
||||
String out;
|
||||
@ -829,8 +829,8 @@ void WebServerHandler::webHandleTestPush() {
|
||||
doc.clear();
|
||||
|
||||
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
|
||||
serializeJson(doc, Serial);
|
||||
Serial.print(CR);
|
||||
serializeJson(doc, EspSerial);
|
||||
EspSerial.print(CR);
|
||||
#endif
|
||||
|
||||
_server->send(200, "application/json", out.c_str());
|
||||
@ -921,8 +921,8 @@ void WebServerHandler::webHandleConfigFormatRead() {
|
||||
out += "\"}";
|
||||
|
||||
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
|
||||
Serial.print(out.c_str());
|
||||
Serial.print(CR);
|
||||
EspSerial.print(out.c_str());
|
||||
EspSerial.print(CR);
|
||||
#endif
|
||||
|
||||
_server->send(200, "application/json", out.c_str());
|
||||
|
@ -176,23 +176,23 @@ void WifiConnection::connectAsync(int wifiIndex) {
|
||||
|
||||
bool WifiConnection::waitForConnection(int maxTime) {
|
||||
#if DEBUG_LEVEL == 6
|
||||
WiFi.printDiag(Serial);
|
||||
WiFi.printDiag(EspSerial);
|
||||
#endif
|
||||
int i = 0;
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
delay(100);
|
||||
|
||||
if (i % 10) Serial.print(".");
|
||||
if (i % 10) EspSerial.print(".");
|
||||
|
||||
if (i++ >
|
||||
(maxTime * 10)) { // Try for maxTime seconds. Since delay is 100ms.
|
||||
writeErrorLog("WIFI: Failed to connect to wifi %d", WiFi.status());
|
||||
WiFi.disconnect();
|
||||
Serial.print(CR);
|
||||
EspSerial.print(CR);
|
||||
return false; // Return to main that we have failed to connect.
|
||||
}
|
||||
}
|
||||
Serial.print(CR);
|
||||
EspSerial.print(CR);
|
||||
Log.notice(F("WIFI: Connected to wifi %s ip=%s." CR), WiFi.SSID().c_str(),
|
||||
getIPAddress().c_str());
|
||||
Log.notice(F("WIFI: Using mDNS name %s." CR), myConfig.getMDNS());
|
||||
|
Loading…
Reference in New Issue
Block a user