diff --git a/boards/default_src/micropython/origin/build/lib/ci130x.py b/boards/default_src/micropython/origin/build/lib/ci130x.py index 7a6bdc38..7fd34940 100644 --- a/boards/default_src/micropython/origin/build/lib/ci130x.py +++ b/boards/default_src/micropython/origin/build/lib/ci130x.py @@ -26,7 +26,7 @@ class CI130X: self._rreg(_CI_ID_GET, 3) except: try: #C130X 启动慢,加延时判断 - time.sleep_ms(500) + time.sleep_ms(850) self._rreg(_CI_ID_GET, 3) except: raise AttributeError("Cannot find a CI130X") diff --git a/boards/default_src/micropython/origin/build/lib/hx720.py b/boards/default_src/micropython/origin/build/lib/hx720.py index 43c6bc45..4079cdf5 100644 --- a/boards/default_src/micropython/origin/build/lib/hx720.py +++ b/boards/default_src/micropython/origin/build/lib/hx720.py @@ -50,18 +50,20 @@ class HX720: self._sck.value(1) self._sck.value(0) - return raw_data | 0xFF000000 if raw_data & 0x800000 else raw_data + return raw_data if raw_data < (1 << (DATA_BITS - 1)) else raw_data - (1 << DATA_BITS) def tare(self, times=10): """清零传感器""" - total = 0 - for _ in range(times): - total += self.read_raw() - self.offset = total / times + _values = [] + for _ in range(max(times, 5)): + _values.append(self.read_raw()) + _values = sorted(_values)[2: -2] + self.offset = sum(_values) / len(_values) def read_weight(self, times=5): """读取重量数据,返回去掉偏移量的平均值""" - total = 0 - for _ in range(times): - total += self.read_raw() - return round((total / times - self.offset) / self.scale, 2) + _values = [] + for _ in range(max(times, 3)): + _values.append(self.read_raw()) + _values = sorted(_values)[1: -1] + return round((sum(_values) / len(_values)- self.offset) / self.scale, 2) diff --git a/boards/default_src/micropython_esp32c2/origin/build/lib/mini_g5.py b/boards/default_src/micropython_esp32c2/origin/build/lib/mini_g5.py new file mode 100644 index 00000000..5038dfdc --- /dev/null +++ b/boards/default_src/micropython_esp32c2/origin/build/lib/mini_g5.py @@ -0,0 +1,30 @@ +""" +MINI G5 -MixGo MINI EXT G5 + +MicroPython library for the MINI G5 (Expansion board for MixGo MINI) +======================================================= +@dahanzimin From the Mixly Team +""" + +import gc +from machine import Pin, SoftI2C + +'''i2c-extboard''' +ext_i2c = SoftI2C(scl=Pin(7), sda=Pin(8), freq=400000) + +'''RFID_Sensor''' +try : + import rc522 + ext_rfid = rc522.RC522(ext_i2c) +except Exception as e: + print("Warning: Failed to communicate with SI522A (RFID) or",e) + +'''ASR_Sensor''' +try : + import ci130x + ext_asr = ci130x.CI130X(ext_i2c) +except Exception as e: + print("Warning: Failed to communicate with CI130X (ASR) or",e) + +'''Reclaim memory''' +gc.collect()