Skip to content

Commit

Permalink
lint cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
johnjones4 committed Sep 9, 2021
1 parent fceaa41 commit f5e7448
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 deletions.
2 changes: 1 addition & 1 deletion air/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from queue import Queue
from threading import Thread

from whitevest.lib.atomic_value import AtomicValue
from whitevest.lib.atomic_buffer import AtomicBuffer
from whitevest.lib.atomic_value import AtomicValue
from whitevest.lib.configuration import Configuration
from whitevest.lib.const import TELEMETRY_TUPLE_LENGTH
from whitevest.lib.utils import (
Expand Down
2 changes: 1 addition & 1 deletion air/whitevest/bin/test_sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import os
import time

from whitevest.lib.atomic_value import AtomicValue
from whitevest.lib.atomic_buffer import AtomicBuffer
from whitevest.lib.atomic_value import AtomicValue
from whitevest.lib.configuration import Configuration
from whitevest.lib.const import TELEMETRY_TUPLE_LENGTH
from whitevest.lib.hardware import (
Expand Down
19 changes: 15 additions & 4 deletions air/whitevest/lib/hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,29 @@
from whitevest.lib.atomic_value import AtomicValue
from whitevest.lib.configuration import Configuration


# pylint: disable=too-few-public-methods
class DummyBMP:
"""Dummy class for the BMP3xx sensor"""

# pylint: disable=no-self-use
def _read(self):
"""Return dummy data"""
return (0.0, 0.0)


# pylint: disable=too-few-public-methods
class DummyMag:
"""Dummy class for the Magnetometer sensor"""

def __init__(self):
self.magnetic = (0.0, 0.0, 0.0)


# pylint: disable=too-few-public-methods
class DummyAccel:
"""Dummy class for the Magnetometer sensor"""

def __init__(self):
self.acceleration = (0.0, 0.0, 0.0)

Expand Down Expand Up @@ -76,7 +87,7 @@ def init_magnetometer_accelerometer(configuration: Configuration):
mag = adafruit_lsm303dlh_mag.LSM303DLH_Mag(i2c)
accel = adafruit_lsm303_accel.LSM303_Accel(i2c)
return mag, accel
except Exception as ex: # pylint: disable=broad-except
except Exception as ex: # pylint: disable=broad-except
mag = DummyMag()
accel = DummyAccel()
logging.exception(ex)
Expand All @@ -102,12 +113,12 @@ def handle_reset_button(_):

GPIO.setmode(GPIO.BCM) # pylint: disable=no-member
channel = int(configuration.get_device_configuration("reset", "pin"))
GPIO.setup( # pylint: disable=no-member
channel, GPIO.IN, pull_up_down=GPIO.PUD_DOWN # pylint: disable=no-member
GPIO.setup( # pylint: disable=no-member
channel, GPIO.IN, pull_up_down=GPIO.PUD_DOWN # pylint: disable=no-member
)
GPIO.add_event_detect( # pylint: disable=no-member
channel,
GPIO.RISING, # pylint: disable=no-member
GPIO.RISING, # pylint: disable=no-member
callback=handle_reset_button,
bouncetime=500, # pylint: disable=no-member
)
14 changes: 8 additions & 6 deletions air/whitevest/lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ def take_gps_reading(sio, gps_value: AtomicValue) -> bool:
line = sio.readline()
gps = pynmea2.parse(line)
if isinstance(gps, pynmea2.types.talker.GGA):
gps_value.update((
gps.latitude if gps else 0.0,
gps.longitude if gps else 0.0,
float(gps.gps_qual) if gps else 0.0,
float(gps.num_sats) if gps else 0.0,
))
gps_value.update(
(
gps.latitude if gps else 0.0,
gps.longitude if gps else 0.0,
float(gps.gps_qual) if gps else 0.0,
float(gps.num_sats) if gps else 0.0,
)
)
return True
return False

Expand Down

0 comments on commit f5e7448

Please sign in to comment.