Move .py library in lib-src + lint

This commit is contained in:
Pierrick C 2020-04-04 15:28:49 +02:00
parent 1774f764b7
commit 97a81aec58
7 changed files with 10 additions and 52 deletions

View File

@ -54,7 +54,6 @@ from machine import Pin
from micropython import const from micropython import const
#import adafruit_bus_spi.spi_spi as spi_spi
__version__ = "0.0.0-auto.0" __version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_MAX31865.git" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_MAX31865.git"
@ -92,10 +91,8 @@ _RTD_B = -5.775e-7
class MAX31865: class MAX31865:
"""Driver for the MAX31865 thermocouple amplifier.""" """Driver for the MAX31865 thermocouple amplifier."""
def __init__( def __init__(self, spi, cs, *, rtd_nominal=100, ref_resistor=430.0,
self, spi, cs, *, rtd_nominal=100, ref_resistor=430.0, wires=2, filter_frequency=60.0):
wires=2, filter_frequency=60
):
self.rtd_nominal = rtd_nominal self.rtd_nominal = rtd_nominal
self.ref_resistor = ref_resistor self.ref_resistor = ref_resistor
self._spi = spi self._spi = spi
@ -157,7 +154,7 @@ class MAX31865:
@property @property
def bias(self): def bias(self):
"""The state of the sensor's bias (True/False).""" """State of the sensor's bias (True/False)."""
return bool(self._read_u8(_MAX31865_CONFIG_REG) & _MAX31865_CONFIG_BIAS) return bool(self._read_u8(_MAX31865_CONFIG_REG) & _MAX31865_CONFIG_BIAS)
@bias.setter @bias.setter
@ -171,7 +168,7 @@ class MAX31865:
@property @property
def auto_convert(self): def auto_convert(self):
"""The state of the sensor's automatic conversion """State of the sensor's automatic conversion
mode (True/False). mode (True/False).
""" """
return bool(self._read_u8(_MAX31865_CONFIG_REG) & _MAX31865_CONFIG_MODEAUTO) return bool(self._read_u8(_MAX31865_CONFIG_REG) & _MAX31865_CONFIG_MODEAUTO)

View File

@ -1,13 +1,14 @@
import utime import time
from . import simple from . import simple
class MQTTClient(simple.MQTTClient): class MQTTClient(simple.MQTTClient):
DELAY = 2 DELAY = 2
DEBUG = False DEBUG = False
def delay(self, i): def delay(self, i):
utime.sleep(self.DELAY) time.sleep(self.DELAY)
def log(self, in_reconnect, e): def log(self, in_reconnect, e):
if self.DEBUG: if self.DEBUG:

Binary file not shown.

View File

@ -1,40 +0,0 @@
"""Divers fonctions utiles
"""
import time
import machine
import network
from umqtt.robust import MQTTClient
def WifiConnect(ssid, psk):
"""Connect to the wifi with given credentials"""
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
nets = wlan.scan()
for net in nets:
net_ssid = net[0].decode()
if net_ssid == ssid:
print('Network found!')
wlan.connect(net_ssid, psk)
while not wlan.isconnected():
machine.idle() # save power while waiting
print('WLAN connection succeeded!')
break
if not wlan.isconnected():
print("WLAN not found/not connected")
return wlan
def now(rtc):
"""Return a string representing date/time now"""
return "{0:04d}/{1:02d}/{2:02d}_{4:02d}:{5:02d}:{6:02d}".format(*rtc.datetime())
def MqttPublish(client, topic, message, retain=False, qos=0, sleep=10):
"""MQTT publish helper"""
client.publish("test/{device}/{topic}".format(device=client.client_id, topic=topic),
message,
retain=retain,
qos=qos)
time.sleep_ms(sleep)

Binary file not shown.