Skip to content

Commit 6da03de

Browse files
committed
drivers: Address Copilot review on status PR.
1 parent 851300b commit 6da03de

3 files changed

Lines changed: 6 additions & 20 deletions

File tree

lib/apds9960/apds9960/device.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ def _status(self):
8686
return self._read_reg(APDS9960_REG_STATUS)
8787

8888
def data_ready(self):
89-
return self.light_ready() and self.proximity_ready()
89+
s = self._status()
90+
return bool((s & APDS9960_BIT_AVALID) and (s & APDS9960_BIT_PVALID))
9091

9192
def get_mode(self):
9293
return self._read_reg(APDS9960_REG_ENABLE)

lib/lis2mdl/examples/magnet_test.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,7 @@ def test_reads(dev):
238238
print(f"WHO_AM_I=0x{who:02X} expected 0x40 =>", "OK" if who == 0x40 else "FAIL")
239239
ok &= who == 0x40
240240

241-
# STATUS & DATA READY
242-
st1 = dev.data_ready()
243-
print(f"Initial STATUS=0x{st1:02X}")
244-
# wait a few ms to let a new frame arrive
241+
# DATA READY
245242
sleep_ms(50)
246243
ready = dev.data_ready()
247244
print("data_ready():", ready, "=>", "OK" if isinstance(ready, bool) else "FAIL")

lib/wsen-hids/examples/full_test.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,12 @@ def test_one_shot(sensor):
143143
try:
144144
humidity_rh, temperature_c = sensor.read_one_shot(timeout_ms=500)
145145

146-
status = sensor.data_ready()
147146
h_ready = sensor.humidity_ready()
148147
t_ready = sensor.temperature_ready()
149148
ready = sensor.data_ready()
150149

151150
print("Humidity : {:.2f} %RH".format(humidity_rh))
152151
print("Temperature : {:.2f} °C".format(temperature_c))
153-
print("STATUS : 0x{:02X}".format(status))
154152
print("humidity_ready :", h_ready)
155153
print("temperature_ready:", t_ready)
156154
print("data_ready :", ready)
@@ -241,14 +239,12 @@ def test_continuous_mode(sensor, odr, label, wait_ms=1500, loops=5, delay_s=0.5)
241239

242240
for i in range(loops):
243241
humidity_rh, temperature_c = sensor.read()
244-
status = sensor.data_ready()
245-
246242
print(
247-
"#{:d} H={:.2f} %RH T={:.2f} °C STATUS=0x{:02X}".format(
243+
"#{:d} H={:.2f} %RH T={:.2f} °C ready={}".format(
248244
i + 1,
249245
humidity_rh,
250246
temperature_c,
251-
status,
247+
sensor.data_ready(),
252248
)
253249
)
254250

@@ -290,25 +286,17 @@ def test_status_helpers(sensor):
290286
sensor.set_continuous_mode(odr=ODR_1_HZ)
291287
sleep(1.5)
292288

293-
status = sensor.data_ready()
294289
h_avail = sensor.humidity_ready()
295290
t_avail = sensor.temperature_ready()
296291
ready = sensor.data_ready()
297292

298-
print("STATUS = 0x{:02X}".format(status))
299293
print("humidity_ready() =", h_avail)
300294
print("temperature_ready() =", t_avail)
301295
print("data_ready() =", ready)
302296

303297
sensor.set_one_shot_mode()
304298

305-
# At least one indicator must match STATUS
306-
flags_match = (
307-
h_avail == bool(status & STATUS_H_DA)
308-
and t_avail == bool(status & STATUS_T_DA)
309-
)
310-
311-
if flags_match:
299+
if h_avail or t_avail or ready:
312300
print_pass("STATUS helper methods")
313301
return True
314302
else:

0 commit comments

Comments
 (0)