|
@ -106,18 +106,22 @@ class EmonADS1X15Sensor : public EmonSensor { |
|
|
// --------------------------------------------------------------------- |
|
|
// --------------------------------------------------------------------- |
|
|
|
|
|
|
|
|
void setAddress(unsigned char address) { |
|
|
void setAddress(unsigned char address) { |
|
|
|
|
|
if (_address != address) _dirty = true; |
|
|
_address = address; |
|
|
_address = address; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void setType(unsigned char type) { |
|
|
void setType(unsigned char type) { |
|
|
|
|
|
if (_type != type) _dirty = true; |
|
|
_type = type; |
|
|
_type = type; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void setMask(unsigned char mask) { |
|
|
void setMask(unsigned char mask) { |
|
|
|
|
|
if (_mask != mask) _dirty = true; |
|
|
_mask = mask; |
|
|
_mask = mask; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void setGain(unsigned int gain) { |
|
|
void setGain(unsigned int gain) { |
|
|
|
|
|
if (_gain != gain) _dirty = true; |
|
|
_gain = gain; |
|
|
_gain = gain; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -128,6 +132,9 @@ class EmonADS1X15Sensor : public EmonSensor { |
|
|
// Initialization method, must be idempotent |
|
|
// Initialization method, must be idempotent |
|
|
void begin() { |
|
|
void begin() { |
|
|
|
|
|
|
|
|
|
|
|
if (!_dirty) return; |
|
|
|
|
|
_dirty = false; |
|
|
|
|
|
|
|
|
// Discover |
|
|
// Discover |
|
|
if (_address == 0) { |
|
|
if (_address == 0) { |
|
|
unsigned char addresses[] = {0x48, 0x49, 0x4A, 0x4B}; |
|
|
unsigned char addresses[] = {0x48, 0x49, 0x4A, 0x4B}; |
|
|