diff --git a/src/debug.h b/src/debug.h index ec303a2..ae4f7b0 100644 --- a/src/debug.h +++ b/src/debug.h @@ -38,7 +38,8 @@ #define LOG_LEVEL LOG_LEVEL_DEBUG #if LOG_LEVEL == LOG_LEVEL_TRACE -#define FULL_DEBUG +#define DEBUG_SENSOR +#define DEBUG_NETWORK #endif #define serialDebug false // Set to true to get Serial output for debugging diff --git a/src/network/udpclient.cpp b/src/network/udpclient.cpp index 402b186..396586a 100644 --- a/src/network/udpclient.cpp +++ b/src/network/udpclient.cpp @@ -575,7 +575,7 @@ void ServerConnection::connect() // receive incoming UDP packets int len = Udp.read(incomingPacket, sizeof(incomingPacket)); -#ifdef FULL_DEBUG +#ifdef DEBUG_NETWORK udpClientLogger.trace("Received %d bytes from %s, port %d", packetSize, Udp.remoteIP().toString().c_str(), Udp.remotePort()); udpClientLogger.traceArray("UDP packet contents: ", incomingPacket, len); #endif @@ -633,7 +633,7 @@ void ServerConnection::update(Sensor * const sensor, Sensor * const sensor2) { int len = Udp.read(incomingPacket, sizeof(incomingPacket)); // receive incoming UDP packets -#ifdef FULL_DEBUG +#ifdef DEBUG_NETWORK udpClientLogger.trace("Received %d bytes from %s, port %d", packetSize, Udp.remoteIP().toString().c_str(), Udp.remotePort()); udpClientLogger.traceArray("UDP packet contents: ", incomingPacket, len); #endif diff --git a/src/sensors/bmi160sensor.cpp b/src/sensors/bmi160sensor.cpp index eaf0690..63a595a 100644 --- a/src/sensors/bmi160sensor.cpp +++ b/src/sensors/bmi160sensor.cpp @@ -193,7 +193,7 @@ void BMI160Sensor::startCalibration(int calibrationType) { uint16_t gyroCalibrationSamples = 2500; float rawGxyz[3] = {0}; -#ifdef FULL_DEBUG +#ifdef DEBUG_SENSOR m_Logger.trace("Calibration temperature: %f", temperature); #endif @@ -213,7 +213,7 @@ void BMI160Sensor::startCalibration(int calibrationType) { config->calibration[sensorId].G_off[1] = rawGxyz[1] / gyroCalibrationSamples; config->calibration[sensorId].G_off[2] = rawGxyz[2] / gyroCalibrationSamples; -#ifdef FULL_DEBUG +#ifdef DEBUG_SENSOR m_Logger.trace("Gyro calibration results: %f %f %f", config->calibration[sensorId].G_off[0], config->calibration[sensorId].G_off[1], config->calibration[sensorId].G_off[2]); #endif diff --git a/src/sensors/bno080sensor.cpp b/src/sensors/bno080sensor.cpp index 8cc7a35..d51966f 100644 --- a/src/sensors/bno080sensor.cpp +++ b/src/sensors/bno080sensor.cpp @@ -28,7 +28,7 @@ void BNO080Sensor::motionSetup() { -#ifdef FULL_DEBUG +#ifdef DEBUG_SENSOR imu.enableDebugging(Serial); #endif if(!imu.begin(addr, Wire, m_IntPin)) { @@ -216,7 +216,7 @@ void BNO080Sensor::sendData() if (useMagnetometerAllTheTime) Network::sendMagnetometerAccuracy(magneticAccuracyEstimate, sensorId); -#ifdef FULL_DEBUG +#ifdef DEBUG_SENSOR m_Logger.trace("Quaternion: %f, %f, %f, %f", UNPACK_QUATERNION(quaternion)); #endif } diff --git a/src/sensors/icm20948sensor.cpp b/src/sensors/icm20948sensor.cpp index b0b5e83..ae242af 100644 --- a/src/sensors/icm20948sensor.cpp +++ b/src/sensors/icm20948sensor.cpp @@ -36,7 +36,7 @@ int bias_save_periods[] = { 120, 180, 300, 600, 600 }; // 2min + 3min + 5min + 1 void ICM20948Sensor::save_bias(bool repeat) { #if defined(SAVE_BIAS) && SAVE_BIAS -#ifdef FULL_DEBUG +#ifdef DEBUG_SENSOR m_Logger.trace("Saving Bias"); #endif #if ESP8266 @@ -62,7 +62,7 @@ void ICM20948Sensor::save_bias(bool repeat) { EEPROM.begin(4096); // max memory usage = 4096 EEPROM.get(addr + 100, count); // 1st imu counter in EEPROM addr: 0x69+100=205, 2nd addr: 0x68+100=204 -#ifdef FULL_DEBUG +#ifdef DEBUG_SENSOR m_Logger.trace("[0x%02X] EEPROM position: %d, count: %d", addr, addr + 100, count); #endif @@ -73,7 +73,7 @@ void ICM20948Sensor::save_bias(bool repeat) { } EEPROM.put(addr + 100, count); -#ifdef FULL_DEBUG +#ifdef DEBUG_SENSOR m_Logger.trace("[0x%02X] bias gyro save(%d): [%d, %d, %d]", addr, count * 12, bias_g[0], bias_g[1], bias_g[2]); m_Logger.trace("[0x%02X] bias accel save(%d): [%d, %d, %d]", addr, count * 12, bias_a[0], bias_a[1], bias_a[2]); m_Logger.trace("[0x%02X] bias CPass save(%d): [%d, %d, %d]", addr, count * 12, bias_m[0], bias_m[1], bias_m[2]); @@ -115,7 +115,7 @@ void ICM20948Sensor::save_bias(bool repeat) { bool gyro_set = bias_g[0] && bias_g[1] && bias_g[2]; bool mag_set = bias_m[0] && bias_m[1] && bias_m[2]; -#ifdef FULL_DEBUG +#ifdef DEBUG_SENSOR m_Logger.trace("bias gyro on IMU: %d, %d, %d", bias_g[0], bias_g[1], bias_g[2]); m_Logger.trace("bias accel on IMU: %d, %d, %d", bias_a[0], bias_a[1], bias_a[2]); m_Logger.trace("bias mag on IMU: %d, %d, %d", bias_m[0], bias_m[1], bias_m[2]); @@ -128,7 +128,7 @@ void ICM20948Sensor::save_bias(bool repeat) { prefs.putInt(auxiliary ? "ba11" : "ba10", bias_a[1]); prefs.putInt(auxiliary ? "ba21" : "ba20", bias_a[2]); -#ifdef FULL_DEBUG +#ifdef DEBUG_SENSOR m_Logger.trace("Wrote Accel Bias"); #endif } @@ -139,7 +139,7 @@ void ICM20948Sensor::save_bias(bool repeat) { prefs.putInt(auxiliary ? "bg11" : "bg10", bias_g[1]); prefs.putInt(auxiliary ? "bg21" : "bg20", bias_g[2]); -#ifdef FULL_DEBUG +#ifdef DEBUG_SENSOR m_Logger.trace("Wrote Gyro Bias"); #endif } @@ -150,7 +150,7 @@ void ICM20948Sensor::save_bias(bool repeat) { prefs.putInt(auxiliary ? "bm11" : "bm10", bias_m[1]); prefs.putInt(auxiliary ? "bm21" : "bm20", bias_m[2]); -#ifdef FULL_DEBUG +#ifdef DEBUG_SENSOR m_Logger.trace("Wrote Mag Bias"); #endif } @@ -177,7 +177,7 @@ void ICM20948Sensor::load_bias() { EEPROM.begin(4096); // max memory usage = 4096 EEPROM.get(addr + 100, count); // 1st imu counter in EEPROM addr: 0x69+100=205, 2nd addr: 0x68+100=204 -#ifdef FULL_DEBUG +#ifdef DEBUG_SENSOR m_Logger.trace("[0x%02X] EEPROM position: %d, count: %d", addr, addr + 100, count); #endif @@ -191,7 +191,7 @@ void ICM20948Sensor::load_bias() { EEPROM.get(3072 + (count * 12), bias_m); // 3072 ~ 4056 EEPROM.end(); -#ifdef FULL_DEBUG +#ifdef DEBUG_SENSOR m_Logger.trace("[0x%02X] EEPROM gyro get(%d): [%d, %d, %d]", addr, count * 12, bias_g[0], bias_g[1], bias_g[2]); m_Logger.trace("[0x%02X] EEPROM accel get(%d): [%d, %d, %d]", addr, count * 12, bias_a[0], bias_a[1], bias_a[2]); m_Logger.trace("[0x%02X] EEPROM CPass get(%d): [%d, %d, %d]", addr, count * 12, bias_m[0], bias_m[1], bias_m[2]); @@ -239,7 +239,7 @@ void ICM20948Sensor::load_bias() { imu.SetBiasCPassZ(bias_m[2]); // Display both values from ESP32 and read back from IMU -#ifdef FULL_DEBUG +#ifdef DEBUG_SENSOR m_Logger.trace("On IMU and on ESP32 should match"); m_Logger.trace("bias gyro on ESP32 : [%d, %d, %d]", bias_g[0], bias_g[1], bias_g[2]); m_Logger.trace("bias accel on ESP32: [%d, %d, %d]", bias_a[0], bias_a[1], bias_a[2]); @@ -345,7 +345,7 @@ void ICM20948Sensor::motionSetup() { prefs.begin("ICM20948", false); #endif - #ifdef FULL_DEBUG + #ifdef DEBUG_SENSOR imu.enableDebugging(Serial); #endif // SparkFun_ICM-20948_ArduinoLibrary only supports 0x68 or 0x69 via boolean, if something else throw a error @@ -578,7 +578,7 @@ void ICM20948Sensor::motionLoop() { { dataavaliable = false; } -#ifdef FULL_DEBUG +#ifdef DEBUG_SENSOR else { m_Logger.trace("e0x%02x", readStatus); diff --git a/src/sensors/mpu9250sensor.cpp b/src/sensors/mpu9250sensor.cpp index aa58ed6..16bffa7 100644 --- a/src/sensors/mpu9250sensor.cpp +++ b/src/sensors/mpu9250sensor.cpp @@ -238,7 +238,7 @@ void MPU9250Sensor::startCalibration(int calibrationType) { Gxyz[1] /= calibrationSamples; Gxyz[2] /= calibrationSamples; -#ifdef FULL_DEBUG +#ifdef DEBUG_SENSOR m_Logger.trace("Gyro calibration results: %f %f %f", Gxyz[0], Gxyz[1], Gxyz[2]); #endif diff --git a/src/sensors/sensor.cpp b/src/sensors/sensor.cpp index 730f5e6..d9d19ca 100644 --- a/src/sensors/sensor.cpp +++ b/src/sensors/sensor.cpp @@ -34,7 +34,7 @@ void Sensor::sendData() { newData = false; Network::sendRotationData(&quaternion, DATA_TYPE_NORMAL, calibrationAccuracy, sensorId); -#ifdef FULL_DEBUG +#ifdef DEBUG_SENSOR m_Logger.trace("Quaternion: %f, %f, %f, %f", UNPACK_QUATERNION(quaternion)); #endif }