修复 1. AGS10的TVOC 数据为准备就绪问题

2. ntp支持多次获取时间
     3. mini的同步讯飞function
This commit is contained in:
dahanzimin
2025-11-05 13:23:50 +08:00
parent af948886e3
commit 00969c770c
3 changed files with 29 additions and 18 deletions

View File

@@ -17,9 +17,10 @@ class AGS10:
def __init__(self, i2c_bus, address=0x1A, delay=1000):
self._i2c = i2c_bus
self._addr = address
self._voc = None
self._voc = 0
self._delay = delay
self._star = 0
self.ready = 0
def _crc8(self, buf, is_byte=False):
'''Perform CRC check on the data'''
@@ -76,8 +77,8 @@ class AGS10:
if time.ticks_diff(time.ticks_ms(), self._star) >= self._delay:
self._star = time.ticks_ms()
_buf = self._rreg(_AGS10_ADC)
if (_buf[0] & 0x01) == 0:
self._voc = int.from_bytes(_buf[1:4], 'big')
self._voc = int.from_bytes(_buf[1:4], 'big')
self.ready = not (_buf[0] & 0x01)
return self._voc / 1000
def read(self, hcho_mw=30.033 , co2_mv=0.853, co2_base=400):