修复 1. AGS10的TVOC 数据为准备就绪问题
2. ntp支持多次获取时间
3. mini的同步讯飞function
This commit is contained in:
@@ -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.ready = not (_buf[0] & 0x01)
|
||||
return self._voc / 1000
|
||||
|
||||
def read(self, hcho_mw=30.033 , co2_mv=0.853, co2_base=400):
|
||||
|
||||
@@ -6,7 +6,9 @@ import ustruct as struct
|
||||
# NTP_DELTA (date(2000, 1, 1) - date(1900, 1, 1)).days * 24*60*60
|
||||
NTP_DELTA=3155673600
|
||||
|
||||
def time(host="pool.ntp.org", utc=28800):
|
||||
def time(host="pool.ntp.org", utc=28800, times=5):
|
||||
for _ in range(times):
|
||||
try:
|
||||
NTP_QUERY = bytearray(48)
|
||||
NTP_QUERY[0] = 0x1B
|
||||
addr = socket.getaddrinfo(host, 123)[0][-1]
|
||||
@@ -21,6 +23,10 @@ def time(host="pool.ntp.org", utc=28800):
|
||||
gc.collect()
|
||||
val = struct.unpack("!I", msg[40:44])[0]
|
||||
return utime.gmtime(val - NTP_DELTA + utc)
|
||||
except Exception as e:
|
||||
error = e
|
||||
utime.sleep(0.1)
|
||||
raise OSError('Error fetching network time', error)
|
||||
|
||||
# There's currently no timezone support in MicroPython, and the RTC is set in UTC time.
|
||||
def settime(times):
|
||||
|
||||
@@ -244,6 +244,10 @@ class LLM_WebSocket(Ws_Param):
|
||||
if "reasoning_content" in text and reas:
|
||||
print("reasoning: ", text["reasoning_content"])
|
||||
#回调
|
||||
if "tool_calls" in text:
|
||||
function = text['tool_calls'][0]['function']
|
||||
if str(function['name']) in self._function[0] and function['arguments']:
|
||||
self._function[0][function['name']](json.loads(function['arguments']))
|
||||
if "function_call" in text:
|
||||
if str(text['function_call']['name']) in self._function[0] and text['function_call']['arguments']:
|
||||
self._function[0][text['function_call']['name']](json.loads(text['function_call']['arguments']))
|
||||
|
||||
Reference in New Issue
Block a user