From 97a81aec58e80e2f6c6af17d550e59c026229dec Mon Sep 17 00:00:00 2001 From: Pierrick C Date: Sat, 4 Apr 2020 15:28:49 +0200 Subject: [PATCH] Move .py library in lib-src + lint --- code/{lib => lib-src}/adafruit_max31865.py | 17 ++++----- code/{lib => lib-src}/bme280_i2c.py | 0 code/{lib => lib-src}/umqtt/robust.py | 5 +-- code/{lib => lib-src}/umqtt/simple.py | 0 code/lib/main_lib.mpy | Bin 655 -> 0 bytes code/lib/main_lib.py | 40 --------------------- code/lib/umqtt/robust.mpy | Bin 596 -> 595 bytes 7 files changed, 10 insertions(+), 52 deletions(-) rename code/{lib => lib-src}/adafruit_max31865.py (96%) rename code/{lib => lib-src}/bme280_i2c.py (100%) rename code/{lib => lib-src}/umqtt/robust.py (95%) rename code/{lib => lib-src}/umqtt/simple.py (100%) delete mode 100644 code/lib/main_lib.mpy delete mode 100644 code/lib/main_lib.py 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 6e63a718dbcdf8efacfb2b1bd72fec91e9369373..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 655 zcmX|9-EI;=7@cJ;T@lE-tQ#XWY$d4+F$EFUgm_`0F*Qn41XH8vCQ>epxD8dz0q6FbHT4>!F}?=?;H zE^_EO2)cQJVjC$OyJc+?9%5(ta1cFp$4872A0tR!M8Hsdy-I;4%6>Vh9gW4yAbfxcOM_E+zwJ|MSHkW z+R#eHnpQ6D04XC2`>(flB|ew#^|y?dFLdtvTuz&i;uG{n=LU0GAkcJl@Z-vOwF7=$ z2XE!Hg`jI89sF9%es4Dd3HZfCJ=A7loM&;VCkCyXfs~g8Y>k+dkqRbD8d*Bn{(BzQ z@vJU9Ek0;1&gU|xgSHSk-UuBb4+KK6mGsCF$?nDjQV-mTW37{WVRUuriCsq}69^Hq z5aZS&&T(lhu7tP$-K}-8kPq&wpvcLfKa)kvq$pg94th@kjeRs6@z zYAwWCgoa;_u<19Js7Lta^PdY&DXs<&)B;k$OwM}o28v16MPySu!4S=I5{&k0U`tF< z*Te8qpMtrV9wW*=%$1ltcFDCqO$?-lERqpIo?(*(+eMcpOUK2xvNj^b{D3l$}{p#d>O|mGTDPMo>6Y{3dS@>waNTU Ft^jYI4ekH{ delta 50 zcmcc2a)o7r7<&LiL!dNQ=|mZ8Mu&+J`HY+sPslU!Onec?C_LGnF`iL&@^Z#BM%BrD GOs)WWf({x0