-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add QMC5883L Sensor + Improvements to HMC5883L #671
Conversation
getting this issue in build checks, not my code ??
think this is related to #667 @OttoWinter ... |
HMC5883LDatarates, unit="Hz", int=False), | ||
cv.Optional(CONF_MEASUREMENT_MODE, default='normal'): validate_enum( | ||
HMC5883LMeasurementModes, int=False), | ||
cv.Optional(CONF_RANGE, default='130uT'): validate_enum(HMC5883L_RANGES, unit="uT"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should accept both µT and uT (otherwise this would be a breaking change).
return; | ||
} | ||
|
||
// if (id != 0x01) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove commented-out code or add comments for future use.
} | ||
|
||
bool QMC5883LComponent::read_byte_16_(uint8_t a_register, uint16_t *data, uint32_t conversion) { | ||
bool success = QMC5883LComponent::I2CDevice::read_byte_16(a_register, data, conversion); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool success = QMC5883LComponent::I2CDevice::read_byte_16(a_register, data, conversion); | |
bool success = this->read_byte_16(a_register, data, conversion); |
def validate_enum(enum_values, unit=None, int=True): | ||
def validate_enum_bound(value): | ||
value = cv.string(value) | ||
if unit and (value.endswith(unit.encode(encoding='UTF-8', errors='strict')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unit.encode
should not be necessary here - value
is already a unicode string (py2: unicode, py3: str)
Thanks @OttoWinter, will try get this done this weekend. |
@OttoWinter Believe this is ready fir review again thx :) |
Either the units are converted to the user values like 1x, 8x oversampling or not printed at all. Printing the machine-value of these is only confusing users.
Move stuff that can be done beforehand out of the bound function, use text_type for py2/3 compatability.
@OttoWinter Did you want to clean up now or later ? |
@timpur What do you mean? |
I have checked QMC on ESP8266 and also on ESP32, it works like a charm. |
Description:
Related issue (if applicable): fixes
Pull request in esphome-docs with documentation (if applicable): esphome/esphome-docs#
Checklist:
tests/
folder).If user exposed functionality or configuration variables are added/changed:
Added QMC5883L sensor and improvements to the HMC5883L sensor
Docs: esphome/esphome-docs#301