Improvements due to code review

This commit is contained in:
svn2208
2021-11-19 10:42:10 +01:00
parent 6e96b99d13
commit 269be21e44
3 changed files with 16 additions and 9 deletions
@@ -165,7 +165,7 @@ Adafruit_HMC5883_Unified::Adafruit_HMC5883_Unified(int32_t sensorID) {
/**************************************************************************/
bool Adafruit_HMC5883_Unified::begin() {
// Enable I2C
Wire.begin();
//Wire.begin(); // This is already done by ESP Easy Core
// Enable the magnetometer
write8(HMC5883_ADDRESS_MAG, HMC5883_REGISTER_MAG_MR_REG_M, 0x00);
+14 -7
View File
@@ -7,7 +7,7 @@
#include <Adafruit_Sensor.h>
#include <Adafruit_HMC5883_U.h>
bool P121_data_struct::begin(bool initSettings)
bool P121_data_struct::begin()
{
if (!initialized)
{
@@ -18,16 +18,23 @@ bool P121_data_struct::begin(bool initSettings)
// Set up oversampling and filter initialization
sensor_t sensor;
mag.getSensor(&sensor);
#ifndef BUILD_NO_DEBUG
addLog(LOG_LEVEL_DEBUG, F("------------------------------------"));
String log = F("Sensor: ");
log += sensor.name;
log += "\nDriver Ver: " + sensor.version;
log += "\nUnique ID: " + sensor.sensor_id;
log += "\nMax Value: " + String(sensor.max_value);
log += "\nMin Value: " + String(sensor.min_value);
log += "\nResolution: " + String(sensor.resolution);
log += F(sensor.name);
log += F("\nDriver Ver: ");
log += sensor.version;
log += F("\nUnique ID: ");
log += sensor.sensor_id;
log += F("\nMax Value: ");
log += String(sensor.max_value);
log += F("\nMin Value: ");
log += String(sensor.min_value);
log += F("\nResolution: ");
log += String(sensor.resolution);
addLog(LOG_LEVEL_DEBUG, log);
addLog(LOG_LEVEL_DEBUG, F("------------------------------------"));
#endif
}
}
+1 -1
View File
@@ -9,7 +9,7 @@
struct P121_data_struct : public PluginTaskData_base
{
bool begin(bool initSettings = true);
bool begin();
Adafruit_HMC5883_Unified mag = Adafruit_HMC5883_Unified(12345);