mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-06-13 08:03:32 +02:00
Add QMC5883L Sensor + Improvements to HMC5883L (#671)
* Add QMC5883L and Updated HMC5883L * add tests * changed to oversampling * fix pylint * fix private method * typo fix * fix protected method * Clean up code and PR recomendations * fix tests * remote file * fix qmc oversampling unit * Remove hmc5883l config logging 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. * Changes for validate_enum Move stuff that can be done beforehand out of the bound function, use text_type for py2/3 compatability. * Remove unused constant * Remove duplicate tests * Repeat remove config print * remove changes to test2 since bin is to large * Add comment to HMC5583L Co-authored-by: Timothy Purchas <timothy@TPF.local> Co-authored-by: Otto Winter <otto@otto-winter.com>
This commit is contained in:
@@ -38,12 +38,9 @@ void HMC5883LComponent::setup() {
|
||||
}
|
||||
|
||||
uint8_t config_a = 0;
|
||||
// 0b0xx00000 << 5 Sample Averaging - 0b00=1 sample, 0b11=8 samples
|
||||
config_a |= 0b01100000;
|
||||
// 0b000xxx00 << 2 Data Output Rate - 0b100=15Hz
|
||||
config_a |= 0b00010000;
|
||||
// 0b000000xx << 0 Measurement Mode - 0b00=high impedance on load
|
||||
config_a |= 0b00000000;
|
||||
config_a |= this->oversampling_ << 5;
|
||||
config_a |= this->datarate_ << 2;
|
||||
config_a |= 0b0 << 0; // Measurement Mode: Normal(high impedance on load)
|
||||
if (!this->write_byte(HMC5883L_REGISTER_CONFIG_A, config_a)) {
|
||||
this->error_code_ = COMMUNICATION_FAILED;
|
||||
this->mark_failed();
|
||||
@@ -61,7 +58,6 @@ void HMC5883LComponent::setup() {
|
||||
uint8_t mode = 0;
|
||||
// Continuous Measurement Mode
|
||||
mode |= 0b00;
|
||||
|
||||
if (!this->write_byte(HMC5883L_REGISTER_MODE, mode)) {
|
||||
this->error_code_ = COMMUNICATION_FAILED;
|
||||
this->mark_failed();
|
||||
|
||||
Reference in New Issue
Block a user