Merge branch 'master' of https://gitee.com/bnu_mixly/mixly3
This commit is contained in:
@@ -14,7 +14,7 @@ class NMEA0183:
|
||||
self._uart.init(baudrate=baudrate, timeout=timeout, rxbuf=1024)
|
||||
self.time=[None, None, None, None, None, None]
|
||||
self.locate=['', None, '', None, None, None, None] #0'1经度,2'3纬度,4海拔m,5速度m/s,6航向°
|
||||
self.status=[False, ' ', 0] #有效标注,定位模式,卫星量
|
||||
self.status=[False, ' ', 0] #有效标注,定位模式,卫星量
|
||||
if not self._chip_id():
|
||||
raise AttributeError("Cannot find a GNSS device")
|
||||
|
||||
@@ -29,11 +29,11 @@ class NMEA0183:
|
||||
for _ in range(10):
|
||||
sleep_ms(300)
|
||||
if self.any():
|
||||
self._uart.write(("$PCAS02,1000*2E\r\n").encode()) #更新频率1HZ
|
||||
self._uart.write(("$PCAS02,1000*2E\r\n").encode()) #更新频率1HZ
|
||||
self._uart.write("$PCAS03,1,0,0,0,1,0,0,0,0,0,,,0,0*02\r\n".encode()) #只加载GNGGA和GNRMC
|
||||
return True
|
||||
|
||||
def _judge(self, buffer, dlen):
|
||||
def _judge(self, buffer, dlen):
|
||||
try:
|
||||
data=buffer.strip().decode().split(',')
|
||||
if len(data) == dlen:
|
||||
|
||||
31
boards/default_src/micropython/origin/build/lib/sht20.py
Normal file
31
boards/default_src/micropython/origin/build/lib/sht20.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from struct import unpack as unp
|
||||
from time import sleep_ms
|
||||
|
||||
# SHT20 default address
|
||||
SHT20_I2CADDR = 64
|
||||
TRI_T_MEASURE_NO_HOLD = b'\xf3'
|
||||
TRI_RH_MEASURE_NO_HOLD = b'\xf5'
|
||||
READ_USER_REG = b'\xe7'
|
||||
WRITE_USER_REG = b'\xe6'
|
||||
SOFT_RESET = b'\xfe'
|
||||
|
||||
class SHT20(object):
|
||||
def __init__(self, i2c_bus):
|
||||
self._address = SHT20_I2CADDR
|
||||
self._bus = i2c_bus
|
||||
|
||||
def get_SHT_temperature(self):
|
||||
self._bus.writeto(self._address, TRI_T_MEASURE_NO_HOLD)
|
||||
sleep_ms(150)
|
||||
origin_data = self._bus.readfrom(self._address, 2)
|
||||
origin_value = unp('>h', origin_data)[0]
|
||||
value = -46.85 + 175.72 * (origin_value / 65536)
|
||||
return value
|
||||
|
||||
def get_SHT_relative_humidity(self):
|
||||
self._bus.writeto(self._address, TRI_RH_MEASURE_NO_HOLD)
|
||||
sleep_ms(150)
|
||||
origin_data = self._bus.readfrom(self._address, 2)
|
||||
origin_value = unp('>H', origin_data)[0]
|
||||
value = -6 + 125 * (origin_value / 65536)
|
||||
return value
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user