drivers/lps22h: Use machine.idle for power saving.
All machine modules should have an idle function.
This commit is contained in:
parent
6753c53318
commit
474c47d595
@ -53,14 +53,6 @@ class LPS22H:
|
|||||||
self.addr = address
|
self.addr = address
|
||||||
self.oneshot = oneshot
|
self.oneshot = oneshot
|
||||||
self.buf = bytearray(1)
|
self.buf = bytearray(1)
|
||||||
|
|
||||||
if hasattr(machine, "idle"):
|
|
||||||
self._go_idle = machine.idle()
|
|
||||||
else:
|
|
||||||
import time
|
|
||||||
|
|
||||||
self._go_idle = lambda: time.sleep_ms(1)
|
|
||||||
|
|
||||||
# ODR=1 EN_LPFP=1 BDU=1
|
# ODR=1 EN_LPFP=1 BDU=1
|
||||||
self._write_reg(_LPS22_CTRL_REG1, 0x1A)
|
self._write_reg(_LPS22_CTRL_REG1, 0x1A)
|
||||||
self.set_oneshot_mode(self.oneshot)
|
self.set_oneshot_mode(self.oneshot)
|
||||||
@ -86,7 +78,7 @@ class LPS22H:
|
|||||||
while True:
|
while True:
|
||||||
if self._read_reg(_LPS22_STATUS) & b:
|
if self._read_reg(_LPS22_STATUS) & b:
|
||||||
return
|
return
|
||||||
self._go_idle()
|
machine.idle()
|
||||||
|
|
||||||
def set_oneshot_mode(self, oneshot):
|
def set_oneshot_mode(self, oneshot):
|
||||||
self._read_reg(_LPS22_CTRL_REG1)
|
self._read_reg(_LPS22_CTRL_REG1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user