adafruit / Adafruit_CircuitPython_BME280

CircuitPython driver for the BME280
MIT License
63 stars 42 forks source link

Provide proxies for I2C and SPI #62

Closed rsbohn closed 1 year ago

rsbohn commented 2 years ago

basic.Adafruit_BME280 provides a simplified interface to the device. advanced.Adafruit_BME280 provides additional functionality.

Each of the above classes has subclasses for _I2C and _SPI busses. The user will instantiate the appropriate subclass based on their connection. basic.Adafruit_BME280_I2C or basic.Adafruit_BME280_SPI for example.

pylint complains that there is duplicate code between the basic and advanced implementations. The code to instantiate, read, and write to the device is duplicated in both implementations.

This pull request provides a single implementation for I2C and for SPI. To use *_Impl I added a parameter to the init method to set the selected implementation class.

Questions:

This work was part of the CircuitPythonDay2022 Sprint.

FoamyGuy commented 1 year ago

I tested this successfully with

Adafruit CircuitPython 8.0.0-beta.0 on 2022-08-18; Adafruit Feather ESP32S2 with ESP32S2
Board ID:adafruit_feather_esp32s2

Using the simpletest script in the examples directory of this repo to connect via I2C and get readings from the sensor.

Thanks again for working on this Dexter.