Perhaps here?
GNU nano 5.4 __init__.py
import time
import threading
import math
import RPi.GPIO as GPIO
import ioexpander as io
from bme280 import BME280
from ltr559 import LTR559
from smbus2 import SMBus
from .history import wind_degrees_to_cardinal
__version__ = '0.0.1'
# Wind Vane
PIN_WV = 8 # P0.3 ANE6
# Anemometer
PIN_ANE1 = 5 # P0.0
PIN_ANE2 = 6 # P0.1
ANE_RADIUS = 7 # Radius from center to the center of a cup, in CM
ANE_CIRCUMFERENCE = ANE_RADIUS * 2 * math.pi
ANE_FACTOR = 2.18 # Anemometer factor
# Rain gauge
PIN_R2 = 3 # P1.2
PIN_R3 = 7 # P1.1
PIN_R4 = 2 # P1.0
PIN_R5 = 1 # P1.5
RAIN_MM_PER_TICK = 0.2794
wind_direction_to_degrees = {
0.9: 0,
2.0: 45,
3.0: 90,
2.8: 135,
2.5: 180,
1.5: 225,
0.3: 270,
0.6: 315
}
class WeatherHAT:
def __init__(self):
self.updated_wind_rain = False
self._lock = threading.Lock()
self._i2c_dev = SMBus(1)
self._bme280 = BME280(i2c_dev=self._i2c_dev)
self._ltr559 = LTR559(i2c_dev=self._i2c_dev)
self._ioe = io.IOE(i2c_addr=0x12, interrupt_pin=4)
# Fudge to enable pull-up on interrupt pin
self._ioe._gpio.setup(self._ioe._interrupt_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
# Input voltage of IO Expander, this is 3.3 on Breakout Garden
self._ioe.set_adc_vref(3.3)
# Wind Vane
self._ioe.set_mode(PIN_WV, io.ADC)
# Anemometer
self._ioe.set_mode(PIN_ANE1, io.OUT)
self._ioe.output(PIN_ANE1, 0)
self._ioe.set_pin_interrupt(PIN_ANE2, True)
self._ioe.setup_switch_counter(PIN_ANE2)
# Rain Sensor
self._ioe.set_mode(PIN_R2, io.IN_PU)
self._ioe.set_mode(PIN_R3, io.OUT)
self._ioe.set_mode(PIN_R4, io.IN_PU)
self._ioe.setup_switch_counter(PIN_R4)
self._ioe.set_mode(PIN_R5, io.IN_PU)
self._ioe.output(PIN_R3, 0)
self._ioe.set_pin_interrupt(PIN_R4, True)
self._ioe.on_interrupt(self.handle_ioe_interrupt)
self._ioe.clear_interrupt()
# Data API... kinda
self.temperature_offset = -7.5
self.device_temperature = 0
self.temperature = 0