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:
Tim P
2019-11-27 04:43:11 +11:00
committed by Otto Winter
parent 36ffef083b
commit fa1adfd934
8 changed files with 378 additions and 15 deletions
+3 -7
View File
@@ -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();