Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions fake_bme280/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
https://circuitpython.org/downloads
"""
import math
import os
import socket as pool
import ssl
import typing # pylint: disable=unused-import
import toml
from micropython import const
import adafruit_requests
from fake_bme280.protocol import I2C_Impl, SPI_Impl
Expand Down Expand Up @@ -75,17 +75,19 @@
_BME280_REGISTER_TEMPDATA = const(0xFA)
_BME280_REGISTER_HUMIDDATA = const(0xFD)

# Load the settings.toml file
toml_config = toml.load("settings.toml")

# OpenWeatherMap API
# GET weather data for a specific location
# TODO: this could be cleaned up a bit..
DATA_SOURCE = (
"http://api.openweathermap.org/data/2.5/weather?q="
+ os.getenv("openweather_location")
+ toml_config["openweather_location"]
+ "&units="
+ os.getenv("openweather_units")
+ toml_config["openweather_units"]
+ "&mode=json"
+ "&appid="
+ os.getenv("openweather_token")
+ toml_config["openweather_token"]
)


Expand Down Expand Up @@ -113,11 +115,6 @@ def __init__(self, bus_implementation: typing.Union[I2C_Impl, SPI_Impl]) -> None
self.sea_level_pressure = 1013.25
"""Pressure in hectoPascals at sea level. Used to calibrate `altitude`."""
self._t_fine = None
# Configure OpenWeather for mock data
self.openweather_token = os.getenv("OPENWEATHER_TOKEN", "default_token")
self.openweather_location = os.getenv(
"OPENWEATHER_LOCATION", "default_location"
)
# Configure a CPython adafruit_requests session
self.requests = adafruit_requests.Session(pool, ssl.create_default_context())
self._current_forcast = None
Expand Down
4 changes: 2 additions & 2 deletions fake_bme280/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
class I2C_Impl:
"Protocol implementation for the I2C bus."

# pylint: disable=too-few-public-methods
# pylint: disable=too-few-public-methods, unused-argument, unused-import
def __init__(self, i2c: I2C, address: int) -> None:
from adafruit_bus_device import ( # pylint: disable=import-outside-toplevel
i2c_device,
)

self._i2c = i2c_device.I2CDevice(i2c, address)
# self._i2c = i2c_device.I2CDevice(i2c, address)


class SPI_Impl:
Expand Down