mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-13 16:42:07 +00:00
derp...
This commit is contained in:
parent
a957065fe8
commit
a231cd2ad0
@ -11,7 +11,8 @@ int32_t RCWL9620Sensor::runOnce()
|
|||||||
if (!hasSensor()) {
|
if (!hasSensor()) {
|
||||||
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
|
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
|
||||||
}
|
}
|
||||||
status = begin(nodeTelemetrySensorsMap[sensorType].first, nodeTelemetrySensorsMap[sensorType].second);
|
status = 1;
|
||||||
|
begin(nodeTelemetrySensorsMap[sensorType].second, nodeTelemetrySensorsMap[sensorType].first);
|
||||||
return initI2CSensor();
|
return initI2CSensor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,16 +25,14 @@ bool RCWL9620Sensor::getMetrics(meshtastic_Telemetry *measurement)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RCWL9620Sensor::begin(uint8_t addr, TwoWire *wire)
|
void RCWL9620Sensor::begin(TwoWire *wire, uint8_t addr, uint8_t sda, uint8_t scl, uint32_t speed)
|
||||||
{
|
{
|
||||||
_wire = wire;
|
_wire = wire;
|
||||||
_addr = addr;
|
_addr = addr;
|
||||||
if (i2c_dev)
|
_sda = sda;
|
||||||
delete i2c_dev;
|
_scl = scl;
|
||||||
i2c_dev = new Adafruit_I2CDevice(_addr, _wire);
|
_speed = speed;
|
||||||
if (!i2c_dev->begin())
|
_wire->begin();
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float RCWL9620Sensor::getDistance()
|
float RCWL9620Sensor::getDistance()
|
||||||
|
@ -1,17 +1,19 @@
|
|||||||
#include "../mesh/generated/meshtastic/telemetry.pb.h"
|
#include "../mesh/generated/meshtastic/telemetry.pb.h"
|
||||||
#include "TelemetrySensor.h"
|
#include "TelemetrySensor.h"
|
||||||
#include <Adafruit_I2CDevice.h>
|
#include <Wire.h>
|
||||||
|
|
||||||
class RCWL9620Sensor : public TelemetrySensor
|
class RCWL9620Sensor : public TelemetrySensor
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
uint8_t _addr;
|
uint8_t _addr;
|
||||||
TwoWire *_wire;
|
TwoWire *_wire;
|
||||||
|
uint8_t _scl;
|
||||||
|
uint8_t _sda;
|
||||||
|
uint8_t _speed;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void setup() override;
|
virtual void setup() override;
|
||||||
bool begin(uint8_t addr = 0x57, TwoWire *wire = &Wire);
|
void begin(TwoWire *wire = &Wire, uint8_t addr = 0x57, uint8_t sda = -1, uint8_t scl = -1, uint32_t speed = 200000L);
|
||||||
Adafruit_I2CDevice *i2c_dev = NULL;
|
|
||||||
float getDistance();
|
float getDistance();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Loading…
Reference in New Issue
Block a user