Skip to content

Commit

Permalink
drivers/lps22h: Use machine.idle for power saving.
Browse files Browse the repository at this point in the history
All machine modules should have an idle function.
  • Loading branch information
iabdalkader authored and dpgeorge committed Jul 8, 2022
1 parent 6753c53 commit 474c47d
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions drivers/lps22h/lps22h.py
Expand Up @@ -53,14 +53,6 @@ def __init__(self, i2c, address=0x5C, oneshot=False):
self.addr = address
self.oneshot = oneshot
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
self._write_reg(_LPS22_CTRL_REG1, 0x1A)
self.set_oneshot_mode(self.oneshot)
Expand All @@ -86,7 +78,7 @@ def _tigger_oneshot(self, b):
while True:
if self._read_reg(_LPS22_STATUS) & b:
return
self._go_idle()
machine.idle()

def set_oneshot_mode(self, oneshot):
self._read_reg(_LPS22_CTRL_REG1)
Expand Down

0 comments on commit 474c47d

Please sign in to comment.