Move .py library in lib-src + lint
This commit is contained in:
parent
1774f764b7
commit
97a81aec58
@ -54,7 +54,6 @@ from machine import Pin
|
||||
|
||||
from micropython import const
|
||||
|
||||
#import adafruit_bus_spi.spi_spi as spi_spi
|
||||
|
||||
__version__ = "0.0.0-auto.0"
|
||||
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_MAX31865.git"
|
||||
@ -92,10 +91,8 @@ _RTD_B = -5.775e-7
|
||||
class MAX31865:
|
||||
"""Driver for the MAX31865 thermocouple amplifier."""
|
||||
|
||||
def __init__(
|
||||
self, spi, cs, *, rtd_nominal=100, ref_resistor=430.0,
|
||||
wires=2, filter_frequency=60
|
||||
):
|
||||
def __init__(self, spi, cs, *, rtd_nominal=100, ref_resistor=430.0,
|
||||
wires=2, filter_frequency=60.0):
|
||||
self.rtd_nominal = rtd_nominal
|
||||
self.ref_resistor = ref_resistor
|
||||
self._spi = spi
|
||||
@ -128,7 +125,7 @@ class MAX31865:
|
||||
# pylint: disable=no-member
|
||||
def _read_u8(self, address):
|
||||
# Read an 8-bit unsigned value from the specified 8-bit address.
|
||||
buf=bytearray(1)
|
||||
buf = bytearray(1)
|
||||
self._cs.value(0)
|
||||
self._spi.write(bytes([address & 0x7F]))
|
||||
self._spi.readinto(buf, 1)
|
||||
@ -137,7 +134,7 @@ class MAX31865:
|
||||
|
||||
def _read_u16(self, address):
|
||||
# Read a 16-bit BE unsigned value from the specified 8-bit address.
|
||||
buf=bytearray(2)
|
||||
buf = bytearray(2)
|
||||
self._cs.value(0)
|
||||
self._spi.write(bytes([address & 0x7F]))
|
||||
self._spi.readinto(buf, 1)
|
||||
@ -146,7 +143,7 @@ class MAX31865:
|
||||
|
||||
def _write_u8(self, address, val):
|
||||
# Write an 8-bit unsigned value to the specified 8-bit address.
|
||||
buf=bytearray(2)
|
||||
buf = bytearray(2)
|
||||
buf[0] = (address | 0x80) & 0xFF
|
||||
buf[1] = val & 0xFF
|
||||
self._cs.value(0)
|
||||
@ -157,7 +154,7 @@ class MAX31865:
|
||||
|
||||
@property
|
||||
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)
|
||||
|
||||
@bias.setter
|
||||
@ -171,7 +168,7 @@ class MAX31865:
|
||||
|
||||
@property
|
||||
def auto_convert(self):
|
||||
"""The state of the sensor's automatic conversion
|
||||
"""State of the sensor's automatic conversion
|
||||
mode (True/False).
|
||||
"""
|
||||
return bool(self._read_u8(_MAX31865_CONFIG_REG) & _MAX31865_CONFIG_MODEAUTO)
|
@ -1,13 +1,14 @@
|
||||
import utime
|
||||
import time
|
||||
from . import simple
|
||||
|
||||
|
||||
class MQTTClient(simple.MQTTClient):
|
||||
|
||||
DELAY = 2
|
||||
DEBUG = False
|
||||
|
||||
def delay(self, i):
|
||||
utime.sleep(self.DELAY)
|
||||
time.sleep(self.DELAY)
|
||||
|
||||
def log(self, in_reconnect, e):
|
||||
if self.DEBUG:
|
Binary file not shown.
@ -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.
Loading…
Reference in New Issue
Block a user