mirror of
https://github.com/alexhopeoconnor/firmware.git
synced 2026-10-14 07:21:30 +10:00
I thought git would be smart enough to understand all the whitespace changes but even with all the flags I know to make it ignore theses it still blows up if there are identical changes on both sides.
I have a solution but it require creating a new commit at the merge base for each conflicting PR and merging it into develop.
I don't think blowing up all PRs is worth for now, maybe if we can coordinate this for V3 let's say.
This reverts commit 0d11331d18.
49 lines
1.4 KiB
C++
49 lines
1.4 KiB
C++
#include "configuration.h"
|
|
|
|
#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR && __has_include(<ClosedCube_OPT3001.h>)
|
|
|
|
#include "../mesh/generated/meshtastic/telemetry.pb.h"
|
|
#include "OPT3001Sensor.h"
|
|
#include "TelemetrySensor.h"
|
|
#include <ClosedCube_OPT3001.h>
|
|
|
|
OPT3001Sensor::OPT3001Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_OPT3001, "OPT3001") {}
|
|
|
|
bool OPT3001Sensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
|
|
{
|
|
LOG_INFO("Init sensor: %s", sensorName);
|
|
auto errorCode = opt3001.begin(dev->address.address);
|
|
status = errorCode == NO_ERROR;
|
|
if (!status) {
|
|
return status;
|
|
}
|
|
|
|
OPT3001_Config newConfig;
|
|
|
|
newConfig.RangeNumber = 0b1100;
|
|
newConfig.ConvertionTime = 0b0;
|
|
newConfig.Latch = 0b1;
|
|
newConfig.ModeOfConversionOperation = 0b11;
|
|
|
|
OPT3001_ErrorCode errorConfig = opt3001.writeConfig(newConfig);
|
|
if (errorConfig != NO_ERROR) {
|
|
LOG_ERROR("OPT3001 configuration error #%d", errorConfig);
|
|
}
|
|
status = errorConfig == NO_ERROR;
|
|
|
|
initI2CSensor();
|
|
return status;
|
|
}
|
|
|
|
bool OPT3001Sensor::getMetrics(meshtastic_Telemetry *measurement)
|
|
{
|
|
measurement->variant.environment_metrics.has_lux = true;
|
|
OPT3001 result = opt3001.readResult();
|
|
|
|
measurement->variant.environment_metrics.lux = result.lux;
|
|
LOG_INFO("Lux: %f", measurement->variant.environment_metrics.lux);
|
|
|
|
return true;
|
|
}
|
|
|
|
#endif |