diff --git a/code/lib/adafruit_max31865.py b/code/lib-src/adafruit_max31865.py similarity index 96% rename from code/lib/adafruit_max31865.py rename to code/lib-src/adafruit_max31865.py index fccfee4..ddf7552 100644 --- a/code/lib/adafruit_max31865.py +++ b/code/lib-src/adafruit_max31865.py @@ -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) diff --git a/code/lib/bme280_i2c.py b/code/lib-src/bme280_i2c.py similarity index 100% rename from code/lib/bme280_i2c.py rename to code/lib-src/bme280_i2c.py diff --git a/code/lib/umqtt/robust.py b/code/lib-src/umqtt/robust.py similarity index 95% rename from code/lib/umqtt/robust.py rename to code/lib-src/umqtt/robust.py index 7ee40e0..983834f 100644 --- a/code/lib/umqtt/robust.py +++ b/code/lib-src/umqtt/robust.py @@ -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: diff --git a/code/lib/umqtt/simple.py b/code/lib-src/umqtt/simple.py similarity index 100% rename from code/lib/umqtt/simple.py rename to code/lib-src/umqtt/simple.py diff --git a/code/lib/main_lib.mpy b/code/lib/main_lib.mpy deleted file mode 100644 index 6e63a71..0000000 Binary files a/code/lib/main_lib.mpy and /dev/null differ diff --git a/code/lib/main_lib.py b/code/lib/main_lib.py deleted file mode 100644 index 06fb8c1..0000000 --- a/code/lib/main_lib.py +++ /dev/null @@ -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) diff --git a/code/lib/umqtt/robust.mpy b/code/lib/umqtt/robust.mpy index 6acf72b..bebc63d 100644 Binary files a/code/lib/umqtt/robust.mpy and b/code/lib/umqtt/robust.mpy differ