更新优化ESPNOW在v1.23.0固件使用

This commit is contained in:
dahanzimin
2024-10-24 20:04:16 +08:00
parent 73ba67166b
commit 21b2275291
3 changed files with 24 additions and 108 deletions

View File

@@ -24,6 +24,8 @@ class DS18X20:
self._ow = onewire.OneWire(Pin(pin, pull=Pin.PULL_UP))
self._buf = bytearray(9)
self._roms = self.scan()
if len(self._roms) == 0:
raise AttributeError("Cannot find a DS18X20")
def scan(self):
return [rom for rom in self._ow.scan() if rom[0] in (0x10, 0x22, 0x28)]