Skip to content

Commit 0f5c7db

Browse files
committed
v2.3.6
1 parent 652b2d3 commit 0f5c7db

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

port/modules/bluebit.py

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1596,4 +1596,50 @@ def get_raw_val(self):
15961596

15971597
def set_threshold(self, threshold):
15981598
'''设置红外探测传感器阈值,模拟值'''
1599-
self.threshold = threshold
1599+
self.threshold = threshold
1600+
1601+
class WaterLevelSensor():
1602+
'''乐动模块 水位传感器'''
1603+
def __init__(self, pin):
1604+
self.pin = MPythonPin(pin, PinMode.ANALOG)
1605+
self.threshold = 1500
1606+
1607+
def detect(self):
1608+
'''是否探测到,布尔类型True/False'''
1609+
tmp = self.pin.read_analog()
1610+
if(tmp>=self.threshold):
1611+
return True
1612+
else:
1613+
return False
1614+
1615+
def get_raw_val(self):
1616+
'''获取水位传感器裸数据,模拟值'''
1617+
return self.pin.read_analog()
1618+
1619+
def set_threshold(self, threshold):
1620+
'''设置水位传感器阈值,模拟值'''
1621+
self.threshold = threshold
1622+
1623+
1624+
class SoilHumiditySensor():
1625+
'''乐动模块 土壤湿度'''
1626+
def __init__(self, pin):
1627+
self.pin = MPythonPin(pin, PinMode.ANALOG)
1628+
self.threshold = 1500
1629+
1630+
def detect(self):
1631+
'''是否探测到,布尔类型True/False'''
1632+
tmp = self.pin.read_analog()
1633+
if(tmp>=self.threshold):
1634+
return True
1635+
else:
1636+
return False
1637+
1638+
def get_raw_val(self):
1639+
'''获取土壤湿度传感器裸数据,模拟值'''
1640+
return self.pin.read_analog()
1641+
1642+
def set_threshold(self, threshold):
1643+
'''设置土壤湿度传感器阈值,模拟值'''
1644+
self.threshold = threshold
1645+

0 commit comments

Comments
 (0)